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

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

Issue 1221503004: Reclaim the CreatedFromSnapshot bit and use it to indicate VM Heap object (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address-code-review-comments Created 5 years, 4 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 | « runtime/vm/snapshot.h ('k') | tests/isolate/isolate.status » ('j') | 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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 isolate, UnhandledException::New(Instance::Cast(result), stacktrace)); 318 isolate, UnhandledException::New(Instance::Cast(result), stacktrace));
319 isolate->long_jump_base()->Jump(1, error); 319 isolate->long_jump_base()->Jump(1, error);
320 } 320 }
321 321
322 322
323 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const { 323 RawObject* SnapshotReader::VmIsolateSnapshotObject(intptr_t index) const {
324 return Object::vm_isolate_snapshot_object_table().At(index); 324 return Object::vm_isolate_snapshot_object_table().At(index);
325 } 325 }
326 326
327 327
328 bool SnapshotReader::is_vm_isolate() const {
329 return isolate_ == Dart::vm_isolate();
330 }
331
332
328 RawObject* SnapshotReader::ReadObjectImpl(bool as_reference, 333 RawObject* SnapshotReader::ReadObjectImpl(bool as_reference,
329 intptr_t patch_object_id, 334 intptr_t patch_object_id,
330 intptr_t patch_offset) { 335 intptr_t patch_offset) {
331 int64_t header_value = Read<int64_t>(); 336 int64_t header_value = Read<int64_t>();
332 if ((header_value & kSmiTagMask) == kSmiTag) { 337 if ((header_value & kSmiTagMask) == kSmiTag) {
333 return NewInteger(header_value); 338 return NewInteger(header_value);
334 } 339 }
335 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin)); 340 ASSERT((header_value <= kIntptrMax) && (header_value >= kIntptrMin));
336 return ReadObjectImpl(static_cast<intptr_t>(header_value), 341 return ReadObjectImpl(static_cast<intptr_t>(header_value),
337 as_reference, 342 as_reference,
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 case kExternalTypedData##clazz##Cid: \ 461 case kExternalTypedData##clazz##Cid: \
457 462
458 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 463 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
459 tags = RawObject::ClassIdTag::update(class_id, tags); 464 tags = RawObject::ClassIdTag::update(class_id, tags);
460 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); 465 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_);
461 break; 466 break;
462 } 467 }
463 #undef SNAPSHOT_READ 468 #undef SNAPSHOT_READ
464 default: UNREACHABLE(); break; 469 default: UNREACHABLE(); break;
465 } 470 }
466 if (kind_ == Snapshot::kFull) {
467 pobj_.SetCreatedFromSnapshot();
468 }
469 return pobj_.raw(); 471 return pobj_.raw();
470 } 472 }
471 473
472 474
473 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id, 475 RawObject* SnapshotReader::ReadInlinedObject(intptr_t object_id,
474 intptr_t class_header, 476 intptr_t class_header,
475 intptr_t tags, 477 intptr_t tags,
476 intptr_t patch_object_id, 478 intptr_t patch_object_id,
477 intptr_t patch_offset) { 479 intptr_t patch_offset) {
478 // Lookup the class based on the class header information. 480 // Lookup the class based on the class header information.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // snapshot (kFull, kScript) with asserts. 531 // snapshot (kFull, kScript) with asserts.
530 offset += kWordSize; 532 offset += kWordSize;
531 } 533 }
532 if (kind_ == Snapshot::kFull) { 534 if (kind_ == Snapshot::kFull) {
533 // We create an uninitialized object in the case of full snapshots, so 535 // We create an uninitialized object in the case of full snapshots, so
534 // we need to initialize any remaining padding area with the Null object. 536 // we need to initialize any remaining padding area with the Null object.
535 while (offset < instance_size) { 537 while (offset < instance_size) {
536 result->SetFieldAtOffset(offset, Object::null_object()); 538 result->SetFieldAtOffset(offset, Object::null_object());
537 offset += kWordSize; 539 offset += kWordSize;
538 } 540 }
539 result->SetCreatedFromSnapshot(); 541 }
540 } else if (RawObject::IsCanonical(tags)) { 542 if (RawObject::IsCanonical(tags)) {
541 *result = result->CheckAndCanonicalize(NULL); 543 if (kind_ == Snapshot::kFull) {
542 ASSERT(!result->IsNull()); 544 result->SetCanonical();
545 } else {
546 *result = result->CheckAndCanonicalize(NULL);
547 ASSERT(!result->IsNull());
548 }
543 } 549 }
544 return result->raw(); 550 return result->raw();
545 } else if (header_id == kStaticImplicitClosureObjectId) { 551 } else if (header_id == kStaticImplicitClosureObjectId) {
546 // We do not use the tags as the implicit static closure 552 // We do not use the tags as the implicit static closure
547 // is going to be created in this isolate or the canonical 553 // is going to be created in this isolate or the canonical
548 // version already created in the isolate will be used. 554 // version already created in the isolate will be used.
549 return ReadStaticImplicitClosure(object_id, class_header); 555 return ReadStaticImplicitClosure(object_id, class_header);
550 } 556 }
551 ASSERT((class_header & kSmiTagMask) != kSmiTag); 557 ASSERT((class_header & kSmiTagMask) != kSmiTag);
552 intptr_t class_id = LookupInternalClass(class_header); 558 intptr_t class_id = LookupInternalClass(class_header);
(...skipping 18 matching lines...) Expand all
571 case kExternalTypedData##clazz##Cid: \ 577 case kExternalTypedData##clazz##Cid: \
572 578
573 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) { 579 CLASS_LIST_TYPED_DATA(SNAPSHOT_READ) {
574 tags = RawObject::ClassIdTag::update(class_id, tags); 580 tags = RawObject::ClassIdTag::update(class_id, tags);
575 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_); 581 pobj_ = ExternalTypedData::ReadFrom(this, object_id, tags, kind_);
576 break; 582 break;
577 } 583 }
578 #undef SNAPSHOT_READ 584 #undef SNAPSHOT_READ
579 default: UNREACHABLE(); break; 585 default: UNREACHABLE(); break;
580 } 586 }
581 if (kind_ == Snapshot::kFull) {
582 pobj_.SetCreatedFromSnapshot();
583 }
584 AddPatchRecord(object_id, patch_object_id, patch_offset); 587 AddPatchRecord(object_id, patch_object_id, patch_offset);
585 return pobj_.raw(); 588 return pobj_.raw();
586 } 589 }
587 590
588 591
589 void SnapshotReader::AddBackRef(intptr_t id, 592 void SnapshotReader::AddBackRef(intptr_t id,
590 Object* obj, 593 Object* obj,
591 DeserializeState state, 594 DeserializeState state,
592 bool defer_canonicalization) { 595 bool defer_canonicalization) {
593 intptr_t index = (id - kMaxPredefinedObjectIds); 596 intptr_t index = (id - kMaxPredefinedObjectIds);
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 object_store()->preallocated_unhandled_exception()); 1067 object_store()->preallocated_unhandled_exception());
1065 Isolate::Current()->long_jump_base()->Jump(1, error); 1068 Isolate::Current()->long_jump_base()->Jump(1, error);
1066 } 1069 }
1067 VerifiedMemory::Accept(address, size); 1070 VerifiedMemory::Accept(address, size);
1068 1071
1069 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag); 1072 RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
1070 uword tags = 0; 1073 uword tags = 0;
1071 ASSERT(class_id != kIllegalCid); 1074 ASSERT(class_id != kIllegalCid);
1072 tags = RawObject::ClassIdTag::update(class_id, tags); 1075 tags = RawObject::ClassIdTag::update(class_id, tags);
1073 tags = RawObject::SizeTag::update(size, tags); 1076 tags = RawObject::SizeTag::update(size, tags);
1077 tags = RawObject::VMHeapObjectTag::update(is_vm_isolate(), tags);
1074 raw_obj->ptr()->tags_ = tags; 1078 raw_obj->ptr()->tags_ = tags;
1075 return raw_obj; 1079 return raw_obj;
1076 } 1080 }
1077 1081
1078 1082
1079 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) { 1083 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) {
1080 intptr_t object_id = GetVMIsolateObjectId(header_value); 1084 intptr_t object_id = GetVMIsolateObjectId(header_value);
1081 if (object_id == kNullObject) { 1085 if (object_id == kNullObject) {
1082 // This is a singleton null object, return it. 1086 // This is a singleton null object, return it.
1083 return Object::null(); 1087 return Object::null();
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1206 }
1203 } 1207 }
1204 } 1208 }
1205 } 1209 }
1206 1210
1207 1211
1208 void SnapshotReader::ArrayReadFrom(intptr_t object_id, 1212 void SnapshotReader::ArrayReadFrom(intptr_t object_id,
1209 const Array& result, 1213 const Array& result,
1210 intptr_t len, 1214 intptr_t len,
1211 intptr_t tags) { 1215 intptr_t tags) {
1212 // Set the object tags.
1213 result.set_tags(tags);
1214
1215 // Setup the object fields. 1216 // Setup the object fields.
1216 const intptr_t typeargs_offset = 1217 const intptr_t typeargs_offset =
1217 GrowableObjectArray::type_arguments_offset() / kWordSize; 1218 GrowableObjectArray::type_arguments_offset() / kWordSize;
1218 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject, 1219 *TypeArgumentsHandle() ^= ReadObjectImpl(kAsInlinedObject,
1219 object_id, 1220 object_id,
1220 typeargs_offset); 1221 typeargs_offset);
1221 result.SetTypeArguments(*TypeArgumentsHandle()); 1222 result.SetTypeArguments(*TypeArgumentsHandle());
1222 1223
1223 bool as_reference = RawObject::IsCanonical(tags) ? false : true; 1224 bool as_reference = RawObject::IsCanonical(tags) ? false : true;
1224 intptr_t offset = result.raw_ptr()->data() - 1225 intptr_t offset = result.raw_ptr()->data() -
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
2046 } 2047 }
2047 } 2048 }
2048 first_unprocessed_object_id_ = next_object_id(); 2049 first_unprocessed_object_id_ = next_object_id();
2049 } 2050 }
2050 2051
2051 2052
2052 void SnapshotWriter::WriteClassId(RawClass* cls) { 2053 void SnapshotWriter::WriteClassId(RawClass* cls) {
2053 ASSERT(kind_ != Snapshot::kFull); 2054 ASSERT(kind_ != Snapshot::kFull);
2054 int class_id = cls->ptr()->id_; 2055 int class_id = cls->ptr()->id_;
2055 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id)); 2056 ASSERT(!IsSingletonClassId(class_id) && !IsObjectStoreClassId(class_id));
2056 // TODO(5411462): Should restrict this to only core-lib classes in this
2057 // case.
2058 // Write out the class and tags information.
2059 WriteVMIsolateObject(kClassCid);
2060 WriteTags(GetObjectTags(cls));
2061 2057
2062 // Write out the library url and class name. 2058 // Write out the library url and class name.
2063 RawLibrary* library = cls->ptr()->library_; 2059 RawLibrary* library = cls->ptr()->library_;
2064 ASSERT(library != Library::null()); 2060 ASSERT(library != Library::null());
2065 WriteObjectImpl(library->ptr()->url_, kAsInlinedObject); 2061 WriteObjectImpl(library->ptr()->url_, kAsInlinedObject);
2066 WriteObjectImpl(cls->ptr()->name_, kAsInlinedObject); 2062 WriteObjectImpl(cls->ptr()->name_, kAsInlinedObject);
2067 } 2063 }
2068 2064
2069 2065
2070 void SnapshotWriter::WriteStaticImplicitClosure(intptr_t object_id, 2066 void SnapshotWriter::WriteStaticImplicitClosure(intptr_t object_id,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
2406 NoSafepointScope no_safepoint; 2402 NoSafepointScope no_safepoint;
2407 WriteObject(obj.raw()); 2403 WriteObject(obj.raw());
2408 UnmarkAll(); 2404 UnmarkAll();
2409 } else { 2405 } else {
2410 ThrowException(exception_type(), exception_msg()); 2406 ThrowException(exception_type(), exception_msg());
2411 } 2407 }
2412 } 2408 }
2413 2409
2414 2410
2415 } // namespace dart 2411 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/snapshot.h ('k') | tests/isolate/isolate.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698