about summary refs log tree commit diff stats
path: root/html/043space.cc.html
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-04-25 22:27:19 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-04-25 22:27:19 -0700
commit32b8fac2799ac7cec613e84a3eb9c009141b6a3a (patch)
tree11f56c1a235abf7b626ea8983fff3d2edb1fcf98 /html/043space.cc.html
parent224972ee9871fcb06ee285fa5f3d9528c034d414 (diff)
downloadmu-32b8fac2799ac7cec613e84a3eb9c009141b6a3a.tar.gz
2866
Diffstat (limited to 'html/043space.cc.html')
-rw-r--r--html/043space.cc.html76
1 files changed, 37 insertions, 39 deletions
diff --git a/html/043space.cc.html b/html/043space.cc.html
index c4783e1e..05049dc3 100644
--- a/html/043space.cc.html
+++ b/html/043space.cc.html
@@ -44,24 +44,24 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color
 <span class="Comment"># if default-space is 10, and if an array of 5 locals lies from location 12 to 16 (inclusive),</span>
 <span class="Comment"># then local 0 is really location 12, local 1 is really location 13, and so on.</span>
 def main [
-  <span class="Comment"># pretend shared:array:location; in practice we'll use new</span>
+  <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
   <span class="Constant">10</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
   <span class="Constant">11</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
-  <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
+  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
   <span class="Constant">1</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">23</span>
 ]
 <span class="traceContains">+mem: storing 23 in location 13</span>
 
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space)</span>
 def main [
-  <span class="Comment"># pretend pointer from outside</span>
-  <span class="Constant">3</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Comment"># pretend shared:array:location; in practice we'll use new</span>
+  <span class="Comment"># pretend pointer from outside (2000 reserved for refcount)</span>
+  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
   <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
   <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">3</span>/unsafe
+  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:address:number<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe  <span class="Comment"># even local variables always contain raw addresses</span>
   <span class="Constant">8</span>:number/<span class="Special">raw &lt;- </span>copy *<span class="Constant">1</span>:address:number
 ]
 <span class="traceContains">+mem: storing 34 in location 8</span>
@@ -88,7 +88,7 @@ def main [
 default_space = <span class="Constant">0</span><span class="Delimiter">;</span>
 
 <span class="Delimiter">:(before &quot;End canonize(x) Special-cases&quot;)</span>
-  absolutize<span class="Delimiter">(</span>x<span class="Delimiter">);</span>
+absolutize<span class="Delimiter">(</span>x<span class="Delimiter">);</span>
 <span class="Delimiter">:(code)</span>
 <span class="Normal">void</span> absolutize<span class="Delimiter">(</span>reagent&amp; x<span class="Delimiter">)</span> <span class="Delimiter">{</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>is_raw<span class="Delimiter">(</span>x<span class="Delimiter">)</span> || is_dummy<span class="Delimiter">(</span>x<span class="Delimiter">))</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
@@ -126,13 +126,11 @@ default_space = <span class="Constant">0</span><span class="Delimiter">;</span>
         || !x<span class="Delimiter">.</span>type
         || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;address&quot;</span><span class="Delimiter">)</span>
         || !x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right
-        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;shared&quot;</span><span class="Delimiter">)</span>
+        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;array&quot;</span><span class="Delimiter">)</span>
         || !x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right
-        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;array&quot;</span><span class="Delimiter">)</span>
-        || !x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right
-        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;location&quot;</span><span class="Delimiter">)</span>
-        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span>
-      raise &lt;&lt; maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> &lt;&lt; <span class="Constant">&quot;'default-space' should be of type address:shared:array:location, but tried to write &quot;</span> &lt;&lt; to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
+        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">&quot;location&quot;</span><span class="Delimiter">)</span>
+        || x<span class="Delimiter">.</span>type<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">-&gt;</span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span>
+      raise &lt;&lt; maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> &lt;&lt; <span class="Constant">&quot;'default-space' should be of type address:array:location, but tried to write &quot;</span> &lt;&lt; to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> &lt;&lt; <span class="cSpecial">'\n'</span> &lt;&lt; end<span class="Delimiter">();</span>
     <span class="Delimiter">}</span>
     current_call<span class="Delimiter">().</span>default_space = data<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
     <span class="Identifier">return</span><span class="Delimiter">;</span>
