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

Side by Side Diff: src/objects.cc

Issue 467293003: Rewrite GetAccessor using the LookupIterator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« 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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 6562 matching lines...) Expand 10 before | Expand all | Expand 10 after
6573 6573
6574 MaybeHandle<Object> JSObject::GetAccessor(Handle<JSObject> object, 6574 MaybeHandle<Object> JSObject::GetAccessor(Handle<JSObject> object,
6575 Handle<Name> name, 6575 Handle<Name> name,
6576 AccessorComponent component) { 6576 AccessorComponent component) {
6577 Isolate* isolate = object->GetIsolate(); 6577 Isolate* isolate = object->GetIsolate();
6578 6578
6579 // Make sure that the top context does not change when doing callbacks or 6579 // Make sure that the top context does not change when doing callbacks or
6580 // interceptor calls. 6580 // interceptor calls.
6581 AssertNoContextChange ncc(isolate); 6581 AssertNoContextChange ncc(isolate);
6582 6582
6583 // Check access rights if needed.
6584 if (object->IsAccessCheckNeeded() &&
6585 !isolate->MayNamedAccess(object, name, v8::ACCESS_HAS)) {
6586 isolate->ReportFailedAccessCheck(object, v8::ACCESS_HAS);
6587 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6588 return isolate->factory()->undefined_value();
6589 }
6590
6591 // Make the lookup and include prototypes. 6583 // Make the lookup and include prototypes.
6592 uint32_t index = 0; 6584 uint32_t index = 0;
6593 if (name->AsArrayIndex(&index)) { 6585 if (name->AsArrayIndex(&index)) {
6594 for (PrototypeIterator iter(isolate, object, 6586 for (PrototypeIterator iter(isolate, object,
6595 PrototypeIterator::START_AT_RECEIVER); 6587 PrototypeIterator::START_AT_RECEIVER);
6596 !iter.IsAtEnd(); iter.Advance()) { 6588 !iter.IsAtEnd(); iter.Advance()) {
6597 if (PrototypeIterator::GetCurrent(iter)->IsJSObject() && 6589 Handle<Object> current = PrototypeIterator::GetCurrent(iter);
6598 JSObject::cast(*PrototypeIterator::GetCurrent(iter)) 6590 // Check access rights if needed.
6599 ->HasDictionaryElements()) { 6591 if (current->IsAccessCheckNeeded() &&
6600 JSObject* js_object = 6592 !isolate->MayNamedAccess(Handle<JSObject>::cast(current), name,
6601 JSObject::cast(*PrototypeIterator::GetCurrent(iter)); 6593 v8::ACCESS_HAS)) {
6594 isolate->ReportFailedAccessCheck(Handle<JSObject>::cast(current),
6595 v8::ACCESS_HAS);
6596 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6597 return isolate->factory()->undefined_value();
6598 }
6599
6600 if (current->IsJSObject() &&
6601 Handle<JSObject>::cast(current)->HasDictionaryElements()) {
6602 JSObject* js_object = JSObject::cast(*current);
6602 SeededNumberDictionary* dictionary = js_object->element_dictionary(); 6603 SeededNumberDictionary* dictionary = js_object->element_dictionary();
6603 int entry = dictionary->FindEntry(index); 6604 int entry = dictionary->FindEntry(index);
6604 if (entry != SeededNumberDictionary::kNotFound) { 6605 if (entry != SeededNumberDictionary::kNotFound) {
6605 Object* element = dictionary->ValueAt(entry); 6606 Object* element = dictionary->ValueAt(entry);
6606 if (dictionary->DetailsAt(entry).type() == CALLBACKS && 6607 if (dictionary->DetailsAt(entry).type() == CALLBACKS &&
6607 element->IsAccessorPair()) { 6608 element->IsAccessorPair()) {
6608 return handle(AccessorPair::cast(element)->GetComponent(component), 6609 return handle(AccessorPair::cast(element)->GetComponent(component),
6609 isolate); 6610 isolate);
6610 } 6611 }
6611 } 6612 }
6612 } 6613 }
6613 } 6614 }
6614 } else { 6615 } else {
6615 for (PrototypeIterator iter(isolate, object, 6616 LookupIterator it(object, name,
6616 PrototypeIterator::START_AT_RECEIVER); 6617 LookupIterator::CHECK_DERIVED_SKIP_INTERCEPTOR);
6617 !iter.IsAtEnd(); iter.Advance()) { 6618 for (; it.IsFound(); it.Next()) {
6618 LookupResult result(isolate); 6619 switch (it.state()) {
6619 JSReceiver::cast(*PrototypeIterator::GetCurrent(iter)) 6620 case LookupIterator::NOT_FOUND:
6620 ->LookupOwn(name, &result); 6621 case LookupIterator::INTERCEPTOR:
6621 if (result.IsFound()) { 6622 UNREACHABLE();
6622 if (result.IsReadOnly()) return isolate->factory()->undefined_value(); 6623
6623 if (result.IsPropertyCallbacks()) { 6624 case LookupIterator::ACCESS_CHECK:
6624 Object* obj = result.GetCallbackObject(); 6625 if (it.HasAccess(v8::ACCESS_HAS)) continue;
6625 if (obj->IsAccessorPair()) { 6626 isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>(),
6626 return handle(AccessorPair::cast(obj)->GetComponent(component), 6627 v8::ACCESS_HAS);
6627 isolate); 6628 RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
6629 return isolate->factory()->undefined_value();
6630
6631 case LookupIterator::JSPROXY:
6632 return isolate->factory()->undefined_value();
6633
6634 case LookupIterator::PROPERTY:
6635 if (!it.HasProperty()) continue;
6636 switch (it.property_kind()) {
6637 case LookupIterator::DATA:
6638 continue;
6639 case LookupIterator::ACCESSOR: {
6640 Handle<Object> maybe_pair = it.GetAccessors();
6641 if (maybe_pair->IsAccessorPair()) {
6642 return handle(
6643 AccessorPair::cast(*maybe_pair)->GetComponent(component),
6644 isolate);
6645 }
6646 }
6628 } 6647 }
6629 }
6630 } 6648 }
6631 } 6649 }
6632 } 6650 }
6633 return isolate->factory()->undefined_value(); 6651 return isolate->factory()->undefined_value();
6634 } 6652 }
6635 6653
6636 6654
6637 Object* JSObject::SlowReverseLookup(Object* value) { 6655 Object* JSObject::SlowReverseLookup(Object* value) {
6638 if (HasFastProperties()) { 6656 if (HasFastProperties()) {
6639 int number_of_own_descriptors = map()->NumberOfOwnDescriptors(); 6657 int number_of_own_descriptors = map()->NumberOfOwnDescriptors();
(...skipping 10007 matching lines...) Expand 10 before | Expand all | Expand 10 after
16647 #define ERROR_MESSAGES_TEXTS(C, T) T, 16665 #define ERROR_MESSAGES_TEXTS(C, T) T,
16648 static const char* error_messages_[] = { 16666 static const char* error_messages_[] = {
16649 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16667 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16650 }; 16668 };
16651 #undef ERROR_MESSAGES_TEXTS 16669 #undef ERROR_MESSAGES_TEXTS
16652 return error_messages_[reason]; 16670 return error_messages_[reason];
16653 } 16671 }
16654 16672
16655 16673
16656 } } // namespace v8::internal 16674 } } // namespace v8::internal
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