| Index: src/contexts.cc
|
| diff --git a/src/contexts.cc b/src/contexts.cc
|
| index 206f4a2e73d17015a17238610b63b92d7553c98b..f769b9bb7e9fd6ce5e874d7dde741aa2de382c45 100644
|
| --- a/src/contexts.cc
|
| +++ b/src/contexts.cc
|
| @@ -118,17 +118,23 @@
|
| }
|
|
|
|
|
| -JSGlobalObject* Context::global_object() {
|
| - return JSGlobalObject::cast(native_context()->extension());
|
| -}
|
| -
|
| -
|
| Context* Context::script_context() {
|
| Context* current = this;
|
| while (!current->IsScriptContext()) {
|
| current = current->previous();
|
| }
|
| return current;
|
| +}
|
| +
|
| +
|
| +Context* Context::native_context() {
|
| + // Fast case: the receiver context is already a native context.
|
| + if (IsNativeContext()) return this;
|
| + // The global object has a direct pointer to the native context. If the
|
| + // following DCHECK fails, the native context is probably being accessed
|
| + // indirectly during bootstrapping. This is unsupported.
|
| + DCHECK(global_object()->IsJSGlobalObject());
|
| + return global_object()->native_context();
|
| }
|
|
|
|
|
| @@ -551,15 +557,6 @@
|
|
|
|
|
| #ifdef DEBUG
|
| -
|
| -bool Context::IsBootstrappingOrNativeContext(Isolate* isolate, Object* object) {
|
| - // During bootstrapping we allow all objects to pass as global
|
| - // objects. This is necessary to fix circular dependencies.
|
| - return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
|
| - isolate->bootstrapper()->IsActive() || object->IsNativeContext();
|
| -}
|
| -
|
| -
|
| bool Context::IsBootstrappingOrValidParentContext(
|
| Object* object, Context* child) {
|
| // During bootstrapping we allow all objects to pass as
|
| @@ -571,6 +568,13 @@
|
| context->IsModuleContext() || !child->IsModuleContext();
|
| }
|
|
|
| +
|
| +bool Context::IsBootstrappingOrGlobalObject(Isolate* isolate, Object* object) {
|
| + // During bootstrapping we allow all objects to pass as global
|
| + // objects. This is necessary to fix circular dependencies.
|
| + return isolate->heap()->gc_state() != Heap::NOT_IN_GC ||
|
| + isolate->bootstrapper()->IsActive() || object->IsJSGlobalObject();
|
| +}
|
| #endif
|
|
|
|
|
|
|