diff options
Diffstat (limited to 'include/data.s')
| -rw-r--r-- | include/data.s | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/include/data.s b/include/data.s index 3ee8213..575b4ae 100644 --- a/include/data.s +++ b/include/data.s @@ -1,6 +1,7 @@ .ifndef _data_s_file _data_s_file: + nop # Format of the info tables: # - code @@ -10,18 +11,21 @@ _data_s_file: # - 8B pointer to evacuate # # Evacuate interface: -# in: %rsi continuation, %rbp what to evacuate +# in: %rbp what to evacuate # out: %rbp where the thing is now +# ret: jump to _gc_evacuate_ret # Notes: # - IND thunks skip themselves on evacuate -# - checking if whether stuff is already in write region are managed by _gc_evacuate prelude +# - checking if whether stuff is already in write region are managed by +# _gc_evacuate prelude # # Scavenge interface: -# in: %rsi continuation, %rbp what to scavenge +# in: %rbp what to scavenge # out: %rbp next thing to scavenge in memory +# ret: jump to _gc_scavenge_ret # -# Saved registers by evacuate and scavenge -# - _uskel_gc needs to preserve %rdi now; that might increase +# Saved registers during the GC process: +# - _uskel_gc uses %r8-%r11 # - scavenges use %r12-%r15 # - %rax-%rdx is scratch and evacuate use @@ -31,10 +35,10 @@ INT_evacuate: pushq 010(%rbp) pushq $INT_code mov %rsp,%rbp - jmp *%rsi + jmp _gc_evacuate_ret INT_scavenge: add $020, %rbp - jmp *%rsi + jmp _gc_scavenge_ret INT_info_table: cell INT_evacuate @@ -49,7 +53,9 @@ IND_evacuate: mov 010(%rbp), %rbp jmp _gc_evacuate IND_scavenge: - jmp 0 # thou shalt not scavenge here + # this should never be triggered but let's play it safe + add $020, %rbp + jmp _gc_scavenge_ret IND_info: cell IND_evacuate @@ -69,17 +75,17 @@ LIST_evacuate: pushq $1 pushq $LIST_code mov %rsp, %rbp - jmp *%rsi + jmp _gc_evacuate_ret + LIST_evacuate_nil: pushq $0 pushq $LIST_code mov %rsp, %rbp - jmp *%rsi + jmp _gc_evacuate_ret LIST_scavenge: cmpq $0, 010(%rbp) je LIST_scavenge_nil mov %rbp, %r15 - mov %rsi, %r14 mov $LIST_scavenge1, %rsi mov 020(%r15), %rbp @@ -95,10 +101,11 @@ LIST_scavenge: mov %r15, %rbp add $040, %rbp - jmp *%r14 + jmp _gc_scavenge_ret + LIST_scavenge_nil: add $020, %rbp - jmp *%rsi + jmp _gc_scavenge_ret LIST_info_table: cell LIST_evacuate @@ -160,15 +167,14 @@ FUN4_code: # | ptr | args | arg[0] | arg[1] | ... | arg[args] | # args wouldn't need to be here but let's keep them for gc simplicity THU_evacuate: - mov 010(%rbp), %rbx - mov %rbx,%rdx - mov %rbx,%rcx + mov 010(%rbp), %rbx # rbx = count of arguments + mov %rbx, %rdx + mov %rbx, %rcx # rcx = count of arguments for later looping add $2, %rdx shl $3, %rdx - add %rbp, %rdx + add %rbp, %rdx # rdx = address of the argument THU_evacuate_one: - dec %rcx - cmp $0, %rcx + sub $1, %rcx jl THU_evacuate_fini sub $010, %rdx pushq (%rdx) @@ -177,32 +183,32 @@ THU_evacuate: pushq %rbx pushq 000(%rbp) mov %rsp, %rbp - jmp *%rsi + jmp _gc_evacuate_ret THU_scavenge: - mov 010(%rbp), %r12 - mov %rbp, %r15 - mov %rsi, %r14 - mov %r12,%r13 - add $2, %r13 - shl $3, %r13 - add %r15, %r13 + mov 010(%rbp), %r13 # r13 = count of arguments (for looping) + mov %rbp, %r15 # r15 = scavengee ptr + mov %r13,%r14 + add $2, %r14 + shl $3, %r14 + add %r15, %r14 # r14 = address of argument + THU_scavenge_one: - sub $010, %r13 - sub $1, %r12 + sub $1, %r13 jl THU_scavenge_fini - mov (%r13), %rbp + sub $010, %r14 + mov (%r14), %rbp mov $THU_scavenge_one_cont, %rsi jmp _gc_evacuate THU_scavenge_one_cont: - mov %rbp, (%r13) + mov %rbp, (%r14) jmp THU_scavenge_one THU_scavenge_fini: - mov %r15, %rbp - mov 010(%rbp), %r13 - add $2, %r13 - shl $3, %r13 - add %r13, %rbp - jmp *%r14 + mov %r15, %rbp # restore rbp + mov 010(%rbp), %r14 + add $2, %r14 + shl $3, %r14 # r14 is size of object + add %r14, %rbp # move rbp to next rbp + jmp _gc_scavenge_ret .endif # _data_s_file |
