From ad9e48b34b8b83c9eb196c6608de145c7960854c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 23 Aug 2014 10:17:33 -0700 Subject: 73 --- new.arc | 47 ----------------------------------------------- new.arc.t | 23 ----------------------- sys.arc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ sys.arc.t | 23 +++++++++++++++++++++++ 4 files changed, 70 insertions(+), 70 deletions(-) delete mode 100644 new.arc delete mode 100644 new.arc.t create mode 100644 sys.arc create mode 100644 sys.arc.t diff --git a/new.arc b/new.arc deleted file mode 100644 index d78ea925..00000000 --- a/new.arc +++ /dev/null @@ -1,47 +0,0 @@ -(load "mu.arc") - -; memory map: 0-2 for convenience numbers -; for these, address == value always; never modify them -(= Zero 0) -(= One 1) -(= Two 2) - -(enq (fn () - (run `(((,Zero integer) <- literal 0) - ((,One integer) <- literal 1) - ((,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*) - -; (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)) - ((3 location) <- add (3 location) (1 integer)) - (reply (4 integer-address))) diff --git a/new.arc.t b/new.arc.t deleted file mode 100644 index 3a5d0acf..00000000 --- a/new.arc.t +++ /dev/null @@ -1,23 +0,0 @@ -(load "new.arc") - -(reset) -;? (prn memory*) -(if (~iso memory*.Root_custodian Allocator_start) - (prn "F - allocator initialized")) - -(reset) -(add-fns - '((main - ((x integer-address) <- new) - ((x integer-address deref) <- literal 34)))) -(run function*!main) -;? (prn memory*) -(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")) - -; other tests to express: -; no other function can increment the pointer -; no later clause can increment the pointer after this base clause -; multiple threads/routines can't call the allocator at once diff --git a/sys.arc b/sys.arc new file mode 100644 index 00000000..d78ea925 --- /dev/null +++ b/sys.arc @@ -0,0 +1,47 @@ +(load "mu.arc") + +; memory map: 0-2 for convenience numbers +; for these, address == value always; never modify them +(= Zero 0) +(= One 1) +(= Two 2) + +(enq (fn () + (run `(((,Zero integer) <- literal 0) + ((,One integer) <- literal 1) + ((,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*) + +; (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)) + ((3 location) <- add (3 location) (1 integer)) + (reply (4 integer-address))) diff --git a/sys.arc.t b/sys.arc.t new file mode 100644 index 00000000..3a5d0acf --- /dev/null +++ b/sys.arc.t @@ -0,0 +1,23 @@ +(load "new.arc") + +(reset) +;? (prn memory*) +(if (~iso memory*.Root_custodian Allocator_start) + (prn "F - allocator initialized")) + +(reset) +(add-fns + '((main + ((x integer-address) <- new) + ((x integer-address deref) <- literal 34)))) +(run function*!main) +;? (prn memory*) +(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")) + +; other tests to express: +; no other function can increment the pointer +; no later clause can increment the pointer after this base clause +; multiple threads/routines can't call the allocator at once -- cgit 1.4.1-2-gfad0