Skip to content

Commit 4ccda0b

Browse files
authored
feat: Make use of initial memory when initializing incremental GC (#1692)
1 parent 369c6fc commit 4ccda0b

File tree

134 files changed

+2820
-1124
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+2820
-1124
lines changed

src/asconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"options": {
77
"explicitStart": true,
88
"exportRuntime": true,
9-
"initialMemory": 256,
9+
"initialMemory": 768,
1010
"runtime": "incremental",
1111
"measure": true
1212
},

std/assembly/rt/itcms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,9 @@ export function __collect(): void {
389389
// @ts-ignore: decorator
390390
@inline const IDLEFACTOR: usize = isDefined(ASC_GC_IDLEFACTOR) ? ASC_GC_IDLEFACTOR : 200;
391391

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

396396
/** Performs a reasonable amount of incremental GC steps. */
397397
function interrupt(): void {

tests/compiler/call-super.optimized.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
(data (i32.const 1488) "\0d\00\00\00 \00\00\00\00\00\00\00 ")
2525
(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 ")
2626
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
27-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
27+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
2828
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
2929
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
3030
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -2200,6 +2200,14 @@
22002200
)
22012201
(func $~start
22022202
(local $0 i32)
2203+
memory.size
2204+
i32.const 16
2205+
i32.shl
2206+
i32.const 17980
2207+
i32.sub
2208+
i32.const 1
2209+
i32.shr_u
2210+
global.set $~lib/rt/itcms/threshold
22032211
i32.const 1216
22042212
call $~lib/rt/itcms/initLazy
22052213
global.set $~lib/rt/itcms/pinSpace

tests/compiler/call-super.untouched.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(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")
2323
(table $0 1 funcref)
2424
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
25-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
25+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
2626
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
2727
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
2828
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -2633,6 +2633,14 @@
26332633
global.set $~lib/memory/__stack_pointer
26342634
)
26352635
(func $start:call-super
2636+
memory.size
2637+
i32.const 16
2638+
i32.shl
2639+
global.get $~lib/memory/__heap_base
2640+
i32.sub
2641+
i32.const 1
2642+
i32.shr_u
2643+
global.set $~lib/rt/itcms/threshold
26362644
i32.const 192
26372645
call $~lib/rt/itcms/initLazy
26382646
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class-implements.optimized.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
(data (i32.const 1504) "\07\00\00\00 \00\00\00\00\00\00\00 ")
2424
(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 ")
2525
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
26-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
26+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
2727
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
2828
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
2929
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -1483,6 +1483,14 @@
14831483
global.get $~lib/memory/__stack_pointer
14841484
i32.const 0
14851485
i32.store
1486+
memory.size
1487+
i32.const 16
1488+
i32.shl
1489+
i32.const 17948
1490+
i32.sub
1491+
i32.const 1
1492+
i32.shr_u
1493+
global.set $~lib/rt/itcms/threshold
14861494
i32.const 1168
14871495
call $~lib/rt/itcms/initLazy
14881496
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class-implements.untouched.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(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")
2323
(table $0 1 funcref)
2424
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
25-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
25+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
2626
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
2727
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
2828
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -2500,6 +2500,14 @@
25002500
global.get $~lib/memory/__stack_pointer
25012501
i32.const 0
25022502
i32.store
2503+
memory.size
2504+
i32.const 16
2505+
i32.shl
2506+
global.get $~lib/memory/__heap_base
2507+
i32.sub
2508+
i32.const 1
2509+
i32.shr_u
2510+
global.set $~lib/rt/itcms/threshold
25032511
i32.const 144
25042512
call $~lib/rt/itcms/initLazy
25052513
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class-overloading.optimized.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
(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 ")
4242
(global $class-overloading/which (mut i32) (i32.const 1056))
4343
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
44-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
44+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
4545
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
4646
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
4747
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -2090,6 +2090,14 @@
20902090
global.get $~lib/memory/__stack_pointer
20912091
i64.const 0
20922092
i64.store
2093+
memory.size
2094+
i32.const 16
2095+
i32.shl
2096+
i32.const 18316
2097+
i32.sub
2098+
i32.const 1
2099+
i32.shr_u
2100+
global.set $~lib/rt/itcms/threshold
20932101
i32.const 1200
20942102
call $~lib/rt/itcms/initLazy
20952103
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class-overloading.untouched.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
(table $0 1 funcref)
3333
(global $class-overloading/which (mut i32) (i32.const 32))
3434
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
35-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
35+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
3636
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
3737
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
3838
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -3383,6 +3383,14 @@
33833383
global.get $~lib/memory/__stack_pointer
33843384
i64.const 0
33853385
i64.store
3386+
memory.size
3387+
i32.const 16
3388+
i32.shl
3389+
global.get $~lib/memory/__heap_base
3390+
i32.sub
3391+
i32.const 1
3392+
i32.shr_u
3393+
global.set $~lib/rt/itcms/threshold
33863394
i32.const 176
33873395
call $~lib/rt/itcms/initLazy
33883396
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class.optimized.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
(data (i32.const 1564) " ")
2828
(data (i32.const 1580) "\02\t")
2929
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
30-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
30+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
3131
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
3232
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
3333
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -1900,6 +1900,14 @@
19001900
end
19011901
)
19021902
(func $~start
1903+
memory.size
1904+
i32.const 16
1905+
i32.shl
1906+
i32.const 17972
1907+
i32.sub
1908+
i32.const 1
1909+
i32.shr_u
1910+
global.set $~lib/rt/itcms/threshold
19031911
i32.const 1168
19041912
call $~lib/rt/itcms/initLazy
19051913
global.set $~lib/rt/itcms/pinSpace

tests/compiler/class.untouched.wat

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
(table $0 1 funcref)
2727
(global $class/Animal.ONE (mut i32) (i32.const 1))
2828
(global $~lib/rt/itcms/total (mut i32) (i32.const 0))
29-
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 1024))
29+
(global $~lib/rt/itcms/threshold (mut i32) (i32.const 0))
3030
(global $~lib/rt/itcms/state (mut i32) (i32.const 0))
3131
(global $~lib/rt/itcms/visitCount (mut i32) (i32.const 0))
3232
(global $~lib/rt/itcms/pinSpace (mut i32) (i32.const 0))
@@ -2611,6 +2611,14 @@
26112611
)
26122612
(func $~start
26132613
call $start:class
2614+
memory.size
2615+
i32.const 16
2616+
i32.shl
2617+
global.get $~lib/memory/__heap_base
2618+
i32.sub
2619+
i32.const 1
2620+
i32.shr_u
2621+
global.set $~lib/rt/itcms/threshold
26142622
i32.const 144
26152623
call $~lib/rt/itcms/initLazy
26162624
global.set $~lib/rt/itcms/pinSpace

0 commit comments

Comments
 (0)