Murdered all the spaces
This commit is contained in:
@@ -30,16 +30,16 @@ gc_alloc:
|
|||||||
pop rdi
|
pop rdi
|
||||||
.collect_end:
|
.collect_end:
|
||||||
add [total_alloc_b], rdi ; update total allocated bytes
|
add [total_alloc_b], rdi ; update total allocated bytes
|
||||||
inc qword [total_alloc_c] ; update total allocation count
|
inc qword [total_alloc_c] ; update total allocation count
|
||||||
push rdi
|
push rdi
|
||||||
call sys_mmap ; allocate size + metadata
|
call sys_mmap ; allocate size + metadata
|
||||||
pop rdi
|
pop rdi
|
||||||
mov byte [rax], 0 ; set mark to 0
|
mov byte [rax], 0 ; set mark to 0
|
||||||
mov qword [rax + 1], rdi ; set total size of object (including metadata)
|
mov qword [rax + 1], rdi ; set total size of object (including metadata)
|
||||||
mov rsi, [alloc_list] ; load first item in allocation list
|
mov rsi, [alloc_list] ; load first item in allocation list
|
||||||
mov qword [rax + 9], rsi ; make current head of allocation list the next item in this object
|
mov qword [rax + 9], rsi ; make current head of allocation list the next item in this object
|
||||||
mov [alloc_list], rax ; update head of allocation list so it points to this object
|
mov [alloc_list], rax ; update head of allocation list so it points to this object
|
||||||
add rax, 17 ; skip metadata for return value
|
add rax, 17 ; skip metadata for return value
|
||||||
ret
|
ret
|
||||||
|
|
||||||
gc_collect:
|
gc_collect:
|
||||||
@@ -116,7 +116,7 @@ gc_sweep:
|
|||||||
mov [rsi + 9], rdx ; unlink the current node by setting the previous node's next to the next node's address
|
mov [rsi + 9], rdx ; unlink the current node by setting the previous node's next to the next node's address
|
||||||
jmp .free_memory
|
jmp .free_memory
|
||||||
.remove_head:
|
.remove_head:
|
||||||
mov [alloc_list], rdx ; update head node to be the next node
|
mov [alloc_list], rdx ; update head node to be the next node
|
||||||
.free_memory:
|
.free_memory:
|
||||||
push rsi ; save previous node since it will also be the previous node for the next item
|
push rsi ; save previous node since it will also be the previous node for the next item
|
||||||
push rdx ; save next node
|
push rdx ; save next node
|
||||||
|
|||||||
Reference in New Issue
Block a user