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

Side by Side Diff: src/runtime/runtime-scopes.cc

Issue 1290053002: Revert of Group lexical context variables for faster look up. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/arguments.h" 8 #include "src/arguments.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 31
32 // May throw a RedeclarationError. 32 // May throw a RedeclarationError.
33 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global, 33 static Object* DeclareGlobals(Isolate* isolate, Handle<GlobalObject> global,
34 Handle<String> name, Handle<Object> value, 34 Handle<String> name, Handle<Object> value,
35 PropertyAttributes attr, bool is_var, 35 PropertyAttributes attr, bool is_var,
36 bool is_const, bool is_function) { 36 bool is_const, bool is_function) {
37 Handle<ScriptContextTable> script_contexts( 37 Handle<ScriptContextTable> script_contexts(
38 global->native_context()->script_context_table()); 38 global->native_context()->script_context_table());
39 // We use LookupLexical to limit lookup to lexical variables. As long as 39 ScriptContextTable::LookupResult lookup;
40 // lexical variables are not used extensively, this is a performance win. 40 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
41 // TODO(yangguo): reconsider this shortcut. 41 IsLexicalVariableMode(lookup.mode)) {
42 if (ScriptContextTable::LookupLexical(script_contexts, name)) {
43 return ThrowRedeclarationError(isolate, name); 42 return ThrowRedeclarationError(isolate, name);
44 } 43 }
45 44
46 // Do the lookup own properties only, see ES5 erratum. 45 // Do the lookup own properties only, see ES5 erratum.
47 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 46 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
48 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 47 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
49 if (!maybe.IsJust()) return isolate->heap()->exception(); 48 if (!maybe.IsJust()) return isolate->heap()->exception();
50 49
51 if (it.IsFound()) { 50 if (it.IsFound()) {
52 PropertyAttributes old_attributes = maybe.FromJust(); 51 PropertyAttributes old_attributes = maybe.FromJust();
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 pretenure_flag); 617 pretenure_flag);
619 } 618 }
620 619
621 static Object* FindNameClash(Handle<ScopeInfo> scope_info, 620 static Object* FindNameClash(Handle<ScopeInfo> scope_info,
622 Handle<GlobalObject> global_object, 621 Handle<GlobalObject> global_object,
623 Handle<ScriptContextTable> script_context) { 622 Handle<ScriptContextTable> script_context) {
624 Isolate* isolate = scope_info->GetIsolate(); 623 Isolate* isolate = scope_info->GetIsolate();
625 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { 624 for (int var = 0; var < scope_info->ContextLocalCount(); var++) {
626 Handle<String> name(scope_info->ContextLocalName(var)); 625 Handle<String> name(scope_info->ContextLocalName(var));
627 VariableMode mode = scope_info->ContextLocalMode(var); 626 VariableMode mode = scope_info->ContextLocalMode(var);
628 if (IsLexicalVariableMode(mode)) { 627 ScriptContextTable::LookupResult lookup;
629 ScriptContextTable::LookupResult lookup; 628 if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
630 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { 629 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
631 return ThrowRedeclarationError(isolate, name);
632 }
633 } else {
634 if (ScriptContextTable::LookupLexical(script_context, name)) {
635 return ThrowRedeclarationError(isolate, name); 630 return ThrowRedeclarationError(isolate, name);
636 } 631 }
637 } 632 }
638 633
639 if (IsLexicalVariableMode(mode)) { 634 if (IsLexicalVariableMode(mode)) {
640 LookupIterator it(global_object, name, 635 LookupIterator it(global_object, name,
641 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 636 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
642 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 637 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
643 if (!maybe.IsJust()) return isolate->heap()->exception(); 638 if (!maybe.IsJust()) return isolate->heap()->exception();
644 if ((maybe.FromJust() & DONT_DELETE) != 0) { 639 if ((maybe.FromJust() & DONT_DELETE) != 0) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 1161
1167 // Lookup in the initial Object.prototype object. 1162 // Lookup in the initial Object.prototype object.
1168 Handle<Object> result; 1163 Handle<Object> result;
1169 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1170 isolate, result, 1165 isolate, result,
1171 Object::GetProperty(isolate->initial_object_prototype(), key)); 1166 Object::GetProperty(isolate->initial_object_prototype(), key));
1172 return *result; 1167 return *result;
1173 } 1168 }
1174 } // namespace internal 1169 } // namespace internal
1175 } // namespace v8 1170 } // namespace v8
OLDNEW
« 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