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

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

Issue 1767123002: [runtime] Pass in receiver as target to the LookupIterator if known to be JSReceiver (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: property-descriptor Created 4 years, 9 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/runtime/runtime-object.cc ('k') | no next file » | 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/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.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/ast/scopeinfo.h" 9 #include "src/ast/scopeinfo.h"
10 #include "src/ast/scopes.h" 10 #include "src/ast/scopes.h"
(...skipping 26 matching lines...) Expand all
37 bool is_const, bool is_function) { 37 bool is_const, bool is_function) {
38 Handle<ScriptContextTable> script_contexts( 38 Handle<ScriptContextTable> script_contexts(
39 global->native_context()->script_context_table()); 39 global->native_context()->script_context_table());
40 ScriptContextTable::LookupResult lookup; 40 ScriptContextTable::LookupResult lookup;
41 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) && 41 if (ScriptContextTable::Lookup(script_contexts, name, &lookup) &&
42 IsLexicalVariableMode(lookup.mode)) { 42 IsLexicalVariableMode(lookup.mode)) {
43 return ThrowRedeclarationError(isolate, name); 43 return ThrowRedeclarationError(isolate, name);
44 } 44 }
45 45
46 // Do the lookup own properties only, see ES5 erratum. 46 // Do the lookup own properties only, see ES5 erratum.
47 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 47 LookupIterator it(global, name, global,
48 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
48 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 49 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
49 if (!maybe.IsJust()) return isolate->heap()->exception(); 50 if (!maybe.IsJust()) return isolate->heap()->exception();
50 51
51 if (it.IsFound()) { 52 if (it.IsFound()) {
52 PropertyAttributes old_attributes = maybe.FromJust(); 53 PropertyAttributes old_attributes = maybe.FromJust();
53 // The name was declared before; check for conflicting re-declarations. 54 // The name was declared before; check for conflicting re-declarations.
54 if (is_const) return ThrowRedeclarationError(isolate, name); 55 if (is_const) return ThrowRedeclarationError(isolate, name);
55 56
56 // Skip var re-declarations. 57 // Skip var re-declarations.
57 if (is_var) return isolate->heap()->undefined_value(); 58 if (is_var) return isolate->heap()->undefined_value();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // All constants are declared with an initial value. The name 176 // All constants are declared with an initial value. The name
176 // of the constant is the first argument and the initial value 177 // of the constant is the first argument and the initial value
177 // is the second. 178 // is the second.
178 RUNTIME_ASSERT(args.length() == 2); 179 RUNTIME_ASSERT(args.length() == 2);
179 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 180 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
180 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 181 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
181 182
182 Handle<JSGlobalObject> global = isolate->global_object(); 183 Handle<JSGlobalObject> global = isolate->global_object();
183 184
184 // Lookup the property as own on the global object. 185 // Lookup the property as own on the global object.
185 LookupIterator it(global, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 186 LookupIterator it(global, name, global,
187 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
186 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 188 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
187 DCHECK(maybe.IsJust()); 189 DCHECK(maybe.IsJust());
188 PropertyAttributes old_attributes = maybe.FromJust(); 190 PropertyAttributes old_attributes = maybe.FromJust();
189 191
190 PropertyAttributes attr = 192 PropertyAttributes attr =
191 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY); 193 static_cast<PropertyAttributes>(DONT_DELETE | READ_ONLY);
192 // Set the value if the property is either missing, or the property attributes 194 // Set the value if the property is either missing, or the property attributes
193 // allow setting the value without invoking an accessor. 195 // allow setting the value without invoking an accessor.
194 if (it.IsFound()) { 196 if (it.IsFound()) {
195 // Ignore if we can't reconfigure the value. 197 // Ignore if we can't reconfigure the value.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 DCHECK(!holder.is_null()); 389 DCHECK(!holder.is_null());
388 } 390 }
389 CHECK(holder->IsJSObject()); 391 CHECK(holder->IsJSObject());
390 } else { 392 } else {
391 // For JSContextExtensionObjects, the initializer can be run multiple times 393 // For JSContextExtensionObjects, the initializer can be run multiple times
392 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the 394 // if in a for loop: for (var i = 0; i < 2; i++) { const x = i; }. Only the
393 // first assignment should go through. For JSGlobalObjects, additionally any 395 // first assignment should go through. For JSGlobalObjects, additionally any
394 // code can run in between that modifies the declared property. 396 // code can run in between that modifies the declared property.
395 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject()); 397 DCHECK(holder->IsJSGlobalObject() || holder->IsJSContextExtensionObject());
396 398
397 LookupIterator it(holder, name, LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 399 LookupIterator it(holder, name, Handle<JSReceiver>::cast(holder),
400 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
398 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 401 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
399 if (!maybe.IsJust()) return isolate->heap()->exception(); 402 if (!maybe.IsJust()) return isolate->heap()->exception();
400 PropertyAttributes old_attributes = maybe.FromJust(); 403 PropertyAttributes old_attributes = maybe.FromJust();
401 404
402 // Ignore if we can't reconfigure the value. 405 // Ignore if we can't reconfigure the value.
403 if ((old_attributes & DONT_DELETE) != 0) { 406 if ((old_attributes & DONT_DELETE) != 0) {
404 if ((old_attributes & READ_ONLY) != 0 || 407 if ((old_attributes & READ_ONLY) != 0 ||
405 it.state() == LookupIterator::ACCESSOR) { 408 it.state() == LookupIterator::ACCESSOR) {
406 return *value; 409 return *value;
407 } 410 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 Handle<String> name(scope_info->ContextLocalName(var)); 704 Handle<String> name(scope_info->ContextLocalName(var));
702 VariableMode mode = scope_info->ContextLocalMode(var); 705 VariableMode mode = scope_info->ContextLocalMode(var);
703 ScriptContextTable::LookupResult lookup; 706 ScriptContextTable::LookupResult lookup;
704 if (ScriptContextTable::Lookup(script_context, name, &lookup)) { 707 if (ScriptContextTable::Lookup(script_context, name, &lookup)) {
705 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) { 708 if (IsLexicalVariableMode(mode) || IsLexicalVariableMode(lookup.mode)) {
706 return ThrowRedeclarationError(isolate, name); 709 return ThrowRedeclarationError(isolate, name);
707 } 710 }
708 } 711 }
709 712
710 if (IsLexicalVariableMode(mode)) { 713 if (IsLexicalVariableMode(mode)) {
711 LookupIterator it(global_object, name, 714 LookupIterator it(global_object, name, global_object,
712 LookupIterator::HIDDEN_SKIP_INTERCEPTOR); 715 LookupIterator::HIDDEN_SKIP_INTERCEPTOR);
713 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it); 716 Maybe<PropertyAttributes> maybe = JSReceiver::GetPropertyAttributes(&it);
714 if (!maybe.IsJust()) return isolate->heap()->exception(); 717 if (!maybe.IsJust()) return isolate->heap()->exception();
715 if ((maybe.FromJust() & DONT_DELETE) != 0) { 718 if ((maybe.FromJust() & DONT_DELETE) != 0) {
716 return ThrowRedeclarationError(isolate, name); 719 return ThrowRedeclarationError(isolate, name);
717 } 720 }
718 721
719 JSGlobalObject::InvalidatePropertyCell(global_object, name); 722 JSGlobalObject::InvalidatePropertyCell(global_object, name);
720 } 723 }
721 } 724 }
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 DCHECK_EQ(2, args.length()); 1135 DCHECK_EQ(2, args.length());
1133 CONVERT_ARG_HANDLE_CHECKED(String, name, 0); 1136 CONVERT_ARG_HANDLE_CHECKED(String, name, 0);
1134 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); 1137 CONVERT_ARG_HANDLE_CHECKED(Object, value, 1);
1135 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value, 1138 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, value,
1136 StoreLookupSlot(name, value, STRICT)); 1139 StoreLookupSlot(name, value, STRICT));
1137 return *value; 1140 return *value;
1138 } 1141 }
1139 1142
1140 } // namespace internal 1143 } // namespace internal
1141 } // namespace v8 1144 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime-object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698