1 Services.prefs.setBoolPref("javascript.options.wasm_tail_calls", true);
2 registerCleanupFunction(() => {
3 Services.prefs.clearUserPref("javascript.options.wasm_tail_calls");
6 // The tests runs code in tight loop with the profiler enabled. It is testing
7 // behavoir of MacroAssembler::wasmCollapseFrameXXXX methods.
8 // It is not guarantee 100% hit since the profiler probes stacks every 1ms,
9 // but it will happen often enough.
10 add_task(async () => {
11 await Services.profiler.StartProfiler(10, 1, ["js"], ["GeckoMain"]);
12 Assert.ok(Services.profiler.IsActive());
14 /* Wasm module that is tested:
16 (func $f (param i64 i64 i64 i64 i64 i64 i64 i64 i64)
44 const b = new Uint8Array([
45 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x14, 0x03, 0x60,
46 0x09, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x7e, 0x00, 0x60,
47 0x01, 0x7e, 0x00, 0x60, 0x00, 0x00, 0x03, 0x04, 0x03, 0x00, 0x01, 0x02,
48 0x07, 0x07, 0x01, 0x03, 0x72, 0x75, 0x6e, 0x00, 0x02, 0x0a, 0x31, 0x03,
49 0x0b, 0x00, 0x20, 0x00, 0x50, 0x0d, 0x00, 0x20, 0x00, 0x12, 0x01, 0x0b,
50 0x19, 0x00, 0x20, 0x00, 0x42, 0x01, 0x7d, 0x42, 0x02, 0x42, 0x06, 0x42,
51 0x03, 0x42, 0x04, 0x42, 0x01, 0x42, 0x02, 0x42, 0x06, 0x42, 0x03, 0x12,
52 0x00, 0x0b, 0x09, 0x00, 0x42, 0x80, 0x80, 0xc0, 0x00, 0x10, 0x01, 0x0b
54 const ins = new WebAssembly.Instance(new WebAssembly.Module(b));
55 for (var i = 0; i < 100; i++) {
59 Assert.ok(true, "Done");
60 await Services.profiler.StopProfiler();
63 add_task(async () => {
64 await Services.profiler.StartProfiler(10, 1, ["js"], ["GeckoMain"]);
65 Assert.ok(Services.profiler.IsActive());
67 /* Wasm modules that are tested:
68 (module (func (export "t")))
71 (import "" "t" (func $g))
72 (table $t 1 1 funcref)
74 (func $f (return_call_indirect $t (i32.const 0)))
75 (func (export "run") (param i64)
88 (elem (i32.const 0) $g)
91 const b0 = new Uint8Array([
92 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
93 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x07, 0x05, 0x01, 0x01, 0x74, 0x00,
94 0x00, 0x0a, 0x04, 0x01, 0x02, 0x00, 0x0b
96 const ins0 = new WebAssembly.Instance(new WebAssembly.Module(b0));
97 const b = new Uint8Array([
98 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x02, 0x60,
99 0x00, 0x00, 0x60, 0x01, 0x7e, 0x00, 0x02, 0x06, 0x01, 0x00, 0x01, 0x74,
100 0x00, 0x00, 0x03, 0x03, 0x02, 0x00, 0x01, 0x04, 0x05, 0x01, 0x70, 0x01,
101 0x01, 0x01, 0x07, 0x07, 0x01, 0x03, 0x72, 0x75, 0x6e, 0x00, 0x02, 0x09,
102 0x07, 0x01, 0x00, 0x41, 0x00, 0x0b, 0x01, 0x00, 0x0a, 0x1f, 0x02, 0x07,
103 0x00, 0x41, 0x00, 0x13, 0x00, 0x00, 0x0b, 0x15, 0x00, 0x03, 0x40, 0x20,
104 0x00, 0x50, 0x0d, 0x01, 0x10, 0x01, 0x20, 0x00, 0x42, 0x01, 0x7d, 0x21,
105 0x00, 0x0c, 0x00, 0x0b, 0x0b
107 const ins = new WebAssembly.Instance(new WebAssembly.Module(b), {"": {t: ins0.exports.t,},});
108 for (var i = 0; i < 100; i++) {
109 ins.exports.run(0x100000n);
112 Assert.ok(true, "Done");
113 await Services.profiler.StopProfiler();
117 * All the tests are implemented with add_task, this starts them automatically.
119 function run_test() {