From be6b24929b5327fc68ac62530ce62988e2e7c486 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Wed, 29 Jun 2016 15:29:41 -0700 Subject: 3078 --- 073deep_copy.cc | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/073deep_copy.cc b/073deep_copy.cc index 3fb17602..57524cfe 100644 --- a/073deep_copy.cc +++ b/073deep_copy.cc @@ -94,10 +94,12 @@ case DEEP_COPY: { case DEEP_COPY: { const reagent& input = current_instruction().ingredients.at(0); // allocate a tiny bit of temporary space for deep_copy() + trace(9991, "run") << "deep-copy: allocating space for temporary" << end(); reagent tmp("tmp:address:number"); tmp.value = allocate(1); products.push_back(deep_copy(input, tmp)); // reclaim Mu memory allocated for tmp + trace(9991, "run") << "deep-copy: reclaiming temporary" << end(); abandon(tmp.value, tmp.type->right, payload_size(tmp)); // reclaim host memory allocated for tmp.type when tmp goes out of scope break; @@ -112,32 +114,38 @@ vector deep_copy(reagent/*copy*/ in, reagent& tmp) { result.push_back(deep_copy_address(in, addresses_copied, tmp)); else deep_copy(in, addresses_copied, result); + trace(9991, "run") << "deep-copy: done" << end(); return result; } // deep-copy an address and return a new address -int deep_copy_address(reagent/*copy*/ canonized_in, map& addresses_copied, reagent& tmp) { +int deep_copy_address(const reagent& canonized_in, map& addresses_copied, const reagent& tmp) { int in_address = canonized_in.value; if (in_address == 0) return 0; + trace(9991, "run") << "deep-copy: copying address " << in_address << end(); if (contains_key(addresses_copied, in_address)) return get(addresses_copied, in_address); // TODO: what about address:address:___? Should deep-copy be doing multiple // lookups? If the goal is to eliminate all common addresses, yes. reagent/*copy*/ payload = canonized_in; payload.properties.push_back(pair("lookup", NULL)); - canonize(payload); int out = allocate(size_of(payload)); - const type_info& info = get(Type, payload.type->value); + reagent/*copy*/ payload_type = payload; + canonize_type(payload_type); + const type_info& info = get(Type, payload_type.type->value); switch (info.kind) { case PRIMITIVE: { - canonized_in.properties.push_back(pair("lookup", NULL)); - vector data = read_memory(canonized_in); - reagent/*copy*/ out_payload = canonized_in; + trace(9991, "run") << "deep-copy: reading ingredient " << payload.value << ' ' << to_string(payload) << end(); + vector data = read_memory(payload); + trace(9991, "run") << "deep-copy: writing result " << out << end(); + reagent/*copy*/ out_payload = payload; // HACK: write_memory interface isn't ideal for this situation; we need // a temporary location to help copy the payload. put(Memory, tmp.value, out); out_payload.value = tmp.value; + trace(9991, "run") << "deep-copy: really writing to " << out_payload.value << ' ' << to_string(out_payload) << end(); write_memory(out_payload, data, -1); + trace(9991, "run") << "deep-copy: output is " << to_string(data) << end(); break; } case CONTAINER: -- cgit 1.4.1-2-gfad0