what std/string would look like

This commit is contained in:
dcode
2019-03-10 02:57:05 +01:00
parent 5c25b0cb72
commit 5a2ab3d7ec
6 changed files with 302 additions and 285 deletions

View File

@ -21,7 +21,6 @@
(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))
@ -2708,7 +2707,7 @@
else
i32.const 0
i32.const 56
i32.const 34
i32.const 32
i32.const 2
call $~lib/env/abort
unreachable
@ -2819,7 +2818,7 @@
if
i32.const 0
i32.const 56
i32.const 49
i32.const 47
i32.const 0
call $~lib/env/abort
unreachable
@ -2831,7 +2830,7 @@
if
i32.const 0
i32.const 56
i32.const 50
i32.const 48
i32.const 0
call $~lib/env/abort
unreachable
@ -2845,7 +2844,7 @@
if
i32.const 0
i32.const 56
i32.const 51
i32.const 49
i32.const 0
call $~lib/env/abort
unreachable
@ -2857,7 +2856,7 @@
if
i32.const 0
i32.const 56
i32.const 52
i32.const 50
i32.const 0
call $~lib/env/abort
unreachable
@ -2872,7 +2871,7 @@
if
i32.const 0
i32.const 56
i32.const 54
i32.const 52
i32.const 0
call $~lib/env/abort
unreachable
@ -2888,7 +2887,7 @@
if
i32.const 0
i32.const 56
i32.const 56
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -2905,7 +2904,7 @@
if
i32.const 0
i32.const 56
i32.const 59
i32.const 57
i32.const 0
call $~lib/env/abort
unreachable
@ -2913,8 +2912,6 @@
global.get $std/runtime/barrier1
call $~lib/runtime/index/ALLOC
global.set $std/runtime/ref4
global.get $std/runtime/ref3
local.set $1
global.get $std/runtime/ref4
local.tee $0
call $~lib/runtime/index/ensureUnregistered
@ -2922,26 +2919,13 @@
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 63
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 64
i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
@ -2957,7 +2941,7 @@
if
i32.const 0
i32.const 56
i32.const 66
i32.const 63
i32.const 0
call $~lib/env/abort
unreachable
@ -2969,7 +2953,7 @@
if
i32.const 0
i32.const 56
i32.const 67
i32.const 64
i32.const 0
call $~lib/env/abort
unreachable
@ -2986,7 +2970,7 @@
if
i32.const 0
i32.const 56
i32.const 70
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -3002,7 +2986,7 @@
if
i32.const 0
i32.const 56
i32.const 71
i32.const 68
i32.const 0
call $~lib/env/abort
unreachable

View File

@ -1,11 +1,9 @@
import "allocator/tlsf";
var register_ref: usize = 0;
var register_parentRef: usize = 0;
@global function __REGISTER_IMPL(ref: usize, parentRef: usize): void {
@global function __REGISTER_IMPL(ref: usize): void {
register_ref = ref;
register_parentRef = parentRef;
}
import {
@ -59,9 +57,8 @@ var ref3 = ALLOC(barrier2);
assert(ref1 == ref3); // reuses space of ref1 (free'd in realloc), ref2 (explicitly free'd)
var ref4 = ALLOC(barrier1);
REGISTER<A>(ref4, ref3); // sets up ref4 and then calls __REGISTER_IMPL
REGISTER<A>(ref4); // should call __REGISTER_IMPL
assert(register_ref == ref4);
assert(register_parentRef == ref3);
var header4 = changetype<HEADER>(register_ref - HEADER_SIZE);
assert(header4.classId == __rt_classid<A>());
assert(header4.payloadSize == barrier1);

View File

@ -37,7 +37,6 @@
(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))
@ -3393,11 +3392,9 @@
br $~lib/memory/memory.free|inlined.1
end
)
(func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vii) (param $0 i32) (param $1 i32)
(func $std/runtime/__REGISTER_IMPL (; 31 ;) (type $FUNCSIG$vi) (param $0 i32)
local.get $0
global.set $std/runtime/register_ref
local.get $1
global.set $std/runtime/register_parentRef
)
(func $~lib/runtime/index/ArrayBufferBase#get:byteLength (; 32 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32)
local.get $0
@ -3415,7 +3412,6 @@
)
(func $start:std/runtime (; 34 ;) (type $FUNCSIG$v)
(local $0 i32)
(local $1 i32)
call $start:~lib/allocator/tlsf
i32.const 43
i32.const 44
@ -3424,7 +3420,7 @@
if
i32.const 0
i32.const 56
i32.const 26
i32.const 24
i32.const 0
call $~lib/env/abort
unreachable
@ -3437,7 +3433,7 @@
if
i32.const 0
i32.const 56
i32.const 32
i32.const 30
i32.const 0
call $~lib/env/abort
unreachable
@ -3458,7 +3454,7 @@
if
i32.const 0
i32.const 56
i32.const 34
i32.const 32
i32.const 2
call $~lib/env/abort
unreachable
@ -3561,7 +3557,7 @@
if
i32.const 0
i32.const 56
i32.const 49
i32.const 47
i32.const 0
call $~lib/env/abort
unreachable
@ -3574,7 +3570,7 @@
if
i32.const 0
i32.const 56
i32.const 50
i32.const 48
i32.const 0
call $~lib/env/abort
unreachable
@ -3588,7 +3584,7 @@
if
i32.const 0
i32.const 56
i32.const 51
i32.const 49
i32.const 0
call $~lib/env/abort
unreachable
@ -3601,7 +3597,7 @@
if
i32.const 0
i32.const 56
i32.const 52
i32.const 50
i32.const 0
call $~lib/env/abort
unreachable
@ -3617,7 +3613,7 @@
if
i32.const 0
i32.const 56
i32.const 54
i32.const 52
i32.const 0
call $~lib/env/abort
unreachable
@ -3634,7 +3630,7 @@
if
i32.const 0
i32.const 56
i32.const 56
i32.const 54
i32.const 0
call $~lib/env/abort
unreachable
@ -3651,7 +3647,7 @@
if
i32.const 0
i32.const 56
i32.const 59
i32.const 57
i32.const 0
call $~lib/env/abort
unreachable
@ -3662,14 +3658,11 @@
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
@ -3679,19 +3672,7 @@
if
i32.const 0
i32.const 56
i32.const 63
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 64
i32.const 61
i32.const 0
call $~lib/env/abort
unreachable
@ -3708,7 +3689,7 @@
if
i32.const 0
i32.const 56
i32.const 66
i32.const 63
i32.const 0
call $~lib/env/abort
unreachable
@ -3721,7 +3702,7 @@
if
i32.const 0
i32.const 56
i32.const 67
i32.const 64
i32.const 0
call $~lib/env/abort
unreachable
@ -3737,7 +3718,7 @@
if
i32.const 0
i32.const 56
i32.const 70
i32.const 67
i32.const 0
call $~lib/env/abort
unreachable
@ -3750,7 +3731,7 @@
if
i32.const 0
i32.const 56
i32.const 71
i32.const 68
i32.const 0
call $~lib/env/abort
unreachable