diff options
Diffstat (limited to 'test/binaryen.js')
-rw-r--r-- | test/binaryen.js/expressions.js | 6 | ||||
-rw-r--r-- | test/binaryen.js/expressions.js.txt | 2 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 22 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 8 | ||||
-rw-r--r-- | test/binaryen.js/tail_calls.js | 1 |
5 files changed, 29 insertions, 10 deletions
diff --git a/test/binaryen.js/expressions.js b/test/binaryen.js/expressions.js index 3d2a5d138..4c97cdb90 100644 --- a/test/binaryen.js/expressions.js +++ b/test/binaryen.js/expressions.js @@ -295,6 +295,7 @@ console.log("# CallIndirect"); (function testCallIndirect() { const module = new binaryen.Module(); + var table = "0"; var target = module.i32.const(42); var params = binaryen.none; var results = binaryen.none; @@ -302,9 +303,10 @@ console.log("# CallIndirect"); module.i32.const(1), module.i32.const(2) ]; - const theCallIndirect = binaryen.CallIndirect(module.call_indirect(target, operands, params, results)); + const theCallIndirect = binaryen.CallIndirect(module.call_indirect(table, target, operands, params, results)); assert(theCallIndirect instanceof binaryen.CallIndirect); assert(theCallIndirect instanceof binaryen.Expression); + assert(theCallIndirect.table === table); assert(theCallIndirect.target === target); assertDeepEqual(theCallIndirect.operands, operands); assert(theCallIndirect.params === params); @@ -346,7 +348,7 @@ console.log("# CallIndirect"); assert( theCallIndirect.toText() == - "(call_indirect (type $i32_i32_=>_i32)\n (i32.const 7)\n (i32.const 6)\n (i32.const 9000)\n)\n" + "(call_indirect $0 (type $i32_i32_=>_i32)\n (i32.const 7)\n (i32.const 6)\n (i32.const 9000)\n)\n" ); module.dispose(); diff --git a/test/binaryen.js/expressions.js.txt b/test/binaryen.js/expressions.js.txt index 5a0353c27..80a642af8 100644 --- a/test/binaryen.js/expressions.js.txt +++ b/test/binaryen.js/expressions.js.txt @@ -42,7 +42,7 @@ ) # CallIndirect -(call_indirect (type $i32_i32_=>_i32) +(call_indirect $0 (type $i32_i32_=>_i32) (i32.const 7) (i32.const 6) (i32.const 9000) diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 39154ef7d..327cf0534 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -517,7 +517,7 @@ function test_core() { ) ), module.i32.eqz( // check the output type of the call node - module.call_indirect(makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32) + module.call_indirect("0", makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32) ), module.drop(module.local.get(0, binaryen.i32)), module.local.set(0, makeInt32(101)), @@ -532,7 +532,7 @@ function test_core() { module.return(makeInt32(1337)), // Tail Call module.return_call("kitchen()sinker", [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], binaryen.i32), - module.return_call_indirect(makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32), + module.return_call_indirect("0", makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32), // Reference types module.ref.is_null(module.ref.null(binaryen.externref)), @@ -661,9 +661,25 @@ function test_core() { module.addGlobalExport("a-global", "a-global-exp"); module.addEventExport("a-event", "a-event-exp"); - // Function table. One per module + // Tables + module.addTable("t1", 0, 2, []); + var tablePtr = module.getTable("t1"); + assert(tablePtr !== 0); + assert(tablePtr === module.getTableByIndex(0)); + var table = binaryen.getTableInfo(tablePtr); + assert(table.name === "t1"); + assert(table.module === ""); + assert(table.base === ""); + assert(table.initial === 0); + assert(table.max === 2); + + module.removeTable("t1"); + assert(module.getNumTables() === 0); + + // Legacy module.setFunctionTable(1, 0xffffffff, [ binaryen.getFunctionInfo(sinker).name ]); + assert(module.getNumTables() === 1); // Memory. One per module diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index 9b45d9a01..4b9de93ab 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -1758,7 +1758,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call_indirect (type $i32_i64_f32_f64_=>_i32) + (call_indirect $0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -1822,7 +1822,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (f32.const 1.2999999523162842) (f64.const 3.7) ) - (return_call_indirect (type $i32_i64_f32_f64_=>_i32) + (return_call_indirect $0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -3620,7 +3620,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call_indirect (type $i32_i64_f32_f64_=>_i32) + (call_indirect $0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -3684,7 +3684,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (f32.const 1.2999999523162842) (f64.const 3.7) ) - (return_call_indirect (type $i32_i64_f32_f64_=>_i32) + (return_call_indirect $0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) diff --git a/test/binaryen.js/tail_calls.js b/test/binaryen.js/tail_calls.js index 1b993be91..61fe5d829 100644 --- a/test/binaryen.js/tail_calls.js +++ b/test/binaryen.js/tail_calls.js @@ -18,6 +18,7 @@ var bar = module.addFunction( binaryen.none, [], module.return_call_indirect( + "0", module.i32.const(0), [], binaryen.none, |