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

Side by Side 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: 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') | src/scopeinfo.cc » ('J')
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 ScriptContextTable::LookupResult lookup; 39 if (ScriptContextTable::LookupLexical(script_contexts, name)) {
40 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
41 IsLexicalVariableMode(lookup.mode)) {
42 return ThrowRedeclarationError(isolate, name); 40 return ThrowRedeclarationError(isolate, name);
43 } 41 }
44 42
45 // Do the lookup own properties only, see ES5 erratum. 43 // Do the lookup own properties only, see ES5 erratum.
46 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 44 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
47 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 45 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
48 if (!maybe.IsJust()) return isolate->heap()->exception(); 46 if (!maybe.IsJust()) return isolate->heap()->exception();
49 47
50 if (it.IsFound()) { 48 if (it.IsFound()) {
51 PropertyAttributes old_attributes = maybe.FromJust(); 49 PropertyAttributes old_attributes = maybe.FromJust();
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 pretenure_flag); 615 pretenure_flag);
618 } 616 }
619 617
620 static Object* FindNameClash(Handle<ScopeInfo> scope_info, 618 static Object* FindNameClash(Handle<ScopeInfo> scope_info,
621 Handle<GlobalObject> global_object, 619 Handle<GlobalObject> global_object,
622 Handle<ScriptContextTable> script_context) { 620 Handle<ScriptContextTable> script_context) {
623 Isolate* isolate = scope_info->GetIsolate(); 621 Isolate* isolate = scope_info->GetIsolate();
624 for (int var = 0; var < scope_info->ContextLocalCount(); var++) { 622 for (int var = 0; var < scope_info->ContextLocalCount(); var++) {
625 Handle<String> name(scope_info->ContextLocalName(var)); 623 Handle<String> name(scope_info->ContextLocalName(var));
626 VariableMode mode = scope_info->ContextLocalMode(var); 624 VariableMode mode = scope_info->ContextLocalMode(var);
627 ScriptContextTable::LookupResult lookup; 625 if (IsLexicalVariableMode(mode)) {
628 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { 626 ScriptContextTable::LookupResult lookup;
629 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) { 627 if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
628 return ThrowRedeclarationError(isolate, name);
629 }
630 } else {
631 if (ScriptContextTable::LookupLexical(script_context, name)) {
630 return ThrowRedeclarationError(isolate, name); 632 return ThrowRedeclarationError(isolate, name);
631 } 633 }
632 } 634 }
633 635
634 if (IsLexicalVariableMode(mode)) { 636 if (IsLexicalVariableMode(mode)) {
635 LookupIterator it(global_object, name, 637 LookupIterator it(global_object, name,
636 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 638 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
637 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 639 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
638 if (!maybe.IsJust()) return isolate->heap()->exception(); 640 if (!maybe.IsJust()) return isolate->heap()->exception();
639 if ((maybe.FromJust() & DONT_DELETE) != 0) { 641 if ((maybe.FromJust() & DONT_DELETE) != 0) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1163
1162 // Lookup in the initial Object.prototype object. 1164 // Lookup in the initial Object.prototype object.
1163 Handle<Object> result; 1165 Handle<Object> result;
1164 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1166 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1165 isolate, result, 1167 isolate, result,
1166 Object::GetProperty(isolate->initial_object_prototype(), key)); 1168 Object::GetProperty(isolate->initial_object_prototype(), key));
1167 return *result; 1169 return *result;
1168 } 1170 }
1169 } // namespace internal 1171 } // namespace internal
1170 } // namespace v8 1172 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | src/scopeinfo.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698