Services.prefs.setBoolPref("javascript.options.wasm_tail_calls" , true );
registerCleanupFunction(() => {
Services.prefs.clearUserPref("javascript.options.wasm_tail_calls" );
});
// The tests runs code in tight loop with the profiler enabled. It is testing
// behavoir of MacroAssembler::wasmCollapseFrameXXXX methods.
// It is not guarantee 100% hit since the profiler probes stacks every 1ms,
// but it will happen often enough.
add_task(async () => {
await Services.profiler.StartProfiler(10 , 1 , ["js" ], ["GeckoMain" ]);
Assert .ok(Services.profiler.IsActive());
/* Wasm module that is tested:
( module
( func $ f ( param i64 i64 i64 i64 i64 i64 i64 i64 i64 )
local . get 0
i64 . eqz
br_if 0
local . get 0
return_call $ g
)
( func $ g ( param i64 )
local . get 0
i64 . const 1
i64 . sub
i64 . const 2
i64 . const 6
i64 . const 3
i64 . const 4
i64 . const 1
i64 . const 2
i64 . const 6
i64 . const 3
return_call $ f
)
( func ( export " run " )
i64 . const 0 x100000
call $ g
)
)
*/
const b = new Uint8Array([
0 x00, 0 x61, 0 x73, 0 x6d, 0 x01, 0 x00, 0 x00, 0 x00, 0 x01, 0 x14, 0 x03, 0 x60,
0 x09, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x7e, 0 x00, 0 x60,
0 x01, 0 x7e, 0 x00, 0 x60, 0 x00, 0 x00, 0 x03, 0 x04, 0 x03, 0 x00, 0 x01, 0 x02,
0 x07, 0 x07, 0 x01, 0 x03, 0 x72, 0 x75, 0 x6e, 0 x00, 0 x02, 0 x0a, 0 x31, 0 x03,
0 x0b, 0 x00, 0 x20, 0 x00, 0 x50, 0 x0d, 0 x00, 0 x20, 0 x00, 0 x12, 0 x01, 0 x0b,
0 x19, 0 x00, 0 x20, 0 x00, 0 x42, 0 x01, 0 x7d, 0 x42, 0 x02, 0 x42, 0 x06, 0 x42,
0 x03, 0 x42, 0 x04, 0 x42, 0 x01, 0 x42, 0 x02, 0 x42, 0 x06, 0 x42, 0 x03, 0 x12,
0 x00, 0 x0b, 0 x09, 0 x00, 0 x42, 0 x80, 0 x80, 0 xc0, 0 x00, 0 x10, 0 x01, 0 x0b
]);
const ins = new WebAssembly.Instance(new WebAssembly.Module(b));
for (var i = 0 ; i < 100 ; i++) {
ins.exports.run();
}
Assert .ok(true , "Done" );
await Services.profiler.StopProfiler();
});
add_task(async () => {
await Services.profiler.StartProfiler(10 , 1 , ["js" ], ["GeckoMain" ]);
Assert .ok(Services.profiler.IsActive());
/* Wasm modules that are tested:
( module ( func ( export " t " ) ) )
( module
( import " " " t " ( func $ g ) )
( table $ t 1 1 funcref )
( func $ f ( return_call_indirect $ t ( i32 . const 0 ) ) )
( func ( export " run " ) ( param i64 )
loop
local . get 0
i64 . eqz
br_if 1
call $ f
local . get 0
i64 . const 1
i64 . sub
local . set 0
br 0
end
)
( elem ( i32 . const 0 ) $ g )
)
*/
const b0 = new Uint8Array([
0 x00, 0 x61, 0 x73, 0 x6d, 0 x01, 0 x00, 0 x00, 0 x00, 0 x01, 0 x04, 0 x01, 0 x60,
0 x00, 0 x00, 0 x03, 0 x02, 0 x01, 0 x00, 0 x07, 0 x05, 0 x01, 0 x01, 0 x74, 0 x00,
0 x00, 0 x0a, 0 x04, 0 x01, 0 x02, 0 x00, 0 x0b
]);
const ins0 = new WebAssembly.Instance(new WebAssembly.Module(b0));
const b = new Uint8Array([
0 x00, 0 x61, 0 x73, 0 x6d, 0 x01, 0 x00, 0 x00, 0 x00, 0 x01, 0 x08, 0 x02, 0 x60,
0 x00, 0 x00, 0 x60, 0 x01, 0 x7e, 0 x00, 0 x02, 0 x06, 0 x01, 0 x00, 0 x01, 0 x74,
0 x00, 0 x00, 0 x03, 0 x03, 0 x02, 0 x00, 0 x01, 0 x04, 0 x05, 0 x01, 0 x70, 0 x01,
0 x01, 0 x01, 0 x07, 0 x07, 0 x01, 0 x03, 0 x72, 0 x75, 0 x6e, 0 x00, 0 x02, 0 x09,
0 x07, 0 x01, 0 x00, 0 x41, 0 x00, 0 x0b, 0 x01, 0 x00, 0 x0a, 0 x1f, 0 x02, 0 x07,
0 x00, 0 x41, 0 x00, 0 x13, 0 x00, 0 x00, 0 x0b, 0 x15, 0 x00, 0 x03, 0 x40, 0 x20,
0 x00, 0 x50, 0 x0d, 0 x01, 0 x10, 0 x01, 0 x20, 0 x00, 0 x42, 0 x01, 0 x7d, 0 x21,
0 x00, 0 x0c, 0 x00, 0 x0b, 0 x0b
]);
const ins = new WebAssembly.Instance(new WebAssembly.Module(b), {"" : {t: ins0.exports.t,},});
for (var i = 0 ; i < 100 ; i++) {
ins.exports.run(0 x100000n);
}
Assert .ok(true , "Done" );
await Services.profiler.StopProfiler();
});
/**
* All the tests are implemented with add_task , this starts them automatically .
*/
function run_test() {
do_get_profile();
run_next_test();
}
Messung V0.5 in Prozent C=93 H=87 G=89
¤ Dauer der Verarbeitung: 0.4 Sekunden
¤
*© Formatika GbR, Deutschland