about summary refs log tree commit diff stats
path: root/mu.arc.t
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-01-26 02:56:08 -0800
committerKartik K. Agaram <vc@akkartik.com>2015-01-26 02:56:08 -0800
commitab1916bb210ebba36d9bdf2823a4208e7b255f70 (patch)
treee9ff3db314d42357ef21660e3db18460bb486fba /mu.arc.t
parent0d8f88f7c2cd73a0c85d85907d20c0e37e4ea101 (diff)
downloadmu-ab1916bb210ebba36d9bdf2823a4208e7b255f70.tar.gz
629
Diffstat (limited to 'mu.arc.t')
-rw-r--r--mu.arc.t34
1 files changed, 33 insertions, 1 deletions
diff --git a/mu.arc.t b/mu.arc.t
index 51316e1c..efa0bf57 100644
--- a/mu.arc.t
+++ b/mu.arc.t
@@ -1952,7 +1952,39 @@
             (~is rep.routine!alloc 92)
             (~is rep.routine!alloc-max 100)
             (~is Memory-allocated-until 100))
-    (prn "F - 'new' skips allocates a new chunk if insufficient space")))
+    (prn "F - 'new' allocates a new chunk if insufficient space")))
+
+(reset)
+(new-trace "new-array-skip-noncontiguous")
+(add-code
+  '((function main [
+      (1:integer-array-address <- new integer-array:literal 4:literal)
+     ])))
+; start allocating from address 30, in chunks of 10 locations each
+(= Memory-allocated-until 30
+   Allocation-chunk 10)
+(let routine make-routine!main
+  (assert:is rep.routine!alloc 30)
+  (assert:is rep.routine!alloc-max 40)
+  ; pretend the current chunk has just one location left
+  (= rep.routine!alloc 39)
+  ; pretend we allocated more memory since we created the routine
+  (= Memory-allocated-until 90)
+  (enq routine running-routines*)
+  ; request 4 locations
+  (run)
+  (each routine completed-routines*
+    (aif rep.routine!error (prn "error - " it)))
+;?   (prn memory*.1) ;? 1
+;?   (prn rep.routine) ;? 1
+;?   (prn Memory-allocated-until) ;? 1
+  (when (or (~is memory*.1 90)
+            (~is rep.routine!alloc 95)
+            (~is rep.routine!alloc-max 100)
+            (~is Memory-allocated-until 100))
+    (prn "F - 'new-array' allocates a new chunk if insufficient space")))
+
+;? (quit) ;? 1
 
 ; Even though our memory locations can now have names, the names are all
 ; globals, accessible from any function. To isolate functions from their