Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: runtime/vm/object.cc

Issue 1391433002: When a snapshot is generated on a 64 bit architecture and then read into a 32 bit architecture, val… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 14437 matching lines...) Expand 10 before | Expand all | Expand 10 after
14448 14448
14449 14449
14450 RawInstance* Instance::CheckAndCanonicalize(const char** error_str) const { 14450 RawInstance* Instance::CheckAndCanonicalize(const char** error_str) const {
14451 ASSERT(!IsNull()); 14451 ASSERT(!IsNull());
14452 if (this->IsCanonical()) { 14452 if (this->IsCanonical()) {
14453 return this->raw(); 14453 return this->raw();
14454 } 14454 }
14455 if (!CheckAndCanonicalizeFields(error_str)) { 14455 if (!CheckAndCanonicalizeFields(error_str)) {
14456 return Instance::null(); 14456 return Instance::null();
14457 } 14457 }
14458 Instance& result = Instance::Handle(); 14458 Thread* thread = Thread::Current();
14459 const Class& cls = Class::Handle(this->clazz()); 14459 Zone* zone = thread->zone();
14460 Array& constants = Array::Handle(cls.constants()); 14460 Isolate* isolate = thread->isolate();
14461 Instance& result = Instance::Handle(zone);
14462 const Class& cls = Class::Handle(zone, this->clazz());
14463 Array& constants = Array::Handle(zone, cls.constants());
14461 const intptr_t constants_len = constants.Length(); 14464 const intptr_t constants_len = constants.Length();
14462 // Linear search to see whether this value is already present in the 14465 // Linear search to see whether this value is already present in the
14463 // list of canonicalized constants. 14466 // list of canonicalized constants.
14464 intptr_t index = 0; 14467 intptr_t index = 0;
14465 while (index < constants_len) { 14468 while (index < constants_len) {
14466 result ^= constants.At(index); 14469 result ^= constants.At(index);
14467 if (result.IsNull()) { 14470 if (result.IsNull()) {
14468 break; 14471 break;
14469 } 14472 }
14470 if (this->CanonicalizeEquals(result)) { 14473 if (this->CanonicalizeEquals(result)) {
14471 ASSERT(result.IsCanonical()); 14474 ASSERT(result.IsCanonical());
14472 return result.raw(); 14475 return result.raw();
14473 } 14476 }
14474 index++; 14477 index++;
14475 } 14478 }
14476 // The value needs to be added to the list. Grow the list if 14479 // The value needs to be added to the list. Grow the list if
14477 // it is full. 14480 // it is full.
14478 result ^= this->raw(); 14481 result ^= this->raw();
14479 if (result.IsNew()) { 14482 if (result.IsNew() ||
14483 (result.InVMHeap() && (isolate != Dart::vm_isolate()))) {
14484 /**
14485 * When a snapshot is generated on a 64 bit architecture and then read
14486 * into a 32 bit architecture, values which are Smi on the 64 bit
14487 * architecture could potentially be converted to Mint objects, however
14488 * since Smi values do not have any notion of canonical bits we lose
14489 * that information when the object becomes a Mint.
14490 * Some of these values could be literal values and end up in the
14491 * VM isolate heap. Later when these values are referenced in a
14492 * constant list we try to ensure that all the objects in the list
14493 * are canonical and try to canonicalize them. When these Mint objects
14494 * are encountered they do not have the canonical bit set and
14495 * canonicalizing them won't work as the VM heap is read only now.
14496 * In these cases we clone the object into the isolate and then
14497 * canonicalize it.
14498 */
14480 // Create a canonical object in old space. 14499 // Create a canonical object in old space.
14481 result ^= Object::Clone(result, Heap::kOld); 14500 result ^= Object::Clone(result, Heap::kOld);
14482 } 14501 }
14483 ASSERT(result.IsOld()); 14502 ASSERT(result.IsOld());
14484 cls.InsertCanonicalConstant(index, result); 14503 cls.InsertCanonicalConstant(index, result);
14485 result.SetCanonical(); 14504 result.SetCanonical();
14486 return result.raw(); 14505 return result.raw();
14487 } 14506 }
14488 14507
14489 14508
(...skipping 7001 matching lines...) Expand 10 before | Expand all | Expand 10 after
21491 return tag_label.ToCString(); 21510 return tag_label.ToCString();
21492 } 21511 }
21493 21512
21494 21513
21495 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 21514 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
21496 Instance::PrintJSONImpl(stream, ref); 21515 Instance::PrintJSONImpl(stream, ref);
21497 } 21516 }
21498 21517
21499 21518
21500 } // namespace dart 21519 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698