about summary refs log tree commit diff stats
path: root/new.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-08-22 10:47:44 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-08-22 10:47:44 -0700
commit2b15484f33c76451fae70b54e64c5bfb7468bf99 (patch)
tree6fe6fc826976ee9ddec16d4068bc55481197a57c /new.arc
parent734e8c28241e95f7425a18d8791b35ff5e98f7db (diff)
downloadmu-2b15484f33c76451fae70b54e64c5bfb7468bf99.tar.gz
70
Diffstat (limited to 'new.arc')
-rw-r--r--new.arc29
1 files changed, 22 insertions, 7 deletions
diff --git a/new.arc b/new.arc
index 88a41263..1a31712c 100644
--- a/new.arc
+++ b/new.arc
@@ -1,14 +1,29 @@
-;; simple slab allocator. Intended only to carve out isolated memory for
-;; different threads/routines as they request.
+; 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 `(((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*)
 
+;; 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
-  ((2 integer-address) <- copy (Root_allocator_pointer integer))
-  ((3 integer) <- literal 1)
-  ((Root_allocator_pointer integer) <- add (Root_allocator_pointer integer) (3 integer))
-  (reply (2 integer-address)))
+  ((4 integer-address) <- copy (3 location))
+  ((3 location) <- add (3 location) (1 integer))
+  (reply (4 integer-address)))