Move context global handle creation out of Genesis.

R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/12919009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13978 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 2416d691
...@@ -147,16 +147,13 @@ class Genesis BASE_EMBEDDED { ...@@ -147,16 +147,13 @@ class Genesis BASE_EMBEDDED {
v8::ExtensionConfiguration* extensions); v8::ExtensionConfiguration* extensions);
~Genesis() { } ~Genesis() { }
Handle<Context> result() { return result_; }
Isolate* isolate() const { return isolate_; } Isolate* isolate() const { return isolate_; }
Factory* factory() const { return isolate_->factory(); } Factory* factory() const { return isolate_->factory(); }
Heap* heap() const { return isolate_->heap(); } Heap* heap() const { return isolate_->heap(); }
private: Handle<Context> result() { return result_; }
Handle<Context> native_context_;
Isolate* isolate_;
private:
Handle<Context> native_context() { return native_context_; } Handle<Context> native_context() { return native_context_; }
// Creates some basic objects. Used for creating a context from scratch. // Creates some basic objects. Used for creating a context from scratch.
...@@ -277,7 +274,9 @@ class Genesis BASE_EMBEDDED { ...@@ -277,7 +274,9 @@ class Genesis BASE_EMBEDDED {
Handle<Context> top_context, Handle<Context> top_context,
bool use_runtime_context); bool use_runtime_context);
Isolate* isolate_;
Handle<Context> result_; Handle<Context> result_;
Handle<Context> native_context_;
// Function instance maps. Function literal maps are created initially with // Function instance maps. Function literal maps are created initially with
// a read only prototype for the processing of JS builtins. Later the function // a read only prototype for the processing of JS builtins. Later the function
...@@ -303,9 +302,9 @@ Handle<Context> Bootstrapper::CreateEnvironment( ...@@ -303,9 +302,9 @@ Handle<Context> Bootstrapper::CreateEnvironment(
v8::Handle<v8::ObjectTemplate> global_template, v8::Handle<v8::ObjectTemplate> global_template,
v8::ExtensionConfiguration* extensions) { v8::ExtensionConfiguration* extensions) {
HandleScope scope(isolate_); HandleScope scope(isolate_);
Handle<Context> env;
Genesis genesis(isolate_, global_object, global_template, extensions); Genesis genesis(isolate_, global_object, global_template, extensions);
env = genesis.result(); Handle<Object> context(isolate_->global_handles()->Create(*genesis.result()));
Handle<Context> env = Handle<Context>::cast(context);
if (!env.is_null()) { if (!env.is_null()) {
if (InstallExtensions(env, extensions)) { if (InstallExtensions(env, extensions)) {
return env; return env;
...@@ -692,9 +691,8 @@ void Genesis::CreateRoots() { ...@@ -692,9 +691,8 @@ void Genesis::CreateRoots() {
// closure and extension object later (we need the empty function // closure and extension object later (we need the empty function
// and the global object, but in order to create those, we need the // and the global object, but in order to create those, we need the
// native context). // native context).
native_context_ = Handle<Context>::cast(isolate()->global_handles()->Create( native_context_ = factory()->NewNativeContext();
*factory()->NewNativeContext())); AddToWeakNativeContextList(*native_context());
AddToWeakNativeContextList(*native_context_);
isolate()->set_context(*native_context()); isolate()->set_context(*native_context());
// Allocate the message listeners object. // Allocate the message listeners object.
...@@ -823,11 +821,11 @@ void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global, ...@@ -823,11 +821,11 @@ void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) { void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
Handle<GlobalObject> inner_global_from_snapshot( Handle<GlobalObject> inner_global_from_snapshot(
GlobalObject::cast(native_context_->extension())); GlobalObject::cast(native_context()->extension()));
Handle<JSBuiltinsObject> builtins_global(native_context_->builtins()); Handle<JSBuiltinsObject> builtins_global(native_context()->builtins());
native_context_->set_extension(*inner_global); native_context()->set_extension(*inner_global);
native_context_->set_global_object(*inner_global); native_context()->set_global_object(*inner_global);
native_context_->set_security_token(*inner_global); native_context()->set_security_token(*inner_global);
static const PropertyAttributes attributes = static const PropertyAttributes attributes =
static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
ForceSetProperty(builtins_global, ForceSetProperty(builtins_global,
...@@ -2417,7 +2415,6 @@ Genesis::Genesis(Isolate* isolate, ...@@ -2417,7 +2415,6 @@ Genesis::Genesis(Isolate* isolate,
// Before creating the roots we must save the context and restore it // Before creating the roots we must save the context and restore it
// on all function exits. // on all function exits.
HandleScope scope(isolate);
SaveContext saved_context(isolate); SaveContext saved_context(isolate);
// During genesis, the boilerplate for stack overflow won't work until the // During genesis, the boilerplate for stack overflow won't work until the
...@@ -2426,12 +2423,10 @@ Genesis::Genesis(Isolate* isolate, ...@@ -2426,12 +2423,10 @@ Genesis::Genesis(Isolate* isolate,
StackLimitCheck check(isolate); StackLimitCheck check(isolate);
if (check.HasOverflowed()) return; if (check.HasOverflowed()) return;
Handle<Context> new_context = Snapshot::NewContextFromSnapshot(); native_context_ = Snapshot::NewContextFromSnapshot();
if (!new_context.is_null()) { if (!native_context().is_null()) {
native_context_ = AddToWeakNativeContextList(*native_context());
Handle<Context>::cast(isolate->global_handles()->Create(*new_context)); isolate->set_context(*native_context());
AddToWeakNativeContextList(*native_context_);
isolate->set_context(*native_context_);
isolate->counters()->contexts_created_by_snapshot()->Increment(); isolate->counters()->contexts_created_by_snapshot()->Increment();
Handle<GlobalObject> inner_global; Handle<GlobalObject> inner_global;
Handle<JSGlobalProxy> global_proxy = Handle<JSGlobalProxy> global_proxy =
...@@ -2467,7 +2462,7 @@ Genesis::Genesis(Isolate* isolate, ...@@ -2467,7 +2462,7 @@ Genesis::Genesis(Isolate* isolate,
InitializeExperimentalGlobal(); InitializeExperimentalGlobal();
if (!InstallExperimentalNatives()) return; if (!InstallExperimentalNatives()) return;
result_ = native_context_; result_ = native_context();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment