From 76751bf1f9df4eb2ee6c216744af9ed1e097132e Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 31 Jul 2017 15:10:38 -0700 Subject: Polymophic stack support (#1117) Emit valid wasm binaries even for corner cases of unreachable code. * emit an unreachable after a node that pushes a value that has unreachable type (where wasm type checking would have pushed a concrete type) * conversely, as a hack, emulate the wasm polymorphic stack mode by not emptying the stack when it has one element and that element is unreachable. this lets further pops work (all returning an unreachable element) --- test/polymorphic_stack.wast.fromBinary.noDebugInfo | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 test/polymorphic_stack.wast.fromBinary.noDebugInfo (limited to 'test/polymorphic_stack.wast.fromBinary.noDebugInfo') diff --git a/test/polymorphic_stack.wast.fromBinary.noDebugInfo b/test/polymorphic_stack.wast.fromBinary.noDebugInfo new file mode 100644 index 000000000..857a3660c --- /dev/null +++ b/test/polymorphic_stack.wast.fromBinary.noDebugInfo @@ -0,0 +1,129 @@ +(module + (type $0 (func (param i32) (result i32))) + (type $1 (func (result i32))) + (type $2 (func (param i32))) + (type $3 (func)) + (import "env" "table" (table 9 9 anyfunc)) + (memory $0 0) + (func $0 (type $1) (result i32) + (block $label$0 (result i32) + (unreachable) + (i32.trunc_u/f64 + (unreachable) + ) + (unreachable) + (br_if $label$0 + (i32.trunc_u/f64 + (unreachable) + ) + (unreachable) + ) + (f32.add + (unreachable) + (f32.const 1) + ) + (unreachable) + ) + ) + (func $1 (type $0) (param $var$0 i32) (result i32) + (block $label$0 (result i32) + (unreachable) + (call $1 + (unreachable) + ) + (i64.eqz + (unreachable) + ) + (drop + (unreachable) + ) + (i32.eqz + (unreachable) + ) + (i64.eqz + (unreachable) + ) + (drop + (unreachable) + ) + (call_indirect $0 + (unreachable) + (unreachable) + ) + (i64.eqz + (unreachable) + ) + (drop + (unreachable) + ) + ) + ) + (func $2 (type $2) (param $var$0 i32) + (local $var$1 f32) + (block $label$0 + (unreachable) + (tee_local $var$0 + (unreachable) + ) + (i64.eqz + (unreachable) + ) + (drop + (unreachable) + ) + (i64.eqz + (unreachable) + ) + (tee_local $var$1 + (unreachable) + ) + (drop + (unreachable) + ) + (unreachable) + ) + (unreachable) + ) + (func $3 (type $3) + (local $var$0 f32) + (if + (i32.const 259) + (block $label$0 + (unreachable) + (tee_local $var$0 + (unreachable) + ) + (unreachable) + ) + ) + ) + (func $4 (type $3) + (unreachable) + (select + (unreachable) + (i32.const 1) + (i32.const 2) + ) + (i64.eqz + (unreachable) + ) + (drop + (unreachable) + ) + ) + (func $5 (type $1) (result i32) + (block $label$0 (result i32) + (block $label$1 + (unreachable) + (br_if $label$0 + (unreachable) + (unreachable) + ) + (unreachable) + (unreachable) + ) + (unreachable) + ) + ) +) + -- cgit v1.2.3