diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-08-22 10:47:44 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-08-22 10:47:44 -0700 |
commit | 2b15484f33c76451fae70b54e64c5bfb7468bf99 (patch) | |
tree | 6fe6fc826976ee9ddec16d4068bc55481197a57c | |
parent | 734e8c28241e95f7425a18d8791b35ff5e98f7db (diff) | |
download | mu-2b15484f33c76451fae70b54e64c5bfb7468bf99.tar.gz |
70
-rw-r--r-- | mu.arc | 1 | ||||
-rw-r--r-- | new.arc | 29 | ||||
-rw-r--r-- | new.arc.t | 8 |
3 files changed, 26 insertions, 12 deletions
diff --git a/mu.arc b/mu.arc index 8658c7fb..a0cfcb76 100644 --- a/mu.arc +++ b/mu.arc @@ -29,6 +29,7 @@ integer-boolean-pair-array (obj array t elem 'integer-boolean-pair) integer-integer-pair (obj size 2 record t elems '(integer integer)) integer-point-pair (obj size 2 record t elems '(integer integer-integer-pair)) + custodian (obj size 1 record t elems '(integer)) )) (= memory* (table)) (= function* (table))) 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))) diff --git a/new.arc.t b/new.arc.t index 5266ea2d..8cb4bb41 100644 --- a/new.arc.t +++ b/new.arc.t @@ -2,10 +2,8 @@ (load "new.arc") (reset) -(add-fns - '((main))) -(run function*!main) -(if (~iso memory*!Root_allocator_pointer Allocator_start) +;? (prn memory*) +(if (~iso memory*.Root_custodian Allocator_start) (prn "F - allocator initialized")) (reset) @@ -15,7 +13,7 @@ ((x integer-address deref) <- literal 34)))) (run function*!main) ;? (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")) (if (~iso memory*.Allocator_start 34) (prn "F - 'new' returns old location")) |