diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 40 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 20 | ||||
-rw-r--r-- | test/binaryen.js/reloc.js | 4 | ||||
-rw-r--r-- | test/binaryen.js/reloc.js.txt | 2 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 31 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 8 | ||||
-rw-r--r-- | test/example/c-api-multiple-tables.c | 44 | ||||
-rw-r--r-- | test/example/c-api-multiple-tables.txt | 5 | ||||
-rw-r--r-- | test/multi-table.wast | 9 | ||||
-rw-r--r-- | test/multi-table.wast.from-wast | 11 | ||||
-rw-r--r-- | test/multi-table.wast.fromBinary | 11 | ||||
-rw-r--r-- | test/multi-table.wast.fromBinary.noDebugInfo | 9 | ||||
-rw-r--r-- | test/passes/fuzz_metrics_noprint.bin.txt | 51 | ||||
-rw-r--r-- | test/passes/translate-to-fuzz_all-features_metrics_noprint.txt | 63 |
14 files changed, 187 insertions, 121 deletions
diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 3aebe0e61..084a7d47b 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -518,7 +518,7 @@ function test_core() { ) ), module.i32.eqz( // check the output type of the call node - module.call_indirect("0", makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32) + module.call_indirect("t0", 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)), @@ -533,7 +533,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("0", makeInt32(2449), [ makeInt32(13), makeInt64(37, 0), makeFloat32(1.3), makeFloat64(3.7) ], iIfF, binaryen.i32), + module.return_call_indirect("t0", 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)), @@ -665,7 +665,7 @@ function test_core() { module.addEventExport("a-event", "a-event-exp"); // Tables - module.addTable("t1", 0, 2, []); + module.addTable("t1", 0, 2); var tablePtr = module.getTable("t1"); assert(tablePtr !== 0); assert(tablePtr === module.getTableByIndex(0)); @@ -676,13 +676,14 @@ function test_core() { 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 ]); + + module.addTable("t0", 1, 0xffffffff); + module.addActiveElementSegment("t0", "e0", [ binaryen.getFunctionInfo(sinker).name ]); assert(module.getNumTables() === 1); + assert(module.getNumElementSegments() === 1); // Memory. One per module @@ -1072,16 +1073,23 @@ function test_for_each() { assert(expected_passive[i] === segment.passive); } + module.addTable("t0", 1, 0xffffffff); + var ftable = module.getTable("t0"); var constExprRef = module.i32.const(0); - module.setFunctionTable(1, 0xffffffff, funcNames, constExprRef); - - var ftable = module.getFunctionTable(); - assert(false === ftable.imported); - assert(1 === ftable.segments.length); - assert(constExprRef === ftable.segments[0].offset); - assert(3 === ftable.segments[0].names.length); - for (i = 0; i < ftable.segments[0].names.length; i++) { - assert(funcNames[i] === ftable.segments[0].names[i]); + module.addActiveElementSegment("t0", "e0", funcNames, constExprRef); + + var tableInfo = binaryen.getTableInfo(ftable); + assert("" === tableInfo.module); + assert("" === tableInfo.base); + + var segments = module.getTableSegments(ftable); + assert(1 === segments.length); + + var elemSegment = binaryen.getElementSegmentInfo(segments[0]); + assert(constExprRef === elemSegment.offset); + assert(3 === elemSegment.data.length); + for (i = 0; i < elemSegment.data.length; i++) { + assert(funcNames[i] === elemSegment.data[i]); } console.log(module.emitText()); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index aff1d1f2d..700e8507f 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -131,8 +131,8 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data passive "I am passive") - (table $0 1 funcref) - (elem (i32.const 0) "$kitchen()sinker") + (table $t0 1 funcref) + (elem $e0 (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 1)) (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) @@ -1759,7 +1759,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call_indirect $0 (type $i32_i64_f32_f64_=>_i32) + (call_indirect $t0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -1823,7 +1823,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (f32.const 1.2999999523162842) (f64.const 3.7) ) - (return_call_indirect $0 (type $i32_i64_f32_f64_=>_i32) + (return_call_indirect $t0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -1993,8 +1993,8 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data passive "I am passive") - (table $0 1 funcref) - (elem (i32.const 0) "$kitchen()sinker") + (table $t0 1 funcref) + (elem $e0 (i32.const 0) "$kitchen()sinker") (global $a-global i32 (i32.const 1)) (event $a-event (attr 0) (param i32)) (export "kitchen_sinker" (func "$kitchen()sinker")) @@ -3621,7 +3621,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} ) (drop (i32.eqz - (call_indirect $0 (type $i32_i64_f32_f64_=>_i32) + (call_indirect $t0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -3685,7 +3685,7 @@ getExpressionInfo(tuple[3])={"id":14,"type":5,"value":3.7} (f32.const 1.2999999523162842) (f64.const 3.7) ) - (return_call_indirect $0 (type $i32_i64_f32_f64_=>_i32) + (return_call_indirect $t0 (type $i32_i64_f32_f64_=>_i32) (i32.const 13) (i64.const 37) (f32.const 1.2999999523162842) @@ -4389,8 +4389,8 @@ sizeof Literal: 24 (memory $0 1 256) (data (i32.const 10) "hello, world") (data (global.get $a-global) "segment data 2") - (table $0 1 funcref) - (elem (i32.const 0) $fn0 $fn1 $fn2) + (table $t0 1 funcref) + (elem $e0 (i32.const 0) $fn0 $fn1 $fn2) (global $a-global i32 (i32.const 125)) (global $a-global2 i32 (i32.const 2)) (global $a-global3 i32 (i32.const 3)) diff --git a/test/binaryen.js/reloc.js b/test/binaryen.js/reloc.js index bb011916d..2b7cc9f90 100644 --- a/test/binaryen.js/reloc.js +++ b/test/binaryen.js/reloc.js @@ -15,7 +15,7 @@ module.setMemory(1, -1, null, [ var func = module.addFunction("func", binaryen.none, binaryen.none, [], module.nop()); module.addGlobalImport("table_base", "env", "table_base", binaryen.i32, false); -module.setFunctionTable(1, -1, [ "func", "func" ], module.global.get("table_base", binaryen.i32)); - +module.addTable("0", 1, -1); +module.addActiveElementSegment("0", "0", [ "func", "func" ], module.global.get("table_base", binaryen.i32)); assert(module.validate()); console.log(module.emitText()); diff --git a/test/binaryen.js/reloc.js.txt b/test/binaryen.js/reloc.js.txt index 729f29b9d..262ba3d0c 100644 --- a/test/binaryen.js/reloc.js.txt +++ b/test/binaryen.js/reloc.js.txt @@ -5,7 +5,7 @@ (memory $0 1) (data (global.get $memory_base) "data data") (table $0 1 funcref) - (elem (global.get $table_base) $func $func) + (elem $0 (global.get $table_base) $func $func) (func $func (nop) ) diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 04f552069..fa23a47ce 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -320,7 +320,7 @@ void test_core() { BinaryenAddEvent( module, "a-event", 0, BinaryenTypeInt32(), BinaryenTypeNone()); - BinaryenAddTable(module, "tab", 0, 100, NULL, 0, makeInt32(module, 0)); + BinaryenAddTable(module, "tab", 0, 100); // Exception handling @@ -855,7 +855,17 @@ void test_core() { // Function table. One per module const char* funcNames[] = { BinaryenFunctionGetName(sinker) }; - BinaryenSetFunctionTable(module, 1, 1, funcNames, 1, BinaryenConst(module, BinaryenLiteralInt32(0))); + BinaryenAddTable(module, "0", 1, 1); + BinaryenAddActiveElementSegment( + module, + "0", + "0", + funcNames, + 1, + BinaryenConst(module, BinaryenLiteralInt32(0))); + BinaryenAddPassiveElementSegment(module, "passive", funcNames, 1); + BinaryenAddPassiveElementSegment(module, "p2", funcNames, 1); + BinaryenRemoveElementSegment(module, "p2"); // Memory. One per module @@ -1382,14 +1392,15 @@ void test_for_each() { BinaryenFunctionGetName(fns[2]) }; BinaryenExpressionRef constExprRef = BinaryenConst(module, BinaryenLiteralInt32(0)); - BinaryenSetFunctionTable(module, 1, 1, funcNames, 3, constExprRef); - assert(0 == BinaryenIsFunctionTableImported(module)); - assert(1 == BinaryenGetNumFunctionTableSegments(module)); - assert(constExprRef == BinaryenGetFunctionTableSegmentOffset(module, 0)); - assert(3 == BinaryenGetFunctionTableSegmentLength(module, 0)); - for (i = 0; i != BinaryenGetFunctionTableSegmentLength(module, 0); ++i) - { - const char * str = BinaryenGetFunctionTableSegmentData(module, 0, i); + BinaryenAddTable(module, "0", 1, 1); + BinaryenAddActiveElementSegment( + module, "0", "0", funcNames, 3, constExprRef); + assert(1 == BinaryenGetNumElementSegments(module)); + BinaryenElementSegmentRef segment = + BinaryenGetElementSegmentByIndex(module, 0); + assert(constExprRef == BinaryenElementSegmentGetOffset(segment)); + for (i = 0; i != BinaryenElementSegmentGetLength(segment); ++i) { + const char* str = BinaryenElementSegmentGetData(segment, i); assert(0 == strcmp(funcNames[i], str)); } } diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index 40b7da26e..761b08c85 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -39,8 +39,10 @@ BinaryenFeatureAll: 8191 (memory $0 (shared 1 256)) (data (i32.const 10) "hello, world") (data passive "I am passive") - (table $tab 1 1 funcref) - (elem (i32.const 0) "$kitchen()sinker") + (table $tab 0 100 funcref) + (table $0 1 1 funcref) + (elem $0 (table $0) (i32.const 0) func "$kitchen()sinker") + (elem $passive func "$kitchen()sinker") (global $a-global i32 (i32.const 7)) (global $a-mutable-global (mut f32) (f32.const 7.5)) (event $a-event (attr 0) (param i32)) @@ -2461,7 +2463,7 @@ validation: 0 (data (i32.const 10) "hello, world") (data (global.get $a-global) "segment data 2") (table $0 1 1 funcref) - (elem (i32.const 0) $fn0 $fn1 $fn2) + (elem $0 (i32.const 0) $fn0 $fn1 $fn2) (global $a-global i32 (i32.const 125)) (export "export0" (func $fn0)) (export "export1" (func $fn1)) diff --git a/test/example/c-api-multiple-tables.c b/test/example/c-api-multiple-tables.c index 625af444c..c19dcdb6f 100644 --- a/test/example/c-api-multiple-tables.c +++ b/test/example/c-api-multiple-tables.c @@ -31,28 +31,42 @@ int main() { BinaryenAddFunction(module, "adder", params, results, NULL, 0, add); const char* funcNames[] = {"adder"}; - BinaryenAddTable(module, - "tab", - 1, - 1, - funcNames, - 1, - BinaryenConst(module, BinaryenLiteralInt32(0))); + BinaryenAddTable(module, "tab", 1, 1); assert(BinaryenGetTable(module, "tab") != NULL); - - BinaryenAddTable(module, - "t2", - 1, - 1, - funcNames, - 1, - BinaryenConst(module, BinaryenLiteralInt32(0))); + BinaryenAddActiveElementSegment( + module, + "tab", + "0", + funcNames, + 1, + BinaryenConst(module, BinaryenLiteralInt32(0))); + + BinaryenAddTable(module, "t2", 1, 1); + BinaryenAddActiveElementSegment( + module, + "t2", + "1", + funcNames, + 1, + BinaryenConst(module, BinaryenLiteralInt32(0))); + BinaryenAddPassiveElementSegment(module, "passive", funcNames, 1); + assert(NULL != BinaryenGetElementSegmentByIndex(module, 2)); + assert(1 == BinayenElementSegmentIsPassive( + BinaryenGetElementSegment(module, "passive"))); BinaryenTableRef t2 = BinaryenGetTableByIndex(module, 1); assert(t2 != NULL); + BinaryenElementSegmentRef elem1 = BinaryenGetElementSegment(module, "1"); + assert(elem1 != NULL); + assert(strcmp(BinaryenElementSegmentGetName(elem1), "1") == 0); + assert(strcmp(BinaryenElementSegmentGetTable(elem1), "t2") == 0); + assert(BinaryenElementSegmentGetLength(elem1) == 1); + assert(strcmp(BinaryenElementSegmentGetData(elem1, 0), funcNames[0]) == 0); assert(strcmp(BinaryenTableGetName(t2), "t2") == 0); BinaryenTableSetName(t2, "table2"); assert(strcmp(BinaryenTableGetName(t2), "table2") == 0); + BinaryenElementSegmentSetTable(elem1, "table2"); + assert(strcmp(BinaryenElementSegmentGetTable(elem1), "table2") == 0); assert(BinaryenTableGetInitial(t2) == 1); BinaryenTableSetInitial(t2, 2); assert(BinaryenTableGetInitial(t2) == 2); diff --git a/test/example/c-api-multiple-tables.txt b/test/example/c-api-multiple-tables.txt index 5b2858e91..8a2963729 100644 --- a/test/example/c-api-multiple-tables.txt +++ b/test/example/c-api-multiple-tables.txt @@ -1,9 +1,10 @@ (module (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) (table $tab 1 1 funcref) - (elem (table $tab) (i32.const 0) func $adder) + (elem $0 (table $tab) (i32.const 0) func $adder) (table $table2 2 2 funcref) - (elem (table $table2) (i32.const 0) func $adder) + (elem $1 (table $table2) (i32.const 0) func $adder) + (elem $passive func $adder) (func $adder (param $0 i32) (param $1 i32) (result i32) (i32.add (local.get $0) diff --git a/test/multi-table.wast b/test/multi-table.wast index 07c1e0077..378d4018a 100644 --- a/test/multi-table.wast +++ b/test/multi-table.wast @@ -7,8 +7,13 @@ ;; add to $t2 (elem (table $t2) (i32.const 0) func $f) - (elem (table $t2) (offset (i32.const 1)) func $f $g) + (elem $activeNonZeroOffset (table $t2) (offset (i32.const 1)) func $f $g) - (func $f) + (elem $passive func $f $g) + (elem $empty func) + (elem $declarative declare func $h) + + (func $f (drop (ref.func $h))) (func $g) + (func $h) )
\ No newline at end of file diff --git a/test/multi-table.wast.from-wast b/test/multi-table.wast.from-wast index 9d1842b70..f60bab8cb 100644 --- a/test/multi-table.wast.from-wast +++ b/test/multi-table.wast.from-wast @@ -4,11 +4,18 @@ (elem (table $t1) (i32.const 0) func $f) (table $t2 3 3 funcref) (elem (table $t2) (i32.const 0) func $f) - (elem (table $t2) (i32.const 1) func $f $g) + (elem $activeNonZeroOffset (table $t2) (i32.const 1) func $f $g) + (elem $passive func $f $g) + (elem declare func $h) (func $f - (nop) + (drop + (ref.func $h) + ) ) (func $g (nop) ) + (func $h + (nop) + ) ) diff --git a/test/multi-table.wast.fromBinary b/test/multi-table.wast.fromBinary index 1bfd568da..13604e69d 100644 --- a/test/multi-table.wast.fromBinary +++ b/test/multi-table.wast.fromBinary @@ -4,12 +4,19 @@ (elem (table $t1) (i32.const 0) func $f) (table $t2 3 3 funcref) (elem (table $t2) (i32.const 0) func $f) - (elem (table $t2) (i32.const 1) func $f $g) + (elem $activeNonZeroOffset (table $t2) (i32.const 1) func $f $g) + (elem $passive func $f $g) + (elem declare func $h) (func $f - (nop) + (drop + (ref.func $h) + ) ) (func $g (nop) ) + (func $h + (nop) + ) ) diff --git a/test/multi-table.wast.fromBinary.noDebugInfo b/test/multi-table.wast.fromBinary.noDebugInfo index 00c3a64cb..77e2ea439 100644 --- a/test/multi-table.wast.fromBinary.noDebugInfo +++ b/test/multi-table.wast.fromBinary.noDebugInfo @@ -5,11 +5,18 @@ (table $0 3 3 funcref) (elem (table $0) (i32.const 0) func $0) (elem (table $0) (i32.const 1) func $0 $1) + (elem func $0 $1) + (elem declare func $2) (func $0 - (nop) + (drop + (ref.func $2) + ) ) (func $1 (nop) ) + (func $2 + (nop) + ) ) diff --git a/test/passes/fuzz_metrics_noprint.bin.txt b/test/passes/fuzz_metrics_noprint.bin.txt index d8c708f3c..eb24adfa4 100644 --- a/test/passes/fuzz_metrics_noprint.bin.txt +++ b/test/passes/fuzz_metrics_noprint.bin.txt @@ -1,31 +1,32 @@ total [events] : 0 - [exports] : 35 - [funcs] : 45 + [exports] : 41 + [funcs] : 55 [globals] : 7 [imports] : 4 [memory-data] : 4 - [table-data] : 16 + [table-data] : 17 [tables] : 1 - [total] : 9206 - [vars] : 186 - Binary : 715 - Block : 1348 - Break : 397 - Call : 285 - CallIndirect : 20 - Const : 1464 - Drop : 63 - GlobalGet : 749 - GlobalSet : 324 - If : 537 - Load : 171 - LocalGet : 888 - LocalSet : 610 - Loop : 248 - Nop : 190 - Return : 338 - Select : 77 - Store : 122 - Unary : 659 - Unreachable : 1 + [total] : 5797 + [vars] : 160 + Binary : 467 + Block : 810 + Break : 212 + Call : 363 + CallIndirect : 32 + Const : 1045 + Drop : 48 + GlobalGet : 460 + GlobalSet : 183 + If : 310 + Load : 131 + LocalGet : 471 + LocalSet : 292 + Loop : 127 + Nop : 69 + Return : 259 + Select : 53 + Store : 53 + Switch : 1 + Unary : 408 + Unreachable : 3 diff --git a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt index 97d0310e1..2fe8a8a9e 100644 --- a/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt +++ b/test/passes/translate-to-fuzz_all-features_metrics_noprint.txt @@ -1,39 +1,42 @@ total [events] : 2 - [exports] : 12 - [funcs] : 14 + [exports] : 7 + [funcs] : 6 [globals] : 6 [imports] : 5 [memory-data] : 22 - [table-data] : 2 + [table-data] : 0 [tables] : 1 - [total] : 555 - [vars] : 42 + [total] : 764 + [vars] : 29 AtomicFence : 2 - AtomicNotify : 1 - Binary : 72 - Block : 60 - Break : 16 - Call : 34 - CallRef : 1 - Const : 109 + Binary : 88 + Block : 79 + Break : 19 + Call : 39 + CallRef : 4 + Const : 166 DataDrop : 1 Drop : 5 - GlobalGet : 28 - GlobalSet : 14 - If : 25 - Load : 20 - LocalGet : 53 - LocalSet : 26 - Loop : 3 - MemoryFill : 1 - Nop : 2 - RefEq : 1 - RefFunc : 2 - RefNull : 26 - Return : 16 - Select : 2 - Store : 3 - TupleExtract : 4 - TupleMake : 6 - Unary : 22 + GlobalGet : 31 + GlobalSet : 19 + If : 33 + Load : 24 + LocalGet : 55 + LocalSet : 32 + Loop : 11 + MemoryCopy : 1 + MemoryInit : 2 + Nop : 6 + RefEq : 2 + RefFunc : 4 + RefIs : 2 + RefNull : 54 + Return : 18 + SIMDExtract : 1 + SIMDShuffle : 1 + Select : 3 + Store : 6 + TupleExtract : 5 + TupleMake : 16 + Unary : 35 |