diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-04-25 22:27:19 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-04-25 22:27:19 -0700 |
commit | 32b8fac2799ac7cec613e84a3eb9c009141b6a3a (patch) | |
tree | 11f56c1a235abf7b626ea8983fff3d2edb1fcf98 /html/043space.cc.html | |
parent | 224972ee9871fcb06ee285fa5f3d9528c034d414 (diff) | |
download | mu-32b8fac2799ac7cec613e84a3eb9c009141b6a3a.tar.gz |
2866
Diffstat (limited to 'html/043space.cc.html')
-rw-r--r-- | html/043space.cc.html | 76 |
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"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> <span class="Constant">11</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Normal">default</span>-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe <span class="Constant">1</span>:number<span class="Special"> <- </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"> <- </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"> <- </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"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> <span class="Constant">1001</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1000</span>/unsafe - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">3</span>/unsafe + <span class="Normal">default</span>-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + <span class="Constant">1</span>:address:number<span class="Special"> <- </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 <- </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 "End canonize(x) Special-cases")</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& 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">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"address"</span><span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"shared"</span><span class="Delimiter">)</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"array"</span><span class="Delimiter">)</span> - || !x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> - || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> - raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'default-space' should be of type address:shared:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << end<span class="Delimiter">();</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>value != get<span class="Delimiter">(</span>Type_ordinal<span class="Delimiter">,</span> <span class="Constant">"location"</span><span class="Delimiter">)</span> + || x<span class="Delimiter">.</span>type<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">-></span>right<span class="Delimiter">)</span> <span class="Delimiter">{</span> + raise << maybe<span class="Delimiter">(</span>current_recipe_name<span class="Delimiter">())</span> << <span class="Constant">"'default-space' should be of type address:array:location, but tried to write "</span> << to_string<span class="Delimiter">(</span>data<span class="Delimiter">)</span> << <span class="cSpecial">'\n'</span> << 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"> <- </span>copy <span class="Constant">10</span>/unsafe - <span class="Constant">1</span>:address:shared:array:location/<span class="Special">raw <- </span>copy <span class="Normal">default</span>-space:address:shared:array:location + <span class="Normal">default</span>-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">10</span>/unsafe + <span class="Constant">1</span>:address:array:location/<span class="Special">raw <- </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"> <- </span>copy <span class="Constant">34</span> - <span class="Constant">13</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">2002</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> <span class="Constant">1001</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1000</span>/unsafe - <span class="Constant">1</span>:address:point<span class="Special"> <- </span>copy <span class="Constant">12</span>/unsafe + <span class="Normal">default</span>-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + <span class="Constant">1</span>:address:point<span class="Special"> <- </span>copy <span class="Constant">2000</span>/unsafe <span class="Constant">9</span>:number/<span class="Special">raw <- </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 "reagent tmp" following "case GET:")</span> -tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span> +<span class="Delimiter">:(before "Read element" following "case GET:")</span> +element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</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"> <- </span>copy <span class="Constant">2</span> - <span class="Constant">13</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> - <span class="Constant">14</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">2</span> <span class="Comment"># length</span> + <span class="Constant">2002</span>:number<span class="Special"> <- </span>copy <span class="Constant">34</span> + <span class="Constant">2003</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># refcount</span> <span class="Constant">1001</span>:number<span class="Special"> <- </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"> <- </span>copy <span class="Constant">1000</span>/unsafe - <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">12</span>/unsafe + <span class="Normal">default</span>-space:address:array:location<span class="Special"> <- </span>copy <span class="Constant">1000</span>/unsafe + <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">2000</span>/unsafe <span class="Constant">9</span>:number/<span class="Special">raw <- </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 "reagent tmp" following "case INDEX:")</span> -tmp<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</span><span class="Delimiter">,</span> <span class="Constant">NULL</span><span class="Delimiter">));</span> +<span class="Delimiter">:(before "Read element" following "case INDEX:")</span> +element<span class="Delimiter">.</span>properties<span class="Delimiter">.</span>push_back<span class="Delimiter">(</span>pair<string<span class="Delimiter">,</span> string_tree*><span class="Delimiter">(</span><span class="Constant">"raw"</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 "End Rewrite Instruction(curr, recipe result)")</span> <span class="Comment">// rewrite `new-default-space` to</span> -<span class="Comment">// `default-space:address:shared:array:location <- new location:type, number-of-locals:literal`</span> +<span class="Comment">// `default-space:address:array:location <- new location:type, number-of-locals:literal`</span> <span class="Comment">// where N is Name[recipe][""]</span> <span class="Normal">if</span> <span class="Delimiter">(</span>curr<span class="Delimiter">.</span>name == <span class="Constant">"new-default-space"</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"> <- </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 <- new [abc]</span> +<span class="CommentedCode">//? x:address:array:character <- 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 "Falling Through End Of Recipe")</span> @@ -279,7 +277,7 @@ try_reclaim_locals<span class="Delimiter">();</span> <span class="Normal">const</span> instruction& 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">"local-scope"</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">"number-of-locals:literal"</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 << <span class="Constant">"new-default-space can't take any results</span><span class="cSpecial">\n</span><span class="Constant">"</span> << 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">"default-space:address:shared:array:location"</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">"default-space:address:array:location"</span><span class="Delimiter">));</span> <span class="Delimiter">}</span> <span class="SalientComment">//:: all recipes must set default-space one way or another</span> |