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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 674e5324eaf80703719a363ad206525890fa79fe..400be3edaebb01269d94481d7b0e7c59c2043e3e 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6548,68 +6548,43 @@ MaybeHandle<Object> JSObject::GetAccessor(Handle<JSObject> object,
// Make the lookup and include prototypes.
uint32_t index = 0;
- if (name->AsArrayIndex(&index)) {
- for (PrototypeIterator iter(isolate, object,
- PrototypeIterator::START_AT_RECEIVER);
- !iter.IsAtEnd(); iter.Advance()) {
- Handle<Object> current = PrototypeIterator::GetCurrent(iter);
- // Check access rights if needed.
- if (current->IsAccessCheckNeeded() &&
- !isolate->MayAccess(Handle<JSObject>::cast(current))) {
- isolate->ReportFailedAccessCheck(Handle<JSObject>::cast(current));
+ LookupIterator::Configuration c =
+ LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR;
+ LookupIterator it = name->AsArrayIndex(&index)
+ ? LookupIterator(isolate, object, index, c)
+ : LookupIterator(object, name, c);
+
+ for (; it.IsFound(); it.Next()) {
+ switch (it.state()) {
+ case LookupIterator::INTERCEPTOR:
+ case LookupIterator::NOT_FOUND:
+ case LookupIterator::TRANSITION:
+ UNREACHABLE();
+
+ case LookupIterator::ACCESS_CHECK:
+ if (it.HasAccess()) continue;
+ isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
return isolate->factory()->undefined_value();
- }
- if (current->IsJSObject() &&
- Handle<JSObject>::cast(current)->HasDictionaryElements()) {
- JSObject* js_object = JSObject::cast(*current);
- SeededNumberDictionary* dictionary = js_object->element_dictionary();
- int entry = dictionary->FindEntry(index);
- if (entry != SeededNumberDictionary::kNotFound) {
- Object* element = dictionary->ValueAt(entry);
- if (dictionary->DetailsAt(entry).type() == ACCESSOR_CONSTANT &&
- element->IsAccessorPair()) {
- return handle(AccessorPair::cast(element)->GetComponent(component),
- isolate);
- }
- }
- }
- }
- } else {
- LookupIterator it(object, name,
- LookupIterator::PROTOTYPE_CHAIN_SKIP_INTERCEPTOR);
- for (; it.IsFound(); it.Next()) {
- switch (it.state()) {
- case LookupIterator::INTERCEPTOR:
- case LookupIterator::NOT_FOUND:
- case LookupIterator::TRANSITION:
- UNREACHABLE();
+ case LookupIterator::JSPROXY:
+ return isolate->factory()->undefined_value();
- case LookupIterator::ACCESS_CHECK:
- if (it.HasAccess()) continue;
- isolate->ReportFailedAccessCheck(it.GetHolder<JSObject>());
- RETURN_EXCEPTION_IF_SCHEDULED_EXCEPTION(isolate, Object);
- return isolate->factory()->undefined_value();
-
- case LookupIterator::JSPROXY:
- return isolate->factory()->undefined_value();
-
- case LookupIterator::INTEGER_INDEXED_EXOTIC:
- return isolate->factory()->undefined_value();
- case LookupIterator::DATA:
- continue;
- case LookupIterator::ACCESSOR: {
- Handle<Object> maybe_pair = it.GetAccessors();
- if (maybe_pair->IsAccessorPair()) {
- return handle(
- AccessorPair::cast(*maybe_pair)->GetComponent(component),
- isolate);
- }
+ case LookupIterator::INTEGER_INDEXED_EXOTIC:
+ return isolate->factory()->undefined_value();
+ case LookupIterator::DATA:
+ continue;
+ case LookupIterator::ACCESSOR: {
+ Handle<Object> maybe_pair = it.GetAccessors();
+ if (maybe_pair->IsAccessorPair()) {
+ return handle(
+ AccessorPair::cast(*maybe_pair)->GetComponent(component),
+ isolate);
}
}
}
}
+
return isolate->factory()->undefined_value();
}
« 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