1 #include "gdb-tests.h"
2 #include "jsapi.h"
3
4 #include <string.h>
5
FRAGMENT(asmjs,segfault)6 FRAGMENT(asmjs, segfault) {
7 using namespace JS;
8
9 int line0 = __LINE__;
10 const char* bytes =
11 "\n"
12 "function f(glob, ffi, heap) {\n"
13 " \"use asm\";\n"
14 " var f32 = new glob.Float32Array(heap);\n"
15 " function g(n) {\n"
16 " n = n | 0;\n"
17 " return +f32[n>>2];\n"
18 " }\n"
19 " return g;\n"
20 "}\n"
21 "\n"
22 "var func = f(this, null, new ArrayBuffer(0x10000));\n"
23 "func(0x10000 << 2);\n"
24 "'ok'\n";
25
26 CompileOptions opts(cx);
27 opts.setFileAndLine(__FILE__, line0 + 1);
28 opts.asmJSOption = JS::AsmJSOption::Enabled;
29 RootedValue rval(cx);
30 bool ok;
31 ok = false;
32
33 ok = Evaluate(cx, opts, bytes, strlen(bytes), &rval);
34
35 breakpoint();
36
37 use(ok);
38 use(rval);
39 }
40