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

Side by Side Diff: src/objects.cc

Issue 1702443002: [runtime] Minor tweaks to LookupIterator for performance (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 10 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
« src/lookup.cc ('K') | « src/lookup.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/objects.h" 5 #include "src/objects.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <iomanip> 8 #include <iomanip>
9 #include <sstream> 9 #include <sstream>
10 10
(...skipping 4475 matching lines...) Expand 10 before | Expand all | Expand 10 after
4486 DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, it->state()); 4486 DCHECK_NE(LookupIterator::INTEGER_INDEXED_EXOTIC, it->state());
4487 4487
4488 Handle<JSObject> receiver = it->GetStoreTarget(); 4488 Handle<JSObject> receiver = it->GetStoreTarget();
4489 4489
4490 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject) 4490 // If the receiver is a JSGlobalProxy, store on the prototype (JSGlobalObject)
4491 // instead. If the prototype is Null, the proxy is detached. 4491 // instead. If the prototype is Null, the proxy is detached.
4492 if (receiver->IsJSGlobalProxy()) return Just(true); 4492 if (receiver->IsJSGlobalProxy()) return Just(true);
4493 4493
4494 Isolate* isolate = it->isolate(); 4494 Isolate* isolate = it->isolate();
4495 4495
4496 if (!receiver->map()->is_extensible() && 4496 if (it->ExtendingNonExtensible(receiver)) {
4497 (it->IsElement() || !isolate->IsInternallyUsedPropertyName(it->name()))) {
4498 RETURN_FAILURE( 4497 RETURN_FAILURE(
4499 isolate, should_throw, 4498 isolate, should_throw,
4500 NewTypeError(MessageTemplate::kObjectNotExtensible, it->GetName())); 4499 NewTypeError(MessageTemplate::kObjectNotExtensible, it->GetName()));
4501 } 4500 }
4502 4501
4503 if (it->IsElement()) { 4502 if (it->IsElement()) {
4504 if (receiver->IsJSArray()) { 4503 if (receiver->IsJSArray()) {
4505 Handle<JSArray> array = Handle<JSArray>::cast(receiver); 4504 Handle<JSArray> array = Handle<JSArray>::cast(receiver);
4506 if (JSArray::WouldChangeReadOnlyLength(array, it->index())) { 4505 if (JSArray::WouldChangeReadOnlyLength(array, it->index())) {
4507 RETURN_FAILURE(array->GetIsolate(), should_throw, 4506 RETURN_FAILURE(array->GetIsolate(), should_throw,
(...skipping 12 matching lines...) Expand all
4520 } 4519 }
4521 } 4520 }
4522 4521
4523 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value, 4522 Maybe<bool> result = JSObject::AddDataElement(receiver, it->index(), value,
4524 attributes, should_throw); 4523 attributes, should_throw);
4525 JSObject::ValidateElements(receiver); 4524 JSObject::ValidateElements(receiver);
4526 return result; 4525 return result;
4527 } else { 4526 } else {
4528 // Migrate to the most up-to-date map that will be able to store |value| 4527 // Migrate to the most up-to-date map that will be able to store |value|
4529 // under it->name() with |attributes|. 4528 // under it->name() with |attributes|.
4530 it->PrepareTransitionToDataProperty(value, attributes, store_mode); 4529 it->PrepareTransitionToDataProperty(receiver, value, attributes,
4530 store_mode);
4531 DCHECK_EQ(LookupIterator::TRANSITION, it->state()); 4531 DCHECK_EQ(LookupIterator::TRANSITION, it->state());
4532 it->ApplyTransitionToDataProperty(); 4532 it->ApplyTransitionToDataProperty(receiver);
4533 4533
4534 // TODO(verwaest): Encapsulate dictionary handling better. 4534 // TODO(verwaest): Encapsulate dictionary handling better.
4535 if (receiver->map()->is_dictionary_map()) { 4535 if (receiver->map()->is_dictionary_map()) {
4536 // TODO(verwaest): Probably should ensure this is done beforehand. 4536 // TODO(verwaest): Probably should ensure this is done beforehand.
4537 it->InternalizeName(); 4537 it->InternalizeName();
4538 // TODO(dcarney): just populate TransitionPropertyCell here? 4538 // TODO(dcarney): just populate TransitionPropertyCell here?
4539 JSObject::AddSlowProperty(receiver, it->name(), value, attributes); 4539 JSObject::AddSlowProperty(receiver, it->name(), value, attributes);
4540 } else { 4540 } else {
4541 // Write the property value. 4541 // Write the property value.
4542 it->WriteDataValue(value); 4542 it->WriteDataValue(value);
(...skipping 5392 matching lines...) Expand 10 before | Expand all | Expand 10 after
9935 9935
9936 // static 9936 // static
9937 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor, 9937 Handle<Map> Map::PrepareForDataProperty(Handle<Map> map, int descriptor,
9938 Handle<Object> value) { 9938 Handle<Object> value) {
9939 // Dictionaries can store any property value. 9939 // Dictionaries can store any property value.
9940 if (map->is_dictionary_map()) return map; 9940 if (map->is_dictionary_map()) return map;
9941 9941
9942 // Migrate to the newest map before storing the property. 9942 // Migrate to the newest map before storing the property.
9943 map = Update(map); 9943 map = Update(map);
9944 9944
9945 Handle<DescriptorArray> descriptors(map->instance_descriptors()); 9945 if (map->instance_descriptors()->CanHoldValue(descriptor, *value)) return map;
9946
9947 if (descriptors->CanHoldValue(descriptor, *value)) return map;
9948 9946
9949 Isolate* isolate = map->GetIsolate(); 9947 Isolate* isolate = map->GetIsolate();
9950 PropertyAttributes attributes = 9948 PropertyAttributes attributes =
9951 descriptors->GetDetails(descriptor).attributes(); 9949 map->instance_descriptors()->GetDetails(descriptor).attributes();
9952 Representation representation = value->OptimalRepresentation(); 9950 Representation representation = value->OptimalRepresentation();
9953 Handle<FieldType> type = value->OptimalType(isolate, representation); 9951 Handle<FieldType> type = value->OptimalType(isolate, representation);
9954 9952
9955 return ReconfigureProperty(map, descriptor, kData, attributes, representation, 9953 return ReconfigureProperty(map, descriptor, kData, attributes, representation,
9956 type, FORCE_FIELD); 9954 type, FORCE_FIELD);
9957 } 9955 }
9958 9956
9959 9957
9960 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name, 9958 Handle<Map> Map::TransitionToDataProperty(Handle<Map> map, Handle<Name> name,
9961 Handle<Object> value, 9959 Handle<Object> value,
(...skipping 10023 matching lines...) Expand 10 before | Expand all | Expand 10 after
19985 if (cell->value() != *new_value) { 19983 if (cell->value() != *new_value) {
19986 cell->set_value(*new_value); 19984 cell->set_value(*new_value);
19987 Isolate* isolate = cell->GetIsolate(); 19985 Isolate* isolate = cell->GetIsolate();
19988 cell->dependent_code()->DeoptimizeDependentCodeGroup( 19986 cell->dependent_code()->DeoptimizeDependentCodeGroup(
19989 isolate, DependentCode::kPropertyCellChangedGroup); 19987 isolate, DependentCode::kPropertyCellChangedGroup);
19990 } 19988 }
19991 } 19989 }
19992 19990
19993 } // namespace internal 19991 } // namespace internal
19994 } // namespace v8 19992 } // namespace v8
OLDNEW
« src/lookup.cc ('K') | « src/lookup.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698