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

Unified Diff: src/contexts.cc

Issue 650663003: harmony-scoping: Correct dynamic lookups on a top level. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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 | test/cctest/test-decls.cc » ('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 30c474d5fff58fd8130f5bc00d58c89f78f1438c..04742942a1845b267ebb4c9b5fe9ce23f920bee4 100644
--- a/src/contexts.cc
+++ b/src/contexts.cc
@@ -122,13 +122,27 @@ Handle<Object> Context::Lookup(Handle<String> name,
PrintF(")\n");
}
+ bool visited_global_context = false;
+
do {
if (FLAG_trace_contexts) {
PrintF(" - looking in context %p", reinterpret_cast<void*>(*context));
+ if (context->IsGlobalContext()) PrintF(" (global context)");
if (context->IsNativeContext()) PrintF(" (native context)");
PrintF("\n");
}
+ if (follow_context_chain && FLAG_harmony_scoping &&
+ !visited_global_context &&
+ (context->IsGlobalContext() || context->IsNativeContext())) {
+ context = Handle<Context>(context->global_object()->global_context());
rossberg 2014/10/29 06:37:17 Add a comment why this detour is necessary.
+ visited_global_context = true;
+ if (FLAG_trace_contexts) {
+ PrintF(" - switching to current global context %p\n",
+ reinterpret_cast<void*>(*context));
+ }
+ }
+
// 1. Check global objects, subjects of with, and extension objects.
if (context->IsNativeContext() ||
context->IsWithContext() ||
@@ -163,7 +177,8 @@ Handle<Object> Context::Lookup(Handle<String> name,
}
// 2. Check the context proper if it has slots.
- if (context->IsFunctionContext() || context->IsBlockContext()) {
+ if (context->IsFunctionContext() || context->IsBlockContext() ||
+ (FLAG_harmony_scoping && context->IsGlobalContext())) {
// Use serialized scope information of functions and blocks to search
// for the context index.
Handle<ScopeInfo> scope_info;
« no previous file with comments | « no previous file | test/cctest/test-decls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698