Commit 84591db1 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Use LookupIterator in SetAccessor / DefineAccessor and remove...

Use LookupIterator in SetAccessor / DefineAccessor and remove "search_hidden_prototypes" from LookupOwn

BUG=
R=jkummerow@chromium.org

Review URL: https://codereview.chromium.org/468163002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@23169 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 604031af
......@@ -143,6 +143,7 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
return property_details_;
}
bool IsConfigurable() const { return !property_details().IsDontDelete(); }
bool IsReadOnly() const { return property_details().IsReadOnly(); }
Representation representation() const {
return property_details().representation();
}
......
......@@ -5771,8 +5771,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());
......@@ -5780,8 +5779,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()) {
......@@ -5805,14 +5803,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);
}
}
......@@ -5822,7 +5812,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();
......@@ -6348,12 +6338,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();
}
}
}
......@@ -6543,11 +6534,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();
}
......
......@@ -1999,8 +1999,7 @@ class JSReceiver: public HeapObject {
// Lookup a property. If found, the result is valid and has
// detailed information.
void LookupOwn(Handle<Name> name, LookupResult* result,
bool search_hidden_prototypes = false);
void LookupOwn(Handle<Name> name, LookupResult* result);
void Lookup(Handle<Name> name, LookupResult* result);
enum KeyCollectionType { OWN_ONLY, INCLUDE_PROTOS };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment