From 8f4549ec0fdb70f57436801c0685c273685df8d0 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 13 Sep 2017 22:23:01 -0700 Subject: 3996 --- 071deep_copy.cc | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/071deep_copy.cc b/071deep_copy.cc index d403200b..a19ca99f 100644 --- a/071deep_copy.cc +++ b/071deep_copy.cc @@ -20,6 +20,16 @@ def main [ # non-address primitives are identical +mem: storing 1 in location 10 +:(scenario deep_copy_null_pointer) +def main [ + local-scope + x:&:num <- copy 0 + y:&:num <- deep-copy x + 10:bool/raw <- equal x, y +] +# null addresses are identical ++mem: storing 1 in location 10 + :(scenario deep_copy_container_without_address) container foo [ x:num @@ -247,7 +257,7 @@ vector deep_copy(reagent/*copy*/ in, map& addresses_copied, co // deep-copy an address and return a new address int deep_copy_address(const reagent& canonized_in, map& addresses_copied, const reagent& tmp) { - if (canonized_in.value == 0) return 0; + if (address_value(canonized_in) == 0) return 0; int in_address = payload_address(canonized_in); trace(9991, "run") << "deep-copy: copying address " << in_address << end(); if (contains_key(addresses_copied, in_address)) { @@ -312,6 +322,13 @@ int payload_address(reagent/*copy*/ x) { return x.value; } +int address_value(const reagent& x) { + assert(is_mu_address(x)); + vector result = read_memory(x); + assert(SIZE(result) == 1); + return static_cast(result.at(0)); +} + :(scenario deep_copy_stress_test_1) container foo1 [ p:&:num -- cgit 1.4.1-2-gfad0