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

Unified Diff: src/runtime/runtime-scopes.cc

Issue 1281883002: Group lexical context variables for faster look up. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: added comments and TODOs Created 5 years, 4 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 | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-scopes.cc
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc
index ff7e783393081cbe731a8d5f265a5b0fa852b773..8b1b90ee2bf0ae4b2bdccee2f405a7b24407ca20 100644
--- a/src/runtime/runtime-scopes.cc
+++ b/src/runtime/runtime-scopes.cc
@@ -36,9 +36,10 @@ static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global,
bool is_const, bool is_function) {
Handle<ScriptContextTable> script_contexts(
global->native_context()->script_context_table());
- ScriptContextTable::LookupResult lookup;
- if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
- IsLexicalVariableMode(lookup.mode)) {
+ // We use LookupLexical to limit lookup to lexical variables. As long as
+ // lexical variables are not used extensively, this is a performance win.
+ // TODO(yangguo): reconsider this shortcut.
+ if (ScriptContextTable::LookupLexical(script_contexts, name)) {
return ThrowRedeclarationError(isolate, name);
}
@@ -624,9 +625,13 @@ static Object* FindNameClash(Handle<ScopeInfo> scope_info,
for (int var = 0; var < scope_info->ContextLocalCount(); var++) {
Handle<String> name(scope_info->ContextLocalName(var));
VariableMode mode = scope_info->ContextLocalMode(var);
- ScriptContextTable::LookupResult lookup;
- if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
- if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
+ if (IsLexicalVariableMode(mode)) {
+ ScriptContextTable::LookupResult lookup;
+ if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
+ return ThrowRedeclarationError(isolate, name);
+ }
+ } else {
+ if (ScriptContextTable::LookupLexical(script_context, name)) {
return ThrowRedeclarationError(isolate, name);
}
}
« no previous file with comments | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698