This commit is contained in:
dcode 2019-03-09 02:37:05 +01:00
parent 0c537c3363
commit 661e239fcb
4 changed files with 258 additions and 282 deletions

View File

@ -1,9 +1,8 @@
import { AL_MASK } from "./allocator"; import { AL_MASK } from "../internal/allocator";
import { __rt_classid } from "../builtins"; import { __rt_classid } from "../builtins";
/** Common runtime header of all objects. */ /** Common runtime header of all objects. */
@unmanaged @unmanaged export class HEADER {
export class HEADER {
/** Unique id of the respective class or a magic value if not yet registered.*/ /** Unique id of the respective class or a magic value if not yet registered.*/
classId: u32; classId: u32;
/** Size of the allocated payload. */ /** Size of the allocated payload. */
@ -67,7 +66,10 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize {
let newRef = changetype<usize>(newHeader) + HEADER_SIZE; let newRef = changetype<usize>(newHeader) + HEADER_SIZE;
memory.copy(newRef, ref, payloadSize); memory.copy(newRef, ref, payloadSize);
memory.fill(newRef + payloadSize, 0, newPayloadSize - payloadSize); memory.fill(newRef + payloadSize, 0, newPayloadSize - payloadSize);
memory.free(changetype<usize>(header)); if (header.classId == HEADER_MAGIC) {
// free right away if not registered yet
memory.free(changetype<usize>(header));
}
header = newHeader; header = newHeader;
ref = newRef; ref = newRef;
} else { } else {
@ -83,20 +85,21 @@ export function REALLOC(ref: usize, newPayloadSize: u32): usize {
return ref; return ref;
} }
/** Frees an object. Must not have been registered with GC yet. */ function ensureUnregistered(ref: usize): HEADER {
export function FREE(ref: usize): void {
assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object
var header = changetype<HEADER>(ref - HEADER_SIZE); var header = changetype<HEADER>(ref - HEADER_SIZE);
assert(header.classId == HEADER_MAGIC); // must be unregistered assert(header.classId == HEADER_MAGIC); // must be unregistered
memory.free(changetype<usize>(header)); return header;
} }
/** Registers a managed object with GC. Cannot be changed anymore afterwards. */ /** Frees an object. Must not have been registered with GC yet. */
export function REGISTER<T>(ref: usize, parentRef: usize): void { export function FREE(ref: usize): void {
assert(ref >= HEAP_BASE + HEADER_SIZE); // must be a heap object memory.free(changetype<usize>(ensureUnregistered(ref)));
var header = changetype<HEADER>(ref - HEADER_SIZE); }
assert(header.classId == HEADER_MAGIC); // must be unregistered
header.classId = __rt_classid<T>(); /** Registers a managed object with GC. Cannot be free'd anymore afterwards. */
@inline export function REGISTER<T>(ref: usize, parentRef: usize): void {
ensureUnregistered(ref).classId = __rt_classid<T>();
if (GC) __REGISTER_IMPL(ref, parentRef); // tslint:disable-line if (GC) __REGISTER_IMPL(ref, parentRef); // tslint:disable-line
} }

View File

@ -16,10 +16,12 @@
(data (i32.const 88) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\001") (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 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 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) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (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/barrier1 (mut i32) (i32.const 0))
(global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0))
(global $std/runtime/barrier3 (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/header2 (mut i32) (i32.const 0))
(global $std/runtime/ref3 (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/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 "memory" (memory $0))
(export "table" (table $0)) (export "table" (table $0))
(start $start) (start $start)
@ -1019,14 +1021,14 @@
if if
unreachable unreachable
end end
i32.const 216 i32.const 208
local.set $3 local.set $3
i32.const 216 i32.const 208
global.set $~lib/allocator/tlsf/ROOT global.set $~lib/allocator/tlsf/ROOT
i32.const 2912 i32.const 2912
i32.const 0 i32.const 0
i32.store i32.store
i32.const 216 i32.const 208
i32.const 0 i32.const 0
i32.store i32.store
i32.const 0 i32.const 0
@ -1036,7 +1038,7 @@
i32.const 22 i32.const 22
i32.lt_u i32.lt_u
if if
i32.const 216 i32.const 208
local.get $1 local.get $1
i32.const 0 i32.const 0
call $~lib/allocator/tlsf/Root#setSLMap call $~lib/allocator/tlsf/Root#setSLMap
@ -1047,7 +1049,7 @@
i32.const 32 i32.const 32
i32.lt_u i32.lt_u
if if
i32.const 216 i32.const 208
local.get $1 local.get $1
local.get $2 local.get $2
i32.const 0 i32.const 0
@ -1066,8 +1068,8 @@
br $repeat|0 br $repeat|0
end end
end end
i32.const 216 i32.const 208
i32.const 3136 i32.const 3128
current_memory current_memory
i32.const 16 i32.const 16
i32.shl i32.shl
@ -1387,7 +1389,7 @@
end end
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) (local $1 i32)
i32.const 1 i32.const 1
i32.const 32 i32.const 32
@ -2551,7 +2553,7 @@
end end
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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -2559,7 +2561,7 @@
local.get $0 local.get $0
i32.const 16 i32.const 16
i32.sub i32.sub
local.tee $5 local.tee $3
i32.load offset=4 i32.load offset=4
local.tee $2 local.tee $2
local.get $1 local.get $1
@ -2581,39 +2583,45 @@
i32.clz i32.clz
i32.sub i32.sub
i32.shl i32.shl
local.tee $3 local.tee $4
i32.lt_u i32.lt_u
if if
local.get $3 local.get $4
call $~lib/allocator/tlsf/__memory_allocate call $~lib/allocator/tlsf/__memory_allocate
local.tee $4 local.tee $5
i32.const -1520547049 i32.const -1520547049
i32.store i32.store
local.get $4 local.get $5
i32.const 0 i32.const 0
i32.store offset=8 i32.store offset=8
local.get $4 local.get $5
i32.const 0 i32.const 0
i32.store offset=12 i32.store offset=12
local.get $4 local.get $5
i32.const 16 i32.const 16
i32.add i32.add
local.tee $3 local.tee $4
local.get $0 local.get $0
local.get $2 local.get $2
call $~lib/internal/memory/memmove call $~lib/internal/memory/memmove
local.get $2 local.get $2
local.get $3 local.get $4
i32.add i32.add
local.get $1 local.get $1
local.get $2 local.get $2
i32.sub i32.sub
call $~lib/internal/memory/memset call $~lib/internal/memory/memset
local.get $5
call $~lib/allocator/tlsf/__memory_free
local.get $4
local.set $5
local.get $3 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 local.set $0
else else
local.get $0 local.get $0
@ -2625,19 +2633,19 @@
call $~lib/internal/memory/memset call $~lib/internal/memory/memset
end end
end end
local.get $5 local.get $3
local.get $1 local.get $1
i32.store offset=4 i32.store offset=4
local.get $0 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 local.get $0
i32.const 228 i32.const 224
i32.lt_u i32.lt_u
if if
i32.const 0 i32.const 0
i32.const 160 i32.const 160
i32.const 88 i32.const 89
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2652,90 +2660,14 @@
if if
i32.const 0 i32.const 0
i32.const 160 i32.const 160
i32.const 90 i32.const 91
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
local.get $0 local.get $0
call $~lib/allocator/tlsf/__memory_free
) )
(func $std/runtime/__REGISTER_IMPL (; 24 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $start:std/runtime (; 24 ;) (type $FUNCSIG$v)
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<A> (; 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)
(local $0 i32) (local $0 i32)
(local $1 i32) (local $1 i32)
(local $2 i32) (local $2 i32)
@ -2775,7 +2707,7 @@
else else
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 23 i32.const 32
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2873,7 +2805,7 @@
f64.const 0 f64.const 0
call $~lib/env/trace call $~lib/env/trace
i32.const 1 i32.const 1
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref1 global.set $std/runtime/ref1
global.get $std/runtime/ref1 global.get $std/runtime/ref1
i32.const 16 i32.const 16
@ -2886,7 +2818,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 38 i32.const 47
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2898,7 +2830,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 39 i32.const 48
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2907,12 +2839,12 @@
local.tee $0 local.tee $0
local.get $0 local.get $0
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
call $~lib/internal/runtime/REALLOC call $~lib/runtime/index/REALLOC
i32.ne i32.ne
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 40 i32.const 49
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2924,14 +2856,14 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 41 i32.const 50
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
call $~lib/internal/runtime/REALLOC call $~lib/runtime/index/REALLOC
global.set $std/runtime/ref2 global.set $std/runtime/ref2
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/ref2 global.get $std/runtime/ref2
@ -2939,7 +2871,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 43 i32.const 52
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -2955,15 +2887,16 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 45 i32.const 54
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/ref2 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 global.get $std/runtime/barrier2
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref3 global.set $std/runtime/ref3
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/ref3 global.get $std/runtime/ref3
@ -2971,32 +2904,80 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 48 i32.const 57
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref4 global.set $std/runtime/ref4
global.get $std/runtime/ref4
global.get $std/runtime/ref3 global.get $std/runtime/ref3
call $~lib/internal/runtime/REGISTER<A> local.set $1
global.get $std/runtime/called global.get $std/runtime/ref4
i32.eqz 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 if
i32.const 0 i32.const 0
i32.const 56 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 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
) )
(func $start (; 27 ;) (type $FUNCSIG$v) (func $start (; 25 ;) (type $FUNCSIG$v)
call $start:std/runtime call $start:std/runtime
) )
(func $null (; 28 ;) (type $FUNCSIG$v) (func $null (; 26 ;) (type $FUNCSIG$v)
nop nop
) )
) )

