Skip to content

Make use of initial memory when initializing the incremental GC #1692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/asconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"options": {
"explicitStart": true,
"exportRuntime": true,
"initialMemory": 256,
"initialMemory": 768,
"runtime": "incremental",
"measure": true
},
Expand Down
4 changes: 2 additions & 2 deletions std/assembly/rt/itcms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ export function __collect(): void {
// @ts-ignore: decorator
@inline const IDLEFACTOR: usize = isDefined(ASC_GC_IDLEFACTOR) ? ASC_GC_IDLEFACTOR : 200;

/** Threshold of objects for the next scheduled GC step. */
/** Threshold of memory used by objects to exceed before interrupting again. */
// @ts-ignore: decorator
@lazy var threshold: usize = GRANULARITY;
@lazy var threshold: usize = ((<usize>memory.size() << 16) - __heap_base) >> 1;

/** Performs a reasonable amount of incremental GC steps. */
function interrupt(): void {
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/call-super.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
(data (i32.const 1488) "\0d\00\00\00 \00\00\00\00\00\00\00 ")
(data (i32.const 1516) " \00\00\00\04\00\00\00 \00\00\00\00\00\00\00 \00\00\00\06\00\00\00 \00\00\00\00\00\00\00 \00\00\00\08\00\00\00 \00\00\00\00\00\00\00 \00\00\00\n\00\00\00 \00\00\00\00\00\00\00 \00\00\00\0c\00\00\00 ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2200,6 +2200,14 @@
)
(func $~start
(local $0 i32)
memory.size
i32.const 16
i32.shl
i32.const 17980
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1216
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/call-super.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(data (i32.const 464) "\0d\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 \00\00\00\04\00\00\00 \00\00\00\00\00\00\00 \00\00\00\06\00\00\00 \00\00\00\00\00\00\00 \00\00\00\08\00\00\00 \00\00\00\00\00\00\00 \00\00\00\n\00\00\00 \00\00\00\00\00\00\00 \00\00\00\0c\00\00\00 \00\00\00\00\00\00\00")
(table $0 1 funcref)
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2633,6 +2633,14 @@
global.set $~lib/memory/__stack_pointer
)
(func $start:call-super
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 192
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class-implements.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(data (i32.const 1504) "\07\00\00\00 \00\00\00\00\00\00\00 ")
(data (i32.const 1532) " \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\06\00\00\00 ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1483,6 +1483,14 @@
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store
memory.size
i32.const 16
i32.shl
i32.const 17948
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1168
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class-implements.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(data (i32.const 480) "\07\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\06\00\00\00 \00\00\00\00\00\00\00")
(table $0 1 funcref)
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2500,6 +2500,14 @@
global.get $~lib/memory/__stack_pointer
i32.const 0
i32.store
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 144
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class-overloading.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
(data (i32.const 1820) " \00\00\00\00\00\00\00 \00\00\00\03\00\00\00 \00\00\00\04\00\00\00 \00\00\00\04\00\00\00 \00\00\00\06\00\00\00 \00\00\00\07\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\t\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\0d\00\00\00 \00\00\00\10\00\00\00 ")
(global $class-overloading/which (mut i32) (i32.const 1056))
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2090,6 +2090,14 @@
global.get $~lib/memory/__stack_pointer
i64.const 0
i64.store
memory.size
i32.const 16
i32.shl
i32.const 18316
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1200
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class-overloading.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
(table $0 1 funcref)
(global $class-overloading/which (mut i32) (i32.const 32))
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -3383,6 +3383,14 @@
global.get $~lib/memory/__stack_pointer
i64.const 0
i64.store
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 176
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
(data (i32.const 1564) " ")
(data (i32.const 1580) "\02\t")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1900,6 +1900,14 @@
end
)
(func $~start
memory.size
i32.const 16
i32.shl
i32.const 17972
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1168
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/class.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
(table $0 1 funcref)
(global $class/Animal.ONE (mut i32) (i32.const 1))
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2611,6 +2611,14 @@
)
(func $~start
call $start:class
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 144
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/constructor.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(data (i32.const 1440) "\0d\00\00\00 \00\00\00\00\00\00\00 ")
(data (i32.const 1468) " \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1792,6 +1792,14 @@
)
(func $start:constructor
(local $0 i32)
memory.size
i32.const 16
i32.shl
i32.const 17932
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1168
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/constructor.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(data (i32.const 416) "\0d\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00")
(table $0 1 funcref)
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2391,6 +2391,14 @@
i32.const 0
)
(func $start:constructor
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 144
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/do.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(data (i32.const 1472) "\04\00\00\00 \00\00\00\00\00\00\00 ")
(data (i32.const 1500) " ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1587,6 +1587,14 @@
call $~lib/builtins/abort
unreachable
end
memory.size
i32.const 16
i32.shl
i32.const 17892
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1200
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/do.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(table $0 1 funcref)
(global $do/ran (mut i32) (i32.const 0))
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -3095,6 +3095,14 @@
end
i32.const 0
global.set $do/ran
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 176
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/empty-exportruntime.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
(data (i32.const 1512) "\01\00\00\00(\00\00\00O\00b\00j\00e\00c\00t\00 \00i\00s\00 \00n\00o\00t\00 \00p\00i\00n\00n\00e\00d")
(data (i32.const 1568) "\03\00\00\00 \00\00\00\00\00\00\00 ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1870,6 +1870,14 @@
unreachable
)
(func $~start
memory.size
i32.const 16
i32.shl
i32.const 17980
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1168
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/empty-exportruntime.untouched.wat
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
(data (i32.const 544) "\03\00\00\00 \00\00\00\00\00\00\00 \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00")
(table $0 1 funcref)
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -2529,6 +2529,14 @@
unreachable
)
(func $~start
memory.size
i32.const 16
i32.shl
global.get $~lib/memory/__heap_base
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 144
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
10 changes: 9 additions & 1 deletion tests/compiler/empty-new.optimized.wat
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
(data (i32.const 1384) "\01\00\00\00\1e\00\00\00~\00l\00i\00b\00/\00r\00t\00/\00t\00l\00s\00f\00.\00t\00s")
(data (i32.const 1440) "\03\00\00\00 \00\00\00\00\00\00\00 ")
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
Expand Down Expand Up @@ -1362,6 +1362,14 @@
)
(func $~start
(local $0 i32)
memory.size
i32.const 16
i32.shl
i32.const 17852
i32.sub
i32.const 1
i32.shr_u
global.set $~lib/rt/itcms/threshold
i32.const 1168
call $~lib/rt/itcms/initLazy
global.set $~lib/rt/itcms/pinSpace
Expand Down
Loading