From 7be19db89c27cedae35da0d71fb838cac80f4f04 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Fri, 13 Mar 2015 09:56:37 -0700 Subject: 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. --- mu.arc | 14 +++++++++++--- 1 file 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))))) -- cgit 1.4.1-2-gfad0