View File

@ -1,4 +1,13 @@
import "allocator/tlsf"; 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 { import {
HEADER, HEADER,
HEADER_SIZE, HEADER_SIZE,
@ -8,7 +17,7 @@ import {
REALLOC, REALLOC,
FREE, FREE,
REGISTER REGISTER
} from "internal/runtime"; } from "runtime";
class A {} class A {}
class B {} 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) assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd)
var ref4 = ALLOC(barrier1); var ref4 = ALLOC(barrier1);
var called = false; REGISTER<A>(ref4, ref3); // sets up ref4 and then calls __REGISTER_IMPL
@global function __REGISTER_IMPL(ref: usize, parentRef: usize): void { assert(register_ref == ref4);
assert(ref == ref4); assert(register_parentRef == ref3);
assert(parentRef == ref3); var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
var header = changetype<HEADER>(ref - HEADER_SIZE); assert(header4.classId == __rt_classid<A>());
assert(header.classId == __rt_classid<A>()); assert(header4.payloadSize == barrier1);
called = true;
}
REGISTER<A>(ref4, ref3); // TODO
assert(called);

View File

@ -16,7 +16,7 @@
(data (i32.const 88) "\08\00\00\00b\00a\00r\00r\00i\00e\00r\001\00") (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 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 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) (table $0 1 funcref)
(elem (i32.const 0) $null) (elem (i32.const 0) $null)
(global $~lib/allocator/tlsf/SL_BITS i32 (i32.const 5)) (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.HL_END i32 (i32.const 2912))
(global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916)) (global $~lib/allocator/tlsf/Root.SIZE i32 (i32.const 2916))
(global $~lib/allocator/tlsf/ROOT (mut i32) (i32.const 0)) (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/barrier1 (mut i32) (i32.const 0))
(global $std/runtime/barrier2 (mut i32) (i32.const 0)) (global $std/runtime/barrier2 (mut i32) (i32.const 0))
(global $std/runtime/barrier3 (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/header2 (mut i32) (i32.const 0))
(global $std/runtime/ref3 (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/ref4 (mut i32) (i32.const 0))
(global $std/runtime/called (mut i32) (i32.const 0)) (global $std/runtime/header4 (mut i32) (i32.const 0))
(global $~lib/memory/HEAP_BASE i32 (i32.const 212)) (global $~lib/memory/HEAP_BASE i32 (i32.const 208))
(export "memory" (memory $0)) (export "memory" (memory $0))
(export "table" (table $0)) (export "table" (table $0))
(start $start) (start $start)
@ -66,7 +68,7 @@
unreachable unreachable
end 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 1
i32.const 32 i32.const 32
local.get $0 local.get $0
@ -1710,7 +1712,7 @@
end end
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 $1 i32)
(local $2 i32) (local $2 i32)
(local $3 i32) (local $3 i32)
@ -1718,7 +1720,7 @@
(local $5 i32) (local $5 i32)
block $~lib/memory/memory.allocate|inlined.0 (result i32) block $~lib/memory/memory.allocate|inlined.0 (result i32)
local.get $0 local.get $0
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
local.set $1 local.set $1
local.get $1 local.get $1
call $~lib/allocator/tlsf/__memory_allocate call $~lib/allocator/tlsf/__memory_allocate
@ -3226,7 +3228,7 @@
end end
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 $2 i32)
(local $3 i32) (local $3 i32)
(local $4 i32) (local $4 i32)
@ -3247,10 +3249,10 @@
i32.lt_u i32.lt_u
if if
local.get $1 local.get $1
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
local.set $4 local.set $4
local.get $3 local.get $3
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
local.get $4 local.get $4
i32.lt_u i32.lt_u
if if
@ -3303,12 +3305,18 @@
local.get $7 local.get $7
call $~lib/internal/memory/memset call $~lib/internal/memory/memset
end end
block $~lib/memory/memory.free|inlined.0 local.get $2
local.get $2 i32.load
local.set $7 i32.const -1520547049
local.get $7 i32.eq
call $~lib/allocator/tlsf/__memory_free if
br $~lib/memory/memory.free|inlined.0 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 end
local.get $5 local.get $5
local.set $2 local.set $2
@ -3338,9 +3346,8 @@
i32.store offset=4 i32.store offset=4
local.get $0 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 $1 i32)
(local $2 i32)
local.get $0 local.get $0
global.get $~lib/memory/HEAP_BASE global.get $~lib/memory/HEAP_BASE
i32.const 16 i32.const 16
@ -3350,7 +3357,7 @@
if if
i32.const 0 i32.const 0
i32.const 160 i32.const 160
i32.const 88 i32.const 89
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3367,107 +3374,33 @@
if if
i32.const 0 i32.const 0
i32.const 160 i32.const 160
i32.const 90 i32.const 91
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end 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 block $~lib/memory/memory.free|inlined.1
local.get $0
call $~lib/runtime/index/ensureUnregistered
local.set $1
local.get $1 local.get $1
local.set $2
local.get $2
call $~lib/allocator/tlsf/__memory_free call $~lib/allocator/tlsf/__memory_free
br $~lib/memory/memory.free|inlined.1 br $~lib/memory/memory.free|inlined.1
end end
) )
(func $std/runtime/__REGISTER_IMPL (; 30 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32) (func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(local $2 i32)
local.get $0 local.get $0
global.get $std/runtime/ref4 global.set $std/runtime/register_ref
i32.eq
i32.eqz
if
i32.const 0
i32.const 56
i32.const 53
i32.const 2
call $~lib/env/abort
unreachable
end
local.get $1 local.get $1
global.get $std/runtime/ref3 global.set $std/runtime/register_parentRef
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<A> (; 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
) )
(func $start:std/runtime (; 32 ;) (type $FUNCSIG$v) (func $start:std/runtime (; 32 ;) (type $FUNCSIG$v)
(local $0 i32) (local $0 i32)
(local $1 i32)
call $start:~lib/allocator/tlsf call $start:~lib/allocator/tlsf
i32.const 43 i32.const 43
i32.const 44 i32.const 44
@ -3476,20 +3409,20 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 15 i32.const 24
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
i32.const 0 i32.const 0
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
i32.const 0 i32.const 0
i32.gt_u i32.gt_u
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 21 i32.const 30
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3504,13 +3437,13 @@
i32.eqz i32.eqz
br_if $break|0 br_if $break|0
local.get $0 local.get $0
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
call $std/runtime/isPowerOf2 call $std/runtime/isPowerOf2
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 23 i32.const 32
i32.const 2 i32.const 2
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3525,7 +3458,7 @@
unreachable unreachable
end end
i32.const 0 i32.const 0
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
global.set $std/runtime/barrier1 global.set $std/runtime/barrier1
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
i32.const 1 i32.const 1
@ -3536,9 +3469,9 @@
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
i32.const 1 i32.const 1
i32.add i32.add
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
i32.eq i32.eq
if if
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
@ -3558,9 +3491,9 @@
global.get $std/runtime/barrier3 global.get $std/runtime/barrier3
i32.const 1 i32.const 1
i32.add i32.add
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
global.get $std/runtime/barrier3 global.get $std/runtime/barrier3
call $~lib/internal/runtime/ALIGN call $~lib/runtime/index/ALIGN
i32.eq i32.eq
if if
global.get $std/runtime/barrier3 global.get $std/runtime/barrier3
@ -3599,7 +3532,7 @@
f64.const 0 f64.const 0
call $~lib/env/trace call $~lib/env/trace
i32.const 1 i32.const 1
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref1 global.set $std/runtime/ref1
global.get $std/runtime/ref1 global.get $std/runtime/ref1
i32.const 16 i32.const 16
@ -3613,7 +3546,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 38 i32.const 47
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3626,7 +3559,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 39 i32.const 48
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3634,13 +3567,13 @@
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
call $~lib/internal/runtime/REALLOC call $~lib/runtime/index/REALLOC
i32.eq i32.eq
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 40 i32.const 49
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3653,14 +3586,14 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 41 i32.const 50
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
call $~lib/internal/runtime/REALLOC call $~lib/runtime/index/REALLOC
global.set $std/runtime/ref2 global.set $std/runtime/ref2
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/ref2 global.get $std/runtime/ref2
@ -3669,7 +3602,7 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 43 i32.const 52
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
@ -3686,15 +3619,15 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 45 i32.const 54
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/ref2 global.get $std/runtime/ref2
call $~lib/internal/runtime/FREE call $~lib/runtime/index/FREE
global.get $std/runtime/barrier2 global.get $std/runtime/barrier2
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref3 global.set $std/runtime/ref3
global.get $std/runtime/ref1 global.get $std/runtime/ref1
global.get $std/runtime/ref3 global.get $std/runtime/ref3
@ -3703,23 +3636,77 @@
if if
i32.const 0 i32.const 0
i32.const 56 i32.const 56
i32.const 48 i32.const 57
i32.const 0 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable
end end
global.get $std/runtime/barrier1 global.get $std/runtime/barrier1
call $~lib/internal/runtime/ALLOC call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref4 global.set $std/runtime/ref4
block $~lib/runtime/index/REGISTER<A>|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/ref4
global.get $std/runtime/ref3 i32.eq
call $~lib/internal/runtime/REGISTER<A>
global.get $std/runtime/called
i32.eqz i32.eqz
if if
i32.const 0 i32.const 0
i32.const 56 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 i32.const 0
call $~lib/env/abort call $~lib/env/abort
unreachable unreachable