diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-08-22 11:30:36 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-08-22 11:30:36 -0700 |
commit | 2ee76bda373acdce71f560908e7c15ae7d97b8f8 (patch) | |
tree | 7365e282d38dee1d10023e60f6de3e9515576c47 | |
parent | 1f18a4fd0a44f1e2f7a4b9d6ef0f8e5832c0c069 (diff) | |
download | mu-2ee76bda373acdce71f560908e7c15ae7d97b8f8.tar.gz |
72 - broken
Thoroughly confused about how to manage memory at initialization time, and how to maintain type information in the simulated machine.
-rw-r--r-- | mu.arc | 4 | ||||
-rw-r--r-- | new.arc | 42 | ||||
-rw-r--r-- | new.arc.t | 1 |
3 files changed, 33 insertions, 14 deletions
diff --git a/mu.arc b/mu.arc index f9af4697..242bba63 100644 --- a/mu.arc +++ b/mu.arc @@ -16,7 +16,7 @@ (def clear () (= types* (obj ; must be scalar or array, sum or product or primitive - type (obj size 1) + type (obj size 5 record t elems '(integer boolean boolean boolean type-array)) location (obj size 1) integer (obj size 1) boolean (obj size 1) @@ -155,6 +155,8 @@ (do1 fn-arg-idx ++.fn-arg-idx)) (m fn-args.idx)) + type + (ty (fn-args arg.0)) otype (ty (fn-oargs arg.0)) jmp diff --git a/new.arc b/new.arc index 1a31712c..d78ea925 100644 --- a/new.arc +++ b/new.arc @@ -1,27 +1,45 @@ -; Memory management primitive. - -(= Allocator_start 1000) ; lower locations reserved +(load "mu.arc") ; 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)))) + ((,Two integer) <- literal 2)))) + initialization-fns*) + +; high-water mark for global memory used so far +; just on host, not in simulated memory +(= Memory-used-until 3) +(def static-new (n) + (inc Memory-used-until n)) + +; copy types* info into simulated machine +(= Type-table Memory-used-until) +(enq (fn () + (each (type typeinfo) types* + (prn type " " typeinfo))) + initialization-fns*) + +(reset) + +(init-fn sizeof) ; todo + +;; 'new' - simple slab allocator. Intended only to carve out isolated memory +;; for different threads/routines as they request. +; memory map: 3 for root custodian (size 1) +(= Root_custodian 3) +(= Allocator_start 1000) ; lower locations reserved + +(enq (fn () + (run `(((,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. +; (type-addr val) <- new (custodian x), (type t) ; memory map: 4-5 locals for slab allocator (init-fn new ((4 integer-address) <- copy (3 location)) diff --git a/new.arc.t b/new.arc.t index 8cb4bb41..3a5d0acf 100644 --- a/new.arc.t +++ b/new.arc.t @@ -1,4 +1,3 @@ -(load "mu.arc") (load "new.arc") (reset) |