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

Side by Side Diff: src/objects.cc

Issue 1178083002: Use LookupIterator for elements in GetAccessor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | 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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 6530 matching lines...) Expand 10 before | Expand all | Expand 10 after
6541 Handle<Name> name, 6541 Handle<Name> name,
6542 AccessorComponent component) { 6542 AccessorComponent component) {
6543 Isolate* isolate = object->GetIsolate(); 6543 Isolate* isolate = object->GetIsolate();
6544 6544
6545 // Make sure that the top context does not change when doing callbacks or 6545 // Make sure that the top context does not change when doing callbacks or
6546 // interceptor calls. 6546 // interceptor calls.
6547 AssertNoContextChange ncc(isolate); 6547 AssertNoContextChange ncc(isolate);
6548 6548
6549 // Make the lookup and include prototypes. 6549 // Make the lookup and include prototypes.
6550 uint32_t index = 0; 6550 uint32_t index = 0;
6551 if (name->AsArrayIndex(&index)) { 6551 LookupIterator::Configuration c =
6552 for (PrototypeIterator iter(isolate, object, 6552 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR;
6553 PrototypeIterator::START_AT_RECEIVER); 6553 LookupIterator it = name->AsArrayIndex(&index)
6554 !iter.IsAtEnd(); iter.Advance()) { 6554 ? LookupIterator(isolate, object, index, c)
6555 Handle<Object> current = PrototypeIterator::GetCurrent(iter); 6555 : LookupIterator(object, name, c);
6556 // Check access rights if needed. 6556
6557 if (current->IsAccessCheckNeeded() && 6557 for (; it.IsFound(); it.Next()) {
6558 !isolate->MayAccess(Handle<JSObject>::cast(current))) { 6558 switch (it.state()) {
6559 isolate->ReportFailedAccessCheck(Handle<JSObject>::cast(current)); 6559 case LookupIterator::INTERCEPTOR:
6560 case LookupIterator::NOT_FOUND:
6561 case LookupIterator::TRANSITION:
6562 UNREACHABLE();
6563
6564 case LookupIterator::ACCESS_CHECK:
6565 if (it.HasAccess()) continue;
6566 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
6560 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 6567 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6561 return isolate->factory()->undefined_value(); 6568 return isolate->factory()->undefined_value();
6562 }
6563 6569
6564 if (current->IsJSObject() && 6570 case LookupIterator::JSPROXY:
6565 Handle<JSObject>::cast(current)->HasDictionaryElements()) { 6571 return isolate->factory()->undefined_value();
6566 JSObject* js_object = JSObject::cast(*current);
6567 SeededNumberDictionary* dictionary = js_object->element_dictionary();
6568 int entry = dictionary->FindEntry(index);
6569 if (entry != SeededNumberDictionary::kNotFound) {
6570 Object* element = dictionary->ValueAt(entry);
6571 if (dictionary->DetailsAt(entry).type() == ACCESSOR_CONSTANT &&
6572 element->IsAccessorPair()) {
6573 return handle(AccessorPair::cast(element)->GetComponent(component),
6574 isolate);
6575 }
6576 }
6577 }
6578 }
6579 } else {
6580 LookupIterator it(object, name,
6581 LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
6582 for (; it.IsFound(); it.Next()) {
6583 switch (it.state()) {
6584 case LookupIterator::INTERCEPTOR:
6585 case LookupIterator::NOT_FOUND:
6586 case LookupIterator::TRANSITION:
6587 UNREACHABLE();
6588 6572
6589 case LookupIterator::ACCESS_CHECK: 6573 case LookupIterator::INTEGER_INDEXED_EXOTIC:
6590 if (it.HasAccess()) continue; 6574 return isolate->factory()->undefined_value();
6591 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>()); 6575 case LookupIterator::DATA:
6592 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object); 6576 continue;
6593 return isolate->factory()->undefined_value(); 6577 case LookupIterator::ACCESSOR: {
6594 6578 Handle<Object> maybe_pair = it.GetAccessors();
6595 case LookupIterator::JSPROXY: 6579 if (maybe_pair->IsAccessorPair()) {
6596 return isolate->factory()->undefined_value(); 6580 return handle(
6597 6581 AccessorPair::cast(*maybe_pair)->GetComponent(component),
6598 case LookupIterator::INTEGER_INDEXED_EXOTIC: 6582 isolate);
6599 return isolate->factory()->undefined_value();
6600 case LookupIterator::DATA:
6601 continue;
6602 case LookupIterator::ACCESSOR: {
6603 Handle<Object> maybe_pair = it.GetAccessors();
6604 if (maybe_pair->IsAccessorPair()) {
6605 return handle(
6606 AccessorPair::cast(*maybe_pair)->GetComponent(component),
6607 isolate);
6608 }
6609 } 6583 }
6610 } 6584 }
6611 } 6585 }
6612 } 6586 }
6587
6613 return isolate->factory()->undefined_value(); 6588 return isolate->factory()->undefined_value();
6614 } 6589 }
6615 6590
6616 6591
6617 Object* JSObject::SlowReverseLookup(Object* value) { 6592 Object* JSObject::SlowReverseLookup(Object* value) {
6618 if (HasFastProperties()) { 6593 if (HasFastProperties()) {
6619 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); 6594 int number_of_own_descriptors = map()->NumberOfOwnDescriptors();
6620 DescriptorArray* descs = map()->instance_descriptors(); 6595 DescriptorArray* descs = map()->instance_descriptors();
6621 bool value_is_number = value->IsNumber(); 6596 bool value_is_number = value->IsNumber();
6622 for (int i = 0; i < number_of_own_descriptors; i++) { 6597 for (int i = 0; i < number_of_own_descriptors; i++) {
(...skipping 10078 matching lines...) Expand 10 before | Expand all | Expand 10 after
16701 Handle<Object> new_value) { 16676 Handle<Object> new_value) {
16702 if (cell->value() != *new_value) { 16677 if (cell->value() != *new_value) {
16703 cell->set_value(*new_value); 16678 cell->set_value(*new_value);
16704 Isolate* isolate = cell->GetIsolate(); 16679 Isolate* isolate = cell->GetIsolate();
16705 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16680 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16706 isolate, DependentCode::kPropertyCellChangedGroup); 16681 isolate, DependentCode::kPropertyCellChangedGroup);
16707 } 16682 }
16708 } 16683 }
16709 } // namespace internal 16684 } // namespace internal
16710 } // namespace v8 16685 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698