From 0aa8638650abadc6d66fb0e027bf4b4131b1f4e3 Mon Sep 17 00:00:00 2001 From: dcode Date: Tue, 8 Dec 2020 13:43:25 +0100 Subject: [PATCH 1/2] Account for virtual stub finalization discovering more virtual calls --- src/compiler.ts | 10 +- tests/compiler/issues/1536.json | 5 + tests/compiler/issues/1536.optimized.wat | 141 ++++++++++ tests/compiler/issues/1536.ts | 29 ++ tests/compiler/issues/1536.untouched.wat | 327 +++++++++++++++++++++++ 5 files changed, 509 insertions(+), 3 deletions(-) create mode 100644 tests/compiler/issues/1536.json create mode 100644 tests/compiler/issues/1536.optimized.wat create mode 100644 tests/compiler/issues/1536.ts create mode 100644 tests/compiler/issues/1536.untouched.wat diff --git a/src/compiler.ts b/src/compiler.ts index f2c106f08d..b77e18416f 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -530,9 +530,13 @@ export class Compiler extends DiagnosticEmitter { } } var virtualCalls = this.virtualCalls; - for (let _values = Set_values(virtualCalls), i = 0, k = _values.length; i < k; ++i) { - let instance = unchecked(_values[i]); - this.finalizeVirtualStub(instance); + while (virtualCalls.size) { + // finalizing a stub may discover more virtual calls, so do this in a loop + for (let _values = Set_values(virtualCalls), i = 0, k = _values.length; i < k; ++i) { + let instance = unchecked(_values[i]); + this.finalizeVirtualStub(instance); + virtualCalls.delete(instance); + } } // finalize runtime features diff --git a/tests/compiler/issues/1536.json b/tests/compiler/issues/1536.json new file mode 100644 index 0000000000..b1da366ff4 --- /dev/null +++ b/tests/compiler/issues/1536.json @@ -0,0 +1,5 @@ +{ + "asc_flags": [ + "--runtime none" + ] +} \ No newline at end of file diff --git a/tests/compiler/issues/1536.optimized.wat b/tests/compiler/issues/1536.optimized.wat new file mode 100644 index 0000000000..3a02aa17c5 --- /dev/null +++ b/tests/compiler/issues/1536.optimized.wat @@ -0,0 +1,141 @@ +(module + (type $none_=>_none (func)) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (type $i32_=>_i32 (func (param i32) (result i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 1036) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d") + (data (i32.const 1100) "\1c\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\005\003\006\00.\00t\00s") + (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) + (global $issues/1536/instance (mut i32) (i32.const 0)) + (export "memory" (memory $0)) + (start $~start) + (func $~lib/rt/stub/__new (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + global.get $~lib/rt/stub/offset + global.get $~lib/rt/stub/offset + i32.const 4 + i32.add + local.tee $3 + i32.const 28 + i32.add + local.tee $1 + memory.size + local.tee $4 + i32.const 16 + i32.shl + i32.const 15 + i32.add + i32.const -16 + i32.and + local.tee $2 + i32.gt_u + if + local.get $4 + local.get $1 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const -65536 + i32.and + i32.const 16 + i32.shr_u + local.tee $2 + local.get $2 + local.get $4 + i32.lt_s + select + memory.grow + i32.const 0 + i32.lt_s + if + local.get $2 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $1 + global.set $~lib/rt/stub/offset + i32.const 28 + i32.store + local.get $3 + i32.const 4 + i32.sub + local.tee $1 + i32.const 0 + i32.store offset=4 + local.get $1 + i32.const 0 + i32.store offset=8 + local.get $1 + local.get $0 + i32.store offset=12 + local.get $1 + i32.const 0 + i32.store offset=16 + local.get $3 + i32.const 16 + i32.add + ) + (func $~start + (local $0 i32) + i32.const 1148 + global.set $~lib/rt/stub/offset + i32.const 4 + call $~lib/rt/stub/__new + local.tee $0 + if (result i32) + local.get $0 + else + i32.const 3 + call $~lib/rt/stub/__new + end + global.set $issues/1536/instance + block $__inlined_func$issues/1536/Base#run@virtual + global.get $issues/1536/instance + i32.const 8 + i32.sub + i32.load + i32.const 4 + i32.eq + if + i32.const 5 + call $~lib/rt/stub/__new + local.tee $0 + if (result i32) + local.get $0 + else + i32.const 6 + call $~lib/rt/stub/__new + end + i32.const 8 + i32.sub + i32.load + i32.const 5 + i32.eq + br_if $__inlined_func$issues/1536/Base#run@virtual + i32.const 1056 + i32.const 1120 + i32.const 6 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + i32.const 1056 + i32.const 1120 + i32.const 18 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + ) +) diff --git a/tests/compiler/issues/1536.ts b/tests/compiler/issues/1536.ts new file mode 100644 index 0000000000..099c86a3b9 --- /dev/null +++ b/tests/compiler/issues/1536.ts @@ -0,0 +1,29 @@ +class A { + public call(): i32 { + return this.callImpl(); + } + public callImpl(): i32 { + throw new Error("not implemented"); + } +} + +class B extends A { + public callImpl(): i32 { + return 3; + } +} + +class Base { + run(): i32 { + throw new Error("not implemented"); + } +} + +class Bar extends Base { + run(): i32 { + return new B().call(); + } +} + +var instance: Base = new Bar(); +assert(instance.run() == 3); diff --git a/tests/compiler/issues/1536.untouched.wat b/tests/compiler/issues/1536.untouched.wat new file mode 100644 index 0000000000..0b3c1f39bf --- /dev/null +++ b/tests/compiler/issues/1536.untouched.wat @@ -0,0 +1,327 @@ +(module + (type $i32_=>_i32 (func (param i32) (result i32))) + (type $none_=>_none (func)) + (type $i32_=>_none (func (param i32))) + (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) + (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) + (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) + (memory $0 1) + (data (i32.const 12) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d\00") + (data (i32.const 76) "\1c\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\005\003\006\00.\00t\00s\00") + (table $0 1 funcref) + (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) + (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) + (global $issues/1536/instance (mut i32) (i32.const 0)) + (global $~lib/memory/__heap_base i32 (i32.const 124)) + (export "memory" (memory $0)) + (start $~start) + (func $~lib/rt/stub/computeSize (param $0 i32) (result i32) + local.get $0 + i32.const 4 + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + i32.const 4 + i32.sub + ) + (func $~lib/rt/stub/maybeGrowMemory (param $0 i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + memory.size + local.set $1 + local.get $1 + i32.const 16 + i32.shl + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + local.set $2 + local.get $0 + local.get $2 + i32.gt_u + if + local.get $0 + local.get $2 + i32.sub + i32.const 65535 + i32.add + i32.const 65535 + i32.const -1 + i32.xor + i32.and + i32.const 16 + i32.shr_u + local.set $3 + local.get $1 + local.tee $4 + local.get $3 + local.tee $5 + local.get $4 + local.get $5 + i32.gt_s + select + local.set $4 + local.get $4 + memory.grow + i32.const 0 + i32.lt_s + if + local.get $3 + memory.grow + i32.const 0 + i32.lt_s + if + unreachable + end + end + end + local.get $0 + global.set $~lib/rt/stub/offset + ) + (func $~lib/rt/stub/__alloc (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741820 + i32.gt_u + if + unreachable + end + global.get $~lib/rt/stub/offset + local.set $1 + global.get $~lib/rt/stub/offset + i32.const 4 + i32.add + local.set $2 + local.get $0 + call $~lib/rt/stub/computeSize + local.set $3 + local.get $2 + local.get $3 + i32.add + call $~lib/rt/stub/maybeGrowMemory + local.get $1 + local.get $3 + i32.store + local.get $2 + ) + (func $~lib/rt/stub/__new (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 1073741804 + i32.gt_u + if + unreachable + end + i32.const 16 + local.get $0 + i32.add + call $~lib/rt/stub/__alloc + local.set $2 + local.get $2 + i32.const 4 + i32.sub + local.set $3 + local.get $3 + i32.const 0 + i32.store offset=4 + local.get $3 + i32.const 0 + i32.store offset=8 + local.get $3 + local.get $1 + i32.store offset=12 + local.get $3 + local.get $0 + i32.store offset=16 + local.get $2 + i32.const 16 + i32.add + ) + (func $~lib/rt/stub/__retain (param $0 i32) (result i32) + local.get $0 + ) + (func $issues/1536/Base#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 3 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + ) + (func $issues/1536/Bar#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 4 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + call $issues/1536/Base#constructor + local.set $0 + local.get $0 + ) + (func $issues/1536/Base#run (param $0 i32) (result i32) + i32.const 32 + i32.const 96 + i32.const 18 + i32.const 5 + call $~lib/builtins/abort + unreachable + ) + (func $start:issues/1536 + global.get $~lib/memory/__heap_base + i32.const 4 + i32.add + i32.const 15 + i32.add + i32.const 15 + i32.const -1 + i32.xor + i32.and + i32.const 4 + i32.sub + global.set $~lib/rt/stub/startOffset + global.get $~lib/rt/stub/startOffset + global.set $~lib/rt/stub/offset + i32.const 0 + call $issues/1536/Bar#constructor + global.set $issues/1536/instance + global.get $issues/1536/instance + call $issues/1536/Base#run@virtual + i32.const 3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 96 + i32.const 29 + i32.const 1 + call $~lib/builtins/abort + unreachable + end + ) + (func $~start + call $start:issues/1536 + ) + (func $issues/1536/A#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 6 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + ) + (func $issues/1536/B#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 5 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + call $issues/1536/A#constructor + local.set $0 + local.get $0 + ) + (func $issues/1536/A#callImpl (param $0 i32) (result i32) + i32.const 32 + i32.const 96 + i32.const 6 + i32.const 5 + call $~lib/builtins/abort + unreachable + ) + (func $issues/1536/A#call (param $0 i32) (result i32) + local.get $0 + call $issues/1536/A#callImpl@virtual + ) + (func $~lib/rt/stub/__release (param $0 i32) + nop + ) + (func $issues/1536/Bar#run (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + i32.const 0 + call $issues/1536/B#constructor + local.tee $1 + call $issues/1536/A#call + local.set $2 + local.get $1 + call $~lib/rt/stub/__release + local.get $2 + ) + (func $issues/1536/Base#run@virtual (param $0 i32) (result i32) + (local $1 i32) + block $default + block $case0 + local.get $0 + i32.const 8 + i32.sub + i32.load + local.set $1 + local.get $1 + i32.const 4 + i32.eq + br_if $case0 + br $default + end + local.get $0 + call $issues/1536/Bar#run + return + end + local.get $0 + call $issues/1536/Base#run + ) + (func $issues/1536/B#callImpl (param $0 i32) (result i32) + i32.const 3 + ) + (func $issues/1536/A#callImpl@virtual (param $0 i32) (result i32) + (local $1 i32) + block $default + block $case0 + local.get $0 + i32.const 8 + i32.sub + i32.load + local.set $1 + local.get $1 + i32.const 5 + i32.eq + br_if $case0 + br $default + end + local.get $0 + call $issues/1536/B#callImpl + return + end + local.get $0 + call $issues/1536/A#callImpl + ) +) From 07b6eef80c2a47963c19999c0827b27c714a316e Mon Sep 17 00:00:00 2001 From: dcode Date: Tue, 8 Dec 2020 23:08:14 +0100 Subject: [PATCH 2/2] integrate into existing test --- .../compiler/class-overloading.optimized.wat | 52 ++- tests/compiler/class-overloading.ts | 32 ++ .../compiler/class-overloading.untouched.wat | 153 +++++++- tests/compiler/issues/1536.json | 5 - tests/compiler/issues/1536.optimized.wat | 141 -------- tests/compiler/issues/1536.ts | 29 -- tests/compiler/issues/1536.untouched.wat | 327 ------------------ 7 files changed, 235 insertions(+), 504 deletions(-) delete mode 100644 tests/compiler/issues/1536.json delete mode 100644 tests/compiler/issues/1536.optimized.wat delete mode 100644 tests/compiler/issues/1536.ts delete mode 100644 tests/compiler/issues/1536.untouched.wat diff --git a/tests/compiler/class-overloading.optimized.wat b/tests/compiler/class-overloading.optimized.wat index c30108abdd..dfab86c32c 100644 --- a/tests/compiler/class-overloading.optimized.wat +++ b/tests/compiler/class-overloading.optimized.wat @@ -14,11 +14,13 @@ (data (i32.const 1228) "\02\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00F") (data (i32.const 1260) "\04\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00I\00B") (data (i32.const 1292) "\04\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00I\00C") + (data (i32.const 1324) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d") (global $class-overloading/which (mut i32) (i32.const 1056)) (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) (global $class-overloading/a (mut i32) (i32.const 0)) (global $class-overloading/ia (mut i32) (i32.const 0)) (global $class-overloading/ic (mut i32) (i32.const 0)) + (global $class-overloading/b2 (mut i32) (i32.const 0)) (global $~started (mut i32) (i32.const 0)) (export "_start" (func $~start)) (export "memory" (memory $0)) @@ -264,7 +266,8 @@ call $class-overloading/B#constructor ) (func $start:class-overloading - i32.const 1324 + (local $0 i32) + i32.const 1388 global.set $~lib/rt/stub/offset i32.const 0 call $class-overloading/B#constructor @@ -633,6 +636,53 @@ call $~lib/builtins/abort unreachable end + i32.const 14 + call $~lib/rt/stub/__new + local.tee $0 + if (result i32) + local.get $0 + else + i32.const 13 + call $~lib/rt/stub/__new + end + global.set $class-overloading/b2 + block $__inlined_func$class-overloading/A2#foo@virtual + global.get $class-overloading/b2 + i32.const 8 + i32.sub + i32.load + i32.const 14 + i32.eq + if + i32.const 15 + call $~lib/rt/stub/__new + local.tee $0 + if (result i32) + local.get $0 + else + i32.const 16 + call $~lib/rt/stub/__new + end + i32.const 8 + i32.sub + i32.load + i32.const 15 + i32.eq + br_if $__inlined_func$class-overloading/A2#foo@virtual + i32.const 1344 + i32.const 1152 + i32.const 186 + i32.const 5 + call $~lib/builtins/abort + unreachable + end + i32.const 1344 + i32.const 1152 + i32.const 198 + i32.const 5 + call $~lib/builtins/abort + unreachable + end ) (func $~start global.get $~started diff --git a/tests/compiler/class-overloading.ts b/tests/compiler/class-overloading.ts index d8f9cf1241..ee4aa5a906 100644 --- a/tests/compiler/class-overloading.ts +++ b/tests/compiler/class-overloading.ts @@ -175,3 +175,35 @@ var ic: IC = new CC(); which = ""; ic.foo(); assert(which == "IC"); + +// Should make stubs for functions discovered when compiling other virtual stubs +class A1 { + public bar(): i32 { + return this.baz(); + // 4) discovers A1#baz + } + public baz(): i32 { + throw new Error("not implemented"); + // 5) discovers B1#baz (overload) + } +} +class B1 extends A1 { + public baz(): i32 { + return 3; + // 6) complete + } +} +class A2 { + foo(): i32 { + throw new Error("not implemented"); + // 2) discovers B2#foo (overload) + } +} +class B2 extends A2 { + foo(): i32 { + return new B1().bar(); + // 3) discovers B1#bar (alias of A1#bar) + } +} +var b2: A2 = new B2(); +assert(b2.foo() == 3); // 1) discovers A2#foo diff --git a/tests/compiler/class-overloading.untouched.wat b/tests/compiler/class-overloading.untouched.wat index 09eeaebd7e..24e8560204 100644 --- a/tests/compiler/class-overloading.untouched.wat +++ b/tests/compiler/class-overloading.untouched.wat @@ -16,6 +16,7 @@ (data (i32.const 204) "\02\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\02\00\00\00F\00") (data (i32.const 236) "\04\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00I\00B\00") (data (i32.const 268) "\04\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\04\00\00\00I\00C\00") + (data (i32.const 300) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d\00") (table $0 1 funcref) (global $class-overloading/which (mut i32) (i32.const 32)) (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) @@ -25,8 +26,9 @@ (global $class-overloading/c (mut i32) (i32.const 0)) (global $class-overloading/ia (mut i32) (i32.const 0)) (global $class-overloading/ic (mut i32) (i32.const 0)) + (global $class-overloading/b2 (mut i32) (i32.const 0)) (global $~started (mut i32) (i32.const 0)) - (global $~lib/memory/__heap_base i32 (i32.const 292)) + (global $~lib/memory/__heap_base i32 (i32.const 352)) (export "_start" (func $~start)) (export "memory" (memory $0)) (func $~lib/rt/stub/computeSize (param $0 i32) (result i32) @@ -589,6 +591,41 @@ end local.get $0 ) + (func $class-overloading/A2#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 13 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + ) + (func $class-overloading/B2#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 14 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + call $class-overloading/A2#constructor + local.set $0 + local.get $0 + ) + (func $class-overloading/A2#foo (param $0 i32) (result i32) + i32.const 320 + i32.const 128 + i32.const 198 + i32.const 5 + call $~lib/builtins/abort + unreachable + ) (func $start:class-overloading (local $0 i32) global.get $~lib/memory/__heap_base @@ -1074,6 +1111,22 @@ call $~lib/builtins/abort unreachable end + i32.const 0 + call $class-overloading/B2#constructor + global.set $class-overloading/b2 + global.get $class-overloading/b2 + call $class-overloading/A2#foo@virtual + i32.const 3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 209 + i32.const 1 + call $~lib/builtins/abort + unreachable + end ) (func $~start global.get $~started @@ -1402,4 +1455,102 @@ end unreachable ) + (func $class-overloading/A1#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 16 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + ) + (func $class-overloading/B1#constructor (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 15 + call $~lib/rt/stub/__new + call $~lib/rt/stub/__retain + local.set $0 + end + local.get $0 + call $class-overloading/A1#constructor + local.set $0 + local.get $0 + ) + (func $class-overloading/A1#baz (param $0 i32) (result i32) + i32.const 320 + i32.const 128 + i32.const 186 + i32.const 5 + call $~lib/builtins/abort + unreachable + ) + (func $class-overloading/A1#bar (param $0 i32) (result i32) + local.get $0 + call $class-overloading/A1#baz@virtual + ) + (func $class-overloading/B2#foo (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + i32.const 0 + call $class-overloading/B1#constructor + local.tee $1 + call $class-overloading/A1#bar + local.set $2 + local.get $1 + call $~lib/rt/stub/__release + local.get $2 + ) + (func $class-overloading/A2#foo@virtual (param $0 i32) (result i32) + (local $1 i32) + block $default + block $case0 + local.get $0 + i32.const 8 + i32.sub + i32.load + local.set $1 + local.get $1 + i32.const 14 + i32.eq + br_if $case0 + br $default + end + local.get $0 + call $class-overloading/B2#foo + return + end + local.get $0 + call $class-overloading/A2#foo + ) + (func $class-overloading/B1#baz (param $0 i32) (result i32) + i32.const 3 + ) + (func $class-overloading/A1#baz@virtual (param $0 i32) (result i32) + (local $1 i32) + block $default + block $case0 + local.get $0 + i32.const 8 + i32.sub + i32.load + local.set $1 + local.get $1 + i32.const 15 + i32.eq + br_if $case0 + br $default + end + local.get $0 + call $class-overloading/B1#baz + return + end + local.get $0 + call $class-overloading/A1#baz + ) ) diff --git a/tests/compiler/issues/1536.json b/tests/compiler/issues/1536.json deleted file mode 100644 index b1da366ff4..0000000000 --- a/tests/compiler/issues/1536.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "asc_flags": [ - "--runtime none" - ] -} \ No newline at end of file diff --git a/tests/compiler/issues/1536.optimized.wat b/tests/compiler/issues/1536.optimized.wat deleted file mode 100644 index 3a02aa17c5..0000000000 --- a/tests/compiler/issues/1536.optimized.wat +++ /dev/null @@ -1,141 +0,0 @@ -(module - (type $none_=>_none (func)) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) - (type $i32_=>_i32 (func (param i32) (result i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 1036) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d") - (data (i32.const 1100) "\1c\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\005\003\006\00.\00t\00s") - (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) - (global $issues/1536/instance (mut i32) (i32.const 0)) - (export "memory" (memory $0)) - (start $~start) - (func $~lib/rt/stub/__new (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - global.get $~lib/rt/stub/offset - global.get $~lib/rt/stub/offset - i32.const 4 - i32.add - local.tee $3 - i32.const 28 - i32.add - local.tee $1 - memory.size - local.tee $4 - i32.const 16 - i32.shl - i32.const 15 - i32.add - i32.const -16 - i32.and - local.tee $2 - i32.gt_u - if - local.get $4 - local.get $1 - local.get $2 - i32.sub - i32.const 65535 - i32.add - i32.const -65536 - i32.and - i32.const 16 - i32.shr_u - local.tee $2 - local.get $2 - local.get $4 - i32.lt_s - select - memory.grow - i32.const 0 - i32.lt_s - if - local.get $2 - memory.grow - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $1 - global.set $~lib/rt/stub/offset - i32.const 28 - i32.store - local.get $3 - i32.const 4 - i32.sub - local.tee $1 - i32.const 0 - i32.store offset=4 - local.get $1 - i32.const 0 - i32.store offset=8 - local.get $1 - local.get $0 - i32.store offset=12 - local.get $1 - i32.const 0 - i32.store offset=16 - local.get $3 - i32.const 16 - i32.add - ) - (func $~start - (local $0 i32) - i32.const 1148 - global.set $~lib/rt/stub/offset - i32.const 4 - call $~lib/rt/stub/__new - local.tee $0 - if (result i32) - local.get $0 - else - i32.const 3 - call $~lib/rt/stub/__new - end - global.set $issues/1536/instance - block $__inlined_func$issues/1536/Base#run@virtual - global.get $issues/1536/instance - i32.const 8 - i32.sub - i32.load - i32.const 4 - i32.eq - if - i32.const 5 - call $~lib/rt/stub/__new - local.tee $0 - if (result i32) - local.get $0 - else - i32.const 6 - call $~lib/rt/stub/__new - end - i32.const 8 - i32.sub - i32.load - i32.const 5 - i32.eq - br_if $__inlined_func$issues/1536/Base#run@virtual - i32.const 1056 - i32.const 1120 - i32.const 6 - i32.const 5 - call $~lib/builtins/abort - unreachable - end - i32.const 1056 - i32.const 1120 - i32.const 18 - i32.const 5 - call $~lib/builtins/abort - unreachable - end - ) -) diff --git a/tests/compiler/issues/1536.ts b/tests/compiler/issues/1536.ts deleted file mode 100644 index 099c86a3b9..0000000000 --- a/tests/compiler/issues/1536.ts +++ /dev/null @@ -1,29 +0,0 @@ -class A { - public call(): i32 { - return this.callImpl(); - } - public callImpl(): i32 { - throw new Error("not implemented"); - } -} - -class B extends A { - public callImpl(): i32 { - return 3; - } -} - -class Base { - run(): i32 { - throw new Error("not implemented"); - } -} - -class Bar extends Base { - run(): i32 { - return new B().call(); - } -} - -var instance: Base = new Bar(); -assert(instance.run() == 3); diff --git a/tests/compiler/issues/1536.untouched.wat b/tests/compiler/issues/1536.untouched.wat deleted file mode 100644 index 0b3c1f39bf..0000000000 --- a/tests/compiler/issues/1536.untouched.wat +++ /dev/null @@ -1,327 +0,0 @@ -(module - (type $i32_=>_i32 (func (param i32) (result i32))) - (type $none_=>_none (func)) - (type $i32_=>_none (func (param i32))) - (type $i32_i32_i32_i32_=>_none (func (param i32 i32 i32 i32))) - (type $i32_i32_=>_i32 (func (param i32 i32) (result i32))) - (import "env" "abort" (func $~lib/builtins/abort (param i32 i32 i32 i32))) - (memory $0 1) - (data (i32.const 12) "\1e\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1e\00\00\00n\00o\00t\00 \00i\00m\00p\00l\00e\00m\00e\00n\00t\00e\00d\00") - (data (i32.const 76) "\1c\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\1c\00\00\00i\00s\00s\00u\00e\00s\00/\001\005\003\006\00.\00t\00s\00") - (table $0 1 funcref) - (global $~lib/rt/stub/startOffset (mut i32) (i32.const 0)) - (global $~lib/rt/stub/offset (mut i32) (i32.const 0)) - (global $issues/1536/instance (mut i32) (i32.const 0)) - (global $~lib/memory/__heap_base i32 (i32.const 124)) - (export "memory" (memory $0)) - (start $~start) - (func $~lib/rt/stub/computeSize (param $0 i32) (result i32) - local.get $0 - i32.const 4 - i32.add - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - i32.const 4 - i32.sub - ) - (func $~lib/rt/stub/maybeGrowMemory (param $0 i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - (local $4 i32) - (local $5 i32) - memory.size - local.set $1 - local.get $1 - i32.const 16 - i32.shl - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - local.set $2 - local.get $0 - local.get $2 - i32.gt_u - if - local.get $0 - local.get $2 - i32.sub - i32.const 65535 - i32.add - i32.const 65535 - i32.const -1 - i32.xor - i32.and - i32.const 16 - i32.shr_u - local.set $3 - local.get $1 - local.tee $4 - local.get $3 - local.tee $5 - local.get $4 - local.get $5 - i32.gt_s - select - local.set $4 - local.get $4 - memory.grow - i32.const 0 - i32.lt_s - if - local.get $3 - memory.grow - i32.const 0 - i32.lt_s - if - unreachable - end - end - end - local.get $0 - global.set $~lib/rt/stub/offset - ) - (func $~lib/rt/stub/__alloc (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741820 - i32.gt_u - if - unreachable - end - global.get $~lib/rt/stub/offset - local.set $1 - global.get $~lib/rt/stub/offset - i32.const 4 - i32.add - local.set $2 - local.get $0 - call $~lib/rt/stub/computeSize - local.set $3 - local.get $2 - local.get $3 - i32.add - call $~lib/rt/stub/maybeGrowMemory - local.get $1 - local.get $3 - i32.store - local.get $2 - ) - (func $~lib/rt/stub/__new (param $0 i32) (param $1 i32) (result i32) - (local $2 i32) - (local $3 i32) - local.get $0 - i32.const 1073741804 - i32.gt_u - if - unreachable - end - i32.const 16 - local.get $0 - i32.add - call $~lib/rt/stub/__alloc - local.set $2 - local.get $2 - i32.const 4 - i32.sub - local.set $3 - local.get $3 - i32.const 0 - i32.store offset=4 - local.get $3 - i32.const 0 - i32.store offset=8 - local.get $3 - local.get $1 - i32.store offset=12 - local.get $3 - local.get $0 - i32.store offset=16 - local.get $2 - i32.const 16 - i32.add - ) - (func $~lib/rt/stub/__retain (param $0 i32) (result i32) - local.get $0 - ) - (func $issues/1536/Base#constructor (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 3 - call $~lib/rt/stub/__new - call $~lib/rt/stub/__retain - local.set $0 - end - local.get $0 - ) - (func $issues/1536/Bar#constructor (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 4 - call $~lib/rt/stub/__new - call $~lib/rt/stub/__retain - local.set $0 - end - local.get $0 - call $issues/1536/Base#constructor - local.set $0 - local.get $0 - ) - (func $issues/1536/Base#run (param $0 i32) (result i32) - i32.const 32 - i32.const 96 - i32.const 18 - i32.const 5 - call $~lib/builtins/abort - unreachable - ) - (func $start:issues/1536 - global.get $~lib/memory/__heap_base - i32.const 4 - i32.add - i32.const 15 - i32.add - i32.const 15 - i32.const -1 - i32.xor - i32.and - i32.const 4 - i32.sub - global.set $~lib/rt/stub/startOffset - global.get $~lib/rt/stub/startOffset - global.set $~lib/rt/stub/offset - i32.const 0 - call $issues/1536/Bar#constructor - global.set $issues/1536/instance - global.get $issues/1536/instance - call $issues/1536/Base#run@virtual - i32.const 3 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 96 - i32.const 29 - i32.const 1 - call $~lib/builtins/abort - unreachable - end - ) - (func $~start - call $start:issues/1536 - ) - (func $issues/1536/A#constructor (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 6 - call $~lib/rt/stub/__new - call $~lib/rt/stub/__retain - local.set $0 - end - local.get $0 - ) - (func $issues/1536/B#constructor (param $0 i32) (result i32) - local.get $0 - i32.eqz - if - i32.const 0 - i32.const 5 - call $~lib/rt/stub/__new - call $~lib/rt/stub/__retain - local.set $0 - end - local.get $0 - call $issues/1536/A#constructor - local.set $0 - local.get $0 - ) - (func $issues/1536/A#callImpl (param $0 i32) (result i32) - i32.const 32 - i32.const 96 - i32.const 6 - i32.const 5 - call $~lib/builtins/abort - unreachable - ) - (func $issues/1536/A#call (param $0 i32) (result i32) - local.get $0 - call $issues/1536/A#callImpl@virtual - ) - (func $~lib/rt/stub/__release (param $0 i32) - nop - ) - (func $issues/1536/Bar#run (param $0 i32) (result i32) - (local $1 i32) - (local $2 i32) - i32.const 0 - call $issues/1536/B#constructor - local.tee $1 - call $issues/1536/A#call - local.set $2 - local.get $1 - call $~lib/rt/stub/__release - local.get $2 - ) - (func $issues/1536/Base#run@virtual (param $0 i32) (result i32) - (local $1 i32) - block $default - block $case0 - local.get $0 - i32.const 8 - i32.sub - i32.load - local.set $1 - local.get $1 - i32.const 4 - i32.eq - br_if $case0 - br $default - end - local.get $0 - call $issues/1536/Bar#run - return - end - local.get $0 - call $issues/1536/Base#run - ) - (func $issues/1536/B#callImpl (param $0 i32) (result i32) - i32.const 3 - ) - (func $issues/1536/A#callImpl@virtual (param $0 i32) (result i32) - (local $1 i32) - block $default - block $case0 - local.get $0 - i32.const 8 - i32.sub - i32.load - local.set $1 - local.get $1 - i32.const 5 - i32.eq - br_if $case0 - br $default - end - local.get $0 - call $issues/1536/B#callImpl - return - end - local.get $0 - call $issues/1536/A#callImpl - ) -)