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

Unified Diff: vm/raw_object_snapshot.cc

Issue 8879063: Changes to set up the object tag bits (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: '' Created 9 years 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
« vm/object.cc ('K') | « vm/raw_object.h ('k') | vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/raw_object_snapshot.cc
===================================================================
--- vm/raw_object_snapshot.cc (revision 2393)
+++ vm/raw_object_snapshot.cc (working copy)
@@ -24,6 +24,7 @@
RawClass* Class::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -36,6 +37,9 @@
cls = Class::GetClass(kind);
reader->AddBackwardReference(object_id, &cls);
+ // Set the object tags.
+ cls.set_tags(tags);
+
// Set all non object fields.
cls.set_instance_size(reader->Read<intptr_t>());
cls.set_type_arguments_instance_field_offset(reader->Read<intptr_t>());
@@ -70,11 +74,11 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
if (kind == Snapshot::kFull) {
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kClassClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kClassClass, ptr()->tags_);
// Write out all the non object pointer fields.
// NOTE: cpp_vtable_ is not written.
@@ -97,6 +101,7 @@
RawUnresolvedClass* UnresolvedClass::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -105,6 +110,9 @@
UnresolvedClass::ZoneHandle(UnresolvedClass::New());
reader->AddBackwardReference(object_id, &unresolved_class);
+ // Set the object tags.
+ unresolved_class.set_tags(tags);
+
// Set all non object fields.
unresolved_class.set_token_index(reader->Read<intptr_t>());
@@ -127,10 +135,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kUnresolvedClassClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kUnresolvedClassClass, ptr()->tags_);
// Write out all the non object pointer fields.
writer->Write<intptr_t>(ptr()->token_index_);
@@ -141,8 +149,9 @@
RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader,
- intptr_t object_id,
- Snapshot::Kind kind) {
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
UNREACHABLE(); // AbstractType is an abstract class.
return NULL;
}
@@ -156,14 +165,18 @@
RawType* Type::ReadFrom(SnapshotReader* reader,
- intptr_t object_id,
- Snapshot::Kind kind) {
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
ASSERT(reader != NULL);
// Allocate parameterized type object.
Type& parameterized_type = Type::ZoneHandle(Type::New());
reader->AddBackwardReference(object_id, &parameterized_type);
+ // Set the object tags.
+ parameterized_type.set_tags(tags);
+
// Set all non object fields.
parameterized_type.set_type_state(reader->Read<int8_t>());
@@ -186,10 +199,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kTypeClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kTypeClass, ptr()->tags_);
// Write out all the non object pointer fields.
writer->Write<int8_t>(ptr()->type_state_);
@@ -201,6 +214,7 @@
RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -209,6 +223,9 @@
TypeParameter::ZoneHandle(TypeParameter::New());
reader->AddBackwardReference(object_id, &type_parameter);
+ // Set the object tags.
+ type_parameter.set_tags(tags);
+
// Set all non object fields.
type_parameter.set_index(reader->Read<intptr_t>());
type_parameter.set_type_state(reader->Read<int8_t>());
@@ -233,10 +250,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kTypeParameterClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kTypeParameterClass, ptr()->tags_);
// Write out all the non object pointer fields.
writer->Write<intptr_t>(ptr()->index_);
@@ -249,6 +266,7 @@
RawInstantiatedType* InstantiatedType::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
ASSERT(kind == Snapshot::kMessage);
@@ -258,6 +276,9 @@
InstantiatedType::ZoneHandle(InstantiatedType::New());
reader->AddBackwardReference(object_id, &instantiated_type);
+ // Set the object tags.
+ instantiated_type.set_tags(tags);
+
// Now set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -278,10 +299,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kInstantiatedTypeClass, ptr()->tags_);
// Write out all the object pointer fields.
visitor.VisitPointers(from(), to());
@@ -291,6 +312,7 @@
RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom(
SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE(); // AbstractTypeArguments is an abstract class.
return TypeArguments::null();
@@ -306,10 +328,10 @@
RawTypeArguments* TypeArguments::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
- const bool is_canonical = reader->Read<bool>();
// Read the length so that we can determine instance size to allocate.
RawSmi* smi_len = GetSmi(reader->Read<intptr_t>());
intptr_t len = Smi::Value(smi_len);
@@ -317,13 +339,17 @@
TypeArguments& type_arguments =
TypeArguments::Handle(TypeArguments::New(len));
reader->AddBackwardReference(object_id, &type_arguments);
+
+ // Now set all the object fields.
AbstractType& type = AbstractType::Handle();
for (intptr_t i = 0; i < len; i++) {
type ^= reader->ReadObject();
type_arguments.SetTypeAt(i, type);
}
- type_arguments.set_is_canonical(is_canonical);
+ // Set the object tags.
+ type_arguments.set_tags(tags);
+
return type_arguments.raw();
}
@@ -334,12 +360,11 @@
ASSERT(writer != NULL);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kTypeArgumentsClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kTypeArgumentsClass, ptr()->tags_);
- writer->Write<bool>(ptr()->is_canonical_);
// Write out the length field.
writer->Write<RawObject*>(ptr()->length_);
@@ -354,6 +379,7 @@
RawInstantiatedTypeArguments* InstantiatedTypeArguments::ReadFrom(
SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
ASSERT(kind == Snapshot::kMessage);
@@ -363,6 +389,9 @@
InstantiatedTypeArguments::ZoneHandle(InstantiatedTypeArguments::New());
reader->AddBackwardReference(object_id, &instantiated_type_arguments);
+ // Set the object tags.
+ instantiated_type_arguments.set_tags(tags);
+
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -383,10 +412,11 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kInstantiatedTypeArgumentsClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kInstantiatedTypeArgumentsClass,
+ ptr()->tags_);
// Write out all the object pointer fields.
visitor.VisitPointers(from(), to());
@@ -395,6 +425,7 @@
RawFunction* Function::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -402,6 +433,9 @@
Function& func = Function::ZoneHandle(Function::New());
reader->AddBackwardReference(object_id, &func);
+ // Set the object tags.
+ func.set_tags(tags);
+
// Set all the non object fields.
func.set_token_index(reader->Read<intptr_t>());
func.set_num_fixed_parameters(reader->Read<intptr_t>());
@@ -432,10 +466,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kFunctionClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kFunctionClass, ptr()->tags_);
// Write out all the non object fields.
writer->Write<intptr_t>(ptr()->token_index_);
@@ -455,6 +489,7 @@
RawField* Field::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -462,6 +497,9 @@
Field& field = Field::ZoneHandle(Field::New());
reader->AddBackwardReference(object_id, &field);
+ // Set the object tags.
+ field.set_tags(tags);
+
// Set all non object fields.
field.set_token_index(reader->Read<intptr_t>());
field.set_is_static(reader->Read<bool>());
@@ -487,10 +525,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kFieldClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kFieldClass, ptr()->tags_);
writer->Write<intptr_t>(ptr()->token_index_);
writer->Write<bool>(ptr()->is_static_);
@@ -504,6 +542,7 @@
RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -515,6 +554,9 @@
TokenStream& token_stream = TokenStream::ZoneHandle(TokenStream::New(len));
reader->AddBackwardReference(object_id, &token_stream);
+ // Set the object tags.
+ token_stream.set_tags(tags);
+
// Read the token stream into the TokenStream.
String& literal = String::Handle();
for (intptr_t i = 0; i < len; i++) {
@@ -533,10 +575,10 @@
ASSERT(writer != NULL);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kTokenStreamClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kTokenStreamClass, ptr()->tags_);
// Write out the length field.
writer->Write<RawObject*>(ptr()->length_);
@@ -551,6 +593,7 @@
RawScript* Script::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -558,6 +601,9 @@
Script& script = Script::ZoneHandle(Script::New());
reader->AddBackwardReference(object_id, &script);
+ // Set the object tags.
+ script.set_tags(tags);
+
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -578,10 +624,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kScriptClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kScriptClass, ptr()->tags_);
// Write out all the object pointer fields.
visitor.VisitPointers(from(), to());
@@ -590,6 +636,7 @@
RawLibrary* Library::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -597,6 +644,9 @@
Library& library = Library::ZoneHandle(Library::New());
reader->AddBackwardReference(object_id, &library);
+ // Set the object tags.
+ library.set_tags(tags);
+
// Set all non object fields.
library.raw_ptr()->num_imports_ = reader->Read<intptr_t>();
library.raw_ptr()->num_imported_into_ = reader->Read<intptr_t>();
@@ -627,10 +677,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kLibraryClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kLibraryClass, ptr()->tags_);
writer->Write<intptr_t>(ptr()->num_imports_);
writer->Write<intptr_t>(ptr()->num_imported_into_);
@@ -648,6 +698,7 @@
RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -655,6 +706,9 @@
LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(LibraryPrefix::New());
reader->AddBackwardReference(object_id, &prefix);
+ // Set the object tags.
+ prefix.set_tags(tags);
+
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -674,10 +728,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kLibraryPrefixClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kLibraryPrefixClass, ptr()->tags_);
// Write out all the object pointer fields.
visitor.VisitPointers(from(), to());
@@ -686,6 +740,7 @@
RawCode* Code::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -703,12 +758,13 @@
// out a null object for it.
ASSERT(writer != NULL);
- writer->WriteObjectHeader(kObjectId, Object::kNullObject);
+ writer->WriteIndexedObject(Object::kNullObject);
}
RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return Instructions::null();
@@ -724,6 +780,7 @@
RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return PcDescriptors::null();
@@ -739,6 +796,7 @@
RawExceptionHandlers* ExceptionHandlers::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return ExceptionHandlers::null();
@@ -754,6 +812,7 @@
RawContext* Context::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -764,6 +823,9 @@
(kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
reader->AddBackwardReference(object_id, &context);
+ // Set the object tags.
+ context.set_tags(tags);
+
// Set the isolate implicitly.
context.set_isolate(Isolate::Current());
@@ -786,10 +848,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kContextClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kContextClass, ptr()->tags_);
// Write out num of variables in the context.
writer->Write<intptr_t>(ptr()->num_variables_);
@@ -803,6 +865,7 @@
RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
ASSERT(kind == Snapshot::kMessage);
@@ -812,6 +875,9 @@
ContextScope& scope = ContextScope::ZoneHandle(ContextScope::New(num_vars));
reader->AddBackwardReference(object_id, &scope);
+ // Set the object tags.
+ scope.set_tags(tags);
+
// Set all the object fields.
// TODO(5411462): Need to assert No GC can happen here, even though
// allocations may happen.
@@ -832,10 +898,10 @@
SnapshotWriterVisitor visitor(writer);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, Object::kContextScopeClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(Object::kContextScopeClass, ptr()->tags_);
// Serialize number of variables.
writer->Write<intptr_t>(ptr()->num_variables_);
@@ -847,6 +913,7 @@
RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNIMPLEMENTED();
return UnhandledException::null();
@@ -861,8 +928,9 @@
RawApiError* ApiError::ReadFrom(SnapshotReader* reader,
- intptr_t object_id,
- Snapshot::Kind kind) {
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
UNIMPLEMENTED();
return ApiError::null();
}
@@ -877,6 +945,7 @@
RawInstance* Instance::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return Instance::null();
@@ -892,6 +961,7 @@
RawMint* Mint::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -902,6 +972,10 @@
Mint& mint = Mint::ZoneHandle(
Mint::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
reader->AddBackwardReference(object_id, &mint);
+
+ // Set the object tags.
+ mint.set_tags(tags);
+
return mint.raw();
}
@@ -912,10 +986,10 @@
ASSERT(writer != NULL);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, ObjectStore::kMintClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(ObjectStore::kMintClass, ptr()->tags_);
// Write out the 64 bit value.
writer->Write<int64_t>(ptr()->value_);
@@ -924,6 +998,7 @@
RawBigint* Bigint::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
// Read in the HexCString representation of the bigint.
@@ -936,6 +1011,10 @@
// Create a Bigint object from HexCString.
Bigint& obj = Bigint::ZoneHandle(BigintOperations::FromHexCString(str));
reader->AddBackwardReference(object_id, &obj);
+
+ // Set the object tags.
+ obj.set_tags(tags);
+
return obj.raw();
}
@@ -946,10 +1025,10 @@
ASSERT(writer != NULL);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, ObjectStore::kBigintClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(ObjectStore::kBigintClass, ptr()->tags_);
// Write out the bigint value as a HEXCstring.
ptr()->bn_.d = ptr()->data_;
@@ -964,6 +1043,7 @@
RawDouble* Double::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
// Read the double value for the object.
@@ -972,6 +1052,10 @@
Double& dbl = Double::ZoneHandle(
Double::New(value, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
reader->AddBackwardReference(object_id, &dbl);
+
+ // Set the object tags.
+ dbl.set_tags(tags);
+
return dbl.raw();
}
@@ -982,10 +1066,10 @@
ASSERT(writer != NULL);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, ObjectStore::kDoubleClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(ObjectStore::kDoubleClass, ptr()->tags_);
// Write out the double value.
writer->Write<double>(ptr()->value_);
@@ -994,6 +1078,7 @@
RawString* String::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE(); // String is an abstract class.
return String::null();
@@ -1010,6 +1095,7 @@
template<typename HandleType, typename CharacterType>
RawString* String::ReadFromImpl(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
// Read the length so that we can determine instance size to allocate.
@@ -1024,40 +1110,50 @@
*str_obj.CharAddr(i) = reader->Read<CharacterType>();
}
reader->AddBackwardReference(object_id, &str_obj);
+
+ // Set the object tags.
+ str_obj.set_tags(tags);
+
+ // Set up the hash value.
str_obj.SetHash(Smi::Value(smi_hash));
+
return str_obj.raw();
}
RawOneByteString* OneByteString::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
return static_cast<RawOneByteString*>(
- ReadFromImpl<OneByteString, uint8_t>(reader, object_id, kind));
+ ReadFromImpl<OneByteString, uint8_t>(reader, object_id, tags, kind));
}
RawTwoByteString* TwoByteString::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
return static_cast<RawTwoByteString*>(
- ReadFromImpl<TwoByteString, uint16_t>(reader, object_id, kind));
+ ReadFromImpl<TwoByteString, uint16_t>(reader, object_id, tags, kind));
}
RawFourByteString* FourByteString::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
return static_cast<RawFourByteString*>(
- ReadFromImpl<FourByteString, uint32_t>(reader, object_id, kind));
+ ReadFromImpl<FourByteString, uint32_t>(reader, object_id, tags, kind));
}
template<typename T>
static void StringWriteTo(SnapshotWriter* writer,
intptr_t object_id,
+ Snapshot::Kind kind,
intptr_t class_id,
- Snapshot::Kind kind,
+ intptr_t tags,
RawSmi* length,
RawSmi* hash,
T* data) {
@@ -1065,10 +1161,10 @@
intptr_t len = Smi::Value(length);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, class_id);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(class_id, tags);
// Write out the length field.
writer->Write<RawObject*>(length);
@@ -1088,8 +1184,9 @@
Snapshot::Kind kind) {
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kOneByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->data_);
@@ -1101,8 +1198,9 @@
Snapshot::Kind kind) {
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kTwoByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->data_);
@@ -1114,8 +1212,9 @@
Snapshot::Kind kind) {
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kFourByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->data_);
@@ -1125,6 +1224,7 @@
RawExternalOneByteString* ExternalOneByteString::ReadFrom(
SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return ExternalOneByteString::null();
@@ -1134,6 +1234,7 @@
RawExternalTwoByteString* ExternalTwoByteString::ReadFrom(
SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return ExternalTwoByteString::null();
@@ -1143,6 +1244,7 @@
RawExternalFourByteString* ExternalFourByteString::ReadFrom(
SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNREACHABLE();
return ExternalFourByteString::null();
@@ -1155,8 +1257,9 @@
// Serialize as a non-external one byte string.
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kOneByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->external_data_->data_);
@@ -1169,8 +1272,9 @@
// Serialize as a non-external two byte string.
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kTwoByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->external_data_->data_);
@@ -1183,8 +1287,9 @@
// Serialize as a non-external four byte string.
StringWriteTo(writer,
object_id,
+ kind,
ObjectStore::kFourByteStringClass,
- kind,
+ ptr()->tags_,
ptr()->length_,
ptr()->hash_,
ptr()->external_data_->data_);
@@ -1192,8 +1297,9 @@
RawBool* Bool::ReadFrom(SnapshotReader* reader,
- intptr_t object_id,
- Snapshot::Kind kind) {
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
UNREACHABLE();
return Bool::null();
}
@@ -1209,6 +1315,7 @@
template <class T>
static RawObject* ArrayReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
@@ -1219,6 +1326,10 @@
T::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
reader->AddBackwardReference(object_id, &result);
+ // Set the object tags.
+ result.set_tags(tags);
+
+ // Setup the object fields.
AbstractTypeArguments& type_arguments = AbstractTypeArguments::Handle();
type_arguments ^= reader->ReadObject();
result.SetTypeArguments(type_arguments);
@@ -1234,18 +1345,19 @@
RawArray* Array::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
- return reinterpret_cast<RawArray*>(ArrayReadFrom<Array>(reader,
- object_id,
- kind));
+ return reinterpret_cast<RawArray*>(
+ ArrayReadFrom<Array>(reader, object_id, tags, kind));
}
RawImmutableArray* ImmutableArray::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
return reinterpret_cast<RawImmutableArray*>(
- ArrayReadFrom<ImmutableArray>(reader, object_id, kind));
+ ArrayReadFrom<ImmutableArray>(reader, object_id, tags, kind));
}
@@ -1253,6 +1365,7 @@
intptr_t object_id,
Snapshot::Kind kind,
intptr_t array_kind,
+ intptr_t tags,
RawSmi* length,
RawAbstractTypeArguments* type_arguments,
RawObject* data[]) {
@@ -1260,10 +1373,10 @@
intptr_t len = Smi::Value(length);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, array_kind);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(array_kind, tags);
// Write out the length field.
writer->Write<RawObject*>(length);
@@ -1285,6 +1398,7 @@
object_id,
kind,
ObjectStore::kArrayClass,
+ ptr()->tags_,
ptr()->length_,
ptr()->type_arguments_,
ptr()->data());
@@ -1298,6 +1412,7 @@
object_id,
kind,
ObjectStore::kImmutableArrayClass,
+ ptr()->tags_,
ptr()->length_,
ptr()->type_arguments_,
ptr()->data());
@@ -1306,6 +1421,7 @@
RawByteBuffer* ByteBuffer::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNIMPLEMENTED();
return ByteBuffer::null();
@@ -1321,6 +1437,7 @@
RawClosure* Closure::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNIMPLEMENTED();
return Closure::null();
@@ -1336,6 +1453,7 @@
RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
UNIMPLEMENTED();
return Stacktrace::null();
@@ -1351,6 +1469,7 @@
RawJSRegExp* JSRegExp::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
+ intptr_t tags,
Snapshot::Kind kind) {
ASSERT(reader != NULL);
ASSERT(kind == Snapshot::kMessage);
@@ -1364,6 +1483,9 @@
JSRegExp::New(len, (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew));
reader->AddBackwardReference(object_id, &regex);
+ // Set the object tags.
+ regex.set_tags(tags);
+
// Read and Set all the other fields.
regex.raw_ptr()->num_bracket_expressions_ = GetSmi(reader->Read<intptr_t>());
String& pattern = String::Handle();
@@ -1385,10 +1507,10 @@
ASSERT(kind == Snapshot::kMessage);
// Write out the serialization header value for this object.
- writer->WriteObjectHeader(kInlined, object_id);
+ writer->WriteSerializationMarker(kInlined, object_id);
- // Write out the class information.
- writer->WriteObjectHeader(kObjectId, ObjectStore::kJSRegExpClass);
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, ptr()->tags_);
// Write out the data length field.
writer->Write<RawObject*>(ptr()->data_length_);
« vm/object.cc ('K') | « vm/raw_object.h ('k') | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698