diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/anyref.wast | 18 | ||||
-rw-r--r-- | test/anyref.wast.from-wast | 19 | ||||
-rw-r--r-- | test/anyref.wast.fromBinary | 20 | ||||
-rw-r--r-- | test/anyref.wast.fromBinary.noDebugInfo | 20 | ||||
-rw-r--r-- | test/binaryen.js/exception-handling.js.txt | 6 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js | 1 | ||||
-rw-r--r-- | test/binaryen.js/kitchen-sink.js.txt | 17 | ||||
-rw-r--r-- | test/binaryen.js/push-pop.js.txt | 2 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.c | 1 | ||||
-rw-r--r-- | test/example/c-api-kitchen-sink.txt | 15 | ||||
-rw-r--r-- | test/unit/input/reference_types_target_feature.wasm | bin | 0 -> 150 bytes | |||
-rw-r--r-- | test/unit/test_features.py | 32 |
12 files changed, 130 insertions, 21 deletions
diff --git a/test/anyref.wast b/test/anyref.wast new file mode 100644 index 000000000..d617d3f42 --- /dev/null +++ b/test/anyref.wast @@ -0,0 +1,18 @@ +(module + (memory 1 1) + (import "env" "test1" (func $test1 (param anyref) (result anyref))) + (import "env" "test2" (global $test2 anyref)) + (export "test1" (func $test1 (param anyref) (result anyref))) + (export "test2" (global $test2)) + (func $anyref_test (param $0 anyref) (result anyref) + (local $1 anyref) + (local.set $1 + (call $test1 + (local.get $0) + ) + ) + (return + (local.get $1) + ) + ) +) diff --git a/test/anyref.wast.from-wast b/test/anyref.wast.from-wast new file mode 100644 index 000000000..117695077 --- /dev/null +++ b/test/anyref.wast.from-wast @@ -0,0 +1,19 @@ +(module + (type $FUNCSIG$aa (func (param anyref) (result anyref))) + (import "env" "test2" (global $test2 anyref)) + (import "env" "test1" (func $test1 (param anyref) (result anyref))) + (memory $0 1 1) + (export "test1" (func $test1)) + (export "test2" (global $test2)) + (func $anyref_test (; 1 ;) (type $FUNCSIG$aa) (param $0 anyref) (result anyref) + (local $1 anyref) + (local.set $1 + (call $test1 + (local.get $0) + ) + ) + (return + (local.get $1) + ) + ) +) diff --git a/test/anyref.wast.fromBinary b/test/anyref.wast.fromBinary new file mode 100644 index 000000000..3d9b223b6 --- /dev/null +++ b/test/anyref.wast.fromBinary @@ -0,0 +1,20 @@ +(module + (type $0 (func (param anyref) (result anyref))) + (import "env" "test2" (global $gimport$1 anyref)) + (import "env" "test1" (func $test1 (param anyref) (result anyref))) + (memory $0 1 1) + (export "test1" (func $test1)) + (export "test2" (global $gimport$1)) + (func $anyref_test (; 1 ;) (type $0) (param $0 anyref) (result anyref) + (local $1 anyref) + (local.set $1 + (call $test1 + (local.get $0) + ) + ) + (return + (local.get $1) + ) + ) +) + diff --git a/test/anyref.wast.fromBinary.noDebugInfo b/test/anyref.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..d397cd3f9 --- /dev/null +++ b/test/anyref.wast.fromBinary.noDebugInfo @@ -0,0 +1,20 @@ +(module + (type $0 (func (param anyref) (result anyref))) + (import "env" "test2" (global $gimport$1 anyref)) + (import "env" "test1" (func $fimport$0 (param anyref) (result anyref))) + (memory $0 1 1) + (export "test1" (func $fimport$0)) + (export "test2" (global $gimport$1)) + (func $0 (; 1 ;) (type $0) (param $0 anyref) (result anyref) + (local $1 anyref) + (local.set $1 + (call $fimport$0 + (local.get $0) + ) + ) + (return + (local.get $1) + ) + ) +) + diff --git a/test/binaryen.js/exception-handling.js.txt b/test/binaryen.js/exception-handling.js.txt index 902ac55e6..cdf45aeaa 100644 --- a/test/binaryen.js/exception-handling.js.txt +++ b/test/binaryen.js/exception-handling.js.txt @@ -26,7 +26,7 @@ ) ) -getExpressionInfo(throw) = {"id":39,"type":7,"event":"e"} -getExpressionInfo(br_on_exn) = {"id":41,"type":6,"name":"l","event":"e"} -getExpressionInfo(rethrow) = {"id":40,"type":7} +getExpressionInfo(throw) = {"id":39,"type":8,"event":"e"} +getExpressionInfo(br_on_exn) = {"id":41,"type":7,"name":"l","event":"e"} +getExpressionInfo(rethrow) = {"id":40,"type":8} getExpressionInfo(try) = {"id":38,"type":0} diff --git a/test/binaryen.js/kitchen-sink.js b/test/binaryen.js/kitchen-sink.js index 163fe8839..f2a78ab34 100644 --- a/test/binaryen.js/kitchen-sink.js +++ b/test/binaryen.js/kitchen-sink.js @@ -57,6 +57,7 @@ function test_types() { console.log("BinaryenTypeFloat32: " + Binaryen.f32); console.log("BinaryenTypeFloat64: " + Binaryen.f64); console.log("BinaryenTypeVec128: " + Binaryen.v128); + console.log("BinaryenTypeAnyref: " + Binaryen.anyref); console.log("BinaryenTypeExnref: " + Binaryen.exnref); console.log("BinaryenTypeUnreachable: " + Binaryen.unreachable); console.log("BinaryenTypeAuto: " + Binaryen.auto); diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt index a1baa5951..07a06b98b 100644 --- a/test/binaryen.js/kitchen-sink.js.txt +++ b/test/binaryen.js/kitchen-sink.js.txt @@ -4,8 +4,9 @@ BinaryenTypeInt64: 2 BinaryenTypeFloat32: 3 BinaryenTypeFloat64: 4 BinaryenTypeVec128: 5 -BinaryenTypeExnref: 6 -BinaryenTypeUnreachable: 7 +BinaryenTypeAnyref: 6 +BinaryenTypeExnref: 7 +BinaryenTypeUnreachable: 8 BinaryenTypeAuto: -1 Binaryen.Features.MVP: 0 Binaryen.Features.Atomics: 1 @@ -15,7 +16,7 @@ Binaryen.Features.NontrappingFPToInt: 4 Binaryen.Features.SignExt: 32 Binaryen.Features.SIMD128: 8 Binaryen.Features.ExceptionHandling: 64 -Binaryen.Features.All: 255 +Binaryen.Features.All: 511 BinaryenInvalidId: 0 BinaryenBlockId: 1 BinaryenIfId: 2 @@ -4759,9 +4760,9 @@ int main() { BinaryenExpressionRef operands[] = { expressions[656] }; expressions[657] = BinaryenThrow(the_module, "a-event", operands, 1); } - expressions[658] = BinaryenPop(the_module, 6); + expressions[658] = BinaryenPop(the_module, 7); expressions[659] = BinaryenLocalSet(the_module, 5, expressions[658]); - expressions[660] = BinaryenLocalGet(the_module, 5, 6); + expressions[660] = BinaryenLocalGet(the_module, 5, 7); expressions[661] = BinaryenBrOnExn(the_module, "try-block", "a-event", expressions[660]); expressions[662] = BinaryenRethrow(the_module, expressions[661]); { @@ -4784,7 +4785,7 @@ int main() { expressions[674] = BinaryenPush(the_module, expressions[673]); expressions[675] = BinaryenPop(the_module, 5); expressions[676] = BinaryenPush(the_module, expressions[675]); - expressions[677] = BinaryenPop(the_module, 6); + expressions[677] = BinaryenPop(the_module, 7); expressions[678] = BinaryenPush(the_module, expressions[677]); expressions[679] = BinaryenNop(the_module); expressions[680] = BinaryenUnreachable(the_module); @@ -4876,7 +4877,7 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} expressions[689] = BinaryenBlock(the_module, "the-body", children, 2, 0); } { - BinaryenType varTypes[] = { 1, 6 }; + BinaryenType varTypes[] = { 1, 7 }; functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[1], varTypes, 2, expressions[689]); } expressions[690] = BinaryenConst(the_module, BinaryenLiteralInt32(1)); @@ -4934,7 +4935,7 @@ getExpressionInfo(f64.const)={"id":14,"type":4,"value":9.5} functionTypes[4] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenModuleSetFeatures(the_module, 255); + BinaryenModuleSetFeatures(the_module, 511); BinaryenModuleGetFeatures(the_module); BinaryenModulePrint(the_module); (module diff --git a/test/binaryen.js/push-pop.js.txt b/test/binaryen.js/push-pop.js.txt index 0597780d9..c9689831f 100644 --- a/test/binaryen.js/push-pop.js.txt +++ b/test/binaryen.js/push-pop.js.txt @@ -27,5 +27,5 @@ getExpressionInfo(i64.pop) = {"id":37,"type":2} getExpressionInfo(f32.pop) = {"id":37,"type":3} getExpressionInfo(f64.pop) = {"id":37,"type":4} getExpressionInfo(v128.pop) = {"id":37,"type":5} -getExpressionInfo(exnref.pop) = {"id":37,"type":6} +getExpressionInfo(exnref.pop) = {"id":37,"type":7} getExpressionInfo(push) = {"id":36} diff --git a/test/example/c-api-kitchen-sink.c b/test/example/c-api-kitchen-sink.c index 661d04ce2..3d9d42fa1 100644 --- a/test/example/c-api-kitchen-sink.c +++ b/test/example/c-api-kitchen-sink.c @@ -155,6 +155,7 @@ void test_types() { printf("BinaryenTypeFloat32: %d\n", BinaryenTypeFloat32()); printf("BinaryenTypeFloat64: %d\n", BinaryenTypeFloat64()); printf("BinaryenTypeVec128: %d\n", BinaryenTypeVec128()); + printf("BinaryenTypeAnyref: %d\n", BinaryenTypeAnyref()); printf("BinaryenTypeExnref: %d\n", BinaryenTypeExnref()); printf("BinaryenTypeUnreachable: %d\n", BinaryenTypeUnreachable()); printf("BinaryenTypeAuto: %d\n", BinaryenTypeAuto()); diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt index e135bd98d..d0582bd79 100644 --- a/test/example/c-api-kitchen-sink.txt +++ b/test/example/c-api-kitchen-sink.txt @@ -4,8 +4,9 @@ BinaryenTypeInt64: 2 BinaryenTypeFloat32: 3 BinaryenTypeFloat64: 4 BinaryenTypeVec128: 5 -BinaryenTypeExnref: 6 -BinaryenTypeUnreachable: 7 +BinaryenTypeAnyref: 6 +BinaryenTypeExnref: 7 +BinaryenTypeUnreachable: 8 BinaryenTypeAuto: -1 BinaryenFeatureMVP: 0 BinaryenFeatureAtomics: 1 @@ -15,7 +16,7 @@ BinaryenFeatureNontrappingFPToInt: 4 BinaryenFeatureSignExt: 32 BinaryenFeatureSIMD128: 8 BinaryenFeatureExceptionHandling: 64 -BinaryenFeatureAll: 255 +BinaryenFeatureAll: 511 (f32.neg (f32.const -33.61199951171875) ) @@ -2022,9 +2023,9 @@ int main() { BinaryenExpressionRef operands[] = { expressions[34] }; expressions[35] = BinaryenThrow(the_module, "a-event", operands, 1); } - expressions[36] = BinaryenPop(the_module, 6); + expressions[36] = BinaryenPop(the_module, 7); expressions[37] = BinaryenLocalSet(the_module, 5, expressions[36]); - expressions[38] = BinaryenLocalGet(the_module, 5, 6); + expressions[38] = BinaryenLocalGet(the_module, 5, 7); expressions[39] = BinaryenBrOnExn(the_module, "try-block", "a-event", expressions[38]); expressions[40] = BinaryenRethrow(the_module, expressions[39]); { @@ -3371,7 +3372,7 @@ int main() { expressions[666] = BinaryenBlock(the_module, "the-body", children, 2, BinaryenTypeAuto()); } { - BinaryenType varTypes[] = { 1, 6 }; + BinaryenType varTypes[] = { 1, 7 }; functions[0] = BinaryenAddFunction(the_module, "kitchen()sinker", functionTypes[0], varTypes, 2, expressions[666]); } expressions[667] = BinaryenConst(the_module, BinaryenLiteralInt32(7)); @@ -3414,7 +3415,7 @@ int main() { functionTypes[4] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0); } BinaryenModuleAutoDrop(the_module); - BinaryenModuleSetFeatures(the_module, 255); + BinaryenModuleSetFeatures(the_module, 511); BinaryenModuleGetFeatures(the_module); BinaryenModuleValidate(the_module); BinaryenModulePrint(the_module); diff --git a/test/unit/input/reference_types_target_feature.wasm b/test/unit/input/reference_types_target_feature.wasm Binary files differnew file mode 100644 index 000000000..7ea8847e9 --- /dev/null +++ b/test/unit/input/reference_types_target_feature.wasm diff --git a/test/unit/test_features.py b/test/unit/test_features.py index 53037307d..c031c07fa 100644 --- a/test/unit/test_features.py +++ b/test/unit/test_features.py @@ -29,6 +29,9 @@ class FeatureValidationTest(BinaryenTestCase): def check_tail_call(self, module, error): self.check_feature(module, error, '--enable-tail-call') + def check_reference_types(self, module, error): + self.check_feature(module, error, '--enable-reference-types') + def test_v128_signature(self): module = ''' (module @@ -144,6 +147,24 @@ class FeatureValidationTest(BinaryenTestCase): ''' self.check_tail_call(module, 'return_call_indirect requires tail calls to be enabled') + def test_reference_types_anyref(self): + module = ''' + (module + (import "env" "test1" (func $test1 (param anyref) (result anyref))) + (import "env" "test2" (global $test2 anyref)) + (export "test1" (func $test1 (param anyref) (result anyref))) + (export "test2" (global $test2)) + (func $anyref_test (param $0 anyref) (result anyref) + (return + (call $test1 + (local.get $0) + ) + ) + ) + ) + ''' + self.check_reference_types(module, 'all used types should be allowed') + def test_exnref_local(self): module = ''' (module @@ -210,6 +231,12 @@ class TargetFeaturesSectionTest(BinaryenTestCase): self.check_features(filename, ['tail-call']) self.assertIn('return_call', self.disassemble(filename)) + def test_reference_types(self): + filename = 'reference_types_target_feature.wasm' + self.roundtrip(filename) + self.check_features(filename, ['reference-types']) + self.assertIn('anyref', self.disassemble(filename)) + def test_exception_handling(self): filename = 'exception_handling_target_feature.wasm' self.roundtrip(filename) @@ -243,7 +270,7 @@ class TargetFeaturesSectionTest(BinaryenTestCase): def test_emit_all_features(self): p = run_process(WASM_OPT + ['--emit-target-features', '-all', '-o', '-'], - input="(module)", check=False, capture_output=True) + input="(module)", check=False, capture_output=True, decode_output=False) self.assertEqual(p.returncode, 0) p2 = run_process(WASM_OPT + ['--print-features', '-o', os.devnull], input=p.stdout, check=False, capture_output=True) @@ -256,5 +283,6 @@ class TargetFeaturesSectionTest(BinaryenTestCase): '--enable-nontrapping-float-to-int', '--enable-sign-ext', '--enable-simd', - '--enable-tail-call' + '--enable-tail-call', + '--enable-reference-types' ], p2.stdout.split()) |