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

Unified Diff: runtime/vm/object.cc

Issue 2780393005: Move the canonical empty context to the VM isolate. (Closed)
Patch Set: . Created 3 years, 9 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/object_store.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 502e747371cf65c5ea75010f1ea648d27e5904a4..e57f9351610eaa783069667bd564321564a524c9 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -113,6 +113,7 @@ Instance* Object::null_instance_ = NULL;
TypeArguments* Object::null_type_arguments_ = NULL;
Array* Object::empty_array_ = NULL;
Array* Object::zero_array_ = NULL;
+Context* Object::empty_context_ = NULL;
ContextScope* Object::empty_context_scope_ = NULL;
ObjectPool* Object::empty_object_pool_ = NULL;
PcDescriptors* Object::empty_descriptors_ = NULL;
@@ -516,6 +517,7 @@ void Object::InitOnce(Isolate* isolate) {
null_type_arguments_ = TypeArguments::ReadOnlyHandle();
empty_array_ = Array::ReadOnlyHandle();
zero_array_ = Array::ReadOnlyHandle();
+ empty_context_ = Context::ReadOnlyHandle();
empty_context_scope_ = ContextScope::ReadOnlyHandle();
empty_object_pool_ = ObjectPool::ReadOnlyHandle();
empty_descriptors_ = PcDescriptors::ReadOnlyHandle();
@@ -777,6 +779,17 @@ void Object::InitOnce(Isolate* isolate) {
zero_array_->SetCanonical();
}
+ // Allocate and initialize the empty context object.
+ {
+ uword address = heap->Allocate(Context::InstanceSize(0), Heap::kOld);
+ InitializeObject(address, kContextCid, Context::InstanceSize(0), true);
+ Context::initializeHandle(empty_context_, reinterpret_cast<RawContext*>(
+ address + kHeapObjectTag));
+ empty_context_->StoreNonPointer(&empty_context_->raw_ptr()->num_variables_,
+ 0);
+ empty_context_->SetCanonical();
+ }
+
// Allocate and initialize the canonical empty context scope object.
{
uword address = heap->Allocate(ContextScope::InstanceSize(0), Heap::kOld);
@@ -922,6 +935,8 @@ void Object::InitOnce(Isolate* isolate) {
ASSERT(empty_array_->IsArray());
ASSERT(!zero_array_->IsSmi());
ASSERT(zero_array_->IsArray());
+ ASSERT(!empty_context_->IsSmi());
+ ASSERT(empty_context_->IsContext());
ASSERT(!empty_context_scope_->IsSmi());
ASSERT(empty_context_scope_->IsContextScope());
ASSERT(!empty_descriptors_->IsSmi());
@@ -1268,9 +1283,6 @@ RawError* Object::Init(Isolate* isolate, kernel::Program* kernel_program) {
GrowableObjectArray::Handle(zone, GrowableObjectArray::New());
object_store->set_pending_classes(pending_classes);
- Context& context = Context::Handle(zone, Context::New(0, Heap::kOld));
- object_store->set_empty_context(context);
-
// Now that the symbol table is initialized and that the core dictionary as
// well as the core implementation dictionary have been setup, preallocate
// remaining classes and register them by name in the dictionaries.
@@ -1787,9 +1799,6 @@ RawError* Object::Init(Isolate* isolate, kernel::Program* kernel_program) {
cls = Class::New<MirrorReference>();
cls = Class::New<UserTag>();
-
- const Context& context = Context::Handle(zone, Context::New(0, Heap::kOld));
- object_store->set_empty_context(context);
}
return Error::null();
}
@@ -6930,12 +6939,8 @@ void Function::BuildSignatureParameters(
RawInstance* Function::ImplicitStaticClosure() const {
if (implicit_static_closure() == Instance::null()) {
- Thread* thread = Thread::Current();
- Isolate* isolate = thread->isolate();
- Zone* zone = thread->zone();
- ObjectStore* object_store = isolate->object_store();
- const Context& context =
- Context::Handle(zone, object_store->empty_context());
+ Zone* zone = Thread::Current()->zone();
+ const Context& context = Object::empty_context();
const TypeArguments& instantiator = TypeArguments::Handle(zone);
Instance& closure = Instance::Handle(
zone, Closure::New(instantiator, *this, context, Heap::kOld));
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698