diff options
Diffstat (limited to 'js/src/jit-test/lib/wasm.js')
-rw-r--r-- | js/src/jit-test/lib/wasm.js | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/js/src/jit-test/lib/wasm.js b/js/src/jit-test/lib/wasm.js index 2b3374ebbe..a5721913e9 100644 --- a/js/src/jit-test/lib/wasm.js +++ b/js/src/jit-test/lib/wasm.js @@ -42,13 +42,12 @@ if (largeArrayBufferSupported()) { } var MaxPagesIn32BitMemory = Math.floor(MaxBytesIn32BitMemory / PageSizeInBytes); -function wasmEvalText(str, imports) { - let binary = wasmTextToBinary(str); - let valid = WebAssembly.validate(binary); +function wasmEvalBinary(binary, imports, compileOptions) { + let valid = WebAssembly.validate(binary, compileOptions); let m; try { - m = new WebAssembly.Module(binary); + m = new WebAssembly.Module(binary, compileOptions); assertEq(valid, true, "failed WebAssembly.validate but still compiled successfully"); } catch(e) { if (!e.toString().match(/out of memory/)) { @@ -60,8 +59,11 @@ function wasmEvalText(str, imports) { return new WebAssembly.Instance(m, imports); } -function wasmValidateText(str) { - let binary = wasmTextToBinary(str); +function wasmEvalText(str, imports, compileOptions) { + return wasmEvalBinary(wasmTextToBinary(str), imports, compileOptions); +} + +function wasmValidateBinary(binary) { let valid = WebAssembly.validate(binary); if (!valid) { new WebAssembly.Module(binary); @@ -70,12 +72,19 @@ function wasmValidateText(str) { assertEq(valid, true, "wasm module was invalid"); } -function wasmFailValidateText(str, pattern) { - let binary = wasmTextToBinary(str); +function wasmFailValidateBinary(binary, pattern) { assertEq(WebAssembly.validate(binary), false, "module passed WebAssembly.validate when it should not have"); assertErrorMessage(() => new WebAssembly.Module(binary), WebAssembly.CompileError, pattern, "module failed WebAssembly.validate but did not fail to compile as expected"); } +function wasmValidateText(str) { + return wasmValidateBinary(wasmTextToBinary(str)); +} + +function wasmFailValidateText(str, pattern) { + return wasmFailValidateBinary(wasmTextToBinary(str), pattern); +} + // Expected compilation failure can happen in a couple of ways: // // - The compiler can be available but not capable of recognizing some opcodes: |