| 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);
|
| }
|
| }
|
|
|