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

Unified Diff: src/objects.cc

Issue 468163002: Use LookupIterator in SetAccessor / DefineAccessor and remove "search_hidden_prototypes" from Looku… (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 side-by-side diff with in-line comments
Download patch
« src/lookup.h ('K') | « src/objects.h ('k') | 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 2526152b8903d4a3d605b663885ef7d3ef091dbd..06e4db5ff60294d01ba37742d37320d604d3f9e5 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -5792,8 +5792,7 @@ int Map::NextFreePropertyIndex() {
}
-void JSReceiver::LookupOwn(
- Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) {
+void JSReceiver::LookupOwn(Handle<Name> name, LookupResult* result) {
DisallowHeapAllocation no_gc;
DCHECK(name->IsName());
@@ -5801,8 +5800,7 @@ void JSReceiver::LookupOwn(
PrototypeIterator iter(GetIsolate(), this);
if (iter.IsAtEnd()) return result->NotFound();
DCHECK(iter.GetCurrent()->IsJSGlobalObject());
- return JSReceiver::cast(iter.GetCurrent())
- ->LookupOwn(name, result, search_hidden_prototypes);
+ return JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
}
if (IsJSProxy()) {
@@ -5826,14 +5824,6 @@ void JSReceiver::LookupOwn(
}
js_object->LookupOwnRealNamedProperty(name, result);
- if (result->IsFound() || name->IsOwn() || !search_hidden_prototypes) return;
-
- PrototypeIterator iter(GetIsolate(), js_object);
- if (!iter.GetCurrent()->IsJSReceiver()) return;
- JSReceiver* receiver = JSReceiver::cast(iter.GetCurrent());
- if (receiver->map()->is_hidden_prototype()) {
- receiver->LookupOwn(name, result, search_hidden_prototypes);
- }
}
@@ -5843,7 +5833,7 @@ void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) {
for (PrototypeIterator iter(GetIsolate(), this,
PrototypeIterator::START_AT_RECEIVER);
!iter.IsAtEnd(); iter.Advance()) {
- JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result, false);
+ JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
if (result->IsFound()) return;
if (name->IsOwn()) {
result->NotFound();
@@ -6369,12 +6359,13 @@ MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object,
Object::GetElement(isolate, object, index).ToHandleChecked();
}
} else {
- LookupResult lookup(isolate);
- object->LookupOwn(name, &lookup, true);
- preexists = lookup.IsProperty();
- if (preexists && lookup.IsDataProperty()) {
- old_value =
- Object::GetPropertyOrElement(object, name).ToHandleChecked();
+ LookupIterator it(object, name,
+ LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+ CHECK(GetPropertyAttributes(&it).has_value);
+ preexists = it.IsFound();
+ if (preexists && (it.property_kind() == LookupIterator::DATA ||
+ it.GetAccessors()->IsAccessorInfo())) {
+ old_value = GetProperty(&it).ToHandleChecked();
}
}
}
@@ -6564,11 +6555,12 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
SetElementCallback(object, index, info, info->property_attributes());
} else {
// Lookup the name.
- LookupResult result(isolate);
- object->LookupOwn(name, &result, true);
+ LookupIterator it(object, name,
+ LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
+ CHECK(GetPropertyAttributes(&it).has_value);
// ES5 forbids turning a property into an accessor if it's not
- // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
- if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) {
+ // configurable. See 8.6.1 (Table 5).
+ if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) {
return factory->undefined_value();
}
« src/lookup.h ('K') | « src/objects.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698