| Index: src/bootstrapper.cc
|
| diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
|
| index 987e2290e5b74565e93282bd650e236d1b18c8d8..3758f4313d28790048474f6bec0bbc534d45128a 100644
|
| --- a/src/bootstrapper.cc
|
| +++ b/src/bootstrapper.cc
|
| @@ -457,15 +457,34 @@ Handle<JSFunction> Genesis::CreateEmptyFunction() {
|
| }
|
|
|
|
|
| +static void AddToWeakGlobalContextList(Context* context) {
|
| + ASSERT(context->IsGlobalContext());
|
| + Heap* heap = Isolate::Current()->heap();
|
| +#ifdef DEBUG
|
| + { // NOLINT
|
| + ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
|
| + // Check that context is not in the list yet.
|
| + for (Object* current = heap->global_contexts_list();
|
| + !current->IsUndefined();
|
| + current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) {
|
| + ASSERT(current != context);
|
| + }
|
| + }
|
| +#endif
|
| + context->set(Context::NEXT_CONTEXT_LINK, heap->global_contexts_list());
|
| + heap->set_global_contexts_list(context);
|
| +}
|
| +
|
| +
|
| void Genesis::CreateRoots() {
|
| Isolate* isolate = Isolate::Current();
|
| // Allocate the global context FixedArray first and then patch the
|
| // closure and extension object later (we need the empty function
|
| // and the global object, but in order to create those, we need the
|
| // global context).
|
| - global_context_ =
|
| - Handle<Context>::cast(
|
| - isolate->global_handles()->Create(*FACTORY->NewGlobalContext()));
|
| + global_context_ = Handle<Context>::cast(isolate->global_handles()->Create(
|
| + *isolate->factory()->NewGlobalContext()));
|
| + AddToWeakGlobalContextList(*global_context_);
|
| isolate->set_context(*global_context());
|
|
|
| // Allocate the message listeners object.
|
| @@ -1572,7 +1591,7 @@ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
|
| = Handle<SharedFunctionInfo>(function->shared());
|
| if (!EnsureCompiled(shared, CLEAR_EXCEPTION)) return false;
|
| // Set the code object on the function object.
|
| - function->set_code(function->shared()->code());
|
| + function->ReplaceCode(function->shared()->code());
|
| builtins->set_javascript_builtin_code(id, shared->code());
|
| }
|
| return true;
|
| @@ -1761,7 +1780,8 @@ Genesis::Genesis(Handle<Object> global_object,
|
| Handle<Context> new_context = Snapshot::NewContextFromSnapshot();
|
| if (!new_context.is_null()) {
|
| global_context_ =
|
| - Handle<Context>::cast(isolate->global_handles()->Create(*new_context));
|
| + Handle<Context>::cast(isolate->global_handles()->Create(*new_context));
|
| + AddToWeakGlobalContextList(*global_context_);
|
| isolate->set_context(*global_context_);
|
| isolate->counters()->contexts_created_by_snapshot()->Increment();
|
| result_ = global_context_;
|
| @@ -1797,11 +1817,6 @@ Genesis::Genesis(Handle<Object> global_object,
|
| isolate->counters()->contexts_created_from_scratch()->Increment();
|
| }
|
|
|
| - // Add this context to the weak list of global contexts.
|
| - (*global_context_)->set(Context::NEXT_CONTEXT_LINK,
|
| - isolate->heap()->global_contexts_list());
|
| - isolate->heap()->set_global_contexts_list(*global_context_);
|
| -
|
| result_ = global_context_;
|
| }
|
|
|
|
|