From f344b250f6f062a1a1902bf69b23ebf9b565de0e Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 17 Sep 2016 15:01:51 -0700 Subject: 3395 --- html/074deep_copy.cc.html | 184 +++++++++++++++++++++++----------------------- 1 file changed, 92 insertions(+), 92 deletions(-) (limited to 'html/074deep_copy.cc.html') diff --git a/html/074deep_copy.cc.html b/html/074deep_copy.cc.html index b440083b..bd40721c 100644 --- a/html/074deep_copy.cc.html +++ b/html/074deep_copy.cc.html @@ -47,23 +47,23 @@ body { font-size: 12pt; font-family: monospace; color: #eeeeee; background-color :(scenario deep_copy_number) def main [ local-scope - x:number <- copy 34 - y:number <- deep-copy x - 10:boolean/raw <- equal x, y + x:num <- copy 34 + y:num <- deep-copy x + 10:bool/raw <- equal x, y ] # non-address primitives are identical +mem: storing 1 in location 10 :(scenario deep_copy_container_without_address) container foo [ - x:number - y:number + x:num + y:num ] def main [ local-scope a:foo <- merge 34, 35 b:foo <- deep-copy a - 10:boolean/raw <- equal a, b + 10:bool/raw <- equal a, b ] # containers are identical as long as they don't contain addresses +mem: storing 1 in location 10 @@ -73,12 +73,12 @@ def main [ def main [ # avoid all memory allocations except the implicit ones inside deep-copy, so # that the result is deterministic - 1:address:number <- copy 100/unsafe # pretend allocation - *1:address:number <- copy 34 - 2:address:number <- deep-copy 1:address:number - 10:boolean <- equal 1:address:number, 2:address:number - 11:boolean <- equal *1:address:number, *2:address:number - 2:address:number <- copy 0 + 1:&:num <- copy 100/unsafe # pretend allocation + *1:&:num <- copy 34 + 2:&:num <- deep-copy 1:&:num + 10:bool <- equal 1:&:num, 2:&:num + 11:bool <- equal *1:&:num, *2:&:num + 2:&:num <- copy 0 ] # the result of deep-copy is a new address +mem: storing 0 in location 10 @@ -95,11 +95,11 @@ def main [ def main [ # avoid all memory allocations except the implicit ones inside deep-copy, so # that the result is deterministic - 1:address:point <- copy 100/unsafe # pretend allocation - *1:address:point <- merge 34, 35 - 2:address:point <- deep-copy 1:address:point - 10:boolean <- equal 1:address:point, 2:address:point - 11:boolean <- equal *1:address:point, *2:address:point + 1:&:point <- copy 100/unsafe # pretend allocation + *1:&:point <- merge 34, 35 + 2:&:point <- deep-copy 1:&:point + 10:bool <- equal 1:&:point, 2:&:point + 11:bool <- equal *1:&:point, *2:&:point ] # the result of deep-copy is a new address +mem: storing 0 in location 10 @@ -111,13 +111,13 @@ def main [ def main [ # avoid all memory allocations except the implicit ones inside deep-copy, so # that the result is deterministic - 1:address:address:number <- copy 100/unsafe # pretend allocation - *1:address:address:number <- copy 150/unsafe - **1:address:address:number <- copy 34 - 2:address:address:number <- deep-copy 1:address:address:number - 10:boolean <- equal 1:address:address:number, 2:address:address:number - 11:boolean <- equal *1:address:address:number, *2:address:address:number - 12:boolean <- equal **1:address:address:number, **2:address:address:number + 1:&:&:num <- copy 100/unsafe # pretend allocation + *1:&:&:num <- copy 150/unsafe + **1:&:&:num <- copy 34 + 2:&:&:num <- deep-copy 1:&:&:num + 10:bool <- equal 1:&:&:num, 2:&:&:num + 11:bool <- equal *1:&:&:num, *2:&:&:num + 12:bool <- equal **1:&:&:num, **2:&:&:num ] # the result of deep-copy is a new address +mem: storing 0 in location 10 @@ -131,18 +131,18 @@ def main [ def main [ # avoid all memory allocations except the implicit ones inside deep-copy, so # that the result is deterministic - 100:number <- copy 1 # pretend refcount - 101:number <- copy 3 # pretend array length - 1:address:array:number <- copy 100/unsafe # pretend allocation - put-index *1:address:array:number, 0, 34 - put-index *1:address:array:number, 1, 35 - put-index *1:address:array:number, 2, 36 - stash [old:], *1:address:array:number - 2:address:array:number <- deep-copy 1:address:array:number - stash 2:address:array:number - stash [new:], *2:address:array:number - 10:boolean <- equal 1:address:array:number, 2:address:array:number - 11:boolean <- equal *1:address:array:number, *2:address:array:number + 100:num <- copy 1 # pretend refcount + 101:num <- copy 3 # pretend array length + 1:&:@:num <- copy 100/unsafe # pretend allocation + put-index *1:&:@:num, 0, 34 + put-index *1:&:@:num, 1, 35 + put-index *1:&:@:num, 2, 36 + stash [old:], *1:&:@:num + 2:&:@:num <- deep-copy 1:&:@:num + stash 2:&:@:num + stash [new:], *2:&:@:num + 10:bool <- equal 1:&:@:num, 2:&:@:num + 11:bool <- equal *1:&:@:num, *2:&:@:num ] +app: old: 3 34 35 36 +app: new: 3 34 35 36 @@ -153,19 +153,19 @@ def main [ :(scenario deep_copy_container_with_address) container foo [ - x:number - y:address:number + x:num + y:&:num ] def main [ local-scope - y0:address:number <- new number:type + y0:&:num <- new number:type *y0 <- copy 35 a:foo <- merge 34, y0 b:foo <- deep-copy a - 10:boolean/raw <- equal a, b - y1:address:number <- get b, y:offset - 11:boolean/raw <- equal y0, y1 - 12:number/raw <- copy *y1 + 10:bool/raw <- equal a, b + y1:&:num <- get b, y:offset + 11:bool/raw <- equal y0, y1 + 12:num/raw <- copy *y1 ] # containers containing addresses are not identical to their deep copies +mem: storing 0 in location 10 @@ -175,19 +175,19 @@ def main [ :(scenario deep_copy_exclusive_container_with_address) exclusive-container foo [ - x:number - y:address:number + x:num + y:&:num ] def main [ local-scope - y0:address:number <- new number:type + y0:&:num <- new number:type *y0 <- copy 34 a:foo <- merge 1/y, y0 b:foo <- deep-copy a - 10:boolean/raw <- equal a, b - y1:address:number, z:boolean <- maybe-convert b, y:variant - 11:boolean/raw <- equal y0, y1 - 12:number/raw <- copy *y1 + 10:bool/raw <- equal a, b + y1:&:num, z:bool <- maybe-convert b, y:variant + 11:bool/raw <- equal y0, y1 + 12:num/raw <- copy *y1 ] # exclusive containers containing addresses are not identical to their deep copies +mem: storing 0 in location 10 @@ -197,24 +197,24 @@ def main [ :(scenario deep_copy_exclusive_container_with_container_with_address) exclusive-container foo [ - x:number + x:num y:bar # inline ] container bar [ - x:address:number + x:&:num ] def main [ local-scope - y0:address:number <- new number:type + y0:&:num <- new number:type *y0 <- copy 34 a:bar <- merge y0 b:foo <- merge 1/y, a c:foo <- deep-copy b - 10:boolean/raw <- equal b, c - d:bar, z:boolean <- maybe-convert c, y:variant - y1:address:number <- get d, x:offset - 11:boolean/raw <- equal y0, y1 - 12:number/raw <- copy *y1 + 10:bool/raw <- equal b, c + d:bar, z:bool <- maybe-convert c, y:variant + y1:&:num <- get d, x:offset + 11:bool/raw <- equal y0, y1 + 12:num/raw <- copy *y1 ] # exclusive containers containing addresses are not identical to their deep copies +mem: storing 0 in location 10 @@ -336,83 +336,83 @@ vector<double> deep_copy:(scenario deep_copy_stress_test_1) container foo1 [ - p:address:number + p:&:num ] container foo2 [ - p:address:foo1 + p:&:foo1 ] exclusive-container foo3 [ - p:address:foo1 - q:address:foo2 + p:&:foo1 + q:&:foo2 ] def main [ local-scope - x:address:number <- new number:type + x:&:num <- new number:type *x <- copy 34 - a:address:foo1 <- new foo1:type + a:&:foo1 <- new foo1:type *a <- merge x - b:address:foo2 <- new foo2:type + b:&:foo2 <- new foo2:type *b <- merge a c:foo3 <- merge 1/q, b d:foo3 <- deep-copy c - e:address:foo2, z:boolean <- maybe-convert d, q:variant - f:address:foo1 <- get *e, p:offset - g:address:number <- get *f, p:offset - 1:number/raw <- copy *g + e:&:foo2, z:bool <- maybe-convert d, q:variant + f:&:foo1 <- get *e, p:offset + g:&:num <- get *f, p:offset + 1:num/raw <- copy *g ] +mem: storing 34 in location 1 :(scenario deep_copy_stress_test_2) container foo1 [ - p:address:number + p:&:num ] container foo2 [ - p:address:foo1 + p:&:foo1 ] exclusive-container foo3 [ - p:address:foo1 - q:address:foo2 + p:&:foo1 + q:&:foo2 ] container foo4 [ - p:number - q:address:foo3 + p:num + q:&:foo3 ] def main [ local-scope - x:address:number <- new number:type + x:&:num <- new number:type *x <- copy 34 - a:address:foo1 <- new foo1:type + a:&:foo1 <- new foo1:type *a <- merge x - b:address:foo2 <- new foo2:type + b:&:foo2 <- new foo2:type *b <- merge a - c:address:foo3 <- new foo3:type + c:&:foo3 <- new foo3:type *c <- merge 1/q, b d:foo4 <- merge 35, c e:foo4 <- deep-copy d - f:address:foo3 <- get e, q:offset - g:address:foo2, z:boolean <- maybe-convert *f, q:variant - h:address:foo1 <- get *g, p:offset - y:address:number <- get *h, p:offset - 1:number/raw <- copy *y + f:&:foo3 <- get e, q:offset + g:&:foo2, z:bool <- maybe-convert *f, q:variant + h:&:foo1 <- get *g, p:offset + y:&:num <- get *h, p:offset + 1:num/raw <- copy *y ] +mem: storing 34 in location 1 :(scenario deep_copy_cycles) container foo [ - p:number - q:address:foo + p:num + q:&:foo ] def main [ local-scope - x:address:foo <- new foo:type + x:&:foo <- new foo:type *x <- put *x, p:offset, 34 *x <- put *x, q:offset, x # create a cycle - y:address:foo <- deep-copy x - 1:number/raw <- get *y, p:offset - y2:address:foo <- get *y, q:offset + y:&:foo <- deep-copy x + 1:num/raw <- get *y, p:offset + y2:&:foo <- get *y, q:offset stash y [vs] y2 - 2:boolean/raw <- equal y, y2 # is it still a cycle? - 3:boolean/raw <- equal x, y # is it the same cycle? + 2:bool/raw <- equal y, y2 # is it still a cycle? + 3:bool/raw <- equal x, y # is it the same cycle? ] +mem: storing 34 in location 1 # deep copy also contains a cycle -- cgit 1.4.1-2-gfad0