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

Unified Diff: runtime/vm/raw_object_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 01aef3ad7f406e500646a74d0b1f266dc5724e20..9a12d08f26e9b3593679cc3ff3ff719424f07f91 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -31,8 +31,9 @@ RawClass* Class::ReadFrom(SnapshotReader* reader,
ASSERT(reader != NULL);
Class& cls = Class::ZoneHandle(reader->zone(), Class::null());
+ bool is_in_fullsnapshot = reader->Read<bool>();
if ((kind == Snapshot::kFull) ||
- (kind == Snapshot::kScript && !RawObject::IsCreatedFromSnapshot(tags))) {
+ (kind == Snapshot::kScript && !is_in_fullsnapshot)) {
// Read in the base information.
classid_t class_id = reader->ReadClassIDValue();
@@ -49,9 +50,6 @@ RawClass* Class::ReadFrom(SnapshotReader* reader,
}
reader->AddBackRef(object_id, &cls, kIsDeserialized);
- // Set the object tags.
- cls.set_tags(tags);
-
// Set all non object fields.
if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
// Instance size of a VM defined class is already set up.
@@ -76,8 +74,10 @@ RawClass* Class::ReadFrom(SnapshotReader* reader,
cls.StorePointer((cls.raw()->from() + i),
reader->PassiveObjectHandle()->raw());
}
+ ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull));
} else {
cls ^= reader->ReadClassId(object_id);
+ ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot());
}
return cls.raw();
}
@@ -87,17 +87,22 @@ void RawClass::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
+ bool is_in_fullsnapshot = Class::IsInFullSnapshot(this);
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
- if ((kind == Snapshot::kFull) ||
- (kind == Snapshot::kScript &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) {
- // Write out the class and tags information.
- writer->WriteVMIsolateObject(kClassCid);
- writer->WriteTags(writer->GetObjectTags(this));
+ // Write out the class and tags information.
+ writer->WriteVMIsolateObject(kClassCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+ // Write out the boolean is_in_fullsnapshot first as this will
+ // help the reader decide how the rest of the information needs
+ // to be interpreted.
+ writer->Write<bool>(is_in_fullsnapshot);
+
+ if ((kind == Snapshot::kFull) ||
+ (kind == Snapshot::kScript && !is_in_fullsnapshot)) {
// Write out all the non object pointer fields.
// NOTE: cpp_vtable_ is not written.
classid_t class_id = ptr()->id_;
@@ -144,9 +149,6 @@ RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(UnresolvedClass));
reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized);
- // Set the object tags.
- unresolved_class.set_tags(tags);
-
// Set all non object fields.
unresolved_class.set_token_pos(reader->Read<int32_t>());
@@ -229,11 +231,9 @@ RawType* Type::ReadFrom(SnapshotReader* reader,
reader->PassiveObjectHandle()->raw());
}
- // Set the object tags.
- type.set_tags(tags);
- if (defer_canonicalization) {
- // We are deferring canonicalization so mark object as not canonical.
- type.ClearCanonical();
+ // Set the canonical bit.
+ if (!defer_canonicalization && RawObject::IsCanonical(tags)) {
+ type.SetCanonical();
}
return type.raw();
@@ -248,6 +248,7 @@ void RawType::WriteTo(SnapshotWriter* writer,
// Only resolved and finalized types should be written to a snapshot.
ASSERT((ptr()->type_state_ == RawType::kFinalizedInstantiated) ||
(ptr()->type_state_ == RawType::kFinalizedUninstantiated));
+ ASSERT(ptr()->type_class_ != Object::null());
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -263,6 +264,7 @@ void RawType::WriteTo(SnapshotWriter* writer,
// Write out all the object pointer fields. Since we will be canonicalizing
// the type object when reading it back we should write out all the fields
// inline and not as references.
+ ASSERT(ptr()->type_class_ != Object::null());
SnapshotWriterVisitor visitor(writer);
visitor.VisitPointers(from(), to());
}
@@ -279,9 +281,6 @@ RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(TypeRef));
reader->AddBackRef(object_id, &type_ref, kIsDeserialized);
- // Set the object tags.
- type_ref.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -327,9 +326,6 @@ RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(TypeParameter));
reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
- // Set the object tags.
- type_parameter.set_tags(tags);
-
// Set all non object fields.
type_parameter.set_token_pos(reader->Read<int32_t>());
type_parameter.set_index(reader->Read<int16_t>());
@@ -389,9 +385,6 @@ RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(BoundedType));
reader->AddBackRef(object_id, &bounded_type, kIsDeserialized);
- // Set the object tags.
- bounded_type.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -478,11 +471,9 @@ RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader,
type_arguments.SetTypeAt(i, *reader->TypeHandle());
}
- // Set the object tags .
- type_arguments.set_tags(tags);
- if (defer_canonicalization) {
- // We are deferring canonicalization so mark object as not canonical.
- type_arguments.ClearCanonical();
+ // Set the canonical bit.
+ if (!defer_canonicalization && RawObject::IsCanonical(tags)) {
+ type_arguments.SetCanonical();
}
return type_arguments.raw();
@@ -522,18 +513,12 @@ RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
// Allocate function object.
PatchClass& cls = PatchClass::ZoneHandle(reader->zone(),
NEW_OBJECT(PatchClass));
reader->AddBackRef(object_id, &cls, kIsDeserialized);
- // Set the object tags.
- cls.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -543,6 +528,9 @@ RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
cls.StorePointer((cls.raw()->from() + i),
reader->PassiveObjectHandle()->raw());
}
+ ASSERT(((kind == Snapshot::kScript) &&
+ !Class::IsInFullSnapshot(cls.source_class())) ||
+ (kind == Snapshot::kFull));
return cls.raw();
}
@@ -552,9 +540,7 @@ void RawPatchClass::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -573,18 +559,13 @@ RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate closure data object.
ClosureData& data = ClosureData::ZoneHandle(
reader->zone(), NEW_OBJECT(ClosureData));
reader->AddBackRef(object_id, &data, kIsDeserialized);
- // Set the object tags.
- data.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -601,9 +582,7 @@ void RawClosureData::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -633,18 +612,13 @@ RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate redirection data object.
RedirectionData& data = RedirectionData::ZoneHandle(
reader->zone(), NEW_OBJECT(RedirectionData));
reader->AddBackRef(object_id, &data, kIsDeserialized);
- // Set the object tags.
- data.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -665,9 +639,7 @@ void RawRedirectionData::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -687,18 +659,13 @@ RawFunction* Function::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate function object.
Function& func = Function::ZoneHandle(
reader->zone(), NEW_OBJECT(Function));
reader->AddBackRef(object_id, &func, kIsDeserialized);
- // Set the object tags.
- func.set_tags(tags);
-
// Set all the non object fields.
func.set_token_pos(reader->Read<int32_t>());
func.set_end_token_pos(reader->Read<int32_t>());
@@ -734,9 +701,7 @@ void RawFunction::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -768,17 +733,12 @@ RawField* Field::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate field object.
Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field));
reader->AddBackRef(object_id, &field, kIsDeserialized);
- // Set the object tags.
- field.set_tags(tags);
-
// Set all non object fields.
field.set_token_pos(reader->Read<int32_t>());
field.set_guarded_cid(reader->Read<int32_t>());
@@ -807,9 +767,7 @@ void RawField::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -842,9 +800,6 @@ RawLiteralToken* LiteralToken::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(LiteralToken));
reader->AddBackRef(object_id, &literal_token, kIsDeserialized);
- // Set the object tags.
- literal_token.set_tags(tags);
-
// Read the token attributes.
Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>());
literal_token.set_kind(token_kind);
@@ -890,9 +845,7 @@ RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Read the length so that we can determine number of tokens to read.
intptr_t len = reader->ReadSmiValue();
@@ -902,9 +855,6 @@ RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT_WITH_LEN(TokenStream, len));
reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
- // Set the object tags.
- token_stream.set_tags(tags);
-
// Read the stream of tokens into the TokenStream object for script
// snapshots as we made a copy of token stream.
if (kind == Snapshot::kScript) {
@@ -928,9 +878,7 @@ void RawTokenStream::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -957,17 +905,12 @@ RawScript* Script::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate script object.
Script& script = Script::ZoneHandle(reader->zone(), NEW_OBJECT(Script));
reader->AddBackRef(object_id, &script, kIsDeserialized);
- // Set the object tags.
- script.set_tags(tags);
-
script.StoreNonPointer(&script.raw_ptr()->line_offset_,
reader->Read<int32_t>());
script.StoreNonPointer(&script.raw_ptr()->col_offset_,
@@ -997,9 +940,7 @@ void RawScript::WriteTo(SnapshotWriter* writer,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
ASSERT(tokens_ != TokenStream::null());
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -1029,18 +970,16 @@ RawLibrary* Library::ReadFrom(SnapshotReader* reader,
Library& library = Library::ZoneHandle(reader->zone(), Library::null());
reader->AddBackRef(object_id, &library, kIsDeserialized);
- if ((kind == Snapshot::kScript) && RawObject::IsCreatedFromSnapshot(tags)) {
- ASSERT(kind != Snapshot::kFull);
+ bool is_in_fullsnapshot = reader->Read<bool>();
+ if ((kind == Snapshot::kScript) && is_in_fullsnapshot) {
// Lookup the object as it should already exist in the heap.
*reader->StringHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
library = Library::LookupLibrary(*reader->StringHandle());
+ ASSERT(library.is_in_fullsnapshot());
} else {
// Allocate library object.
library = NEW_OBJECT(Library);
- // Set the object tags.
- library.set_tags(tags);
-
// Set all non object fields.
library.StoreNonPointer(&library.raw_ptr()->index_,
reader->ReadClassIDValue());
@@ -1056,6 +995,11 @@ RawLibrary* Library::ReadFrom(SnapshotReader* reader,
reader->Read<bool>());
library.StoreNonPointer(&library.raw_ptr()->debuggable_,
reader->Read<bool>());
+ if (kind == Snapshot::kFull) {
+ is_in_fullsnapshot = true;
+ }
+ library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_,
+ is_in_fullsnapshot);
// The native resolver and symbolizer are not serialized.
library.set_native_entry_resolver(NULL);
library.set_native_entry_symbol_resolver(NULL);
@@ -1092,12 +1036,16 @@ void RawLibrary::WriteTo(SnapshotWriter* writer,
writer->WriteVMIsolateObject(kLibraryCid);
writer->WriteTags(writer->GetObjectTags(this));
- if ((kind == Snapshot::kScript) &&
- RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) {
- ASSERT(kind != Snapshot::kFull);
+ // Write out the boolean is_in_fullsnapshot_ first as this will
+ // help the reader decide how the rest of the information needs
+ // to be interpreted.
+ writer->Write<bool>(ptr()->is_in_fullsnapshot_);
+
+ if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) {
// Write out library URL so that it can be looked up when reading.
writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject);
} else {
+ ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_);
// Write out all non object fields.
writer->WriteClassIDValue(ptr()->index_);
writer->WriteClassIDValue(ptr()->num_anonymous_);
@@ -1124,18 +1072,13 @@ RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate library prefix object.
LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
reader->zone(), NEW_OBJECT(LibraryPrefix));
reader->AddBackRef(object_id, &prefix, kIsDeserialized);
- // Set the object tags.
- prefix.set_tags(tags);
-
// Set all non object fields.
prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
reader->Read<int16_t>());
@@ -1161,9 +1104,7 @@ void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -1188,18 +1129,13 @@ RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(tags)) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Allocate Namespace object.
Namespace& ns = Namespace::ZoneHandle(
reader->zone(), NEW_OBJECT(Namespace));
reader->AddBackRef(object_id, &ns, kIsDeserialized);
- // Set the object tags.
- ns.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -1218,9 +1154,7 @@ void RawNamespace::WriteTo(SnapshotWriter* writer,
intptr_t object_id,
Snapshot::Kind kind) {
ASSERT(writer != NULL);
- ASSERT(((kind == Snapshot::kScript) &&
- !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) ||
- (kind == Snapshot::kFull));
+ ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
// Write out the serialization header value for this object.
writer->WriteInlinedObjectHeader(object_id);
@@ -1296,9 +1230,6 @@ RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
PcDescriptors::New(length));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
if (result.Length() > 0) {
NoSafepointScope no_safepoint;
intptr_t len = result.Length();
@@ -1343,9 +1274,6 @@ RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
Stackmap::New(length, register_bit_count, pc_offset));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
if (result.Length() > 0) {
NoSafepointScope no_safepoint;
intptr_t len = (result.Length() + 7) / 8;
@@ -1390,9 +1318,6 @@ RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader,
LocalVarDescriptors::New(num_entries));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
for (intptr_t i = 0; i < num_entries; i++) {
(*reader->StringHandle()) ^= reader->ReadObjectImpl(kAsReference);
result.StorePointer(result.raw()->nameAddrAt(i),
@@ -1446,9 +1371,6 @@ RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
ExceptionHandlers::New(*reader->ArrayHandle()));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
if (result.num_entries() > 0) {
NoSafepointScope no_safepoint;
const intptr_t len =
@@ -1496,9 +1418,6 @@ RawContext* Context::ReadFrom(SnapshotReader* reader,
} else {
context ^= NEW_OBJECT_WITH_LEN(Context, num_vars);
- // Set the object tags.
- context.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -1627,9 +1546,6 @@ RawApiError* ApiError::ReadFrom(SnapshotReader* reader,
ApiError::ZoneHandle(reader->zone(), NEW_OBJECT(ApiError));
reader->AddBackRef(object_id, &api_error, kIsDeserialized);
- // Set the object tags.
- api_error.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -1673,9 +1589,6 @@ RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader,
LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError));
reader->AddBackRef(object_id, &language_error, kIsDeserialized);
- // Set the object tags.
- language_error.set_tags(tags);
-
// Set all non object fields.
language_error.set_token_pos(reader->Read<int32_t>());
language_error.set_kind(reader->Read<uint8_t>());
@@ -1725,9 +1638,6 @@ RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
reader->zone(), NEW_OBJECT(UnhandledException));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -1784,26 +1694,20 @@ RawInstance* Instance::ReadFrom(SnapshotReader* reader,
Instance& obj = Instance::ZoneHandle(reader->zone(), Instance::null());
if (kind == Snapshot::kFull) {
obj = reader->NewInstance();
+ // Set the canonical bit.
+ if (RawObject::IsCanonical(tags)) {
+ obj.SetCanonical();
+ }
} else {
obj ^= Object::Allocate(kInstanceCid,
Instance::InstanceSize(),
HEAP_SPACE(kind));
- // When reading a script snapshot we need to canonicalize only those object
- // references that are objects from the core library (loaded from a
- // full snapshot). Objects that are only in the script need not be
- // canonicalized as they are already canonical.
- // When reading a message snapshot we always have to canonicalize.
- if (RawObject::IsCanonical(tags) &&
- (RawObject::IsCreatedFromSnapshot(tags) ||
- (kind == Snapshot::kMessage))) {
+ if (RawObject::IsCanonical(tags)) {
obj = obj.CheckAndCanonicalize(NULL);
}
}
reader->AddBackRef(object_id, &obj, kIsDeserialized);
- // Set the object tags.
- obj.set_tags(tags);
-
return obj.raw();
}
@@ -1844,25 +1748,21 @@ RawInteger* Mint::ReadFrom(SnapshotReader* reader,
Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null());
if (kind == Snapshot::kFull) {
mint = reader->NewMint(value);
- // Set the object tags.
- mint.set_tags(tags);
+ // Set the canonical bit.
+ if (RawObject::IsCanonical(tags)) {
+ mint.SetCanonical();
+ }
} else {
// When reading a script snapshot we need to canonicalize only those object
// references that are objects from the core library (loaded from a
// full snapshot). Objects that are only in the script need not be
// canonicalized as they are already canonical.
// When reading a message snapshot we always have to canonicalize.
- if (RawObject::IsCanonical(tags) &&
- (RawObject::IsCreatedFromSnapshot(tags) ||
- (kind == Snapshot::kMessage))) {
+ if (RawObject::IsCanonical(tags)) {
mint = Mint::NewCanonical(value);
- ASSERT(mint.IsCanonical() &&
- (kind == Snapshot::kMessage ||
- RawObject::IsCreatedFromSnapshot(mint.raw()->ptr()->tags_)));
+ ASSERT(mint.IsCanonical());
} else {
mint = Mint::New(value, HEAP_SPACE(kind));
- // Set the object tags.
- mint.set_tags(tags);
}
}
reader->AddBackRef(object_id, &mint, kIsDeserialized);
@@ -1910,25 +1810,17 @@ RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
// If it is a canonical constant make it one.
// When reading a full snapshot we don't need to canonicalize the object
// as it would already be a canonical object.
- // When reading a script snapshot we need to canonicalize only those object
- // references that are objects from the core library (loaded from a
- // full snapshot). Objects that are only in the script need not be
- // canonicalized as they are already canonical.
- // When reading a message snapshot we always have to canonicalize the object.
- if (kind == Snapshot::kFull) {
- // Set the object tags.
- obj.set_tags(tags);
- } else if (RawObject::IsCanonical(tags) &&
- (RawObject::IsCreatedFromSnapshot(tags) ||
- (kind == Snapshot::kMessage))) {
- obj ^= obj.CheckAndCanonicalize(NULL);
- ASSERT(!obj.IsNull());
- ASSERT(obj.IsCanonical() &&
- (kind == Snapshot::kMessage ||
- RawObject::IsCreatedFromSnapshot(obj.raw()->ptr()->tags_)));
- } else {
- // Set the object tags.
- obj.set_tags(tags);
+ // When reading a script snapshot or a message snapshot we always have
+ // to canonicalize the object.
+ if (RawObject::IsCanonical(tags)) {
+ if (kind == Snapshot::kFull) {
+ // Set the canonical bit.
+ obj.SetCanonical();
+ } else {
+ obj ^= obj.CheckAndCanonicalize(NULL);
+ ASSERT(!obj.IsNull());
+ ASSERT(obj.IsCanonical());
+ }
}
return obj.raw();
}
@@ -1965,23 +1857,20 @@ RawDouble* Double::ReadFrom(SnapshotReader* reader,
Double& dbl = Double::ZoneHandle(reader->zone(), Double::null());
if (kind == Snapshot::kFull) {
dbl = reader->NewDouble(value);
- // Set the object tags.
- dbl.set_tags(tags);
+ // Set the canonical bit.
+ if (RawObject::IsCanonical(tags)) {
+ dbl.SetCanonical();
+ }
} else {
// When reading a script snapshot we need to canonicalize only those object
// references that are objects from the core library (loaded from a
// full snapshot). Objects that are only in the script need not be
// canonicalized as they are already canonical.
- if (RawObject::IsCanonical(tags) &&
- RawObject::IsCreatedFromSnapshot(tags)) {
+ if (RawObject::IsCanonical(tags)) {
dbl = Double::NewCanonical(value);
- ASSERT(dbl.IsCanonical() &&
- (kind == Snapshot::kMessage ||
- RawObject::IsCreatedFromSnapshot(dbl.raw()->ptr()->tags_)));
+ ASSERT(dbl.IsCanonical());
} else {
dbl = Double::New(value, HEAP_SPACE(kind));
- // Set the object tags.
- dbl.set_tags(tags);
}
}
reader->AddBackRef(object_id, &dbl, kIsDeserialized);
@@ -2041,7 +1930,6 @@ void String::ReadFromImpl(SnapshotReader* reader,
} else {
// Set up the string object.
*str_obj = StringType::New(len, HEAP_SPACE(kind));
- str_obj->set_tags(tags);
str_obj->SetHash(0); // Will get computed when needed.
if (len == 0) {
return;
@@ -2072,7 +1960,9 @@ RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
ASSERT(Thread::Current()->no_safepoint_scope_depth() != 0);
RawOneByteString* obj = reader->NewOneByteString(len);
str_obj = obj;
- str_obj.set_tags(tags);
+ if (RawObject::IsCanonical(tags)) {
+ str_obj.SetCanonical();
+ }
str_obj.SetHash(hash);
if (len > 0) {
uint8_t* raw_ptr = CharAddr(str_obj, 0);
@@ -2101,7 +1991,9 @@ RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader,
if (kind == Snapshot::kFull) {
RawTwoByteString* obj = reader->NewTwoByteString(len);
str_obj = obj;
- str_obj.set_tags(tags);
+ if (RawObject::IsCanonical(tags)) {
+ str_obj.SetCanonical();
+ }
str_obj.SetHash(hash);
NoSafepointScope no_safepoint;
uint16_t* raw_ptr = (len > 0)? CharAddr(str_obj, 0) : NULL;
@@ -2290,7 +2182,11 @@ RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader,
}
reader->ArrayReadFrom(object_id, *array, len, tags);
if (RawObject::IsCanonical(tags)) {
- *array ^= array->CheckAndCanonicalize(NULL);
+ if (kind == Snapshot::kFull) {
+ array->SetCanonical();
+ } else {
+ *array ^= array->CheckAndCanonicalize(NULL);
+ }
}
return raw(*array);
}
@@ -2396,8 +2292,6 @@ RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind));
}
reader->AddBackRef(object_id, &map, kIsDeserialized);
- // Set the object tags.
- map.set_tags(tags);
// Read the type arguments.
const intptr_t typeargs_offset =
@@ -2509,8 +2403,6 @@ RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader,
simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
}
reader->AddBackRef(object_id, &simd, kIsDeserialized);
- // Set the object tags.
- simd.set_tags(tags);
return simd.raw();
}
@@ -2555,8 +2447,6 @@ RawInt32x4* Int32x4::ReadFrom(SnapshotReader* reader,
simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
}
reader->AddBackRef(object_id, &simd, kIsDeserialized);
- // Set the object tags.
- simd.set_tags(tags);
return simd.raw();
}
@@ -2599,8 +2489,6 @@ RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader,
simd = Float64x2::New(value0, value1, HEAP_SPACE(kind));
}
reader->AddBackRef(object_id, &simd, kIsDeserialized);
- // Set the object tags.
- simd.set_tags(tags);
return simd.raw();
}
@@ -2642,9 +2530,6 @@ RawTypedData* TypedData::ReadFrom(SnapshotReader* reader,
: TypedData::New(cid, len, HEAP_SPACE(kind)));
reader->AddBackRef(object_id, &result, kIsDeserialized);
- // Set the object tags.
- result.set_tags(tags);
-
// Setup the array elements.
intptr_t element_size = ElementSizeInBytes(cid);
intptr_t length_in_bytes = len * element_size;
@@ -2993,9 +2878,6 @@ RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader,
reader->zone(), JSRegExp::New(HEAP_SPACE(kind)));
reader->AddBackRef(object_id, &regex, kIsDeserialized);
- // Set the object tags.
- regex.set_tags(tags);
-
// Read and Set all the other fields.
regex.StoreSmi(&regex.raw_ptr()->num_bracket_expressions_,
reader->ReadAsSmi());
@@ -3043,9 +2925,6 @@ RawWeakProperty* WeakProperty::ReadFrom(SnapshotReader* reader,
reader->zone(), WeakProperty::New(HEAP_SPACE(kind)));
reader->AddBackRef(object_id, &weak_property, kIsDeserialized);
- // Set the object tags.
- weak_property.set_tags(tags);
-
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698