diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2016-09-17 15:01:51 -0700 |
commit | f344b250f6f062a1a1902bf69b23ebf9b565de0e (patch) | |
tree | 199bd32a9aee198d5028b1c21b83d2cf0944b2b6 /html/037abandon.cc.html | |
parent | 897ae8c1855f830d8819759ea327d147f28a09bf (diff) | |
download | mu-f344b250f6f062a1a1902bf69b23ebf9b565de0e.tar.gz |
3395
Diffstat (limited to 'html/037abandon.cc.html')
-rw-r--r-- | html/037abandon.cc.html | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/html/037abandon.cc.html b/html/037abandon.cc.html index a6d10bee..6984c154 100644 --- a/html/037abandon.cc.html +++ b/html/037abandon.cc.html @@ -38,12 +38,12 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color <span class="Delimiter">:(scenario new_reclaim)</span> def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:number <span class="Comment"># because 1 will get reset during abandon below</span> - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> - <span class="Constant">3</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Comment"># must be same size as abandoned memory to reuse</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:number - <span class="Constant">5</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:number<span class="Delimiter">,</span> <span class="Constant">4</span>:number + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:num <span class="Comment"># because 1 will get reset during abandon below</span> + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> + <span class="Constant">3</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Comment"># must be same size as abandoned memory to reuse</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:num + <span class="Constant">5</span>:<span class="Normal">bool</span><span class="Special"> <- </span>equal <span class="Constant">2</span>:num<span class="Delimiter">,</span> <span class="Constant">4</span>:num ] <span class="Comment"># both allocations should have returned the same address</span> <span class="traceContains">+mem: storing 1 in location 5</span> @@ -110,34 +110,34 @@ map<<span class="Normal">int</span><span class="Delimiter">,</span> <span cla <span class="Delimiter">:(scenario new_differing_size_no_reclaim)</span> def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:number - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> - <span class="Constant">3</span>:address:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># different size</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:array:number - <span class="Constant">5</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:number<span class="Delimiter">,</span> <span class="Constant">4</span>:number + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:num + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> + <span class="Constant">3</span>:address:array:num<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># different size</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:array:num + <span class="Constant">5</span>:<span class="Normal">bool</span><span class="Special"> <- </span>equal <span class="Constant">2</span>:num<span class="Delimiter">,</span> <span class="Constant">4</span>:num ] <span class="Comment"># no reuse</span> <span class="traceContains">+mem: storing 0 in location 5</span> <span class="Delimiter">:(scenario new_reclaim_array)</span> def main [ - <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> - <span class="Constant">2</span>:number<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:array:number - <span class="Constant">1</span>:address:array:number<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> - <span class="Constant">3</span>:address:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># same size</span> - <span class="Constant">4</span>:number<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:array:number - <span class="Constant">5</span>:boolean<span class="Special"> <- </span>equal <span class="Constant">2</span>:number<span class="Delimiter">,</span> <span class="Constant">4</span>:number + <span class="Constant">1</span>:address:array:num<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> + <span class="Constant">2</span>:num<span class="Special"> <- </span>copy <span class="Constant">1</span>:address:array:num + <span class="Constant">1</span>:address:array:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Comment"># abandon</span> + <span class="Constant">3</span>:address:array:num<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">2</span> <span class="Comment"># same size</span> + <span class="Constant">4</span>:num<span class="Special"> <- </span>copy <span class="Constant">3</span>:address:array:num + <span class="Constant">5</span>:<span class="Normal">bool</span><span class="Special"> <- </span>equal <span class="Constant">2</span>:num<span class="Delimiter">,</span> <span class="Constant">4</span>:num ] <span class="Comment"># both calls to new returned identical addresses</span> <span class="traceContains">+mem: storing 1 in location 5</span> <span class="Delimiter">:(scenario abandon_on_overwrite)</span> def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Comment"># over-writing one allocation with another</span> - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> @@ -146,15 +146,15 @@ def main [ <span class="Delimiter">:(scenario abandon_after_call)</span> def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Comment"># passing in addresses to recipes increments refcount</span> - foo <span class="Constant">1</span>:address:number - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + foo <span class="Constant">1</span>:address:num + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] def foo [ - <span class="Constant">2</span>:address:number<span class="Special"> <- </span>next-ingredient + <span class="Constant">2</span>:address:num<span class="Special"> <- </span>next-ingredient <span class="Comment"># return does NOT yet decrement refcount; memory must be explicitly managed</span> - <span class="Constant">2</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> @@ -170,12 +170,12 @@ def foo [ <span class="Delimiter">:(scenario abandon_on_overwrite_array)</span> def main [ - <span class="Constant">1</span>:number<span class="Special"> <- </span>copy <span class="Constant">30</span> + <span class="Constant">1</span>:num<span class="Special"> <- </span>copy <span class="Constant">30</span> <span class="Comment"># allocate an array</span> - <span class="Constant">10</span>:address:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">20</span> - <span class="Constant">11</span>:number<span class="Special"> <- </span>copy <span class="Constant">10</span>:address:array:number <span class="Comment"># doesn't increment refcount</span> + <span class="Constant">10</span>:address:array:num<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">20</span> + <span class="Constant">11</span>:num<span class="Special"> <- </span>copy <span class="Constant">10</span>:address:array:num <span class="Comment"># doesn't increment refcount</span> <span class="Comment"># allocate another array in its place, implicitly freeing the previous allocation</span> - <span class="Constant">10</span>:address:array:number<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">25</span> + <span class="Constant">10</span>:address:array:num<span class="Special"> <- </span><span class="Normal">new</span> number:type<span class="Delimiter">,</span> <span class="Constant">25</span> ] <span class="traceContains">+run: {10: ("address" "array" "number")} <- new {number: "type"}, {25: "literal"}</span> <span class="Comment"># abandoned array is of old size (20, not 25)</span> @@ -184,13 +184,13 @@ def main [ <span class="Delimiter">:(scenario refcounts_abandon_address_in_container)</span> <span class="Comment"># container containing an address</span> container foo [ - <span class="Normal">x</span>:address:number + <span class="Normal">x</span>:address:num ] def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Constant">2</span>:address:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type - *<span class="Constant">2</span>:address:foo<span class="Special"> <- </span>put *<span class="Constant">2</span>:address:foo<span class="Delimiter">,</span> x:offset<span class="Delimiter">,</span> <span class="Constant">1</span>:address:number - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + *<span class="Constant">2</span>:address:foo<span class="Special"> <- </span>put *<span class="Constant">2</span>:address:foo<span class="Delimiter">,</span> x:offset<span class="Delimiter">,</span> <span class="Constant">1</span>:address:num + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant">2</span>:address:foo<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> @@ -213,11 +213,11 @@ def main [ <span class="Comment"># todo: move past dilated reagent</span> <span class="Delimiter">:(scenario refcounts_abandon_address_in_array)</span> def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type - <span class="Constant">2</span>:address:array:address:number<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> - *<span class="Constant">2</span>:address:array:address:number<span class="Special"> <- </span>put-index *<span class="Constant">2</span>:address:array:address:number<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:number - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> - <span class="Constant">2</span>:address:array:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">2</span>:address:array:address:num<span class="Special"> <- </span><span class="Normal">new</span> <span class="Delimiter">{(</span>address number<span class="Delimiter">)</span>: type<span class="Delimiter">},</span> <span class="Constant">3</span> + *<span class="Constant">2</span>:address:array:address:num<span class="Special"> <- </span>put-index *<span class="Constant">2</span>:address:array:address:num<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">1</span>:address:num + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">2</span>:address:array:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> ] <span class="traceContains">+run: {1: ("address" "number")} <- new {number: "type"}</span> <span class="traceContains">+mem: incrementing refcount of 1000: 0 -> 1</span> @@ -233,14 +233,14 @@ def main [ <span class="Delimiter">:(scenario refcounts_abandon_address_in_container_in_array)</span> <span class="Comment"># container containing an address</span> container foo [ - <span class="Normal">x</span>:address:number + <span class="Normal">x</span>:address:num ] def main [ - <span class="Constant">1</span>:address:number<span class="Special"> <- </span><span class="Normal">new</span> number:type + <span class="Constant">1</span>:address:num<span class="Special"> <- </span><span class="Normal">new</span> number:type <span class="Constant">2</span>:address:array:foo<span class="Special"> <- </span><span class="Normal">new</span> foo:type<span class="Delimiter">,</span> <span class="Constant">3</span> - <span class="Constant">3</span>:foo<span class="Special"> <- </span>merge <span class="Constant">1</span>:address:number + <span class="Constant">3</span>:foo<span class="Special"> <- </span>merge <span class="Constant">1</span>:address:num *<span class="Constant">2</span>:address:array:foo<span class="Special"> <- </span>put-index *<span class="Constant">2</span>:address:array:foo<span class="Delimiter">,</span> <span class="Constant">1</span><span class="Delimiter">,</span> <span class="Constant">3</span>:foo - <span class="Constant">1</span>:address:number<span class="Special"> <- </span>copy <span class="Constant">0</span> + <span class="Constant">1</span>:address:num<span class="Special"> <- </span>copy <span class="Constant">0</span> <span class="Constant">3</span>:foo<span class="Special"> <- </span>merge <span class="Constant">0</span> <span class="Constant">2</span>:address:array:foo<span class="Special"> <- </span>copy <span class="Constant">0</span> ] |