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 { ...@@ -143,6 +143,7 @@ class LookupIterator V8_FINAL BASE_EMBEDDED {
return property_details_; return property_details_;
} }
bool IsConfigurable() const { return !property_details().IsDontDelete(); } bool IsConfigurable() const { return !property_details().IsDontDelete(); }
bool IsReadOnly() const { return property_details().IsReadOnly(); }
Representation representation() const { Representation representation() const {
return property_details().representation(); return property_details().representation();
} }
......
...@@ -5771,8 +5771,7 @@ int Map::NextFreePropertyIndex() { ...@@ -5771,8 +5771,7 @@ int Map::NextFreePropertyIndex() {
} }
void JSReceiver::LookupOwn( void JSReceiver::LookupOwn(Handle<Name> name, LookupResult* result) {
Handle<Name> name, LookupResult* result, bool search_hidden_prototypes) {
DisallowHeapAllocation no_gc; DisallowHeapAllocation no_gc;
DCHECK(name->IsName()); DCHECK(name->IsName());
...@@ -5780,8 +5779,7 @@ void JSReceiver::LookupOwn( ...@@ -5780,8 +5779,7 @@ void JSReceiver::LookupOwn(
PrototypeIterator iter(GetIsolate(), this); PrototypeIterator iter(GetIsolate(), this);
if (iter.IsAtEnd()) return result->NotFound(); if (iter.IsAtEnd()) return result->NotFound();
DCHECK(iter.GetCurrent()->IsJSGlobalObject()); DCHECK(iter.GetCurrent()->IsJSGlobalObject());
return JSReceiver::cast(iter.GetCurrent()) return JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
->LookupOwn(name, result, search_hidden_prototypes);
} }
if (IsJSProxy()) { if (IsJSProxy()) {
...@@ -5805,14 +5803,6 @@ void JSReceiver::LookupOwn( ...@@ -5805,14 +5803,6 @@ void JSReceiver::LookupOwn(
} }
js_object->LookupOwnRealNamedProperty(name, result); 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) { ...@@ -5822,7 +5812,7 @@ void JSReceiver::Lookup(Handle<Name> name, LookupResult* result) {
for (PrototypeIterator iter(GetIsolate(), this, for (PrototypeIterator iter(GetIsolate(), this,
PrototypeIterator::START_AT_RECEIVER); PrototypeIterator::START_AT_RECEIVER);
!iter.IsAtEnd(); iter.Advance()) { !iter.IsAtEnd(); iter.Advance()) {
JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result, false); JSReceiver::cast(iter.GetCurrent())->LookupOwn(name, result);
if (result->IsFound()) return; if (result->IsFound()) return;
if (name->IsOwn()) { if (name->IsOwn()) {
result->NotFound(); result->NotFound();
...@@ -6348,12 +6338,13 @@ MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object, ...@@ -6348,12 +6338,13 @@ MaybeHandle<Object> JSObject::DefineAccessor(Handle<JSObject> object,
Object::GetElement(isolate, object, index).ToHandleChecked(); Object::GetElement(isolate, object, index).ToHandleChecked();
} }
} else { } else {
LookupResult lookup(isolate); LookupIterator it(object, name,
object->LookupOwn(name, &lookup, true); LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
preexists = lookup.IsProperty(); CHECK(GetPropertyAttributes(&it).has_value);
if (preexists && lookup.IsDataProperty()) { preexists = it.IsFound();
old_value = if (preexists && (it.property_kind() == LookupIterator::DATA ||
Object::GetPropertyOrElement(object, name).ToHandleChecked(); it.GetAccessors()->IsAccessorInfo())) {
old_value = GetProperty(&it).ToHandleChecked();
} }
} }
} }
...@@ -6543,11 +6534,12 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object, ...@@ -6543,11 +6534,12 @@ MaybeHandle<Object> JSObject::SetAccessor(Handle<JSObject> object,
SetElementCallback(object, index, info, info->property_attributes()); SetElementCallback(object, index, info, info->property_attributes());
} else { } else {
// Lookup the name. // Lookup the name.
LookupResult result(isolate); LookupIterator it(object, name,
object->LookupOwn(name, &result, true); LookupIterator::CHECK_HIDDEN_SKIP_INTERCEPTOR);
CHECK(GetPropertyAttributes(&it).has_value);
// ES5 forbids turning a property into an accessor if it's not // 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). // configurable. See 8.6.1 (Table 5).
if (result.IsFound() && (result.IsReadOnly() || result.IsDontDelete())) { if (it.IsFound() && (it.IsReadOnly() || !it.IsConfigurable())) {
return factory->undefined_value(); return factory->undefined_value();
} }
......
...@@ -1999,8 +1999,7 @@ class JSReceiver: public HeapObject { ...@@ -1999,8 +1999,7 @@ class JSReceiver: public HeapObject {
// Lookup a property. If found, the result is valid and has // Lookup a property. If found, the result is valid and has
// detailed information. // detailed information.
void LookupOwn(Handle<Name> name, LookupResult* result, void LookupOwn(Handle<Name> name, LookupResult* result);
bool search_hidden_prototypes = false);
void Lookup(Handle<Name> name, LookupResult* result); void Lookup(Handle<Name> name, LookupResult* result);
enum KeyCollectionType { OWN_ONLY, INCLUDE_PROTOS }; 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