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

Unified Diff: src/contexts.cc

Issue 1478303002: Revert of [runtime] Replace global object link with native context link in all contexts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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 | « src/contexts.h ('k') | src/contexts-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/contexts.h ('k') | src/contexts-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698