From 661e239fcb25f2be3a0a3be17251c16a2e0a603c Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 9 Mar 2019 02:37:05 +0100 Subject: [PATCH] refactor --- .../{internal/runtime.ts => runtime/index.ts} | 29 +- tests/compiler/std/runtime.optimized.wat | 235 ++++++++--------- tests/compiler/std/runtime.ts | 27 +- tests/compiler/std/runtime.untouched.wat | 249 +++++++++--------- 4 files changed, 258 insertions(+), 282 deletions(-) rename std/assembly/{internal/runtime.ts => runtime/index.ts} (87%) diff --git a/std/assembly/internal/runtime.ts b/std/assembly/runtime/index.ts similarity index 87% rename from std/assembly/internal/runtime.ts rename to std/assembly/runtime/index.ts index a979094a..184c9ae8 100644 --- a/std/assembly/internal/runtime.ts +++ b/std/assembly/runtime/index.ts @@ -1,9 +1,8 @@ -import { AL_MASK } from "./allocator"; +import { AL_MASK } from "../internal/allocator"; import { __rt_classid } from "../builtins"; /** Common runtime header of all objects. */ -@unmanaged -export class HEADER { +@unmanaged export class HEADER { /** Unique id of the respective class or a magic value if not yet registered.*/ classId: u32; /** Size of the allocated payload. */ @@ -67,7 +66,10 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize { let newRef = changetype(newHeader) + HEADER_SIZE; memory.copy(newRef, ref, payloadSize); memory.fill(newRef + payloadSize, 0, newPayloadSize - payloadSize); - memory.free(changetype(header)); + if (header.classId == HEADER_MAGIC) { + // free right away if not registered yet + memory.free(changetype(header)); + } header = newHeader; ref = newRef; } else { @@ -83,20 +85,21 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize { return ref; } -/** Frees an object. Must not have been registered with GC yet. */ -export function FREE(ref: usize): void { +function ensureUnregistered(ref: usize): HEADER { assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object var header = changetype
(ref - HEADER_SIZE); assert(header.classId == HEADER_MAGIC); // must be unregistered - memory.free(changetype(header)); + return header; } -/** Registers a managed object with GC. Cannot be changed anymore afterwards. */ -export function REGISTER(ref: usize, parentRef: usize): void { - assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object - var header = changetype
(ref - HEADER_SIZE); - assert(header.classId == HEADER_MAGIC); // must be unregistered - header.classId = __rt_classid(); +/** Frees an object. Must not have been registered with GC yet. */ +export function FREE(ref: usize): void { + memory.free(changetype(ensureUnregistered(ref))); +} + +/** Registers a managed object with GC. Cannot be free'd anymore afterwards. */ +@inline export function REGISTER(ref: usize, parentRef: usize): void { + ensureUnregistered(ref).classId = __rt_classid(); if (GC) __REGISTER_IMPL(ref, parentRef); // tslint:disable-line } diff --git a/tests/compiler/std/runtime.optimized.wat b/tests/compiler/std/runtime.optimized.wat index 8f243117..a1cb1be9 100644 --- a/tests/compiler/std/runtime.optimized.wat +++ b/tests/compiler/std/runtime.optimized.wat @@ -16,10 +16,12 @@ (data (i32.const 88) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\001") (data (i32.const 112) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\002") (data (i32.const 136) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\003") - (data (i32.const 160) "\18\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s") + (data (i32.const 160) "\15\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00/\00i\00n\00d\00e\00x\00.\00t\00s") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) + (global $std/runtime/register_ref (mut i32) (i32.const 0)) + (global $std/runtime/register_parentRef (mut i32) (i32.const 0)) (global $std/runtime/barrier1 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier3 (mut i32) (i32.const 0)) @@ -29,7 +31,7 @@ (global $std/runtime/header2 (mut i32) (i32.const 0)) (global $std/runtime/ref3 (mut i32) (i32.const 0)) (global $std/runtime/ref4 (mut i32) (i32.const 0)) - (global $std/runtime/called (mut i32) (i32.const 0)) + (global $std/runtime/header4 (mut i32) (i32.const 0)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -1019,14 +1021,14 @@ if unreachable end - i32.const 216 + i32.const 208 local.set $3 - i32.const 216 + i32.const 208 global.set $~lib/allocator/tlsf/ROOT i32.const 2912 i32.const 0 i32.store - i32.const 216 + i32.const 208 i32.const 0 i32.store i32.const 0 @@ -1036,7 +1038,7 @@ i32.const 22 i32.lt_u if - i32.const 216 + i32.const 208 local.get $1 i32.const 0 call $~lib/allocator/tlsf/Root#setSLMap @@ -1047,7 +1049,7 @@ i32.const 32 i32.lt_u if - i32.const 216 + i32.const 208 local.get $1 local.get $2 i32.const 0 @@ -1066,8 +1068,8 @@ br $repeat|0 end end - i32.const 216 - i32.const 3136 + i32.const 208 + i32.const 3128 current_memory i32.const 16 i32.shl @@ -1387,7 +1389,7 @@ end end ) - (func $~lib/internal/runtime/ALLOC (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/runtime/index/ALLOC (; 18 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) i32.const 1 i32.const 32 @@ -2551,7 +2553,7 @@ end end ) - (func $~lib/internal/runtime/REALLOC (; 22 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/runtime/index/REALLOC (; 22 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -2559,7 +2561,7 @@ local.get $0 i32.const 16 i32.sub - local.tee $5 + local.tee $3 i32.load offset=4 local.tee $2 local.get $1 @@ -2581,39 +2583,45 @@ i32.clz i32.sub i32.shl - local.tee $3 + local.tee $4 i32.lt_u if - local.get $3 + local.get $4 call $~lib/allocator/tlsf/__memory_allocate - local.tee $4 + local.tee $5 i32.const -1520547049 i32.store - local.get $4 + local.get $5 i32.const 0 i32.store offset=8 - local.get $4 + local.get $5 i32.const 0 i32.store offset=12 - local.get $4 + local.get $5 i32.const 16 i32.add - local.tee $3 + local.tee $4 local.get $0 local.get $2 call $~lib/internal/memory/memmove local.get $2 - local.get $3 + local.get $4 i32.add local.get $1 local.get $2 i32.sub call $~lib/internal/memory/memset - local.get $5 - call $~lib/allocator/tlsf/__memory_free - local.get $4 - local.set $5 local.get $3 + i32.load + i32.const -1520547049 + i32.eq + if + local.get $3 + call $~lib/allocator/tlsf/__memory_free + end + local.get $5 + local.set $3 + local.get $4 local.set $0 else local.get $0 @@ -2625,19 +2633,19 @@ call $~lib/internal/memory/memset end end - local.get $5 + local.get $3 local.get $1 i32.store offset=4 local.get $0 ) - (func $~lib/internal/runtime/FREE (; 23 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/runtime/index/ensureUnregistered (; 23 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) local.get $0 - i32.const 228 + i32.const 224 i32.lt_u if i32.const 0 i32.const 160 - i32.const 88 + i32.const 89 i32.const 2 call $~lib/env/abort unreachable @@ -2652,90 +2660,14 @@ if i32.const 0 i32.const 160 - i32.const 90 + i32.const 91 i32.const 2 call $~lib/env/abort unreachable end local.get $0 - call $~lib/allocator/tlsf/__memory_free ) - (func $std/runtime/__REGISTER_IMPL (; 24 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - local.get $0 - global.get $std/runtime/ref4 - i32.ne - if - i32.const 0 - i32.const 56 - i32.const 53 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $1 - global.get $std/runtime/ref3 - i32.ne - if - i32.const 0 - i32.const 56 - i32.const 54 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - i32.load - i32.const 43 - i32.ne - if - i32.const 0 - i32.const 56 - i32.const 56 - i32.const 2 - call $~lib/env/abort - unreachable - end - i32.const 1 - global.set $std/runtime/called - ) - (func $~lib/internal/runtime/REGISTER (; 25 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - i32.const 228 - i32.lt_u - if - i32.const 0 - i32.const 160 - i32.const 96 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.tee $2 - i32.load - i32.const -1520547049 - i32.ne - if - i32.const 0 - i32.const 160 - i32.const 98 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $2 - i32.const 43 - i32.store - local.get $0 - local.get $1 - call $std/runtime/__REGISTER_IMPL - ) - (func $start:std/runtime (; 26 ;) (type $FUNCSIG$v) + (func $start:std/runtime (; 24 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 i32) (local $2 i32) @@ -2775,7 +2707,7 @@ else i32.const 0 i32.const 56 - i32.const 23 + i32.const 32 i32.const 2 call $~lib/env/abort unreachable @@ -2873,7 +2805,7 @@ f64.const 0 call $~lib/env/trace i32.const 1 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref1 global.get $std/runtime/ref1 i32.const 16 @@ -2886,7 +2818,7 @@ if i32.const 0 i32.const 56 - i32.const 38 + i32.const 47 i32.const 0 call $~lib/env/abort unreachable @@ -2898,7 +2830,7 @@ if i32.const 0 i32.const 56 - i32.const 39 + i32.const 48 i32.const 0 call $~lib/env/abort unreachable @@ -2907,12 +2839,12 @@ local.tee $0 local.get $0 global.get $std/runtime/barrier1 - call $~lib/internal/runtime/REALLOC + call $~lib/runtime/index/REALLOC i32.ne if i32.const 0 i32.const 56 - i32.const 40 + i32.const 49 i32.const 0 call $~lib/env/abort unreachable @@ -2924,14 +2856,14 @@ if i32.const 0 i32.const 56 - i32.const 41 + i32.const 50 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/ref1 global.get $std/runtime/barrier2 - call $~lib/internal/runtime/REALLOC + call $~lib/runtime/index/REALLOC global.set $std/runtime/ref2 global.get $std/runtime/ref1 global.get $std/runtime/ref2 @@ -2939,7 +2871,7 @@ if i32.const 0 i32.const 56 - i32.const 43 + i32.const 52 i32.const 0 call $~lib/env/abort unreachable @@ -2955,15 +2887,16 @@ if i32.const 0 i32.const 56 - i32.const 45 + i32.const 54 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/ref2 - call $~lib/internal/runtime/FREE + call $~lib/runtime/index/ensureUnregistered + call $~lib/allocator/tlsf/__memory_free global.get $std/runtime/barrier2 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref3 global.get $std/runtime/ref1 global.get $std/runtime/ref3 @@ -2971,32 +2904,80 @@ if i32.const 0 i32.const 56 - i32.const 48 + i32.const 57 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/barrier1 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref4 - global.get $std/runtime/ref4 global.get $std/runtime/ref3 - call $~lib/internal/runtime/REGISTER - global.get $std/runtime/called - i32.eqz + local.set $1 + global.get $std/runtime/ref4 + local.tee $0 + call $~lib/runtime/index/ensureUnregistered + i32.const 43 + i32.store + local.get $0 + global.set $std/runtime/register_ref + local.get $1 + global.set $std/runtime/register_parentRef + global.get $std/runtime/register_ref + global.get $std/runtime/ref4 + i32.ne if i32.const 0 i32.const 56 - i32.const 60 + i32.const 61 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/register_parentRef + global.get $std/runtime/ref3 + i32.ne + if + i32.const 0 + i32.const 56 + i32.const 62 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/register_ref + i32.const 16 + i32.sub + global.set $std/runtime/header4 + global.get $std/runtime/header4 + i32.load + i32.const 43 + i32.ne + if + i32.const 0 + i32.const 56 + i32.const 64 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/barrier1 + global.get $std/runtime/header4 + i32.load offset=4 + i32.ne + if + i32.const 0 + i32.const 56 + i32.const 65 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 27 ;) (type $FUNCSIG$v) + (func $start (; 25 ;) (type $FUNCSIG$v) call $start:std/runtime ) - (func $null (; 28 ;) (type $FUNCSIG$v) + (func $null (; 26 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/runtime.ts b/tests/compiler/std/runtime.ts index dd89399e..f2e233c9 100644 --- a/tests/compiler/std/runtime.ts +++ b/tests/compiler/std/runtime.ts @@ -1,4 +1,13 @@ import "allocator/tlsf"; + +var register_ref: usize = 0; +var register_parentRef: usize = 0; + +@global function __REGISTER_IMPL(ref: usize, parentRef: usize): void { + register_ref = ref; + register_parentRef = parentRef; +} + import { HEADER, HEADER_SIZE, @@ -8,7 +17,7 @@ import { REALLOC, FREE, REGISTER -} from "internal/runtime"; +} from "runtime"; class A {} class B {} @@ -48,13 +57,9 @@ var ref3 = ALLOC(barrier2); assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd) var ref4 = ALLOC(barrier1); -var called = false; -@global function __REGISTER_IMPL(ref: usize, parentRef: usize): void { - assert(ref == ref4); - assert(parentRef == ref3); - var header = changetype
(ref - HEADER_SIZE); - assert(header.classId == __rt_classid()); - called = true; -} -REGISTER(ref4, ref3); // TODO -assert(called); +REGISTER(ref4, ref3); // sets up ref4 and then calls __REGISTER_IMPL +assert(register_ref == ref4); +assert(register_parentRef == ref3); +var header4 = changetype
(register_ref - HEADER_SIZE); +assert(header4.classId == __rt_classid()); +assert(header4.payloadSize == barrier1); diff --git a/tests/compiler/std/runtime.untouched.wat b/tests/compiler/std/runtime.untouched.wat index 9de6f5ea..ccd59de1 100644 --- a/tests/compiler/std/runtime.untouched.wat +++ b/tests/compiler/std/runtime.untouched.wat @@ -16,7 +16,7 @@ (data (i32.const 88) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\001\00") (data (i32.const 112) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\002\00") (data (i32.const 136) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\003\00") - (data (i32.const 160) "\18\00\00\00~\00l\00i\00b\00/\00i\00n\00t\00e\00r\00n\00a\00l\00/\00r\00u\00n\00t\00i\00m\00e\00.\00t\00s\00") + (data (i32.const 160) "\15\00\00\00~\00l\00i\00b\00/\00r\00u\00n\00t\00i\00m\00e\00/\00i\00n\00d\00e\00x\00.\00t\00s\00") (table $0 1 funcref) (elem (i32.const 0) $null) (global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) @@ -36,6 +36,8 @@ (global $~lib/allocator/tlsf/Root.HL_END i32 (i32.const 2912)) (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) (global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) + (global $std/runtime/register_ref (mut i32) (i32.const 0)) + (global $std/runtime/register_parentRef (mut i32) (i32.const 0)) (global $std/runtime/barrier1 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier3 (mut i32) (i32.const 0)) @@ -45,8 +47,8 @@ (global $std/runtime/header2 (mut i32) (i32.const 0)) (global $std/runtime/ref3 (mut i32) (i32.const 0)) (global $std/runtime/ref4 (mut i32) (i32.const 0)) - (global $std/runtime/called (mut i32) (i32.const 0)) - (global $~lib/memory/HEAP_BASE i32 (i32.const 212)) + (global $std/runtime/header4 (mut i32) (i32.const 0)) + (global $~lib/memory/HEAP_BASE i32 (i32.const 208)) (export "memory" (memory $0)) (export "table" (table $0)) (start $start) @@ -66,7 +68,7 @@ unreachable end ) - (func $~lib/internal/runtime/ALIGN (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/runtime/index/ALIGN (; 3 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) i32.const 1 i32.const 32 local.get $0 @@ -1710,7 +1712,7 @@ end end ) - (func $~lib/internal/runtime/ALLOC (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (func $~lib/runtime/index/ALLOC (; 24 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -1718,7 +1720,7 @@ (local $5 i32) block $~lib/memory/memory.allocate|inlined.0 (result i32) local.get $0 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN local.set $1 local.get $1 call $~lib/allocator/tlsf/__memory_allocate @@ -3226,7 +3228,7 @@ end end ) - (func $~lib/internal/runtime/REALLOC (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) + (func $~lib/runtime/index/REALLOC (; 28 ;) (type $FUNCSIG$iii) (param $0 i32) (param $1 i32) (result i32) (local $2 i32) (local $3 i32) (local $4 i32) @@ -3247,10 +3249,10 @@ i32.lt_u if local.get $1 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN local.set $4 local.get $3 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN local.get $4 i32.lt_u if @@ -3303,12 +3305,18 @@ local.get $7 call $~lib/internal/memory/memset end - block $~lib/memory/memory.free|inlined.0 - local.get $2 - local.set $7 - local.get $7 - call $~lib/allocator/tlsf/__memory_free - br $~lib/memory/memory.free|inlined.0 + local.get $2 + i32.load + i32.const -1520547049 + i32.eq + if + block $~lib/memory/memory.free|inlined.0 + local.get $2 + local.set $7 + local.get $7 + call $~lib/allocator/tlsf/__memory_free + br $~lib/memory/memory.free|inlined.0 + end end local.get $5 local.set $2 @@ -3338,9 +3346,8 @@ i32.store offset=4 local.get $0 ) - (func $~lib/internal/runtime/FREE (; 29 ;) (type $FUNCSIG$vi) (param $0 i32) + (func $~lib/runtime/index/ensureUnregistered (; 29 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) (local $1 i32) - (local $2 i32) local.get $0 global.get $~lib/memory/HEAP_BASE i32.const 16 @@ -3350,7 +3357,7 @@ if i32.const 0 i32.const 160 - i32.const 88 + i32.const 89 i32.const 2 call $~lib/env/abort unreachable @@ -3367,107 +3374,33 @@ if i32.const 0 i32.const 160 - i32.const 90 + i32.const 91 i32.const 2 call $~lib/env/abort unreachable end + local.get $1 + ) + (func $~lib/runtime/index/FREE (; 30 ;) (type $FUNCSIG$vi) (param $0 i32) + (local $1 i32) block $~lib/memory/memory.free|inlined.1 + local.get $0 + call $~lib/runtime/index/ensureUnregistered + local.set $1 local.get $1 - local.set $2 - local.get $2 call $~lib/allocator/tlsf/__memory_free br $~lib/memory/memory.free|inlined.1 end ) - (func $std/runtime/__REGISTER_IMPL (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) + (func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) local.get $0 - global.get $std/runtime/ref4 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 53 - i32.const 2 - call $~lib/env/abort - unreachable - end + global.set $std/runtime/register_ref local.get $1 - global.get $std/runtime/ref3 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 54 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.set $2 - local.get $2 - i32.load - i32.const 43 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 56 - i32.const 56 - i32.const 2 - call $~lib/env/abort - unreachable - end - i32.const 1 - global.set $std/runtime/called - ) - (func $~lib/internal/runtime/REGISTER (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) - (local $2 i32) - local.get $0 - global.get $~lib/memory/HEAP_BASE - i32.const 16 - i32.add - i32.ge_u - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 96 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $0 - i32.const 16 - i32.sub - local.set $2 - local.get $2 - i32.load - i32.const -1520547049 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 160 - i32.const 98 - i32.const 2 - call $~lib/env/abort - unreachable - end - local.get $2 - i32.const 43 - i32.store - local.get $0 - local.get $1 - call $std/runtime/__REGISTER_IMPL + global.set $std/runtime/register_parentRef ) (func $start:std/runtime (; 32 ;) (type $FUNCSIG$v) (local $0 i32) + (local $1 i32) call $start:~lib/allocator/tlsf i32.const 43 i32.const 44 @@ -3476,20 +3409,20 @@ if i32.const 0 i32.const 56 - i32.const 15 + i32.const 24 i32.const 0 call $~lib/env/abort unreachable end i32.const 0 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN i32.const 0 i32.gt_u i32.eqz if i32.const 0 i32.const 56 - i32.const 21 + i32.const 30 i32.const 0 call $~lib/env/abort unreachable @@ -3504,13 +3437,13 @@ i32.eqz br_if $break|0 local.get $0 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN call $std/runtime/isPowerOf2 i32.eqz if i32.const 0 i32.const 56 - i32.const 23 + i32.const 32 i32.const 2 call $~lib/env/abort unreachable @@ -3525,7 +3458,7 @@ unreachable end i32.const 0 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN global.set $std/runtime/barrier1 global.get $std/runtime/barrier1 i32.const 1 @@ -3536,9 +3469,9 @@ global.get $std/runtime/barrier2 i32.const 1 i32.add - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN global.get $std/runtime/barrier2 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN i32.eq if global.get $std/runtime/barrier2 @@ -3558,9 +3491,9 @@ global.get $std/runtime/barrier3 i32.const 1 i32.add - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN global.get $std/runtime/barrier3 - call $~lib/internal/runtime/ALIGN + call $~lib/runtime/index/ALIGN i32.eq if global.get $std/runtime/barrier3 @@ -3599,7 +3532,7 @@ f64.const 0 call $~lib/env/trace i32.const 1 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref1 global.get $std/runtime/ref1 i32.const 16 @@ -3613,7 +3546,7 @@ if i32.const 0 i32.const 56 - i32.const 38 + i32.const 47 i32.const 0 call $~lib/env/abort unreachable @@ -3626,7 +3559,7 @@ if i32.const 0 i32.const 56 - i32.const 39 + i32.const 48 i32.const 0 call $~lib/env/abort unreachable @@ -3634,13 +3567,13 @@ global.get $std/runtime/ref1 global.get $std/runtime/ref1 global.get $std/runtime/barrier1 - call $~lib/internal/runtime/REALLOC + call $~lib/runtime/index/REALLOC i32.eq i32.eqz if i32.const 0 i32.const 56 - i32.const 40 + i32.const 49 i32.const 0 call $~lib/env/abort unreachable @@ -3653,14 +3586,14 @@ if i32.const 0 i32.const 56 - i32.const 41 + i32.const 50 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/ref1 global.get $std/runtime/barrier2 - call $~lib/internal/runtime/REALLOC + call $~lib/runtime/index/REALLOC global.set $std/runtime/ref2 global.get $std/runtime/ref1 global.get $std/runtime/ref2 @@ -3669,7 +3602,7 @@ if i32.const 0 i32.const 56 - i32.const 43 + i32.const 52 i32.const 0 call $~lib/env/abort unreachable @@ -3686,15 +3619,15 @@ if i32.const 0 i32.const 56 - i32.const 45 + i32.const 54 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/ref2 - call $~lib/internal/runtime/FREE + call $~lib/runtime/index/FREE global.get $std/runtime/barrier2 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref3 global.get $std/runtime/ref1 global.get $std/runtime/ref3 @@ -3703,23 +3636,77 @@ if i32.const 0 i32.const 56 - i32.const 48 + i32.const 57 i32.const 0 call $~lib/env/abort unreachable end global.get $std/runtime/barrier1 - call $~lib/internal/runtime/ALLOC + call $~lib/runtime/index/ALLOC global.set $std/runtime/ref4 + block $~lib/runtime/index/REGISTER|inlined.0 + global.get $std/runtime/ref4 + local.set $0 + global.get $std/runtime/ref3 + local.set $1 + local.get $0 + call $~lib/runtime/index/ensureUnregistered + i32.const 43 + i32.store + local.get $0 + local.get $1 + call $std/runtime/__REGISTER_IMPL + end + global.get $std/runtime/register_ref global.get $std/runtime/ref4 - global.get $std/runtime/ref3 - call $~lib/internal/runtime/REGISTER - global.get $std/runtime/called + i32.eq i32.eqz if i32.const 0 i32.const 56 - i32.const 60 + i32.const 61 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/register_parentRef + global.get $std/runtime/ref3 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 56 + i32.const 62 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/register_ref + i32.const 16 + i32.sub + global.set $std/runtime/header4 + global.get $std/runtime/header4 + i32.load + i32.const 43 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 56 + i32.const 64 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $std/runtime/header4 + i32.load offset=4 + global.get $std/runtime/barrier1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 56 + i32.const 65 i32.const 0 call $~lib/env/abort unreachable