@@ -140,8 +138,8 @@ default_space = <span class="Constant">0</span><span class="Delimiter">;</span>
 
 <span class="Delimiter">:(scenario get_default_space)</span>
 def main [
-  <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
-  <span class="Constant">1</span>:address:shared:array:location/<span class="Special">raw &lt;- </span>copy <span class="Normal">default</span>-space:address:shared:array:location
+  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">10</span>/unsafe
+  <span class="Constant">1</span>:address:array:location/<span class="Special">raw &lt;- </span>copy <span class="Normal">default</span>-space:address:array:location
 ]
 <span class="traceContains">+mem: storing 10 in location 1</span>
 
@@ -156,42 +154,42 @@ def main [
 
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space_in_get)</span>
 def main [
-  <span class="Comment"># pretend pointer to container from outside</span>
-  <span class="Constant">12</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Constant">13</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
-  <span class="Comment"># pretend shared:array:location; in practice we'll use new</span>
+  <span class="Comment"># pretend pointer to container from outside (2000 reserved for refcount)</span>
+  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Constant">2002</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
+  <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
   <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
   <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:point<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>/unsafe
+  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:address:point<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
   <span class="Constant">9</span>:number/<span class="Special">raw &lt;- </span>get *<span class="Constant">1</span>:address:point<span class="Delimiter">,</span> <span class="Constant">1</span>:offset
 ]
 <span class="traceContains">+mem: storing 35 in location 9</span>
 
-<span class="Delimiter">:(after &quot;reagent tmp&quot; following &quot;case GET:&quot;)</span>
-tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span><span class="Constant">&quot;raw&quot;</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span>
+<span class="Delimiter">:(before &quot;Read element&quot; following &quot;case GET:&quot;)</span>
+element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span><span class="Constant">&quot;raw&quot;</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span>
 
 <span class="SalientComment">//:: fix 'index'</span>
 
 <span class="Delimiter">:(scenario lookup_sidesteps_default_space_in_index)</span>
 def main [
-  <span class="Comment"># pretend pointer to array from outside</span>
-  <span class="Constant">12</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>
-  <span class="Constant">13</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Constant">14</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
-  <span class="Comment"># pretend shared:array:location; in practice we'll use new</span>
+  <span class="Comment"># pretend pointer to array from outside (2000 reserved for refcount)</span>
+  <span class="Constant">2001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">2</span>  <span class="Comment"># length</span>
+  <span class="Constant">2002</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
+  <span class="Constant">2003</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">35</span>
+  <span class="Comment"># pretend address:array:location; in practice we'll use new</span>
   <span class="Constant">1000</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">0</span>  <span class="Comment"># refcount</span>
   <span class="Constant">1001</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">5</span>  <span class="Comment"># length</span>
   <span class="Comment"># actual start of this recipe</span>
-  <span class="Normal">default</span>-space:address:shared:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
-  <span class="Constant">1</span>:address:array:number<span class="Special"> &lt;- </span>copy <span class="Constant">12</span>/unsafe
+  <span class="Normal">default</span>-space:address:array:location<span class="Special"> &lt;- </span>copy <span class="Constant">1000</span>/unsafe
+  <span class="Constant">1</span>:address:array:number<span class="Special"> &lt;- </span>copy <span class="Constant">2000</span>/unsafe
   <span class="Constant">9</span>:number/<span class="Special">raw &lt;- </span>index *<span class="Constant">1</span>:address:array:number<span class="Delimiter">,</span> <span class="Constant">1</span>
 ]
 <span class="traceContains">+mem: storing 35 in location 9</span>
 
