mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-18 17:31:29 +00:00
Rework static memory segment creation; Fix stdlib gc hooks not marking own fields; Align everything to 8 bytes that might be touched by GC
This commit is contained in:
@ -29,10 +29,10 @@
|
||||
(global $std/gc-basics/obj2 (mut i32) (i32.const 0))
|
||||
(global $~started (mut i32) (i32.const 0))
|
||||
(global $HEAP_BASE i32 (i32.const 60))
|
||||
(table 2 2 anyfunc)
|
||||
(elem (i32.const 0) $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark)
|
||||
(table 3 3 anyfunc)
|
||||
(elem (i32.const 0) $std/gc-basics/MyObject_visit $~lib/collector/itcm/__gc_mark $~lib/string/String~gc)
|
||||
(memory $0 1)
|
||||
(data (i32.const 8) "\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s\00")
|
||||
(data (i32.const 8) "\00\00\00\00\00\00\00\00\02\00\00\00\00\00\00\00\10\00\00\00s\00t\00d\00/\00g\00c\00-\00b\00a\00s\00i\00c\00s\00.\00t\00s\00")
|
||||
(export "memory" (memory $0))
|
||||
(export "table" (table $0))
|
||||
(export "main" (func $std/gc-basics/main))
|
||||
@ -47,105 +47,108 @@
|
||||
(local $5 i32)
|
||||
(local $6 i32)
|
||||
(if
|
||||
(get_local $0)
|
||||
(block
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $0)
|
||||
(get_global $~lib/internal/allocator/MAX_SIZE_32)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(get_global $~lib/allocator/arena/offset)
|
||||
)
|
||||
(set_local $2
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(i32.gt_u
|
||||
(get_local $0)
|
||||
(get_global $~lib/internal/allocator/MAX_SIZE_32)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
(set_local $1
|
||||
(get_global $~lib/allocator/arena/offset)
|
||||
)
|
||||
(set_local $4
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.add
|
||||
(get_local $1)
|
||||
(select
|
||||
(tee_local $2
|
||||
(get_local $0)
|
||||
)
|
||||
(get_global $~lib/internal/allocator/AL_MASK)
|
||||
)
|
||||
(i32.xor
|
||||
(get_global $~lib/internal/allocator/AL_MASK)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(current_memory)
|
||||
)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
(i32.shl
|
||||
(get_local $3)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $4
|
||||
(i32.shr_u
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(get_local $2)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 65535)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.const 65535)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
(tee_local $3
|
||||
(i32.const 1)
|
||||
)
|
||||
)
|
||||
(set_local $5
|
||||
(select
|
||||
(tee_local $5
|
||||
(get_local $3)
|
||||
)
|
||||
(tee_local $6
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $5)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(get_local $5)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(get_local $4)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
(i32.gt_u
|
||||
(get_local $2)
|
||||
(get_local $3)
|
||||
)
|
||||
)
|
||||
)
|
||||
(get_global $~lib/internal/allocator/AL_MASK)
|
||||
)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_local $2)
|
||||
)
|
||||
(return
|
||||
(get_local $1)
|
||||
(i32.xor
|
||||
(get_global $~lib/internal/allocator/AL_MASK)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
)
|
||||
(i32.const 0)
|
||||
(set_local $5
|
||||
(current_memory)
|
||||
)
|
||||
(if
|
||||
(i32.gt_u
|
||||
(get_local $4)
|
||||
(i32.shl
|
||||
(get_local $5)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(block
|
||||
(set_local $2
|
||||
(i32.shr_u
|
||||
(i32.and
|
||||
(i32.add
|
||||
(i32.sub
|
||||
(get_local $4)
|
||||
(get_local $1)
|
||||
)
|
||||
(i32.const 65535)
|
||||
)
|
||||
(i32.xor
|
||||
(i32.const 65535)
|
||||
(i32.const -1)
|
||||
)
|
||||
)
|
||||
(i32.const 16)
|
||||
)
|
||||
)
|
||||
(set_local $3
|
||||
(select
|
||||
(tee_local $3
|
||||
(get_local $5)
|
||||
)
|
||||
(tee_local $6
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.gt_s
|
||||
(get_local $3)
|
||||
(get_local $6)
|
||||
)
|
||||
)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(get_local $3)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(if
|
||||
(i32.lt_s
|
||||
(grow_memory
|
||||
(get_local $2)
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(unreachable)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(set_global $~lib/allocator/arena/offset
|
||||
(get_local $4)
|
||||
)
|
||||
(get_local $1)
|
||||
)
|
||||
(func $~lib/collector/itcm/ManagedObjectList#clear (; 3 ;) (type $iv) (param $0 i32)
|
||||
(i32.store
|
||||
@ -583,7 +586,18 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/collector/itcm/__gc_collect (; 15 ;) (type $v)
|
||||
(func $~lib/string/String~gc (; 15 ;) (type $iv) (param $0 i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_local $0)
|
||||
)
|
||||
(return)
|
||||
)
|
||||
(call $~lib/collector/itcm/__gc_mark
|
||||
(get_local $0)
|
||||
)
|
||||
)
|
||||
(func $~lib/collector/itcm/__gc_collect (; 16 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(block $break|0
|
||||
(block $case1|0
|
||||
@ -623,11 +637,11 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(func $~lib/gc/gc.collect (; 16 ;) (type $v)
|
||||
(func $~lib/gc/gc.collect (; 17 ;) (type $v)
|
||||
(call $~lib/collector/itcm/__gc_collect)
|
||||
(return)
|
||||
)
|
||||
(func $std/gc-basics/main (; 17 ;) (type $i) (result i32)
|
||||
(func $std/gc-basics/main (; 18 ;) (type $i) (result i32)
|
||||
(if
|
||||
(i32.eqz
|
||||
(get_global $~started)
|
||||
@ -641,7 +655,7 @@
|
||||
)
|
||||
(i32.const 0)
|
||||
)
|
||||
(func $start (; 18 ;) (type $v)
|
||||
(func $start (; 19 ;) (type $v)
|
||||
(local $0 i32)
|
||||
(local $1 i32)
|
||||
(local $2 i32)
|
||||
@ -749,7 +763,7 @@
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 24)
|
||||
(i32.const 21)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -771,7 +785,7 @@
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 24)
|
||||
(i32.const 23)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -793,7 +807,7 @@
|
||||
(block
|
||||
(call $~lib/env/abort
|
||||
(i32.const 0)
|
||||
(i32.const 8)
|
||||
(i32.const 24)
|
||||
(i32.const 25)
|
||||
(i32.const 2)
|
||||
)
|
||||
@ -807,7 +821,7 @@
|
||||
)
|
||||
(call $~lib/gc/gc.collect)
|
||||
)
|
||||
(func $~iterateRoots (; 19 ;) (type $iv) (param $0 i32)
|
||||
(func $~iterateRoots (; 20 ;) (type $iv) (param $0 i32)
|
||||
(call_indirect (type $iv)
|
||||
(get_global $std/gc-basics/obj)
|
||||
(get_local $0)
|
||||
|
Reference in New Issue
Block a user