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

Unified Diff: src/contexts.cc

Issue 1214903017: Return this in Context::native_context if receiver is a native context. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Update comment Created 5 years, 6 months 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 | « no previous file | no next file » | 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 61b83c2c4e546b7a37d25007ee0ea26d1de6ef4f..0c27681a7dca42554f6d835e626d84d058708c79 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -85,22 +85,13 @@ Context* Context::script_context() {
Context* Context::native_context() {
- // Fast case: the global object for this context has been set. In
- // that case, the global object has a direct pointer to the global
- // context.
- if (global_object()->IsGlobalObject()) {
- return global_object()->native_context();
- }
-
- // During bootstrapping, the global object might not be set and we
- // have to search the context chain to find the native context.
- DCHECK(this->GetIsolate()->bootstrapper()->IsActive());
- Context* current = this;
- while (!current->IsNativeContext()) {
- JSFunction* closure = JSFunction::cast(current->closure());
- current = Context::cast(closure->context());
- }
- return current;
+ // 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()->IsGlobalObject());
+ return global_object()->native_context();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698