diff options
Diffstat (limited to 'include/gc.s')
| -rw-r--r-- | include/gc.s | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/include/gc.s b/include/gc.s index 636a6a2..ae71d5c 100644 --- a/include/gc.s +++ b/include/gc.s @@ -74,6 +74,8 @@ _uskel_alloc: cmp %r14, %rax cmova %rax, %r14 + and $0xfffffffffffffff8, %r14 #align + alloc_goes_mmap: mov $9, %rax # mmap mov $0, %rdi # addr = NULL @@ -94,7 +96,7 @@ _uskel_alloc: _uskel_gc_init: mov %rsi, %r13 - movq $0x100, _gc_min_alloc + movq $0x100, _gc_min_alloc # must be higher than 2x the biggest thunk possible movq $0x180, _gc_grow_ratio movq $0x40, _gc_shrink_ratio mov $0, %rsp # fake original rsp for first alloc run @@ -121,7 +123,7 @@ _uskel_gc: # point the writer to the new memory area mov _write_region_end, %rsp - mov %rsp, %rdi # %rdi is "the last scavenged thing" + mov %rsp, %r8 # % r8 is the "last thing that was scavenged" # start by evacuating the thunk and cont mov _gc_backup_thunk, %rbp @@ -139,27 +141,26 @@ _uskel_gc: # scavenge everything _uskel_gc_scavenge: # start at what we wrote last - mov %rsp, %rbp + mov %rsp, %rbp # rbp is the iterator (conveniently) + mov %rsp, %r9 # % r9 stores where we started with this evacuate round # if the thing is already scavenged, we didn't write anything, mark done. - cmp %rbp, %rdi + cmp %rbp, %r8 jbe _uskel_gc_scavenge_end _uskel_gc_scavenge1: # if all ok, scavenge one thing (moving %rbp) and recheck - mov $_uskel_gc_scavenge1_ret, %rsi mov (%rbp), %rax jmp *-020(%rax) # scavenge position in infotable - _uskel_gc_scavenge1_ret: - cmp %rbp, %rdi + _gc_scavenge_ret: + cmp %rbp, %r8 ja _uskel_gc_scavenge1 - # everything above rsp is now scavenged, continue with next round - mov %rsp, %rdi + # everything above r9 is now scavenged, continue with next round + mov %r9, %r8 # we started at r9, so that is now "done" jmp _uskel_gc_scavenge _uskel_gc_scavenge_end: - # deallocate the old memory region mov $11, %rax # munmap mov _gc_region_end, %rsi @@ -188,14 +189,22 @@ _uskel_gc: _gc_evacuate: # check if we are really out of the target region cmp _write_region_start, %rbp - jb _gc_evacuate_ok + jb _gc_evacuate_go cmp _write_region_end, %rbp - jae _gc_evacuate_ok + jae _gc_evacuate_go + _gc_evacuate_skip: # if not, let's just jump to cont and leave %rbp as result jmp *%rsi - _gc_evacuate_ok: + _gc_evacuate_go: # if we should evacuate, jump to the evac routine + mov %rbp, %r10 mov (%rbp), %rax jmp *-030(%rax) + _gc_evacuate_ret: + # install the indirection + movq $IND_code, 000(%r10) + mov %rbp, 010(%r10) + jmp *%rsi + .endif #_gc_s_file |