-<span class="Delimiter">:(after &quot;reagent tmp&quot; following &quot;case INDEX:&quot;)</span>
-tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span><span class="Constant">&quot;raw&quot;</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span>
+<span class="Delimiter">:(before &quot;Read element&quot; following &quot;case INDEX:&quot;)</span>
+element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair&lt;string<span class="Delimiter">,</span> string_tree*&gt;<span class="Delimiter">(</span><span class="Constant">&quot;raw&quot;</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span>
 
 <span class="SalientComment">//:: convenience operation to automatically deduce the amount of space to</span>
 <span class="SalientComment">//:: allocate in a default space with names</span>
@@ -213,7 +211,7 @@ def main [
 
 <span class="Delimiter">:(before &quot;End Rewrite Instruction(curr, recipe result)&quot;)</span>
 <span class="Comment">// rewrite `new-default-space` to</span>
-<span class="Comment">//   `default-space:address:shared:array:location &lt;- new location:type, number-of-locals:literal`</span>
+<span class="Comment">//   `default-space:address:array:location &lt;- new location:type, number-of-locals:literal`</span>
 <span class="Comment">// where N is Name[recipe][&quot;&quot;]</span>
 <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">&quot;new-default-space&quot;</span><span class="Delimiter">)</span> <span class="Delimiter">{</span>
   rewrite_default_space_instruction<span class="Delimiter">(</span>curr<span class="Delimiter">);</span>
@@ -244,7 +242,7 @@ def main [
 def foo [
   local-scope
   <span class="Normal">x</span>:number<span class="Special"> &lt;- </span>copy <span class="Constant">34</span>
-  <span class="Identifier">return</span> <span class="Normal">default</span>-space:address:shared:array:location
+  <span class="Identifier">return</span> <span class="Normal">default</span>-space:address:array:location
 ]
 <span class="Comment"># both calls to foo should have received the same default-space</span>
 <span class="traceContains">+mem: storing 1 in location 3</span>
@@ -253,9 +251,9 @@ def foo [
 <span class="CommentedCode">//? :(scenario local_scope_frees_up_allocations)</span>
 <span class="CommentedCode">//? def main [</span>
 <span class="CommentedCode">//?   local-scope</span>
-<span class="CommentedCode">//?   x:address:shared:array:character &lt;- new [abc]</span>
+<span class="CommentedCode">//?   x:address:array:character &lt;- new [abc]</span>
 <span class="CommentedCode">//? ]</span>
-<span class="CommentedCode">//? +mem: clearing x:address:shared:array:character</span>
+<span class="CommentedCode">//? +mem: clearing x:address:array:character</span>
 
 <span class="Comment">//: todo: do this in a transform, rather than magically in the reply instruction</span>
 <span class="Delimiter">:(after &quot;Falling Through End Of Recipe&quot;)</span>
@@ -279,7 +277,7 @@ try_reclaim_locals<span class="Delimiter">();</span>
   <span class="Normal">const</span> instruction&amp; inst = exiting_recipe<span class="Delimiter">.</span>steps<span class="Delimiter">.</span>at<span class="Delimiter">(</span><span class="Constant">0</span><span class="Delimiter">);</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>inst<span class="Delimiter">.</span>old_name != <span class="Constant">&quot;local-scope&quot;</span><span class="Delimiter">)</span> <span class="Identifier">return</span><span class="Delimiter">;</span>
   <span class="Comment">// reclaim any local variables unless they're being returned</span>
-  <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">: this isn't working yet. Doesn't handle address:shared stored in</span>
+  <span class="Comment">// </span><span class="Todo">TODO</span><span class="Comment">: this isn't working yet. Doesn't handle address stored in</span>
   <span class="Comment">// containers created by 'copy' or 'merge'. We'd end up deleting the address</span>
   <span class="Comment">// even if some container containing it was returned.</span>
   <span class="Comment">// This might doom our whole refcounting-based approach :/</span>
@@ -320,7 +318,7 @@ try_reclaim_locals<span class="Delimiter">();</span>
   curr<span class="Delimiter">.</span>ingredients<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">&quot;number-of-locals:literal&quot;</span><span class="Delimiter">));</span>
   <span class="Normal">if</span> <span class="Delimiter">(</span>!curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>empty<span class="Delimiter">())</span>
     raise &lt;&lt; <span class="Constant">&quot;new-default-space can't take any results</span><span class="cSpecial">\n</span><span class="Constant">&quot;</span> &lt;&lt; end<span class="Delimiter">();</span>
-  curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">&quot;default-space:address:shared:array:location&quot;</span><span class="Delimiter">));</span>
+  curr<span class="Delimiter">.</span>products<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>reagent<span class="Delimiter">(</span><span class="Constant">&quot;default-space:address:array:location&quot;</span><span class="Delimiter">));</span>
 <span class="Delimiter">}</span>
 
 <span class="SalientComment">//:: all recipes must set default-space one way or another</span>