WIP runtime more. How do I mark primitives+broken hearts?
This commit is contained in:
parent
6ae13b1c86
commit
f91fa39aef
@ -3,9 +3,9 @@
|
|||||||
;; These need to be initialized with the runtime
|
;; These need to be initialized with the runtime
|
||||||
(variable scan 0)
|
(variable scan 0)
|
||||||
(variable free 0)
|
(variable free 0)
|
||||||
(variable root 0)
|
|
||||||
(variable old 0)
|
(variable old 0)
|
||||||
(variable new 0)
|
(variable new 0)
|
||||||
|
(variable root 0)
|
||||||
|
|
||||||
(push main)
|
(push main)
|
||||||
(jmp)
|
(jmp)
|
||||||
@ -36,21 +36,81 @@ alloc-do-gc
|
|||||||
(push alloc)
|
(push alloc)
|
||||||
(jmp)
|
(jmp)
|
||||||
|
|
||||||
gc-start ;; ( -- )
|
gc-run ;; ( -- )
|
||||||
; Move scan & free to start of new memory
|
; Move scan & free to start of new memory
|
||||||
(ref new)
|
(ref new)
|
||||||
(dup)
|
(dup)
|
||||||
(set! free)
|
(set! free)
|
||||||
(set! scan)
|
(set! scan)
|
||||||
(ref root)
|
(ref root)
|
||||||
(push relocate-object)
|
(push relocate-cons)
|
||||||
(call)
|
(call)
|
||||||
(push gc-loop)
|
(push gc-loop)
|
||||||
(call)
|
(call)
|
||||||
|
; Flip old and new
|
||||||
|
(ref old)
|
||||||
|
(ref new)
|
||||||
|
(set! old)
|
||||||
|
(set! new)
|
||||||
(return)
|
(return)
|
||||||
|
|
||||||
relocate-object ;; (o -- )
|
relocate-cons ;; (o -- )
|
||||||
;; TODO
|
(dup)
|
||||||
|
(@)
|
||||||
|
(push relocate-reg)
|
||||||
|
(call)
|
||||||
|
(push 4)
|
||||||
|
(+)
|
||||||
|
(@)
|
||||||
|
(push relocate-reg)
|
||||||
|
|
||||||
|
relocate-reg ;; (r -- )
|
||||||
|
(dup)
|
||||||
|
(push cons?)
|
||||||
|
(call)
|
||||||
|
(push reg-relocated)
|
||||||
|
(if)
|
||||||
|
(dup)
|
||||||
|
(push eol?)
|
||||||
|
(call)
|
||||||
|
(not)
|
||||||
|
(push reg-relocated)
|
||||||
|
(if)
|
||||||
|
(dup)
|
||||||
|
(push broken-heart?)
|
||||||
|
(call)
|
||||||
|
(push copy-and-construct)
|
||||||
|
(if)
|
||||||
|
(dup) ;; Broken heart, copy updated address from cdr
|
||||||
|
(push 4)
|
||||||
|
(+)
|
||||||
|
(@) ;; Retrieve new address
|
||||||
|
(dup)
|
||||||
|
(!) ;; Write it here
|
||||||
|
(push reg-relocated)
|
||||||
|
(jmp)
|
||||||
|
copy-and-construct
|
||||||
|
(dup) ;; Wasn't a broken heart, move car to new memory
|
||||||
|
(@)
|
||||||
|
(push free)
|
||||||
|
(!)
|
||||||
|
(dup) ;; Push cdr to new memory
|
||||||
|
(push 4)
|
||||||
|
(+)
|
||||||
|
(@)
|
||||||
|
(push free)
|
||||||
|
(push 4)
|
||||||
|
(+)
|
||||||
|
(!)
|
||||||
|
(dup) ;; Construct the broken heart
|
||||||
|
(push install-broken-heart)
|
||||||
|
(call)
|
||||||
|
(ref free) ;; Move free pointer
|
||||||
|
(push 8)
|
||||||
|
(+)
|
||||||
|
(set! free)
|
||||||
|
reg-relocated
|
||||||
|
(drop)
|
||||||
|
(return)
|
||||||
main
|
main
|
||||||
;; TODO
|
;; TODO
|
||||||
|
Loading…
Reference in New Issue
Block a user