This commit is contained in:
parent
734e8c2824
commit
2b15484f33
1
mu.arc
1
mu.arc
|
@ -29,6 +29,7 @@
|
||||||
integer-boolean-pair-array (obj array t elem 'integer-boolean-pair)
|
integer-boolean-pair-array (obj array t elem 'integer-boolean-pair)
|
||||||
integer-integer-pair (obj size 2 record t elems '(integer integer))
|
integer-integer-pair (obj size 2 record t elems '(integer integer))
|
||||||
integer-point-pair (obj size 2 record t elems '(integer integer-integer-pair))
|
integer-point-pair (obj size 2 record t elems '(integer integer-integer-pair))
|
||||||
|
custodian (obj size 1 record t elems '(integer))
|
||||||
))
|
))
|
||||||
(= memory* (table))
|
(= memory* (table))
|
||||||
(= function* (table)))
|
(= function* (table)))
|
||||||
|
|
29
new.arc
29
new.arc
|
@ -1,14 +1,29 @@
|
||||||
;; simple slab allocator. Intended only to carve out isolated memory for
|
; Memory management primitive.
|
||||||
;; different threads/routines as they request.
|
|
||||||
|
|
||||||
(= Allocator_start 1000) ; lower locations reserved
|
(= Allocator_start 1000) ; lower locations reserved
|
||||||
|
|
||||||
|
; memory map: 0-2 for convenience numbers
|
||||||
|
; for these, address == value always; never modify them
|
||||||
|
(= Zero 0)
|
||||||
|
(= One 1)
|
||||||
|
(= Two 2)
|
||||||
|
; memory map: 3 for root custodian (size 1)
|
||||||
|
; 'new' will allocate from custodians. Custodians will be arranged in trees,
|
||||||
|
; each node knowing its parent. The root custodian controls all memory
|
||||||
|
; allocations. And it's located at..
|
||||||
|
(= Root_custodian 3)
|
||||||
|
|
||||||
(enq (fn ()
|
(enq (fn ()
|
||||||
(run `(((Root_allocator_pointer location) <- literal ,Allocator_start))))
|
(run `(((,Zero integer) <- literal 0)
|
||||||
|
((,One integer) <- literal 1)
|
||||||
|
((,Two integer) <- literal 2)
|
||||||
|
((,Root_custodian location) <- literal ,Allocator_start))))
|
||||||
initialization-fns*)
|
initialization-fns*)
|
||||||
|
|
||||||
|
;; simple slab allocator. Intended only to carve out isolated memory for
|
||||||
|
;; different threads/routines as they request.
|
||||||
|
; memory map: 4-5 locals for slab allocator
|
||||||
(init-fn new
|
(init-fn new
|
||||||
((2 integer-address) <- copy (Root_allocator_pointer integer))
|
((4 integer-address) <- copy (3 location))
|
||||||
((3 integer) <- literal 1)
|
((3 location) <- add (3 location) (1 integer))
|
||||||
((Root_allocator_pointer integer) <- add (Root_allocator_pointer integer) (3 integer))
|
(reply (4 integer-address)))
|
||||||
(reply (2 integer-address)))
|
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
(load "new.arc")
|
(load "new.arc")
|
||||||
|
|
||||||
(reset)
|
(reset)
|
||||||
(add-fns
|
;? (prn memory*)
|
||||||
'((main)))
|
(if (~iso memory*.Root_custodian Allocator_start)
|
||||||
(run function*!main)
|
|
||||||
(if (~iso memory*!Root_allocator_pointer Allocator_start)
|
|
||||||
(prn "F - allocator initialized"))
|
(prn "F - allocator initialized"))
|
||||||
|
|
||||||
(reset)
|
(reset)
|
||||||
|
@ -15,7 +13,7 @@
|
||||||
((x integer-address deref) <- literal 34))))
|
((x integer-address deref) <- literal 34))))
|
||||||
(run function*!main)
|
(run function*!main)
|
||||||
;? (prn memory*)
|
;? (prn memory*)
|
||||||
(if (~iso memory*!Root_allocator_pointer (+ Allocator_start 1))
|
(if (~iso memory*.Root_custodian (+ Allocator_start 1))
|
||||||
(prn "F - 'new' increments allocator pointer"))
|
(prn "F - 'new' increments allocator pointer"))
|
||||||
(if (~iso memory*.Allocator_start 34)
|
(if (~iso memory*.Allocator_start 34)
|
||||||
(prn "F - 'new' returns old location"))
|
(prn "F - 'new' returns old location"))
|
||||||
|
|
Loading…
Reference in New Issue