From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/wasm/ion-lazy-tables.js | 68 +++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 js/src/jit-test/tests/wasm/ion-lazy-tables.js (limited to 'js/src/jit-test/tests/wasm/ion-lazy-tables.js') diff --git a/js/src/jit-test/tests/wasm/ion-lazy-tables.js b/js/src/jit-test/tests/wasm/ion-lazy-tables.js new file mode 100644 index 0000000000..b4a868170e --- /dev/null +++ b/js/src/jit-test/tests/wasm/ion-lazy-tables.js @@ -0,0 +1,68 @@ +// |jit-test| skip-if: !getJitCompilerOptions()['baseline.enable'] +// These tests need at least baseline to make sense. + +const { assertStackTrace, startProfiling, endProfiling, assertEqPreciseStacks } = WasmHelpers; + +const options = getJitCompilerOptions(); +const TRIGGER = options['baseline.warmup.trigger'] + 10; +const ITER = 2 * TRIGGER; +const EXCEPTION_ITER = TRIGGER + 5; + +const SLOW_ENTRY_STACK = ['', '!>', '0,!>', '!>', '']; +const FAST_ENTRY_STACK = ['', '>', '0,>', '>', '']; +const INLINED_CALL_STACK = ['', '0', '']; +const EXPECTED_STACKS = [SLOW_ENTRY_STACK, FAST_ENTRY_STACK, INLINED_CALL_STACK]; + +function main() { + var { table } = wasmEvalText(`(module + (func (param i32) (param i32) (result i32) + local.get 0 + local.get 1 + i32.add + ) + (table (export "table") 10 funcref) + (elem (i32.const 0) 0) + )`).exports; + + for (var i = 0; i < ITER; i++) { + startProfiling(); + assertEq(table.get(0)(i, i+1), i*2+1); + assertEqPreciseStacks(endProfiling(), EXPECTED_STACKS); + } +} + +function withTier2() { + setJitCompilerOption('wasm.delay-tier2', 1); + + var module = new WebAssembly.Module(wasmTextToBinary(`(module + (func (param i32) (param i32) (result i32) + local.get 0 + local.get 1 + i32.add + ) + (table (export "table") 10 funcref) + (elem (i32.const 0) 0) + )`)); + var { table } = new WebAssembly.Instance(module).exports; + + let i = 0; + do { + i++; + startProfiling(); + assertEq(table.get(0)(i, i+1), i*2+1); + assertEqPreciseStacks(endProfiling(), EXPECTED_STACKS); + } while (!wasmHasTier2CompilationCompleted(module)); + + for (i = 0; i < ITER; i++) { + startProfiling(); + assertEq(table.get(0)(i, i+1), i*2+1); + assertEqPreciseStacks(endProfiling(), EXPECTED_STACKS); + } + + setJitCompilerOption('wasm.delay-tier2', 0); +} + +enableGeckoProfiling(); +main(); +withTier2(); +disableGeckoProfiling(); -- cgit v1.2.3