Chromium Code Reviews| Index: runtime/vm/object.cc |
| diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc |
| index ff4d497e028904dd7478c0b7ddcf670d2f81de9c..1e47f62cc3bfeb10cd823a988415d4ce3cd2f63a 100644 |
| --- a/runtime/vm/object.cc |
| +++ b/runtime/vm/object.cc |
| @@ -14455,9 +14455,12 @@ RawInstance* Instance::CheckAndCanonicalize(const char** error_str) const { |
| if (!CheckAndCanonicalizeFields(error_str)) { |
| return Instance::null(); |
| } |
| - Instance& result = Instance::Handle(); |
| - const Class& cls = Class::Handle(this->clazz()); |
| - Array& constants = Array::Handle(cls.constants()); |
| + Thread* thread = Thread::Current(); |
| + Zone* zone = thread->zone(); |
| + Isolate* isolate = thread->isolate(); |
| + Instance& result = Instance::Handle(zone); |
| + const Class& cls = Class::Handle(zone, this->clazz()); |
| + Array& constants = Array::Handle(zone, cls.constants()); |
| const intptr_t constants_len = constants.Length(); |
| // Linear search to see whether this value is already present in the |
| // list of canonicalized constants. |
| @@ -14476,7 +14479,8 @@ RawInstance* Instance::CheckAndCanonicalize(const char** error_str) const { |
| // The value needs to be added to the list. Grow the list if |
| // it is full. |
| result ^= this->raw(); |
| - if (result.IsNew()) { |
| + if (result.IsNew() || |
| + (result.InVMHeap() && (isolate != Dart::vm_isolate()))) { |
| // Create a canonical object in old space. |
|
srdjan
2015/10/05 18:06:36
Maybe comment here briefly why this is necessary.
siva
2015/10/05 21:51:05
Done.
|
| result ^= Object::Clone(result, Heap::kOld); |
| } |