diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index ab0f3e75628..17a2fe2c2d3 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -71,14 +71,13 @@ static RawObject* AllocateUninitialized(PageSpace* old_space, intptr_t size) { void Deserializer::InitializeHeader(RawObject* raw, intptr_t class_id, intptr_t size, - bool is_vm_isolate, bool is_canonical) { ASSERT(Utils::IsAligned(size, kObjectAlignment)); uint32_t tags = 0; tags = RawObject::ClassIdTag::update(class_id, tags); tags = RawObject::SizeTag::update(size, tags); - tags = RawObject::VMHeapObjectTag::update(is_vm_isolate, tags); - tags = RawObject::CanonicalObjectTag::update(is_canonical, tags); + tags = RawObject::ReadOnlyBit::update(false, tags); + tags = RawObject::CanonicalBit::update(is_canonical, tags); tags = RawObject::OldBit::update(true, tags); tags = RawObject::OldAndNotMarkedBit::update(true, tags); tags = RawObject::OldAndNotRememberedBit::update(true, tags); @@ -224,7 +223,6 @@ class ClassDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); ClassTable* table = d->isolate()->class_table(); for (intptr_t id = predefined_start_index_; id < predefined_stop_index_; @@ -255,8 +253,7 @@ class ClassDeserializationCluster : public DeserializationCluster { for (intptr_t id = start_index_; id < stop_index_; id++) { RawClass* cls = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(cls, kClassCid, Class::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(cls, kClassCid, Class::InstanceSize()); ReadFromTo(cls); intptr_t class_id = d->ReadCid(); @@ -360,8 +357,6 @@ class TypeArgumentsDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawTypeArguments* type_args = reinterpret_cast(d->Ref(id)); @@ -369,7 +364,7 @@ class TypeArgumentsDeserializationCluster : public DeserializationCluster { bool is_canonical = d->Read(); Deserializer::InitializeHeader(type_args, kTypeArgumentsCid, TypeArguments::InstanceSize(length), - is_vm_object, is_canonical); + is_canonical); type_args->ptr()->length_ = Smi::New(length); type_args->ptr()->hash_ = Smi::New(d->Read()); type_args->ptr()->instantiations_ = @@ -438,12 +433,10 @@ class PatchClassDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawPatchClass* cls = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(cls, kPatchClassCid, - PatchClass::InstanceSize(), is_vm_object); + PatchClass::InstanceSize()); ReadFromTo(cls); #if !defined(DART_PRECOMPILED_RUNTIME) if (d->kind() != Snapshot::kFullAOT) { @@ -540,12 +533,11 @@ class FunctionDeserializationCluster : public DeserializationCluster { void ReadFill(Deserializer* d) { Snapshot::Kind kind = d->kind(); - bool is_vm_object = d->isolate() == Dart::vm_isolate(); for (intptr_t id = start_index_; id < stop_index_; id++) { RawFunction* func = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(func, kFunctionCid, - Function::InstanceSize(), is_vm_object); + Function::InstanceSize()); ReadFromTo(func); if (kind == Snapshot::kFull) { @@ -699,12 +691,10 @@ class ClosureDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawClosureData* data = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(data, kClosureDataCid, - ClosureData::InstanceSize(), is_vm_object); + ClosureData::InstanceSize()); if (d->kind() == Snapshot::kFullAOT) { data->ptr()->context_scope_ = ContextScope::null(); } else { @@ -771,12 +761,10 @@ class SignatureDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawSignatureData* data = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader( - data, kSignatureDataCid, SignatureData::InstanceSize(), is_vm_object); + Deserializer::InitializeHeader(data, kSignatureDataCid, + SignatureData::InstanceSize()); ReadFromTo(data); } } @@ -836,14 +824,11 @@ class RedirectionDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawRedirectionData* data = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(data, kRedirectionDataCid, - RedirectionData::InstanceSize(), - is_vm_object); + RedirectionData::InstanceSize()); ReadFromTo(data); } } @@ -980,12 +965,10 @@ class FieldDeserializationCluster : public DeserializationCluster { void ReadFill(Deserializer* d) { Snapshot::Kind kind = d->kind(); - bool is_vm_object = d->isolate() == Dart::vm_isolate(); for (intptr_t id = start_index_; id < stop_index_; id++) { RawField* field = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(field, kFieldCid, Field::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(field, kFieldCid, Field::InstanceSize()); ReadFromTo(field); if (kind != Snapshot::kFullAOT) { field->ptr()->token_pos_ = d->ReadTokenPosition(); @@ -1079,12 +1062,10 @@ class ScriptDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawScript* script = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(script, kScriptCid, Script::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(script, kScriptCid, + Script::InstanceSize()); ReadFromTo(script); script->ptr()->line_offset_ = d->Read(); script->ptr()->col_offset_ = d->Read(); @@ -1155,12 +1136,9 @@ class LibraryDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawLibrary* lib = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(lib, kLibraryCid, Library::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(lib, kLibraryCid, Library::InstanceSize()); ReadFromTo(lib); lib->ptr()->native_entry_resolver_ = NULL; lib->ptr()->native_entry_symbol_resolver_ = NULL; @@ -1231,12 +1209,10 @@ class NamespaceDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawNamespace* ns = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(ns, kNamespaceCid, - Namespace::InstanceSize(), is_vm_object); + Namespace::InstanceSize()); ReadFromTo(ns); } } @@ -1298,14 +1274,11 @@ class KernelProgramInfoDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawKernelProgramInfo* info = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(info, kKernelProgramInfoCid, - KernelProgramInfo::InstanceSize(), - is_vm_object); + KernelProgramInfo::InstanceSize()); ReadFromTo(info); } } @@ -1432,8 +1405,6 @@ class CodeDeserializationCluster : public DeserializationCluster { ~CodeDeserializationCluster() {} void ReadAlloc(Deserializer* d) { - const bool is_vm_object = d->isolate() == Dart::vm_isolate(); - start_index_ = d->next_index(); PageSpace* old_space = d->heap()->old_space(); const intptr_t count = d->ReadUnsigned(); @@ -1448,7 +1419,7 @@ class CodeDeserializationCluster : public DeserializationCluster { code_order = static_cast( AllocateUninitialized(old_space, Array::InstanceSize(count))); Deserializer::InitializeHeader(code_order, kArrayCid, - Array::InstanceSize(count), is_vm_object, + Array::InstanceSize(count), /*is_canonical=*/false); code_order->ptr()->type_arguments_ = TypeArguments::null(); code_order->ptr()->length_ = Smi::New(code_order_length); @@ -1471,12 +1442,9 @@ class CodeDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - const bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawCode* code = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(code, kCodeCid, Code::InstanceSize(0), - is_vm_object); + Deserializer::InitializeHeader(code, kCodeCid, Code::InstanceSize(0)); RawInstructions* instr = d->ReadInstructions(); @@ -1600,12 +1568,11 @@ class BytecodeDeserializationCluster : public DeserializationCluster { void ReadFill(Deserializer* d) { ASSERT(d->kind() == Snapshot::kFullJIT); - bool is_vm_object = d->isolate() == Dart::vm_isolate(); for (intptr_t id = start_index_; id < stop_index_; id++) { RawBytecode* bytecode = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(bytecode, kBytecodeCid, - Bytecode::InstanceSize(), is_vm_object); + Bytecode::InstanceSize()); bytecode->ptr()->instructions_ = 0; bytecode->ptr()->instructions_size_ = d->Read(); ReadFromTo(bytecode); @@ -1741,12 +1708,11 @@ class ObjectPoolDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); for (intptr_t id = start_index_; id < stop_index_; id += 1) { intptr_t length = d->ReadUnsigned(); RawObjectPool* pool = reinterpret_cast(d->Ref(id + 0)); - Deserializer::InitializeHeader( - pool, kObjectPoolCid, ObjectPool::InstanceSize(length), is_vm_object); + Deserializer::InitializeHeader(pool, kObjectPoolCid, + ObjectPool::InstanceSize(length)); pool->ptr()->length_ = length; for (intptr_t j = 0; j < length; j++) { const uint8_t entry_bits = d->Read(); @@ -1795,7 +1761,7 @@ class RODataSerializationCluster : public SerializationCluster { // will be loaded into read-only memory. Extra bytes due to allocation // rounding need to be deterministically set for reliable deduplication in // shared images. - if (object->IsVMHeapObject()) { + if (object->IsReadOnly()) { // This object is already read-only. } else { Object::FinalizeReadOnlyObject(object); @@ -1950,15 +1916,12 @@ class ExceptionHandlersDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawExceptionHandlers* handlers = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); Deserializer::InitializeHeader(handlers, kExceptionHandlersCid, - ExceptionHandlers::InstanceSize(length), - is_vm_object); + ExceptionHandlers::InstanceSize(length)); handlers->ptr()->num_entries_ = length; handlers->ptr()->handled_types_data_ = reinterpret_cast(d->ReadRef()); @@ -2041,13 +2004,11 @@ class ContextDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawContext* context = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); - Deserializer::InitializeHeader( - context, kContextCid, Context::InstanceSize(length), is_vm_object); + Deserializer::InitializeHeader(context, kContextCid, + Context::InstanceSize(length)); context->ptr()->num_variables_ = length; context->ptr()->parent_ = reinterpret_cast(d->ReadRef()); for (intptr_t j = 0; j < length; j++) { @@ -2119,14 +2080,11 @@ class ContextScopeDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawContextScope* scope = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); Deserializer::InitializeHeader(scope, kContextScopeCid, - ContextScope::InstanceSize(length), - is_vm_object); + ContextScope::InstanceSize(length)); scope->ptr()->num_variables_ = length; scope->ptr()->is_implicit_ = d->Read(); ReadFromTo(scope, length); @@ -2187,14 +2145,11 @@ class UnlinkedCallDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawUnlinkedCall* unlinked = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(unlinked, kUnlinkedCallCid, - UnlinkedCall::InstanceSize(), - is_vm_object); + UnlinkedCall::InstanceSize()); ReadFromTo(unlinked); } } @@ -2257,12 +2212,9 @@ class ICDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawICData* ic = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(ic, kICDataCid, ICData::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(ic, kICDataCid, ICData::InstanceSize()); ReadFromTo(ic); NOT_IN_PRECOMPILED(ic->ptr()->deopt_id_ = d->Read()); ic->ptr()->state_bits_ = d->Read(); @@ -2325,14 +2277,11 @@ class MegamorphicCacheDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawMegamorphicCache* cache = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(cache, kMegamorphicCacheCid, - MegamorphicCache::InstanceSize(), - is_vm_object); + MegamorphicCache::InstanceSize()); ReadFromTo(cache); cache->ptr()->filled_entry_count_ = d->Read(); } @@ -2419,14 +2368,11 @@ class SubtypeTestCacheDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawSubtypeTestCache* cache = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(cache, kSubtypeTestCacheCid, - SubtypeTestCache::InstanceSize(), - is_vm_object); + SubtypeTestCache::InstanceSize()); cache->ptr()->cache_ = reinterpret_cast(d->ReadRef()); } } @@ -2488,13 +2434,10 @@ class LanguageErrorDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawLanguageError* error = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(error, kLanguageErrorCid, - LanguageError::InstanceSize(), - is_vm_object); + LanguageError::InstanceSize()); ReadFromTo(error); error->ptr()->token_pos_ = d->ReadTokenPosition(); error->ptr()->report_after_token_ = d->Read(); @@ -2557,14 +2500,11 @@ class UnhandledExceptionDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawUnhandledException* exception = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(exception, kUnhandledExceptionCid, - UnhandledException::InstanceSize(), - is_vm_object); + UnhandledException::InstanceSize()); ReadFromTo(exception); } } @@ -2659,13 +2599,12 @@ class InstanceDeserializationCluster : public DeserializationCluster { intptr_t next_field_offset = next_field_offset_in_words_ << kWordSizeLog2; intptr_t instance_size = Object::RoundedAllocationSize(instance_size_in_words_ * kWordSize); - bool is_vm_object = d->isolate() == Dart::vm_isolate(); for (intptr_t id = start_index_; id < stop_index_; id++) { RawInstance* instance = reinterpret_cast(d->Ref(id)); bool is_canonical = d->Read(); Deserializer::InitializeHeader(instance, cid_, instance_size, - is_vm_object, is_canonical); + is_canonical); intptr_t offset = Instance::NextFieldOffset(); while (offset < next_field_offset) { RawObject** p = reinterpret_cast( @@ -2744,14 +2683,11 @@ class LibraryPrefixDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawLibraryPrefix* prefix = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(prefix, kLibraryPrefixCid, - LibraryPrefix::InstanceSize(), - is_vm_object); + LibraryPrefix::InstanceSize()); ReadFromTo(prefix); prefix->ptr()->num_imports_ = d->Read(); prefix->ptr()->is_deferred_load_ = d->Read(); @@ -2851,13 +2787,12 @@ class TypeDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - const bool is_vm_isolate = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = canonical_start_index_; id < canonical_stop_index_; id++) { RawType* type = reinterpret_cast(d->Ref(id)); + bool is_canonical = true; Deserializer::InitializeHeader(type, kTypeCid, Type::InstanceSize(), - is_vm_isolate, true); + is_canonical); ReadFromTo(type); type->ptr()->token_pos_ = d->ReadTokenPosition(); type->ptr()->type_state_ = d->Read(); @@ -2865,8 +2800,9 @@ class TypeDeserializationCluster : public DeserializationCluster { for (intptr_t id = start_index_; id < stop_index_; id++) { RawType* type = reinterpret_cast(d->Ref(id)); + bool is_canonical = false; Deserializer::InitializeHeader(type, kTypeCid, Type::InstanceSize(), - is_vm_isolate); + is_canonical); ReadFromTo(type); type->ptr()->token_pos_ = d->ReadTokenPosition(); type->ptr()->type_state_ = d->Read(); @@ -2961,12 +2897,10 @@ class TypeRefDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - const bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawTypeRef* type = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(type, kTypeRefCid, TypeRef::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(type, kTypeRefCid, + TypeRef::InstanceSize()); ReadFromTo(type); } } @@ -3051,12 +2985,10 @@ class TypeParameterDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawTypeParameter* type = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader( - type, kTypeParameterCid, TypeParameter::InstanceSize(), is_vm_object); + Deserializer::InitializeHeader(type, kTypeParameterCid, + TypeParameter::InstanceSize()); ReadFromTo(type); type->ptr()->parameterized_class_id_ = d->Read(); type->ptr()->token_pos_ = d->ReadTokenPosition(); @@ -3139,14 +3071,11 @@ class ClosureDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawClosure* closure = reinterpret_cast(d->Ref(id)); bool is_canonical = d->Read(); Deserializer::InitializeHeader(closure, kClosureCid, - Closure::InstanceSize(), is_vm_object, - is_canonical); + Closure::InstanceSize(), is_canonical); ReadFromTo(closure); } } @@ -3203,7 +3132,6 @@ class MintDeserializationCluster : public DeserializationCluster { void ReadAlloc(Deserializer* d) { PageSpace* old_space = d->heap()->old_space(); - bool is_vm_object = d->isolate() == Dart::vm_isolate(); start_index_ = d->next_index(); intptr_t count = d->ReadUnsigned(); @@ -3216,7 +3144,7 @@ class MintDeserializationCluster : public DeserializationCluster { RawMint* mint = static_cast( AllocateUninitialized(old_space, Mint::InstanceSize())); Deserializer::InitializeHeader(mint, kMintCid, Mint::InstanceSize(), - is_vm_object, is_canonical); + is_canonical); mint->ptr()->value_ = value; d->AssignRef(mint); } @@ -3292,13 +3220,11 @@ class DoubleDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawDouble* dbl = reinterpret_cast(d->Ref(id)); bool is_canonical = d->Read(); Deserializer::InitializeHeader(dbl, kDoubleCid, Double::InstanceSize(), - is_vm_object, is_canonical); + is_canonical); dbl->ptr()->value_ = d->Read(); } } @@ -3360,15 +3286,13 @@ class GrowableObjectArrayDeserializationCluster } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawGrowableObjectArray* list = reinterpret_cast(d->Ref(id)); bool is_canonical = d->Read(); Deserializer::InitializeHeader(list, kGrowableObjectArrayCid, GrowableObjectArray::InstanceSize(), - is_vm_object, is_canonical); + is_canonical); ReadFromTo(list); } } @@ -3438,7 +3362,6 @@ class TypedDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); intptr_t element_size = TypedData::ElementSizeInBytes(cid_); for (intptr_t id = start_index_; id < stop_index_; id++) { @@ -3446,9 +3369,8 @@ class TypedDataDeserializationCluster : public DeserializationCluster { intptr_t length = d->ReadUnsigned(); bool is_canonical = d->Read(); intptr_t length_in_bytes = length * element_size; - Deserializer::InitializeHeader(data, cid_, - TypedData::InstanceSize(length_in_bytes), - is_vm_object, is_canonical); + Deserializer::InitializeHeader( + data, cid_, TypedData::InstanceSize(length_in_bytes), is_canonical); data->ptr()->length_ = Smi::New(length); uint8_t* cdata = reinterpret_cast(data->ptr()->data()); d->ReadBytes(cdata, length_in_bytes); @@ -3519,15 +3441,14 @@ class ExternalTypedDataDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); intptr_t element_size = ExternalTypedData::ElementSizeInBytes(cid_); for (intptr_t id = start_index_; id < stop_index_; id++) { RawExternalTypedData* data = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); - Deserializer::InitializeHeader( - data, cid_, ExternalTypedData::InstanceSize(), is_vm_object); + Deserializer::InitializeHeader(data, cid_, + ExternalTypedData::InstanceSize()); data->ptr()->length_ = Smi::New(length); d->Align(ExternalTypedData::kDataSerializationAlignment); data->ptr()->data_ = const_cast(d->CurrentBufferAddress()); @@ -3593,12 +3514,10 @@ class StackTraceDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawStackTrace* trace = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(trace, kStackTraceCid, - StackTrace::InstanceSize(), is_vm_object); + StackTrace::InstanceSize()); ReadFromTo(trace); } } @@ -3658,12 +3577,10 @@ class RegExpDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawRegExp* regexp = reinterpret_cast(d->Ref(id)); - Deserializer::InitializeHeader(regexp, kRegExpCid, RegExp::InstanceSize(), - is_vm_object); + Deserializer::InitializeHeader(regexp, kRegExpCid, + RegExp::InstanceSize()); ReadFromTo(regexp); regexp->ptr()->num_registers_ = d->Read(); regexp->ptr()->type_flags_ = d->Read(); @@ -3724,14 +3641,11 @@ class WeakPropertyDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawWeakProperty* property = reinterpret_cast(d->Ref(id)); Deserializer::InitializeHeader(property, kWeakPropertyCid, - WeakProperty::InstanceSize(), - is_vm_object); + WeakProperty::InstanceSize()); ReadFromTo(property); } } @@ -3823,15 +3737,13 @@ class LinkedHashMapDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); PageSpace* old_space = d->heap()->old_space(); for (intptr_t id = start_index_; id < stop_index_; id++) { RawLinkedHashMap* map = reinterpret_cast(d->Ref(id)); bool is_canonical = d->Read(); - Deserializer::InitializeHeader(map, kLinkedHashMapCid, - LinkedHashMap::InstanceSize(), - is_vm_object, is_canonical); + Deserializer::InitializeHeader( + map, kLinkedHashMapCid, LinkedHashMap::InstanceSize(), is_canonical); map->ptr()->type_arguments_ = reinterpret_cast(d->ReadRef()); @@ -3934,14 +3846,12 @@ class ArrayDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawArray* array = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); bool is_canonical = d->Read(); Deserializer::InitializeHeader(array, cid_, Array::InstanceSize(length), - is_vm_object, is_canonical); + is_canonical); array->ptr()->type_arguments_ = reinterpret_cast(d->ReadRef()); array->ptr()->length_ = Smi::New(length); @@ -4016,15 +3926,13 @@ class OneByteStringDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawOneByteString* str = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); bool is_canonical = d->Read(); Deserializer::InitializeHeader(str, kOneByteStringCid, OneByteString::InstanceSize(length), - is_vm_object, is_canonical); + is_canonical); str->ptr()->length_ = Smi::New(length); String::SetCachedHash(str, d->Read()); for (intptr_t j = 0; j < length; j++) { @@ -4095,15 +4003,13 @@ class TwoByteStringDeserializationCluster : public DeserializationCluster { } void ReadFill(Deserializer* d) { - bool is_vm_object = d->isolate() == Dart::vm_isolate(); - for (intptr_t id = start_index_; id < stop_index_; id++) { RawTwoByteString* str = reinterpret_cast(d->Ref(id)); intptr_t length = d->ReadUnsigned(); bool is_canonical = d->Read(); Deserializer::InitializeHeader(str, kTwoByteStringCid, TwoByteString::InstanceSize(length), - is_vm_object, is_canonical); + is_canonical); str->ptr()->length_ = Smi::New(length); String::SetCachedHash(str, d->Read()); uint8_t* cdata = reinterpret_cast(str->ptr()->data()); diff --git a/runtime/vm/clustered_snapshot.h b/runtime/vm/clustered_snapshot.h index 3ed6575915c..22337150c44 100644 --- a/runtime/vm/clustered_snapshot.h +++ b/runtime/vm/clustered_snapshot.h @@ -491,7 +491,6 @@ class Deserializer : public ThreadStackResource { static void InitializeHeader(RawObject* raw, intptr_t cid, intptr_t size, - bool is_vm_isolate, bool is_canonical = false); // Reads raw data (for basic types). diff --git a/runtime/vm/compiler/aot/precompiler.cc b/runtime/vm/compiler/aot/precompiler.cc index 1c08d63201e..205a928c0f6 100644 --- a/runtime/vm/compiler/aot/precompiler.cc +++ b/runtime/vm/compiler/aot/precompiler.cc @@ -1506,7 +1506,7 @@ void Precompiler::AttachOptimizedTypeTestingStub() { for (intptr_t i = 0; i < types.length(); i++) { const AbstractType& type = types.At(i); - if (type.InVMHeap()) { + if (type.IsReadOnly()) { // The only important types in the vm isolate are "dynamic"/"void", which // will get their optimized top-type testing stub installed at creation. continue; diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc index 70f614f5d6b..16dddf635d8 100644 --- a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc +++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc @@ -33,7 +33,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& stub = Code::ZoneHandle(object_store->write_barrier_wrappers_stub()); - if (!stub.InVMHeap()) { + if (!stub.IsReadOnly()) { assembler_->generate_invoke_write_barrier_wrapper_ = [&](Condition condition, Register reg) { const intptr_t offset_into_target = @@ -46,7 +46,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& array_stub = Code::ZoneHandle(object_store->array_write_barrier_stub()); - if (!array_stub.InVMHeap()) { + if (!array_stub.IsReadOnly()) { assembler_->generate_invoke_array_write_barrier_ = [&](Condition condition) { AddPcRelativeCallStubTarget(array_stub); @@ -951,7 +951,8 @@ void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, const Code& stub, RawPcDescriptors::Kind kind, LocationSummary* locs) { - if (FLAG_precompiled_mode && FLAG_use_bare_instructions && !stub.InVMHeap()) { + if (FLAG_precompiled_mode && FLAG_use_bare_instructions && + !stub.IsReadOnly()) { AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(); EmitCallsiteMetadata(token_pos, DeoptId::kNone, kind, locs); diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc index b128224b30b..d01b9185c9c 100644 --- a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc +++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc @@ -32,7 +32,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& stub = Code::ZoneHandle(object_store->write_barrier_wrappers_stub()); - if (!stub.InVMHeap()) { + if (!stub.IsReadOnly()) { assembler_->generate_invoke_write_barrier_wrapper_ = [&](Register reg) { const intptr_t offset_into_target = Thread::WriteBarrierWrappersOffsetForRegister(reg); @@ -43,7 +43,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& array_stub = Code::ZoneHandle(object_store->array_write_barrier_stub()); - if (!array_stub.InVMHeap()) { + if (!array_stub.IsReadOnly()) { assembler_->generate_invoke_array_write_barrier_ = [&]() { AddPcRelativeCallStubTarget(array_stub); assembler_->GenerateUnRelocatedPcRelativeCall(); @@ -944,7 +944,8 @@ void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, const Code& stub, RawPcDescriptors::Kind kind, LocationSummary* locs) { - if (FLAG_precompiled_mode && FLAG_use_bare_instructions && !stub.InVMHeap()) { + if (FLAG_precompiled_mode && FLAG_use_bare_instructions && + !stub.IsReadOnly()) { AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(); EmitCallsiteMetadata(token_pos, DeoptId::kNone, kind, locs); diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc index 0f087facbc1..e5c711eecb1 100644 --- a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc +++ b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc @@ -31,7 +31,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& stub = Code::ZoneHandle(object_store->write_barrier_wrappers_stub()); - if (!stub.InVMHeap()) { + if (!stub.IsReadOnly()) { assembler_->generate_invoke_write_barrier_wrapper_ = [&](Register reg) { const intptr_t offset_into_target = Thread::WriteBarrierWrappersOffsetForRegister(reg); @@ -42,7 +42,7 @@ void FlowGraphCompiler::ArchSpecificInitialization() { const auto& array_stub = Code::ZoneHandle(object_store->array_write_barrier_stub()); - if (!array_stub.InVMHeap()) { + if (!array_stub.IsReadOnly()) { assembler_->generate_invoke_array_write_barrier_ = [&]() { AddPcRelativeCallStubTarget(array_stub); assembler_->GenerateUnRelocatedPcRelativeCall(); @@ -940,7 +940,8 @@ void FlowGraphCompiler::GenerateCall(TokenPosition token_pos, const Code& stub, RawPcDescriptors::Kind kind, LocationSummary* locs) { - if (FLAG_precompiled_mode && FLAG_use_bare_instructions && !stub.InVMHeap()) { + if (FLAG_precompiled_mode && FLAG_use_bare_instructions && + !stub.IsReadOnly()) { AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(); EmitCallsiteMetadata(token_pos, DeoptId::kNone, kind, locs); diff --git a/runtime/vm/compiler/backend/il.cc b/runtime/vm/compiler/backend/il.cc index a6e818659da..4dbdd20bee9 100644 --- a/runtime/vm/compiler/backend/il.cc +++ b/runtime/vm/compiler/backend/il.cc @@ -260,7 +260,7 @@ void HierarchyInfo::BuildRangesForJIT(ClassTable* table, bool use_subtype_test, bool include_abstract, bool exclude_null) { - if (dst_klass.InVMHeap()) { + if (dst_klass.IsReadOnly()) { BuildRangesFor(table, ranges, dst_klass, use_subtype_test, include_abstract, exclude_null); return; diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h index 316e9841344..2d815ae284e 100644 --- a/runtime/vm/compiler/backend/il.h +++ b/runtime/vm/compiler/backend/il.h @@ -3110,7 +3110,7 @@ class TemplateDartCall : public TemplateDefinition { argument_names_(argument_names), arguments_(arguments), token_pos_(token_pos) { - ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); + ASSERT(argument_names.IsZoneHandle() || argument_names.IsReadOnly()); } RawString* Selector() { diff --git a/runtime/vm/compiler/backend/il_arm.cc b/runtime/vm/compiler/backend/il_arm.cc index 6c3ea35a1e3..033b20051a7 100644 --- a/runtime/vm/compiler/backend/il_arm.cc +++ b/runtime/vm/compiler/backend/il_arm.cc @@ -3083,7 +3083,7 @@ void CheckStackOverflowInstr::EmitNativeCode(FlowGraphCompiler* compiler) { : object_store->stack_overflow_stub_without_fpu_regs_stub()); const bool using_shared_stub = locs()->call_on_shared_slow_path(); if (FLAG_precompiled_mode && FLAG_use_bare_instructions && - using_shared_stub && !stub.InVMHeap()) { + using_shared_stub && !stub.IsReadOnly()) { compiler->AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(LS); @@ -5778,7 +5778,7 @@ void CheckNullInstr::EmitNativeCode(FlowGraphCompiler* compiler) { : object_store->null_error_stub_without_fpu_regs_stub()); const bool using_shared_stub = locs()->call_on_shared_slow_path(); if (FLAG_precompiled_mode && FLAG_use_bare_instructions && - using_shared_stub && !stub.InVMHeap()) { + using_shared_stub && !stub.IsReadOnly()) { compiler->AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(EQUAL); diff --git a/runtime/vm/compiler/backend/il_arm64.cc b/runtime/vm/compiler/backend/il_arm64.cc index ba567b01f19..64296ab9025 100644 --- a/runtime/vm/compiler/backend/il_arm64.cc +++ b/runtime/vm/compiler/backend/il_arm64.cc @@ -2727,7 +2727,7 @@ class CheckStackOverflowSlowPath : object_store->stack_overflow_stub_without_fpu_regs_stub()); if (FLAG_precompiled_mode && FLAG_use_bare_instructions && - using_shared_stub && !stub.InVMHeap()) { + using_shared_stub && !stub.IsReadOnly()) { compiler->AddPcRelativeCallStubTarget(stub); __ GenerateUnRelocatedPcRelativeCall(); @@ -4995,7 +4995,7 @@ void NullErrorSlowPath::EmitSharedStubCall(FlowGraphCompiler* compiler, live_fpu_regs ? object_store->null_error_stub_with_fpu_regs_stub() : object_store->null_error_stub_without_fpu_regs_stub()); if (FLAG_precompiled_mode && FLAG_use_bare_instructions && - using_shared_stub && !stub.InVMHeap()) { + using_shared_stub && !stub.IsReadOnly()) { compiler->AddPcRelativeCallStubTarget(stub); compiler->assembler()->GenerateUnRelocatedPcRelativeCall(); return; diff --git a/runtime/vm/compiler/cha.cc b/runtime/vm/compiler/cha.cc index 5a2fcdd2100..7856c72676c 100644 --- a/runtime/vm/compiler/cha.cc +++ b/runtime/vm/compiler/cha.cc @@ -39,7 +39,7 @@ bool CHA::HasSubclasses(const Class& cls) { // read-only. // TODO(fschneider): Enable tracking of CHA dependent code for VM heap // classes. - if (cls.InVMHeap()) return true; + if (cls.IsReadOnly()) return true; if (cls.IsObjectClass()) { // Class Object has subclasses, although we do not keep track of them. @@ -58,7 +58,7 @@ bool CHA::HasSubclasses(intptr_t cid) const { bool CHA::ConcreteSubclasses(const Class& cls, GrowableArray* class_ids) { - if (cls.InVMHeap()) return false; + if (cls.IsReadOnly()) return false; if (cls.IsObjectClass()) return false; if (!cls.is_abstract()) { @@ -87,7 +87,7 @@ bool CHA::IsImplemented(const Class& cls) { // read-only. // TODO(fschneider): Enable tracking of CHA dependent code for VM heap // classes. - if (cls.InVMHeap()) return true; + if (cls.IsReadOnly()) return true; return cls.is_implemented(); } @@ -129,7 +129,7 @@ bool CHA::HasOverride(const Class& cls, // read-only. // TODO(fschneider): Enable tracking of CHA dependent code for VM heap // classes. - if (cls.InVMHeap()) return true; + if (cls.IsReadOnly()) return true; // Subclasses of Object are not tracked by CHA. Safely assume that overrides // exist. diff --git a/runtime/vm/compiler/frontend/constant_evaluator.cc b/runtime/vm/compiler/frontend/constant_evaluator.cc index 1be64ab9b3e..6733249b2d7 100644 --- a/runtime/vm/compiler/frontend/constant_evaluator.cc +++ b/runtime/vm/compiler/frontend/constant_evaluator.cc @@ -1037,7 +1037,7 @@ bool ConstantEvaluator::GetCachedConstant(intptr_t kernel_offset, } bool is_present = false; - ASSERT(!script_.InVMHeap()); + ASSERT(!script_.IsReadOnly()); if (script_.compile_time_constants() == Array::null()) { return false; } @@ -1067,7 +1067,7 @@ void ConstantEvaluator::CacheConstantValue(intptr_t kernel_offset, return; } const intptr_t kInitialConstMapSize = 16; - ASSERT(!script_.InVMHeap()); + ASSERT(!script_.IsReadOnly()); if (script_.compile_time_constants() == Array::null()) { const Array& array = Array::Handle( HashTables::New(kInitialConstMapSize, Heap::kNew)); diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc index d89816bc688..ce665912611 100644 --- a/runtime/vm/compiler/runtime_api.cc +++ b/runtime/vm/compiler/runtime_api.cc @@ -769,7 +769,7 @@ uword Code::EntryPointOf(const dart::Code& code) { } bool CanEmbedAsRawPointerInGeneratedCode(const dart::Object& obj) { - return obj.IsSmi() || obj.InVMHeap(); + return obj.IsSmi() || obj.IsReadOnly(); } word ToRawPointer(const dart::Object& a) { diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc index 8301543d012..10257fb534c 100644 --- a/runtime/vm/dart_api_impl.cc +++ b/runtime/vm/dart_api_impl.cc @@ -490,7 +490,7 @@ void Api::Init() { } static Dart_Handle InitNewReadOnlyApiHandle(RawObject* raw) { - ASSERT(raw->IsVMHeapObject()); + ASSERT(raw->IsReadOnly()); LocalHandle* ref = Dart::AllocateReadOnlyApiHandle(); ref->set_raw(raw); return ref->apiHandle(); diff --git a/runtime/vm/hash_table.h b/runtime/vm/hash_table.h index 250a8d0ce56..b84e35ffe6d 100644 --- a/runtime/vm/hash_table.h +++ b/runtime/vm/hash_table.h @@ -302,7 +302,7 @@ class HashTable : public ValueObject { } void UpdateCollisions(intptr_t collisions) const { if (KeyTraits::ReportStats()) { - if (data_->raw()->IsVMHeapObject()) { + if (data_->raw()->IsReadOnly()) { return; } AdjustSmiValueAt(kNumProbesIndex, collisions + 1); diff --git a/runtime/vm/heap/become.cc b/runtime/vm/heap/become.cc index 1b1823af125..9cda40a3221 100644 --- a/runtime/vm/heap/become.cc +++ b/runtime/vm/heap/become.cc @@ -193,14 +193,14 @@ void Become::CrashDump(RawObject* before_obj, RawObject* after_obj) { OS::PrintErr("BEFORE ADDRESS: %p\n", before_obj); OS::PrintErr("BEFORE IS HEAP OBJECT: %s", before_obj->IsHeapObject() ? "YES" : "NO"); - OS::PrintErr("BEFORE IS VM HEAP OBJECT: %s", - before_obj->IsVMHeapObject() ? "YES" : "NO"); + OS::PrintErr("BEFORE IS READ ONLY OBJECT: %s", + before_obj->IsReadOnly() ? "YES" : "NO"); OS::PrintErr("AFTER ADDRESS: %p\n", after_obj); OS::PrintErr("AFTER IS HEAP OBJECT: %s", after_obj->IsHeapObject() ? "YES" : "NO"); - OS::PrintErr("AFTER IS VM HEAP OBJECT: %s", - after_obj->IsVMHeapObject() ? "YES" : "NO"); + OS::PrintErr("AFTER IS READ ONLY OBJECT: %s", + after_obj->IsReadOnly() ? "YES" : "NO"); if (before_obj->IsHeapObject()) { OS::PrintErr("BEFORE OBJECT CLASS ID=%" Pd "\n", before_obj->GetClassId()); @@ -240,7 +240,7 @@ void Become::ElementsForwardIdentity(const Array& before, const Array& after) { CrashDump(before_obj, after_obj); FATAL("become: Cannot become immediates"); } - if (before_obj->IsVMHeapObject()) { + if (before_obj->IsReadOnly()) { CrashDump(before_obj, after_obj); FATAL("become: Cannot forward VM heap objects"); } diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc index 838e2b7fa01..88e6bb9236d 100644 --- a/runtime/vm/image_snapshot.cc +++ b/runtime/vm/image_snapshot.cc @@ -331,9 +331,9 @@ void ImageWriter::WriteROData(WriteStream* stream) { uword start = reinterpret_cast(obj.raw()) - kHeapObjectTag; uword end = start + obj.raw()->HeapSize(); - // Write object header with the mark and VM heap bits set. + // Write object header with the mark and read-only bits set. uword marked_tags = obj.raw()->ptr()->tags_; - marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); + marked_tags = RawObject::ReadOnlyBit::update(true, marked_tags); marked_tags = RawObject::OldBit::update(true, marked_tags); marked_tags = RawObject::OldAndNotMarkedBit::update(false, marked_tags); marked_tags = RawObject::OldAndNotRememberedBit::update(true, marked_tags); @@ -482,9 +482,9 @@ void AssemblyImageWriter::WriteText(WriteStream* clustered_stream, bool vm) { uword beginning = reinterpret_cast(insns.raw_ptr()); uword entry = beginning + Instructions::HeaderSize(); - // Write Instructions with the mark and VM heap bits set. + // Write Instructions with the mark and read-only bits set. uword marked_tags = insns.raw_ptr()->tags_; - marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); + marked_tags = RawObject::ReadOnlyBit::update(true, marked_tags); marked_tags = RawObject::OldBit::update(true, marked_tags); marked_tags = RawObject::OldAndNotMarkedBit::update(false, marked_tags); marked_tags = @@ -732,9 +732,9 @@ void BlobImageWriter::WriteText(WriteStream* clustered_stream, bool vm) { ASSERT(Utils::IsAligned(beginning, sizeof(uword))); ASSERT(Utils::IsAligned(entry, sizeof(uword))); - // Write Instructions with the mark and VM heap bits set. + // Write Instructions with the mark and read-only bits set. uword marked_tags = insns.raw_ptr()->tags_; - marked_tags = RawObject::VMHeapObjectTag::update(true, marked_tags); + marked_tags = RawObject::ReadOnlyBit::update(true, marked_tags); marked_tags = RawObject::OldBit::update(true, marked_tags); marked_tags = RawObject::OldAndNotMarkedBit::update(false, marked_tags); marked_tags = RawObject::OldAndNotRememberedBit::update(true, marked_tags); diff --git a/runtime/vm/message.cc b/runtime/vm/message.cc index 82816de1077..7af0251e0af 100644 --- a/runtime/vm/message.cc +++ b/runtime/vm/message.cc @@ -40,7 +40,7 @@ Message::Message(Dart_Port dest_port, snapshot_length_(0), finalizable_data_(NULL), priority_(priority) { - ASSERT(!raw_obj->IsHeapObject() || raw_obj->IsVMHeapObject()); + ASSERT(!raw_obj->IsHeapObject() || raw_obj->IsReadOnly()); ASSERT((priority == kNormalPriority) || (delivery_failure_port == kIllegalPort)); ASSERT(IsRaw()); diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index f5c494a057f..c8d57628f11 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -456,7 +456,7 @@ void Object::InitNull(Isolate* isolate) { uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); null_ = reinterpret_cast(address + kHeapObjectTag); // The call below is using 'null_' to initialize itself. - InitializeObject(address, kNullCid, Instance::InstanceSize(), true); + InitializeObject(address, kNullCid, Instance::InstanceSize()); } } @@ -502,7 +502,7 @@ void Object::Init(Isolate* isolate) { intptr_t size = Class::InstanceSize(); uword address = heap->Allocate(size, Heap::kOld); class_class_ = reinterpret_cast(address + kHeapObjectTag); - InitializeObject(address, Class::kClassId, size, true); + InitializeObject(address, Class::kClassId, size); Class fake; // Initialization from Class::New. @@ -701,7 +701,7 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the empty_array instance. { uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld); - InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(0), true); + InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(0)); Array::initializeHandle( empty_array_, reinterpret_cast(address + kHeapObjectTag)); empty_array_->StoreSmi(&empty_array_->raw_ptr()->length_, Smi::New(0)); @@ -712,7 +712,7 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the zero_array instance. { uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld); - InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(1), true); + InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(1)); Array::initializeHandle( zero_array_, reinterpret_cast(address + kHeapObjectTag)); zero_array_->StoreSmi(&zero_array_->raw_ptr()->length_, Smi::New(1)); @@ -724,8 +724,7 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the canonical empty context scope object. { uword address = heap->Allocate(ContextScope::InstanceSize(0), Heap::kOld); - InitializeObject(address, kContextScopeCid, ContextScope::InstanceSize(0), - true); + InitializeObject(address, kContextScopeCid, ContextScope::InstanceSize(0)); ContextScope::initializeHandle( empty_context_scope_, reinterpret_cast(address + kHeapObjectTag)); @@ -739,8 +738,7 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the canonical empty object pool object. { uword address = heap->Allocate(ObjectPool::InstanceSize(0), Heap::kOld); - InitializeObject(address, kObjectPoolCid, ObjectPool::InstanceSize(0), - true); + InitializeObject(address, kObjectPoolCid, ObjectPool::InstanceSize(0)); ObjectPool::initializeHandle( empty_object_pool_, reinterpret_cast(address + kHeapObjectTag)); @@ -752,8 +750,8 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the empty_descriptors instance. { uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld); - InitializeObject(address, kPcDescriptorsCid, PcDescriptors::InstanceSize(0), - true); + InitializeObject(address, kPcDescriptorsCid, + PcDescriptors::InstanceSize(0)); PcDescriptors::initializeHandle( empty_descriptors_, reinterpret_cast(address + kHeapObjectTag)); @@ -767,7 +765,7 @@ void Object::Init(Isolate* isolate) { uword address = heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld); InitializeObject(address, kLocalVarDescriptorsCid, - LocalVarDescriptors::InstanceSize(0), true); + LocalVarDescriptors::InstanceSize(0)); LocalVarDescriptors::initializeHandle( empty_var_descriptors_, reinterpret_cast(address + kHeapObjectTag)); @@ -783,7 +781,7 @@ void Object::Init(Isolate* isolate) { uword address = heap->Allocate(ExceptionHandlers::InstanceSize(0), Heap::kOld); InitializeObject(address, kExceptionHandlersCid, - ExceptionHandlers::InstanceSize(0), true); + ExceptionHandlers::InstanceSize(0)); ExceptionHandlers::initializeHandle( empty_exception_handlers_, reinterpret_cast(address + kHeapObjectTag)); @@ -795,8 +793,8 @@ void Object::Init(Isolate* isolate) { // Allocate and initialize the canonical empty type arguments object. { uword address = heap->Allocate(TypeArguments::InstanceSize(0), Heap::kOld); - InitializeObject(address, kTypeArgumentsCid, TypeArguments::InstanceSize(0), - true); + InitializeObject(address, kTypeArgumentsCid, + TypeArguments::InstanceSize(0)); TypeArguments::initializeHandle( empty_type_arguments_, reinterpret_cast(address + kHeapObjectTag)); @@ -1009,8 +1007,8 @@ class FinalizeVMIsolateVisitor : public ObjectVisitor { // No forwarding corpses in the VM isolate. ASSERT(!obj->IsForwardingCorpse()); if (!obj->IsFreeListElement()) { - ASSERT(obj->IsVMHeapObject()); obj->SetMarkBitUnsynchronized(); + obj->SetReadOnlyUnsynchronized(); Object::FinalizeReadOnlyObject(obj); #if defined(HASH_IN_OBJECT_HEADER) // These objects end up in the read-only VM isolate which is shared @@ -1200,8 +1198,7 @@ void Object::MakeUnusedSpaceTraversable(const Object& obj, reinterpret_cast(RawObject::FromAddr(addr)); uword new_tags = RawObject::ClassIdTag::update(kTypedDataInt8ArrayCid, 0); new_tags = RawObject::SizeTag::update(leftover_size, new_tags); - new_tags = RawObject::VMHeapObjectTag::update(obj.raw()->IsVMHeapObject(), - new_tags); + new_tags = RawObject::ReadOnlyBit::update(false, new_tags); const bool is_old = obj.raw()->IsOldObject(); new_tags = RawObject::OldBit::update(is_old, new_tags); new_tags = RawObject::OldAndNotMarkedBit::update(is_old, new_tags); @@ -1232,8 +1229,7 @@ void Object::MakeUnusedSpaceTraversable(const Object& obj, RawObject* raw = reinterpret_cast(RawObject::FromAddr(addr)); uword new_tags = RawObject::ClassIdTag::update(kInstanceCid, 0); new_tags = RawObject::SizeTag::update(leftover_size, new_tags); - new_tags = RawObject::VMHeapObjectTag::update(obj.raw()->IsVMHeapObject(), - new_tags); + new_tags = RawObject::ReadOnlyBit::update(false, new_tags); const bool is_old = obj.raw()->IsOldObject(); new_tags = RawObject::OldBit::update(is_old, new_tags); new_tags = RawObject::OldAndNotMarkedBit::update(is_old, new_tags); @@ -2016,12 +2012,12 @@ RawError* Object::Init(Isolate* isolate, } #if defined(DEBUG) -bool Object::InVMHeap() const { - if (FLAG_verify_handles && raw()->IsVMHeapObject()) { +bool Object::IsReadOnly() const { + if (FLAG_verify_handles && raw()->IsReadOnly()) { Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); ASSERT(vm_isolate_heap->Contains(RawObject::ToAddr(raw()))); } - return raw()->IsVMHeapObject(); + return raw()->IsReadOnly(); } #endif // DEBUG @@ -2033,10 +2029,7 @@ RawString* Object::DictionaryName() const { return String::null(); } -void Object::InitializeObject(uword address, - intptr_t class_id, - intptr_t size, - bool is_vm_object) { +void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) { uword initial_value = (class_id == kInstructionsCid) ? Assembler::GetBreakInstructionFiller() : reinterpret_cast(null_); @@ -2050,7 +2043,7 @@ void Object::InitializeObject(uword address, ASSERT(class_id != kIllegalCid); tags = RawObject::ClassIdTag::update(class_id, tags); tags = RawObject::SizeTag::update(size, tags); - tags = RawObject::VMHeapObjectTag::update(is_vm_object, tags); + tags = RawObject::ReadOnlyBit::update(false, tags); const bool is_old = (address & kNewObjectAlignmentOffset) == kOldObjectAlignmentOffset; tags = RawObject::OldBit::update(is_old, tags); @@ -2061,7 +2054,6 @@ void Object::InitializeObject(uword address, #if defined(HASH_IN_OBJECT_HEADER) reinterpret_cast(address)->hash_ = 0; #endif - ASSERT(is_vm_object == RawObject::IsVMHeapObject(tags)); } void Object::CheckHandle() const { @@ -2092,8 +2084,7 @@ RawObject* Object::Allocate(intptr_t cls_id, intptr_t size, Heap::Space space) { Thread* thread = Thread::Current(); ASSERT(thread->execution_state() == Thread::kThreadInVM); ASSERT(thread->no_callback_scope_depth() == 0); - Isolate* isolate = thread->isolate(); - Heap* heap = isolate->heap(); + Heap* heap = thread->heap(); uword address; @@ -2104,15 +2095,16 @@ RawObject* Object::Allocate(intptr_t cls_id, intptr_t size, Heap::Space space) { } else { address = heap->Allocate(size, space); } - if (address == 0) { + if (UNLIKELY(address == 0)) { // Use the preallocated out of memory exception to avoid calling // into dart code or allocating any code. const Instance& exception = - Instance::Handle(isolate->object_store()->out_of_memory()); + Instance::Handle(thread->isolate()->object_store()->out_of_memory()); Exceptions::Throw(thread, exception); UNREACHABLE(); } #ifndef PRODUCT + Isolate* isolate = thread->isolate(); ClassTable* class_table = isolate->class_table(); if (space == Heap::kNew) { class_table->UpdateAllocatedNew(cls_id, size); @@ -2125,7 +2117,7 @@ RawObject* Object::Allocate(intptr_t cls_id, intptr_t size, Heap::Space space) { } #endif // !PRODUCT NoSafepointScope no_safepoint; - InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate())); + InitializeObject(address, cls_id, size); RawObject* raw_obj = reinterpret_cast(address + kHeapObjectTag); ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_)); if (raw_obj->IsOldObject() && thread->is_marking()) { @@ -16076,7 +16068,7 @@ RawInstance* Instance::CheckAndCanonicalize(Thread* thread, return result.raw(); } if (IsNew()) { - ASSERT((isolate == Dart::vm_isolate()) || !InVMHeap()); + ASSERT((isolate == Dart::vm_isolate()) || !IsReadOnly()); // Create a canonical object in old space. result ^= Object::Clone(*this, Heap::kOld); } else { @@ -17421,7 +17413,7 @@ RawAbstractType* Type::Canonicalize(TrailPtr trail) const { ASSERT(!IsFunctionType()); Type& type = Type::Handle(zone, cls.declaration_type()); if (type.IsNull()) { - ASSERT(!cls.raw()->IsVMHeapObject() || (isolate == Dart::vm_isolate())); + ASSERT(!cls.raw()->IsReadOnly() || (isolate == Dart::vm_isolate())); // Canonicalize the type arguments of the supertype, if any. TypeArguments& type_args = TypeArguments::Handle(zone, arguments()); type_args = type_args.Canonicalize(trail); diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 4928e9fb57c..b80bd632831 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -307,9 +307,9 @@ class Object { bool IsNew() const { return raw()->IsNewObject(); } bool IsOld() const { return raw()->IsOldObject(); } #if defined(DEBUG) - bool InVMHeap() const; + bool IsReadOnly() const; #else - bool InVMHeap() const { return raw()->IsVMHeapObject(); } + bool IsReadOnly() const { return raw()->IsReadOnly(); } #endif // DEBUG // Print the object on stdout for debugging. @@ -637,10 +637,7 @@ class Object { return -kWordSize; } - static void InitializeObject(uword address, - intptr_t id, - intptr_t size, - bool is_vm_object); + static void InitializeObject(uword address, intptr_t id, intptr_t size); static void RegisterClass(const Class& cls, const String& name, diff --git a/runtime/vm/object_graph.cc b/runtime/vm/object_graph.cc index 6b7cda35a76..5a5e740e878 100644 --- a/runtime/vm/object_graph.cc +++ b/runtime/vm/object_graph.cc @@ -532,7 +532,7 @@ class WritePointerVisitor : public ObjectPointerVisitor { virtual void VisitPointers(RawObject** first, RawObject** last) { for (RawObject** current = first; current <= last; ++current) { RawObject* object = *current; - if (!object->IsHeapObject() || object->IsVMHeapObject()) { + if (!object->IsHeapObject() || object->IsReadOnly()) { // Ignore smis and objects in the VM isolate for now. // TODO(koda): To track which field each pointer corresponds to, // we'll need to encode which fields were omitted here. diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 179a09186c6..3c22b278ed3 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -84,7 +84,7 @@ class ParsedFunction : public ZoneAllocated { #if defined(DEBUG) if (list == NULL) return; for (intptr_t i = 0; i < list->length(); i++) { - ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->InVMHeap()); + ASSERT(list->At(i)->IsZoneHandle() || list->At(i)->IsReadOnly()); } #endif } diff --git a/runtime/vm/program_visitor.cc b/runtime/vm/program_visitor.cc index 8260a86cd3a..660f102db9f 100644 --- a/runtime/vm/program_visitor.cc +++ b/runtime/vm/program_visitor.cc @@ -653,7 +653,8 @@ void ProgramVisitor::DedupLists() { if (FLAG_precompiled_mode) { if (!function.IsSignatureFunction() && !function.IsClosureFunction() && - (function.name() != Symbols::Call().raw()) && !list_.InVMHeap()) { + (function.name() != Symbols::Call().raw()) && + !list_.IsReadOnly()) { // Parameter types not needed for function type tests. for (intptr_t i = 0; i < list_.Length(); i++) { list_.SetAt(i, Object::dynamic_type()); @@ -668,7 +669,7 @@ void ProgramVisitor::DedupLists() { if (!list_.IsNull()) { // Preserve parameter names in case of recompilation for the JIT. if (FLAG_precompiled_mode) { - if (!function.HasOptionalNamedParameters() && !list_.InVMHeap()) { + if (!function.HasOptionalNamedParameters() && !list_.IsReadOnly()) { // Parameter names not needed for resolution. for (intptr_t i = 0; i < list_.Length(); i++) { list_.SetAt(i, Symbols::OptimizedOut()); @@ -681,7 +682,7 @@ void ProgramVisitor::DedupLists() { } RawArray* DedupList(const Array& list) { - if (list.InVMHeap()) { + if (list.IsReadOnly()) { // Avoid using read-only VM objects for de-duplication. return list.raw(); } diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h index a4333c39c16..89d15543935 100644 --- a/runtime/vm/raw_object.h +++ b/runtime/vm/raw_object.h @@ -121,7 +121,7 @@ class RawObject { kOldBit = 3, // Incremental barrier source. kOldAndNotRememberedBit = 4, // Generational barrier source. kCanonicalBit = 5, - kVMHeapObjectBit = 6, + kReadOnlyBit = 6, kGraphMarkedBit = 7, // ObjectGraph needs to mark through new space. kSizeTagPos = 8, @@ -190,13 +190,11 @@ class RawObject { class NewBit : public BitField {}; - class CanonicalObjectTag : public BitField { - }; + class CanonicalBit : public BitField {}; class GraphMarkedBit : public BitField {}; - class VMHeapObjectTag : public BitField { - }; + class ReadOnlyBit : public BitField {}; class OldBit : public BitField {}; @@ -250,7 +248,8 @@ class RawObject { return (addr & kObjectAlignmentMask) != kOldObjectBits; } - // Support for GC marking bit. + // Support for GC marking bit. Marked objects are either grey (not yet + // visited) or black (already visited). bool IsMarked() const { ASSERT(IsOldObject()); return !OldAndNotMarkedBit::decode(ptr()->tags_); @@ -278,25 +277,33 @@ class RawObject { return TryClearTagBit(); } - // Support for object tags. - bool IsCanonical() const { return CanonicalObjectTag::decode(ptr()->tags_); } - void SetCanonical() { UpdateTagBit(true); } - void ClearCanonical() { UpdateTagBit(false); } - bool IsVMHeapObject() const { return VMHeapObjectTag::decode(ptr()->tags_); } - void SetVMHeapObject() { UpdateTagBit(true); } + // Canonical objects have the property that two canonical objects are + // logically equal iff they are the same object (pointer equal). + bool IsCanonical() const { return CanonicalBit::decode(ptr()->tags_); } + void SetCanonical() { UpdateTagBit(true); } + void ClearCanonical() { UpdateTagBit(false); } - // Support for ObjectGraph marking bit. + // Objects in the VM-isolate's heap or on an image page from an AppJIT or + // AppAOT snapshot are permanently read-only. They may never be modified + // again. In particular, they cannot be marked. + bool IsReadOnly() const { return ReadOnlyBit::decode(ptr()->tags_); } + void SetReadOnlyUnsynchronized() { + ptr()->tags_ = ReadOnlyBit::update(true, ptr()->tags_); + } + + // Support for ObjectGraph marking bit, used by various tools provided by the + // VM-service. bool IsGraphMarked() const { - if (IsVMHeapObject()) return true; + if (IsReadOnly()) return true; return GraphMarkedBit::decode(ptr()->tags_); } void SetGraphMarked() { - ASSERT(!IsVMHeapObject()); + ASSERT(!IsReadOnly()); uint32_t tags = ptr()->tags_; ptr()->tags_ = GraphMarkedBit::update(true, tags); } void ClearGraphMarked() { - ASSERT(!IsVMHeapObject()); + ASSERT(!IsReadOnly()); uint32_t tags = ptr()->tags_; ptr()->tags_ = GraphMarkedBit::update(false, tags); } @@ -463,12 +470,10 @@ class RawObject { return reinterpret_cast(raw_obj->ptr()); } - static bool IsVMHeapObject(intptr_t value) { - return VMHeapObjectTag::decode(value); - } + static bool IsReadOnly(intptr_t value) { return ReadOnlyBit::decode(value); } static bool IsCanonical(intptr_t value) { - return CanonicalObjectTag::decode(value); + return CanonicalBit::decode(value); } // Class Id predicates. diff --git a/runtime/vm/snapshot.cc b/runtime/vm/snapshot.cc index bf62b08bdf2..0b9df59f00c 100644 --- a/runtime/vm/snapshot.cc +++ b/runtime/vm/snapshot.cc @@ -1015,7 +1015,7 @@ bool SnapshotWriter::CheckAndWritePredefinedObject(RawObject* rawobj) { // Now check if it is an object from the VM isolate. These objects are shared // by all isolates. - if (rawobj->IsVMHeapObject() && HandleVMIsolateObject(rawobj)) { + if (rawobj->IsReadOnly() && HandleVMIsolateObject(rawobj)) { return true; } diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc index 3abefb795be..78cea42939f 100644 --- a/runtime/vm/thread.cc +++ b/runtime/vm/thread.cc @@ -740,7 +740,7 @@ intptr_t Thread::OffsetFromThread(const Object& object) { // [object] is in fact a [Code] object. if (object.IsCode()) { #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ - ASSERT((expr)->IsVMHeapObject()); \ + ASSERT((expr)->IsReadOnly()); \ if (object.raw() == expr) { \ return Thread::member_name##offset(); \ } @@ -751,7 +751,6 @@ intptr_t Thread::OffsetFromThread(const Object& object) { // For non [Code] objects we check if the object equals to any of the cached // non-stub entries. #define COMPUTE_OFFSET(type_name, member_name, expr, default_init_value) \ - ASSERT((expr)->IsVMHeapObject()); \ if (object.raw() == expr) { \ return Thread::member_name##offset(); \ }