diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-11-01 13:57:52 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-11-01 13:57:52 -0700 |
commit | 6cba4dbe70c4fc8850092c4aafe058b4f3d827c7 (patch) | |
tree | dc38416b23f76f2ed50ee4d679df15d59e9c133e | |
parent | 41cfcf7d4e86dd42633f654f475cc0d21272464b (diff) | |
download | mu-6cba4dbe70c4fc8850092c4aafe058b4f3d827c7.tar.gz |
208
-rw-r--r-- | mu.arc.t | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/mu.arc.t b/mu.arc.t index aeacfa9e..c98731e7 100644 --- a/mu.arc.t +++ b/mu.arc.t @@ -1279,6 +1279,48 @@ ((nil integer) <- add (1 integer) (2 integer)))) (prn "F - convert-names never renames nil")) +; A rudimentary memory allocator. Eventually we want to write this in mu. + +(reset) +(new-trace "new-primitive") +(add-fns + '((main + ((1 integer-address) <- new (integer literal))))) +(let before Memory-in-use-until + (run 'main) +;? (prn memory*) + (if (~iso memory*.1 before) + (prn "F - 'new' returns current high-water mark")) + (if (~iso Memory-in-use-until (+ before 1)) + (prn "F - 'new' on primitive types increments high-water mark by their size"))) + +(reset) +(new-trace "new-array-literal") +(add-fns + '((main + ((1 type-array-address) <- new (type-array literal) (5 literal))))) +(let before Memory-in-use-until + (run 'main) +;? (prn memory*) + (if (~iso memory*.1 before) + (prn "F - 'new' on array with literal size returns current high-water mark")) + (if (~iso Memory-in-use-until (+ before 6)) + (prn "F - 'new' on primitive arrays increments high-water mark by their size"))) + +(reset) +(new-trace "new-array-direct") +(add-fns + '((main + ((1 integer) <- copy (5 literal)) + ((2 type-array-address) <- new (type-array literal) (1 integer))))) +(let before Memory-in-use-until + (run 'main) +;? (prn memory*) + (if (~iso memory*.2 before) + (prn "F - 'new' on array with variable size returns current high-water mark")) + (if (~iso Memory-in-use-until (+ before 6)) + (prn "F - 'new' on primitive arrays increments high-water mark by their (variable) size"))) + (reset) (new-trace "set-default-scope") (add-fns @@ -1494,48 +1536,6 @@ (if (~and (is memory*.3 t) (is memory*.12 37)) (prn "F - different calls can exercise different clauses of the same function")) -; A rudimentary memory allocator. Eventually we want to write this in mu. - -(reset) -(new-trace "new-primitive") -(add-fns - '((main - ((1 integer-address) <- new (integer literal))))) -(let before Memory-in-use-until - (run 'main) -;? (prn memory*) - (if (~iso memory*.1 before) - (prn "F - 'new' returns current high-water mark")) - (if (~iso Memory-in-use-until (+ before 1)) - (prn "F - 'new' on primitive types increments high-water mark by their size"))) - -(reset) -(new-trace "new-array-literal") -(add-fns - '((main - ((1 type-array-address) <- new (type-array literal) (5 literal))))) -(let before Memory-in-use-until - (run 'main) -;? (prn memory*) - (if (~iso memory*.1 before) - (prn "F - 'new' on array with literal size returns current high-water mark")) - (if (~iso Memory-in-use-until (+ before 6)) - (prn "F - 'new' on primitive arrays increments high-water mark by their size"))) - -(reset) -(new-trace "new-array-direct") -(add-fns - '((main - ((1 integer) <- copy (5 literal)) - ((2 type-array-address) <- new (type-array literal) (1 integer))))) -(let before Memory-in-use-until - (run 'main) -;? (prn memory*) - (if (~iso memory*.2 before) - (prn "F - 'new' on array with variable size returns current high-water mark")) - (if (~iso Memory-in-use-until (+ before 6)) - (prn "F - 'new' on primitive arrays increments high-water mark by their (variable) size"))) - ; A rudimentary process scheduler. You can 'run' multiple functions at once, ; and they share the virtual processor. ; There's also a 'fork' primitive to let functions create new threads of |