diff options
author | Myles Borins <mylesborins@google.com> | 2018-04-10 21:39:51 -0400 |
---|---|---|
committer | Myles Borins <mylesborins@google.com> | 2018-04-11 13:22:42 -0400 |
commit | 12a1b9b8049462e47181a298120243dc83e81c55 (patch) | |
tree | 8605276308c8b4e3597516961266bae1af57557a /deps/v8/test/mjsunit/wasm | |
parent | 78cd8263354705b767ef8c6a651740efe4931ba0 (diff) | |
download | node-new-12a1b9b8049462e47181a298120243dc83e81c55.tar.gz |
deps: update V8 to 6.6.346.23
PR-URL: https://github.com/nodejs/node/pull/19201
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/test/mjsunit/wasm')
-rw-r--r-- | deps/v8/test/mjsunit/wasm/OWNERS | 2 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/asm-wasm-f32.js | 19 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/asm-wasm-f64.js | 30 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/compiled-module-serialization.js | 20 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/errors.js | 27 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/function-prototype.js | 5 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/import-function.js (renamed from deps/v8/test/mjsunit/wasm/import-table.js) | 0 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/indirect-tables.js | 130 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/interpreter.js | 31 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/liftoff.js | 16 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/memory-size.js | 46 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/table-grow.js | 2 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js | 326 | ||||
-rw-r--r-- | deps/v8/test/mjsunit/wasm/wasm-constants.js | 10 |
14 files changed, 252 insertions, 412 deletions
diff --git a/deps/v8/test/mjsunit/wasm/OWNERS b/deps/v8/test/mjsunit/wasm/OWNERS index 5bd472f49d..d9195d8e54 100644 --- a/deps/v8/test/mjsunit/wasm/OWNERS +++ b/deps/v8/test/mjsunit/wasm/OWNERS @@ -2,6 +2,4 @@ ahaas@chromium.org bradnelson@chromium.org clemensh@chromium.org eholk@chromium.org -mtrofin@chromium.org -rossberg@chromium.org titzer@chromium.org diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js b/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js index a1af7a4393..1a89c3ef1a 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm-f32.js @@ -200,23 +200,8 @@ var inputs = [ ]; var funcs = [ - f32_add, - f32_sub, - f32_mul, - f32_div, - f32_ceil, - f32_floor, -// TODO(bradnelson) f32_sqrt, -// TODO(bradnelson) f32_abs, -// TODO(bradnelson) f32_min is wrong for -0 -// TODO(bradnelson) f32_max is wrong for -0 - f32_eq, - f32_ne, - f32_lt, - f32_lteq, - f32_gt, - f32_gteq, - f32_neg, + f32_add, f32_sub, f32_mul, f32_div, f32_ceil, f32_floor, f32_sqrt, f32_abs, + f32_min, f32_max, f32_eq, f32_ne, f32_lt, f32_lteq, f32_gt, f32_gteq, f32_neg ]; (function () { diff --git a/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js b/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js index c7b439fede..a07de98558 100644 --- a/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js +++ b/deps/v8/test/mjsunit/wasm/asm-wasm-f64.js @@ -262,32 +262,10 @@ var inputs = [ ]; var funcs = [ - f64_add, - f64_sub, - f64_mul, - f64_div, - f64_eq, - f64_ne, - f64_lt, - f64_lteq, - f64_gt, - f64_gteq, - f64_ceil, - f64_floor, -// TODO(bradnelson) f64_sqrt, - f64_abs, - f64_neg, -// TODO(bradnelson) f64_min is wrong for -0 -// TODO(bradnelson) f64_max is wrong for -0 - f64_acos, - f64_asin, - f64_atan, - f64_cos, - f64_sin, - f64_tan, - f64_exp, - f64_log, - f64_atan2, + f64_add, f64_sub, f64_mul, f64_div, f64_eq, f64_ne, f64_lt, + f64_lteq, f64_gt, f64_gteq, f64_ceil, f64_floor, f64_sqrt, f64_abs, + f64_neg, f64_min, f64_max, f64_acos, f64_asin, f64_atan, f64_cos, + f64_sin, f64_tan, f64_exp, f64_log, f64_atan2, ]; (function () { diff --git a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js index 0ec3296b03..d254c9e620 100644 --- a/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js +++ b/deps/v8/test/mjsunit/wasm/compiled-module-serialization.js @@ -98,6 +98,26 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); assertEquals(clone.constructor, compiled_module.constructor); })(); +(function SerializeWrappersWithSameSignature() { + let builder = new WasmModuleBuilder(); + builder.addFunction("main", kSig_i_v) + .addBody([kExprI32Const, 42]) + .exportFunc(); + builder.addFunction("main_same_signature", kSig_i_v) + .addBody([kExprI32Const, 23]) + .exportFunc(); + + var wire_bytes = builder.toBuffer(); + var compiled_module = new WebAssembly.Module(wire_bytes); + var serialized = %SerializeWasmModule(compiled_module); + var clone = %DeserializeWasmModule(serialized, wire_bytes); + + assertNotNull(clone); + assertFalse(clone == undefined); + assertFalse(clone == compiled_module); + assertEquals(clone.constructor, compiled_module.constructor); +})(); + (function SerializeAfterInstantiation() { let builder = new WasmModuleBuilder(); builder.addFunction("main", kSig_i_v) diff --git a/deps/v8/test/mjsunit/wasm/errors.js b/deps/v8/test/mjsunit/wasm/errors.js index a90236459f..0d4893c18a 100644 --- a/deps/v8/test/mjsunit/wasm/errors.js +++ b/deps/v8/test/mjsunit/wasm/errors.js @@ -160,15 +160,22 @@ function assertConversionError(bytes, imports, msg) { (function TestConversionError() { let b = builder(); - b.addImport("foo", "bar", kSig_v_l); - assertConversionError(b.addFunction("run", kSig_v_v).addBody([ - kExprI64Const, 0, kExprCallFunction, 0 - ]).exportFunc().end().toBuffer(), {foo:{bar: (l)=>{}}}, "invalid type"); - - b = builder() - assertConversionError(builder().addFunction("run", kSig_l_v).addBody([ - kExprI64Const, 0 - ]).exportFunc().end().toBuffer(), {}, "invalid type"); + b.addImport('foo', 'bar', kSig_v_l); + let buffer = b.addFunction('run', kSig_v_v) + .addBody([kExprI64Const, 0, kExprCallFunction, 0]) + .exportFunc() + .end() + .toBuffer(); + assertConversionError( + buffer, {foo: {bar: (l) => {}}}, kTrapMsgs[kTrapTypeError]); + + buffer = builder() + .addFunction('run', kSig_l_v) + .addBody([kExprI64Const, 0]) + .exportFunc() + .end() + .toBuffer(); + assertConversionError(buffer, {}, kTrapMsgs[kTrapTypeError]); })(); @@ -178,7 +185,7 @@ function assertConversionError(bytes, imports, msg) { builder.addImport("mod", "func", sig); builder.addFunction("main", sig) .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprCallFunction, 0]) - .exportAs("main") + .exportAs("main"); var main = builder.instantiate({ mod: { func: ()=>{%DebugTrace();} diff --git a/deps/v8/test/mjsunit/wasm/function-prototype.js b/deps/v8/test/mjsunit/wasm/function-prototype.js index d3356cec80..c2f1edd5c4 100644 --- a/deps/v8/test/mjsunit/wasm/function-prototype.js +++ b/deps/v8/test/mjsunit/wasm/function-prototype.js @@ -17,8 +17,9 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var func = builder.instantiate().exports.nine; // Check type and existence of prototype - assertEquals("function", typeof func.apply); - assertTrue(func.prototype != undefined); + assertEquals('function', typeof func); + assertEquals('function', typeof func.apply); + assertEquals('prototype' in func, false); assertEquals(String(f.index), func.name); assertEquals(undefined, func.displayName); diff --git a/deps/v8/test/mjsunit/wasm/import-table.js b/deps/v8/test/mjsunit/wasm/import-function.js index 2c89e45c3e..2c89e45c3e 100644 --- a/deps/v8/test/mjsunit/wasm/import-table.js +++ b/deps/v8/test/mjsunit/wasm/import-function.js diff --git a/deps/v8/test/mjsunit/wasm/indirect-tables.js b/deps/v8/test/mjsunit/wasm/indirect-tables.js index 88d1bb719a..9176ec4932 100644 --- a/deps/v8/test/mjsunit/wasm/indirect-tables.js +++ b/deps/v8/test/mjsunit/wasm/indirect-tables.js @@ -33,7 +33,7 @@ function AddFunctions(builder) { function js_div(a, b) { return (a / b) | 0; } (function ExportedTableTest() { - print("ExportedTableTest..."); + print(arguments.callee.name); let builder = new WasmModuleBuilder(); @@ -102,9 +102,9 @@ function js_div(a, b) { return (a / b) | 0; } })(); -(function ImportedTableTest() { +(function ImportedTableTest1() { let kTableSize = 10; - print("ImportedTableTest..."); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); let d = builder.addImport("q", "js_div", kSig_i_ii); @@ -172,9 +172,9 @@ function js_div(a, b) { return (a / b) | 0; } } })(); -(function ImportedTableTest() { +(function ImportedTableTest2() { let kTableSize = 10; - print("ManualTableTest..."); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); @@ -240,7 +240,7 @@ function js_div(a, b) { return (a / b) | 0; } (function CumulativeTest() { - print("CumulativeTest..."); + print(arguments.callee.name); let kTableSize = 10; let table = new WebAssembly.Table( @@ -251,7 +251,7 @@ function js_div(a, b) { return (a / b) | 0; } builder.addImportedTable("x", "table", kTableSize, kTableSize); let g = builder.addImportedGlobal("x", "base", kWasmI32); let sig_index = builder.addType(kSig_i_v); - builder.addFunction("g", sig_index) + let f = builder.addFunction("f", sig_index) .addBody([ kExprGetGlobal, g ]); @@ -260,7 +260,7 @@ function js_div(a, b) { return (a / b) | 0; } kExprGetLocal, 0, kExprCallIndirect, sig_index, kTableZero]) // -- .exportAs("main"); - builder.addFunctionTableInit(g, true, [g]); + builder.addFunctionTableInit(g, true, [f.index]); let module = new WebAssembly.Module(builder.toBuffer()); @@ -283,7 +283,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TwoWayTest() { - print("TwoWayTest..."); + print(arguments.callee.name); let kTableSize = 3; // Module {m1} defines the table and exports it. @@ -342,7 +342,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function MismatchedTableSize() { - print("MismatchedTableSize..."); + print(arguments.callee.name); let kTableSize = 5; for (var expsize = 1; expsize < 4; expsize++) { @@ -374,7 +374,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TableGrowBoundsCheck() { - print("TableGrowBoundsCheck"); + print(arguments.callee.name); var kMaxSize = 30, kInitSize = 5; let table = new WebAssembly.Table({element: "anyfunc", initial: kInitSize, maximum: kMaxSize}); @@ -398,7 +398,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function CumulativeGrowTest() { - print("CumulativeGrowTest..."); + print(arguments.callee.name); let table = new WebAssembly.Table({ element: "anyfunc", initial: 10, maximum: 30}); var builder = new WasmModuleBuilder(); @@ -460,7 +460,7 @@ function js_div(a, b) { return (a / b) | 0; } (function TestImportTooLarge() { - print("TestImportTooLarge..."); + print(arguments.callee.name); let builder = new WasmModuleBuilder(); builder.addImportedTable("t", "t", 1, 2); @@ -478,7 +478,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function TableImportLargerThanCompiled() { - print("TableImportLargerThanCompiled..."); + print(arguments.callee.name); var kMaxSize = 30, kInitSize = 5; var builder = new WasmModuleBuilder(); builder.addImportedTable("x", "table", 1, 35); @@ -492,7 +492,7 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function ModulesShareTableAndGrow() { - print("ModulesShareTableAndGrow..."); + print(arguments.callee.name); let module1 = (() => { let builder = new WasmModuleBuilder(); builder.addImportedTable("x", "table", 1, 35); @@ -525,7 +525,7 @@ function js_div(a, b) { return (a / b) | 0; } (function MultipleElementSegments() { let kTableSize = 10; - print("MultipleElementSegments..."); + print(arguments.callee.name); let mul = (a, b) => a * b; let add = (a, b) => a + b; @@ -603,7 +603,8 @@ function js_div(a, b) { return (a / b) | 0; } })(); (function IndirectCallIntoOtherInstance() { - print("IndirectCallIntoOtherInstance..."); + print(arguments.callee.name); + var mem_1 = new WebAssembly.Memory({initial: 1}); var mem_2 = new WebAssembly.Memory({initial: 1}); var view_1 = new Int32Array(mem_1.buffer); @@ -644,7 +645,7 @@ function js_div(a, b) { return (a / b) | 0; } (function ImportedFreestandingTable() { - print("ImportedFreestandingTable..."); + print(arguments.callee.name); function forceGc() { gc(); @@ -709,7 +710,8 @@ function js_div(a, b) { return (a / b) | 0; } // Remove this test when v8:7232 is addressed comprehensively. (function TablesAreImmutableInWasmCallstacks() { - print('TablesAreImmutableInWasmCallstacks...'); + print(arguments.callee.name); + let table = new WebAssembly.Table({initial:2, element:'anyfunc'}); let builder = new WasmModuleBuilder(); @@ -743,3 +745,93 @@ function js_div(a, b) { return (a / b) | 0; } table.set(0, null); assertEquals(null, table.get(0)); })(); + +(function ImportedWasmFunctionPutIntoTable() { + print(arguments.callee.name); + + let wasm_mul = (() => { + let builder = new WasmModuleBuilder(); + builder.addFunction("mul", kSig_i_ii) + .addBody( + [kExprGetLocal, 0, + kExprGetLocal, 1, + kExprI32Mul]) + .exportFunc(); + return builder.instantiate().exports.mul; + })(); + + let builder = new WasmModuleBuilder(); + + let j = builder.addImport("q", "js_div", kSig_i_ii); + let w = builder.addImport("q", "wasm_mul", kSig_i_ii); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 33, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + builder.setFunctionTableBounds(10, 10); + let g = builder.addImportedGlobal("q", "base", kWasmI32); + builder.addFunctionTableInit(g, true, [j, w]); + + let module = new WebAssembly.Module(builder.toBuffer()); + for (var i = 0; i < 5; i++) { + let instance = new WebAssembly.Instance(module, {q: {base: i, js_div: js_div, wasm_mul: wasm_mul}}); + let j = i + 1; + + assertThrows(() => {instance.exports.main(j, i-1)}); + assertEquals((33/j)|0, instance.exports.main(j, i+0)); + assertEquals((33*j)|0, instance.exports.main(j, i+1)); + assertThrows(() => {instance.exports.main(j, i+2)}); + } + +})(); + +(function ImportedWasmFunctionPutIntoImportedTable() { + print(arguments.callee.name); + + let kTableSize = 10; + + let wasm_mul = (() => { + let builder = new WasmModuleBuilder(); + builder.addFunction("mul", kSig_i_ii) + .addBody( + [kExprGetLocal, 0, + kExprGetLocal, 1, + kExprI32Mul]) + .exportFunc(); + return builder.instantiate().exports.mul; + })(); + + let table = new WebAssembly.Table({element: "anyfunc", + initial: kTableSize, + maximum: kTableSize}); + + let builder = new WasmModuleBuilder(); + + let j = builder.addImport("q", "js_div", kSig_i_ii); + let w = builder.addImport("q", "wasm_mul", kSig_i_ii); + builder.addImportedTable("q", "table", kTableSize, kTableSize); + builder.addFunction("main", kSig_i_ii) + .addBody([ + kExprI32Const, 44, // -- + kExprGetLocal, 0, // -- + kExprGetLocal, 1, // -- + kExprCallIndirect, 0, kTableZero]) // -- + .exportAs("main"); + + let g = builder.addImportedGlobal("q", "base", kWasmI32); + builder.addFunctionTableInit(g, true, [j, w]); + + let module = new WebAssembly.Module(builder.toBuffer()); + for (var i = 0; i < 5; i++) { + let instance = new WebAssembly.Instance(module, {q: {base: i, js_div: js_div, wasm_mul: wasm_mul, table: table}}); + let j = i + 1; + + assertEquals((44/j)|0, instance.exports.main(j, i+0)); + assertEquals((44*j)|0, instance.exports.main(j, i+1)); + assertThrows(() => {instance.exports.main(j, i+2)}); + } +})(); diff --git a/deps/v8/test/mjsunit/wasm/interpreter.js b/deps/v8/test/mjsunit/wasm/interpreter.js index f5697eb00f..a57498b9a8 100644 --- a/deps/v8/test/mjsunit/wasm/interpreter.js +++ b/deps/v8/test/mjsunit/wasm/interpreter.js @@ -296,7 +296,7 @@ function checkStack(stack, expected_lines) { } catch (e) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ - 'TypeError: invalid type', // - + 'TypeError: ' + kTrapMsgs[kTrapTypeError], // - ' at direct (wasm-function[1]:1)', // - ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - @@ -309,7 +309,7 @@ function checkStack(stack, expected_lines) { } catch (e) { if (!(e instanceof TypeError)) throw e; checkStack(stripPath(e.stack), [ - 'TypeError: invalid type', // - + 'TypeError: ' + kTrapMsgs[kTrapTypeError], // - ' at indirect (wasm-function[2]:1)', // - ' at main (wasm-function[3]:3)', // - /^ at testIllegalImports \(interpreter.js:\d+:22\)$/, // - @@ -493,3 +493,30 @@ function checkStack(stack, expected_lines) { tab.set(0, instance1.exports.exp); instance2.exports.call2(); })(); + +(function testTableCall3() { + // See crbug.com/814562. + print(arguments.callee.name); + const builder0 = new WasmModuleBuilder(); + const sig_index = builder0.addType(kSig_i_v); + builder0.addFunction('main', kSig_i_i) + .addBody([ + kExprGetLocal, 0, // -- + kExprCallIndirect, sig_index, kTableZero + ]) // -- + .exportAs('main'); + builder0.setFunctionTableBounds(3, 3); + builder0.addExportOfKind('table', kExternalTable); + const module0 = new WebAssembly.Module(builder0.toBuffer()); + const instance0 = new WebAssembly.Instance(module0); + + const builder1 = new WasmModuleBuilder(); + builder1.addFunction('main', kSig_i_v).addBody([kExprUnreachable]); + builder1.addImportedTable('z', 'table'); + builder1.addFunctionTableInit(0, false, [0], true); + const module1 = new WebAssembly.Module(builder1.toBuffer()); + const instance1 = + new WebAssembly.Instance(module1, {z: {table: instance0.exports.table}}); + assertThrows( + () => instance0.exports.main(0), WebAssembly.RuntimeError, 'unreachable'); +})(); diff --git a/deps/v8/test/mjsunit/wasm/liftoff.js b/deps/v8/test/mjsunit/wasm/liftoff.js index b65f83f9ec..c57cbfc090 100644 --- a/deps/v8/test/mjsunit/wasm/liftoff.js +++ b/deps/v8/test/mjsunit/wasm/liftoff.js @@ -7,6 +7,22 @@ load('test/mjsunit/wasm/wasm-constants.js'); load('test/mjsunit/wasm/wasm-module-builder.js'); +(function testLiftoffFlag() { + print(arguments.callee.name); + const builder = new WasmModuleBuilder(); + builder.addFunction('i32_add', kSig_i_ii) + .addBody([kExprGetLocal, 0, kExprGetLocal, 1, kExprI32Add]) + .exportFunc(); + + const module = new WebAssembly.Module(builder.toBuffer()); + const instance = new WebAssembly.Instance(module); + const instance2 = new WebAssembly.Instance(module); + + assertEquals(%IsLiftoffFunction(instance.exports.i32_add), + %IsLiftoffFunction(instance2.exports.i32_add)); +})(); + + (function testLiftoffSync() { print(arguments.callee.name); const builder = new WasmModuleBuilder(); diff --git a/deps/v8/test/mjsunit/wasm/memory-size.js b/deps/v8/test/mjsunit/wasm/memory-size.js index 0c96efb798..f803df2e3d 100644 --- a/deps/v8/test/mjsunit/wasm/memory-size.js +++ b/deps/v8/test/mjsunit/wasm/memory-size.js @@ -7,8 +7,11 @@ load("test/mjsunit/wasm/wasm-constants.js"); load("test/mjsunit/wasm/wasm-module-builder.js"); +var kV8MaxWasmMemoryPages = 32767; // ~ 2 GiB +var kSpecMaxWasmMemoryPages = 65536; // 4 GiB + (function testMemorySizeZero() { - print("testMemorySizeZero()"); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); builder.addMemory(0, 0, false); builder.addFunction("memory_size", kSig_i_v) @@ -19,7 +22,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); })(); (function testMemorySizeNonZero() { - print("testMemorySizeNonZero()"); + print(arguments.callee.name); var builder = new WasmModuleBuilder(); var size = 11; builder.addMemory(size, size, false); @@ -29,3 +32,42 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); var module = builder.instantiate(); assertEquals(size, module.exports.memory_size()); })(); + +(function testMemorySizeSpecMaxOk() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, kSpecMaxWasmMemoryPages, true); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(1, module.exports.memory_size()); +})(); + +(function testMemorySizeV8MaxPlus1Throws() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(kV8MaxWasmMemoryPages + 1, + kV8MaxWasmMemoryPages + 1, false); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + assertThrows(() => builder.instantiate()); +})(); + +(function testMemorySpecMaxOk() { + print(arguments.callee.name); + var builder = new WasmModuleBuilder(); + builder.addMemory(1, kSpecMaxWasmMemoryPages, false); + builder.addFunction("memory_size", kSig_i_v) + .addBody([kExprMemorySize, kMemoryZero]) + .exportFunc(); + var module = builder.instantiate(); + assertEquals(1, module.exports.memory_size()); +})(); + +(function testMemoryInitialMaxPlus1Throws() { + print(arguments.callee.name); + assertThrows(() => new WebAssembly.Memory( + {initial: kV8WasmMaxMemoryPages + 1})); +})(); diff --git a/deps/v8/test/mjsunit/wasm/table-grow.js b/deps/v8/test/mjsunit/wasm/table-grow.js index a9a4ba298c..c78d272139 100644 --- a/deps/v8/test/mjsunit/wasm/table-grow.js +++ b/deps/v8/test/mjsunit/wasm/table-grow.js @@ -286,7 +286,7 @@ let id = (() => { // identity exported function assertInvalidFunction = function(s) { assertThrows( () => instances[i].exports.main(s), WebAssembly.RuntimeError, - /invalid function/); + kTrapMsgs[kTrapFuncInvalid]); } assertInvalidFunction(size); assertInvalidFunction(size + 1); diff --git a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js b/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js deleted file mode 100644 index e298468350..0000000000 --- a/deps/v8/test/mjsunit/wasm/test-import-export-wrapper.js +++ /dev/null @@ -1,326 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Flags: --expose-wasm --allow-natives-syntax - -load("test/mjsunit/wasm/wasm-constants.js"); -load("test/mjsunit/wasm/wasm-module-builder.js"); - -var expect_elison = 0; -var expect_no_elison = 1; -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, first_import and second_export have same signature, -// So that wrappers will be removed -(function TestWasmWrapperElision() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index = second_module.addType(kSig_i_i); - second_module - .addImport("import_module_2", "import_name_2", sig_index); - second_module - .addFunction("second_export", sig_index) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index = first_module.addType(kSig_i_i); - first_module - .addImport("import_module_1", "import_name_1", sig_index); - first_module - .addFunction("first_export", sig_index) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index) - .addBody([ - kExprI32Const, 1, - kExprGetLocal, 0, - kExprI32Add, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(2), 3); - assertEquals(the_export(-1), 0); - assertEquals(the_export(0), 1); - assertEquals(the_export(5.5), 6); - assertEquals(%CheckWasmWrapperElision(the_export, expect_elison), true); -})(); - -// Function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this test, first_import and second_export have the same signature, and -// therefore the wrappers will be removed. If the wrappers are not removed, then -// the test crashes because of the int64 parameter, which is not allowed in the -// wrappers. -(function TestWasmWrapperElisionInt64() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index1 = second_module.addType(kSig_i_i); - var sig_index_ll = second_module.addType(kSig_l_l); - second_module - .addImport("import_module_2", "import_name_2", sig_index1); - second_module - .addFunction("second_export", sig_index_ll) - .addBody([ - kExprGetLocal, 0, - kExprI32ConvertI64, - kExprCallFunction, 0, - kExprI64SConvertI32, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index = first_module.addType(kSig_i_v); - var sig_index_ll = first_module.addType(kSig_l_l); - first_module - .addImport("import_module_1", "import_name_1", sig_index_ll); - first_module - .addFunction("first_export", sig_index) - .addBody([ - kExprI64Const, 2, - kExprCallFunction, 2, - kExprI32ConvertI64, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_ll) - .addBody([ - kExprI64Const, 1, - kExprGetLocal, 0, - kExprI64Add, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(), 3); -})(); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has fewer params than first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionLessParams() { - var imported = function (a) { - return a; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_1 = second_module.addType(kSig_i_i); - second_module - .addImport("import_module_2", "import_name_2", sig_index_1); - second_module - .addFunction("second_export", sig_index_1) - .addBody([ - kExprGetLocal, 0, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(4, 5), 4); - assertEquals(the_export(-1, 4), -1); - assertEquals(the_export(0, 2), 0); - assertEquals(the_export(9.9, 4.3), 9); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has more params than first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionMoreParams() { - var imported = function (a, b, c) { - return a+b+c; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_3 = second_module.addType(kSig_i_iii); - second_module - .addImport("import_module_2", "import_name_2", sig_index_3); - second_module - .addFunction("second_export", sig_index_3) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprGetLocal, 2, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(5, 6), 11); - assertEquals(the_export(-1, -4), -5); - assertEquals(the_export(0, 0), 0); - assertEquals(the_export(1.1, 2.7), 3); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - -// function calls stack: first_export -> first_func -> first_import -> -// second_export -> second_import -// In this case, second_export has different params type with first_import, -// so instantiation should fail. -assertThrows(function TestWasmWrapperNoElisionTypeMismatch() { - var imported = function (a, b) { - return a+b; - }; - - var second_module = new WasmModuleBuilder(); - var sig_index_2 = second_module.addType(kSig_d_dd); - second_module - .addImport("import_module_2", "import_name_2", sig_index_2); - second_module - .addFunction("second_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]) - .exportFunc(); - - var first_module = new WasmModuleBuilder(); - var sig_index_2 = first_module.addType(kSig_i_ii); - first_module - .addImport("import_module_1", "import_name_1", sig_index_2); - first_module - .addFunction("first_export", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 2, - kExprReturn - ]) - .exportFunc(); - first_module - .addFunction("first_func", sig_index_2) - .addBody([ - kExprGetLocal, 0, - kExprGetLocal, 1, - kExprCallFunction, 0, - kExprReturn - ]); - - var f = second_module - .instantiate({import_module_2: {import_name_2: imported}}) - .exports.second_export; - var the_export = first_module - .instantiate({import_module_1: {import_name_1: f}}) - .exports.first_export; - assertEquals(the_export(2.8, 9.1), 11); - assertEquals(the_export(-1.7, -2.5), -3); - assertEquals(the_export(0.0, 0.0), 0); - assertEquals(the_export(2, -2), 0); - assertEquals(%CheckWasmWrapperElision(the_export, expect_no_elison), true); -}); - - -(function TestSimpleI64Ret() { - var builder = new WasmModuleBuilder(); - builder.addFunction("exp", kSig_l_v) - .addBody([ - kExprI64Const, 23 - ]) - .exportFunc(); - var exported = builder.instantiate().exports.exp; - - var builder = new WasmModuleBuilder(); - builder.addImport("imp", "func", kSig_l_v); - builder.addFunction("main", kSig_i_v) - .addBody([ - kExprCallFunction, 0, - kExprI32ConvertI64 - ]) - .exportFunc(); - - var instance = builder.instantiate({imp: {func: exported}}); - - assertEquals(23, instance.exports.main()); - -})(); diff --git a/deps/v8/test/mjsunit/wasm/wasm-constants.js b/deps/v8/test/mjsunit/wasm/wasm-constants.js index 4c86065b89..4a303c77ac 100644 --- a/deps/v8/test/mjsunit/wasm/wasm-constants.js +++ b/deps/v8/test/mjsunit/wasm/wasm-constants.js @@ -114,7 +114,7 @@ let kSig_i_dd = makeSig([kWasmF64, kWasmF64], [kWasmI32]); let kSig_v_v = makeSig([], []); let kSig_i_v = makeSig([], [kWasmI32]); let kSig_l_v = makeSig([], [kWasmI64]); -let kSig_f_v = makeSig([], [kWasmF64]); +let kSig_f_v = makeSig([], [kWasmF32]); let kSig_d_v = makeSig([], [kWasmF64]); let kSig_v_i = makeSig([kWasmI32], []); let kSig_v_ii = makeSig([kWasmI32, kWasmI32], []); @@ -374,7 +374,7 @@ let kTrapRemByZero = 4; let kTrapFloatUnrepresentable = 5; let kTrapFuncInvalid = 6; let kTrapFuncSigMismatch = 7; -let kTrapInvalidIndex = 8; +let kTrapTypeError = 8; let kTrapMsgs = [ "unreachable", @@ -382,10 +382,10 @@ let kTrapMsgs = [ "divide by zero", "divide result unrepresentable", "remainder by zero", - "integer result unrepresentable", - "invalid function", + "float unrepresentable in integer range", + "invalid index into function table", "function signature mismatch", - "invalid index into function table" + "wasm function signature contains illegal type" ]; function assertTraps(trap, code) { |