summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/binaryen.js/kitchen-sink.js.txt4
-rw-r--r--test/example/c-api-kitchen-sink.txt4
-rw-r--r--test/tail-call.wast11
-rw-r--r--test/tail-call.wast.from-wast13
-rw-r--r--test/tail-call.wast.fromBinary14
-rw-r--r--test/tail-call.wast.fromBinary.noDebugInfo14
-rwxr-xr-xtest/unit/input/tail_call_target_feature.wasmbin0 -> 129 bytes
-rw-r--r--test/unit/test_features.py25
8 files changed, 79 insertions, 6 deletions
diff --git a/test/binaryen.js/kitchen-sink.js.txt b/test/binaryen.js/kitchen-sink.js.txt
index 85085fa82..45c58c54d 100644
--- a/test/binaryen.js/kitchen-sink.js.txt
+++ b/test/binaryen.js/kitchen-sink.js.txt
@@ -15,7 +15,7 @@ Binaryen.Features.NontrappingFPToInt: 4
Binaryen.Features.SignExt: 32
Binaryen.Features.SIMD128: 8
Binaryen.Features.ExceptionHandling: 64
-Binaryen.Features.All: 127
+Binaryen.Features.All: 255
BinaryenInvalidId: 0
BinaryenBlockId: 1
BinaryenIfId: 2
@@ -3406,7 +3406,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, 127);
+ BinaryenModuleSetFeatures(the_module, 255);
BinaryenModuleGetFeatures(the_module);
BinaryenModuleValidate(the_module);
BinaryenModulePrint(the_module);
diff --git a/test/example/c-api-kitchen-sink.txt b/test/example/c-api-kitchen-sink.txt
index e5e16c6fe..ee8d9c7b3 100644
--- a/test/example/c-api-kitchen-sink.txt
+++ b/test/example/c-api-kitchen-sink.txt
@@ -15,7 +15,7 @@ BinaryenFeatureNontrappingFPToInt: 4
BinaryenFeatureSignExt: 32
BinaryenFeatureSIMD128: 8
BinaryenFeatureExceptionHandling: 64
-BinaryenFeatureAll: 127
+BinaryenFeatureAll: 255
(f32.neg
(f32.const -33.61199951171875)
)
@@ -3351,7 +3351,7 @@ int main() {
functionTypes[4] = BinaryenAddFunctionType(the_module, NULL, 0, paramTypes, 0);
}
BinaryenModuleAutoDrop(the_module);
- BinaryenModuleSetFeatures(the_module, 127);
+ BinaryenModuleSetFeatures(the_module, 255);
BinaryenModuleGetFeatures(the_module);
BinaryenModuleValidate(the_module);
BinaryenModulePrint(the_module);
diff --git a/test/tail-call.wast b/test/tail-call.wast
new file mode 100644
index 000000000..ceea1239e
--- /dev/null
+++ b/test/tail-call.wast
@@ -0,0 +1,11 @@
+(module
+ (type $void (func))
+ (table 1 1 funcref)
+ (elem (i32.const 0) $foo)
+ (func $foo
+ (return_call $bar)
+ )
+ (func $bar
+ (return_call_indirect (type $void) (i32.const 0))
+ )
+) \ No newline at end of file
diff --git a/test/tail-call.wast.from-wast b/test/tail-call.wast.from-wast
new file mode 100644
index 000000000..b05b2f3d6
--- /dev/null
+++ b/test/tail-call.wast.from-wast
@@ -0,0 +1,13 @@
+(module
+ (type $void (func))
+ (table $0 1 1 funcref)
+ (elem (i32.const 0) $foo)
+ (func $foo (; 0 ;) (type $void)
+ (return_call $bar)
+ )
+ (func $bar (; 1 ;) (type $void)
+ (return_call_indirect (type $void)
+ (i32.const 0)
+ )
+ )
+)
diff --git a/test/tail-call.wast.fromBinary b/test/tail-call.wast.fromBinary
new file mode 100644
index 000000000..15c1e61b0
--- /dev/null
+++ b/test/tail-call.wast.fromBinary
@@ -0,0 +1,14 @@
+(module
+ (type $0 (func))
+ (table $0 1 1 funcref)
+ (elem (i32.const 0) $foo)
+ (func $foo (; 0 ;) (type $0)
+ (return_call $bar)
+ )
+ (func $bar (; 1 ;) (type $0)
+ (return_call_indirect (type $0)
+ (i32.const 0)
+ )
+ )
+)
+
diff --git a/test/tail-call.wast.fromBinary.noDebugInfo b/test/tail-call.wast.fromBinary.noDebugInfo
new file mode 100644
index 000000000..1523db761
--- /dev/null
+++ b/test/tail-call.wast.fromBinary.noDebugInfo
@@ -0,0 +1,14 @@
+(module
+ (type $0 (func))
+ (table $0 1 1 funcref)
+ (elem (i32.const 0) $0)
+ (func $0 (; 0 ;) (type $0)
+ (return_call $1)
+ )
+ (func $1 (; 1 ;) (type $0)
+ (return_call_indirect (type $0)
+ (i32.const 0)
+ )
+ )
+)
+
diff --git a/test/unit/input/tail_call_target_feature.wasm b/test/unit/input/tail_call_target_feature.wasm
new file mode 100755
index 000000000..063b6d2a5
--- /dev/null
+++ b/test/unit/input/tail_call_target_feature.wasm
Binary files differ
diff --git a/test/unit/test_features.py b/test/unit/test_features.py
index afb873d30..968aaa252 100644
--- a/test/unit/test_features.py
+++ b/test/unit/test_features.py
@@ -27,6 +27,9 @@ class FeatureValidationTest(BinaryenTestCase):
def check_exception_handling(self, module, error):
self.check_feature(module, error, '--enable-exception-handling')
+ def check_tail_call(self, module, error):
+ self.check_feature(module, error, '--enable-tail-call')
+
def test_v128_signature(self):
module = '''
(module
@@ -117,6 +120,17 @@ class FeatureValidationTest(BinaryenTestCase):
'''
self.check_bulk_mem(module, 'nonzero segment flags (bulk memory is disabled)')
+ def test_tail_call(self):
+ module = '''
+ (module
+ (func $bar)
+ (func $foo
+ (return_call $bar)
+ )
+ )
+ '''
+ self.check_tail_call(module, 'return_call requires tail calls to be enabled')
+
class TargetFeaturesSectionTest(BinaryenTestCase):
def test_atomics(self):
@@ -156,6 +170,12 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
self.check_features(filename, ['simd'])
self.assertIn('i32x4.splat', self.disassemble(filename))
+ def test_tailcall(self):
+ filename = 'tail_call_target_feature.wasm'
+ self.roundtrip(filename)
+ self.check_features(filename, ['tail-call'])
+ self.assertIn('return_call', self.disassemble(filename))
+
def test_incompatible_features(self):
path = self.input_path('signext_target_feature.wasm')
p = run_process(
@@ -188,7 +208,7 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
p2 = run_process(WASM_OPT + ['--print-features', '-o', os.devnull],
input=p.stdout, check=False, capture_output=True)
self.assertEqual(p2.returncode, 0)
- self.assertEqual(p2.stdout.split(), [
+ self.assertEqual([
'--enable-threads',
'--enable-bulk-memory',
'--enable-exception-handling',
@@ -196,4 +216,5 @@ class TargetFeaturesSectionTest(BinaryenTestCase):
'--enable-nontrapping-float-to-int',
'--enable-sign-ext',
'--enable-simd',
- ])
+ '--enable-tail-call'
+ ], p2.stdout.split())