From 3f297457d815c55629136d39a94ddf2a6e4c07ae Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 23 Jul 2025 20:40:50 +0200 Subject: [PATCH] [js] Align br_table limits with V8/Gecko. --- js/src/jit-test/tests/asm.js/testControlFlow.js | 6 +++--- js/src/wasm/WasmTypes.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/js/src/jit-test/tests/asm.js/testControlFlow.js b/js/src/jit-test/tests/asm.js/testControlFlow.js index 40711cd6ce..bef7f12e84 100644 --- a/js/src/jit-test/tests/asm.js/testControlFlow.js +++ b/js/src/jit-test/tests/asm.js/testControlFlow.js @@ -148,11 +148,11 @@ var exp = asmLink(asmCompile(USE_ASM + "var x=0; function a() { return x|0 } fun assertEq(exp.c(10), undefined); assertEq(exp.a(), 10); -var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; switch(i|0) { case 1: i=-1; break; case 133742: i=2; break; default: i=42; break } return i|0 } return f")); +var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; switch(i|0) { case 1: i=-1; break; case 65520: i=2; break; default: i=42; break } return i|0 } return f")); assertEq(f(1), -1); assertEq(f(2), 42); -assertEq(f(133742), 2); -assertEq(f(133743), 42); +assertEq(f(65520), 2); +assertEq(f(65521), 42); var f = asmLink(asmCompile(USE_ASM + "function f(i) { i=i|0; switch(i|0) { case 1: i=42; break; default: i=13 } return i|0 } return f")); assertEq(f(-1), 13); diff --git a/js/src/wasm/WasmTypes.h b/js/src/wasm/WasmTypes.h index 57c737e454..2ea527bdfb 100644 --- a/js/src/wasm/WasmTypes.h +++ b/js/src/wasm/WasmTypes.h @@ -1332,7 +1332,7 @@ static const unsigned MaxTableElems = 1024 * 1024; static const unsigned MaxDataSegments = 64 * 1024; static const unsigned MaxElemSegments = 64 * 1024; static const unsigned MaxArgsPerFunc = 4 * 1024; -static const unsigned MaxBrTableElems = 4 * 1024 * 1024; +static const unsigned MaxBrTableElems = 65520; // To be able to assign function indices during compilation while the number of // imports is still unknown, asm.js sets a maximum number of imports so it can