about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-03-13 09:56:37 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-03-13 09:56:37 -0700
commit7be19db89c27cedae35da0d71fb838cac80f4f04 (patch)
tree75641b01a7d079dcbc5065b03a9e8737402f3326
parent7999ab74006a53ec18c4e475d95aa5a7fffd4ace (diff)
downloadmu-7be19db89c27cedae35da0d71fb838cac80f4f04.tar.gz
898 - experiment: make memory a vector
But racket takes too long to allocate a million locations, and anything
smaller is currently infeasible.

Ok, forget how slow writing to memory is, and focus on the C++ version.
-rw-r--r--mu.arc14
1 files changed, 11 insertions, 3 deletions
diff --git a/mu.arc b/mu.arc
index d206714b..e8e00187 100644
--- a/mu.arc
+++ b/mu.arc
@@ -132,7 +132,8 @@
 ;   at compile time: mapping names to locations
 (on-init
   (= type* (table))  ; name -> type info
-  (= memory* (table))  ; address -> value
+  (= memory* ($.make-vector 1000000))  ; address -> value
+;?   (= memory* ($.make-vector 1000000000))  ; address -> value
   (= function* (table))  ; name -> [instructions]
   ; transforming mu programs
   (= location* (table))  ; function -> {name -> index into default-space}
@@ -1153,8 +1154,13 @@
 (def deref (operand)
   (assert (pos '(deref) metadata.operand))
   (assert address?.operand)
-  (cons `(,(memory* v.operand) ,@typeinfo.operand!elem)
-        (drop-one '(deref) metadata.operand)))
+  (if (isa v.operand 'int)
+    (cons `(,(memory* v.operand) ,@typeinfo.operand!elem)
+          (drop-one '(deref) metadata.operand))
+    ; non-numeric address should only happen during freezing
+    ; no address available, and type can't be an array
+    (cons `(abcfoo ,@typeinfo.operand!elem)
+          (drop-one '(deref) metadata.operand))))
 
 (def drop-one (f x)
   (when acons.x  ; proper lists only
@@ -1367,6 +1373,7 @@
 ;?           (tr "about to rename args: @op")
           (when (in op 'get 'get-address)
             ; special case: map field offset by looking up type table
+            (prn args.0)
             (with (basetype  (typeof args.0)
                    field  (v args.1))
 ;?               (tr 111 " " args.0 " " basetype)
@@ -1645,6 +1652,7 @@
     (while change
       (= change nil)
       (each (name body)  canon.function-table
+        (prn name)
         (when (no location*.name)
           (= change t))
         (or= location*.name (assign-names-to-location body name)))))