Index: src/runtime/runtime-scopes.cc |
diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc |
index 8b1b90ee2bf0ae4b2bdccee2f405a7b24407ca20..ff7e783393081cbe731a8d5f265a5b0fa852b773 100644 |
--- a/src/runtime/runtime-scopes.cc |
+++ b/src/runtime/runtime-scopes.cc |
@@ -36,10 +36,9 @@ |
bool is_const, bool is_function) { |
Handle<ScriptContextTable> script_contexts( |
global->native_context()->script_context_table()); |
- // 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)) { |
+ ScriptContextTable::LookupResult lookup; |
+ if (ScriptContextTable::Lookup(script_contexts, name, &lookup) && |
+ IsLexicalVariableMode(lookup.mode)) { |
return ThrowRedeclarationError(isolate, name); |
} |
@@ -625,13 +624,9 @@ |
for (int var = 0; var < scope_info->ContextLocalCount(); var++) { |
Handle<String> name(scope_info->ContextLocalName(var)); |
VariableMode mode = scope_info->ContextLocalMode(var); |
- if (IsLexicalVariableMode(mode)) { |
- ScriptContextTable::LookupResult lookup; |
- if (ScriptContextTable::Lookup(script_context, name, &lookup)) { |
- return ThrowRedeclarationError(isolate, name); |
- } |
- } else { |
- if (ScriptContextTable::LookupLexical(script_context, name)) { |
+ ScriptContextTable::LookupResult lookup; |
+ if (ScriptContextTable::Lookup(script_context, name, &lookup)) { |
+ if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) { |
return ThrowRedeclarationError(isolate, name); |
} |
} |