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

Unified Diff: runtime/vm/object.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/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 88ebd0e8e941309c6b21a740741755ce938ac85a..4351b1de8550367d85468b233b91bf0471998692 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -399,7 +399,7 @@ void Object::InitNull(Isolate* isolate) {
uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld);
null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag);
// The call below is using 'null_' to initialize itself.
- InitializeObject(address, kNullCid, Instance::InstanceSize());
+ InitializeObject(address, kNullCid, Instance::InstanceSize(), true);
}
}
@@ -462,7 +462,7 @@ void Object::InitOnce(Isolate* isolate) {
intptr_t size = Class::InstanceSize();
uword address = heap->Allocate(size, Heap::kOld);
class_class_ = reinterpret_cast<RawClass*>(address + kHeapObjectTag);
- InitializeObject(address, Class::kClassId, size);
+ InitializeObject(address, Class::kClassId, size, true);
Class fake;
// Initialization from Class::New<Class>.
@@ -635,7 +635,7 @@ void Object::InitOnce(Isolate* isolate) {
// Allocate and initialize the empty_array instance.
{
uword address = heap->Allocate(Array::InstanceSize(0), Heap::kOld);
- InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(0));
+ InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(0), true);
Array::initializeHandle(
empty_array_,
reinterpret_cast<RawArray*>(address + kHeapObjectTag));
@@ -646,7 +646,7 @@ void Object::InitOnce(Isolate* isolate) {
// Allocate and initialize the zero_array instance.
{
uword address = heap->Allocate(Array::InstanceSize(1), Heap::kOld);
- InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(1));
+ InitializeObject(address, kImmutableArrayCid, Array::InstanceSize(1), true);
Array::initializeHandle(
zero_array_,
reinterpret_cast<RawArray*>(address + kHeapObjectTag));
@@ -661,7 +661,8 @@ void Object::InitOnce(Isolate* isolate) {
heap->Allocate(ObjectPool::InstanceSize(0), Heap::kOld);
InitializeObject(address,
kObjectPoolCid,
- ObjectPool::InstanceSize(0));
+ ObjectPool::InstanceSize(0),
+ true);
ObjectPool::initializeHandle(
empty_object_pool_,
reinterpret_cast<RawObjectPool*>(address + kHeapObjectTag));
@@ -673,7 +674,8 @@ void Object::InitOnce(Isolate* isolate) {
{
uword address = heap->Allocate(PcDescriptors::InstanceSize(0), Heap::kOld);
InitializeObject(address, kPcDescriptorsCid,
- PcDescriptors::InstanceSize(0));
+ PcDescriptors::InstanceSize(0),
+ true);
PcDescriptors::initializeHandle(
empty_descriptors_,
reinterpret_cast<RawPcDescriptors*>(address + kHeapObjectTag));
@@ -687,7 +689,8 @@ void Object::InitOnce(Isolate* isolate) {
heap->Allocate(LocalVarDescriptors::InstanceSize(0), Heap::kOld);
InitializeObject(address,
kLocalVarDescriptorsCid,
- LocalVarDescriptors::InstanceSize(0));
+ LocalVarDescriptors::InstanceSize(0),
+ true);
LocalVarDescriptors::initializeHandle(
empty_var_descriptors_,
reinterpret_cast<RawLocalVarDescriptors*>(address + kHeapObjectTag));
@@ -703,7 +706,8 @@ void Object::InitOnce(Isolate* isolate) {
heap->Allocate(ExceptionHandlers::InstanceSize(0), Heap::kOld);
InitializeObject(address,
kExceptionHandlersCid,
- ExceptionHandlers::InstanceSize(0));
+ ExceptionHandlers::InstanceSize(0),
+ true);
ExceptionHandlers::initializeHandle(
empty_exception_handlers_,
reinterpret_cast<RawExceptionHandlers*>(address + kHeapObjectTag));
@@ -809,6 +813,7 @@ class PremarkingVisitor : public ObjectVisitor {
ASSERT(!obj->IsMarked());
// Free list elements should never be marked.
if (!obj->IsFreeListElement()) {
+ ASSERT(obj->IsVMHeapObject());
obj->SetMarkBitUnsynchronized();
}
}
@@ -1674,7 +1679,10 @@ RawString* Object::DictionaryName() const {
}
-void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) {
+void Object::InitializeObject(uword address,
+ intptr_t class_id,
+ intptr_t size,
+ bool is_vm_object) {
// TODO(iposva): Get a proper halt instruction from the assembler which
// would be needed here for code objects.
uword initial_value = reinterpret_cast<uword>(null_);
@@ -1688,7 +1696,9 @@ void Object::InitializeObject(uword address, intptr_t class_id, intptr_t size) {
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);
reinterpret_cast<RawObject*>(address)->tags_ = tags;
+ ASSERT(is_vm_object == RawObject::IsVMHeapObject(tags));
VerifiedMemory::Accept(address, size);
}
@@ -1746,7 +1756,7 @@ RawObject* Object::Allocate(intptr_t cls_id,
Profiler::RecordAllocation(isolate, cls_id);
}
NoSafepointScope no_safepoint;
- InitializeObject(address, cls_id, size);
+ InitializeObject(address, cls_id, size, (isolate == Dart::vm_isolate()));
RawObject* raw_obj = reinterpret_cast<RawObject*>(address + kHeapObjectTag);
ASSERT(cls_id == RawObject::ClassIdTag::decode(raw_obj->ptr()->tags_));
return raw_obj;
@@ -1840,6 +1850,12 @@ RawString* Class::UserVisibleName() const {
}
+bool Class::IsInFullSnapshot() const {
+ NoSafepointScope no_safepoint;
+ return raw_ptr()->library_->ptr()->is_in_fullsnapshot_;
+}
+
+
RawType* Class::SignatureType() const {
ASSERT(IsSignatureClass());
const Function& function = Function::Handle(signature_function());
@@ -9826,6 +9842,7 @@ RawLibrary* Library::NewLibraryHelper(const String& url,
result.StorePointer(&result.raw_ptr()->load_error_, Instance::null());
result.set_native_entry_resolver(NULL);
result.set_native_entry_symbol_resolver(NULL);
+ result.set_is_in_fullsnapshot(false);
result.StoreNonPointer(&result.raw_ptr()->corelib_imported_, true);
result.set_debuggable(false);
result.set_is_dart_scheme(url.StartsWith(Symbols::DartScheme()));
@@ -15258,6 +15275,7 @@ RawType* Type::NewNonParameterizedType(const Class& type_class) {
void Type::SetIsFinalized() const {
ASSERT(!IsFinalized());
if (IsInstantiated()) {
+ ASSERT(HasResolvedTypeClass());
set_type_state(RawType::kFinalizedInstantiated);
} else {
set_type_state(RawType::kFinalizedUninstantiated);
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698