about summary refs log tree commit diff stats
path: root/new.arc
blob: 1a31712cb31fb530c53364a3f72d21396b874ff8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
; Memory management primitive.

(= 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 ()
       (run `(((,Zero integer) <- literal 0)
              ((,One integer) <- literal 1)
              ((,Two integer) <- literal 2)
              ((,Root_custodian location) <- literal ,Allocator_start))))
     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
  ((4 integer-address) <- copy (3 location))
  ((3 location) <- add (3 location) (1 integer))
  (reply (4 integer-address)))