Index: src/contexts.cc |
diff --git a/src/contexts.cc b/src/contexts.cc |
index 76784bd704602b955924c6255c8883b013b1e624..7c610aff674ed3e9cb73122b77209a75ddb99fe8 100644 |
--- a/src/contexts.cc |
+++ b/src/contexts.cc |
@@ -304,10 +304,14 @@ void Context::ClearOptimizedFunctions() { |
#ifdef DEBUG |
-bool Context::IsBootstrappingOrContext(Object* object) { |
+bool Context::IsBootstrappingOrValidContext(Object* object) { |
// During bootstrapping we allow all objects to pass as |
// contexts. This is necessary to fix circular dependencies. |
- return Isolate::Current()->bootstrapper()->IsActive() || object->IsContext(); |
+ if (Isolate::Current()->bootstrapper()->IsActive()) return true; |
+ if (!object->IsContext()) return false; |
+ Context* context = Context::cast(object); |
+ return context->IsGlobalContext() || context->IsModuleContext() || |
+ !this->IsModuleContext(); |
} |