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

Unified Diff: src/objects.cc

Issue 1416053007: Introduce LookupIterator::Restart() and use it (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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.cc ('K') | « src/lookup.cc ('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 49e8b52d944f7b65c362460db47f6cb6001864a6..1e5315b978e67fb8e9314cd993a5184f60ff3269 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -6054,8 +6054,8 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
return false;
}
// 3. Let extensible be the value of the [[Extensible]] internal slot of O.
- Handle<JSObject> o = Handle<JSObject>::cast(it->GetReceiver());
- bool extensible = JSObject::IsExtensible(o);
+ Handle<JSObject> object = Handle<JSObject>::cast(it->GetReceiver());
+ bool extensible = JSObject::IsExtensible(object);
bool desc_is_data_descriptor = PropertyDescriptor::IsDataDescriptor(desc);
bool desc_is_accessor_descriptor =
@@ -6074,12 +6074,12 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
}
return false;
}
- // We have to use a fresh LookupIterator to handle interceptors properly.
- LookupIterator lookup_for_store =
- it->IsElement() ? LookupIterator(isolate, it->GetReceiver(),
- it->index(), LookupIterator::HIDDEN)
- : LookupIterator(it->GetReceiver(), it->name(),
- LookupIterator::HIDDEN);
+ // We have to reset the LookupIterator to handle interceptors properly.
+ Map* map = Handle<HeapObject>::cast(object)->map();
+ if ((it->IsElement() && map->has_indexed_interceptor()) ||
+ (!it->IsElement() && map->has_named_interceptor())) {
+ it->Restart();
+ }
// 2c. If IsGenericDescriptor(Desc) or IsDataDescriptor(Desc) is true, then:
// (This is equivalent to !IsAccessorDescriptor(desc).)
@@ -6091,7 +6091,7 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
// [[Configurable]] attribute values are described by Desc. If the value
// of an attribute field of Desc is absent, the attribute of the newly
// created property is set to its default value.
- if (!o->IsUndefined()) {
+ if (!object->IsUndefined()) {
if (!desc->has_writable()) desc->set_writable(false);
if (!desc->has_enumerable()) desc->set_enumerable(false);
if (!desc->has_configurable()) desc->set_configurable(false);
@@ -6101,8 +6101,7 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
: Handle<Object>::cast(isolate->factory()->undefined_value()));
MaybeHandle<Object> result =
JSObject::DefineOwnPropertyIgnoreAttributes(
- &lookup_for_store, value, desc->ToAttributes(),
- JSObject::DONT_FORCE_FIELD);
+ it, value, desc->ToAttributes(), JSObject::DONT_FORCE_FIELD);
if (result.is_null()) return false;
}
} else {
@@ -6113,7 +6112,7 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
// [[Configurable]] attribute values are described by Desc. If the value
// of an attribute field of Desc is absent, the attribute of the newly
// created property is set to its default value.
- if (!o->IsUndefined()) {
+ if (!object->IsUndefined()) {
if (!desc->has_enumerable()) desc->set_enumerable(false);
if (!desc->has_configurable()) desc->set_configurable(false);
Handle<Object> getter(
@@ -6124,8 +6123,8 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
desc->has_set()
? desc->set()
: Handle<Object>::cast(isolate->factory()->undefined_value()));
- MaybeHandle<Object> result = JSObject::DefineAccessor(
- &lookup_for_store, getter, setter, desc->ToAttributes());
+ MaybeHandle<Object> result =
+ JSObject::DefineAccessor(it, getter, setter, desc->ToAttributes());
if (result.is_null()) return false;
}
}
@@ -6213,10 +6212,11 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
// [Strong mode] Disallow changing writable -> readonly for
// non-configurable properties.
if (current.writable() && desc->has_writable() && !desc->writable() &&
- o->map()->is_strong()) {
+ object->map()->is_strong()) {
if (should_throw == THROW_ON_ERROR) {
isolate->Throw(*isolate->factory()->NewTypeError(
- MessageTemplate::kStrongRedefineDisallowed, o, it->GetName()));
+ MessageTemplate::kStrongRedefineDisallowed, object,
+ it->GetName()));
}
return false;
}
@@ -6271,7 +6271,7 @@ bool JSReceiver::OrdinaryDefineOwnProperty(LookupIterator* it,
}
// 10. If O is not undefined, then:
- if (!o->IsUndefined()) {
+ if (!object->IsUndefined()) {
// 10a. For each field of Desc that is present, set the corresponding
// attribute of the property named P of object O to the value of the field.
PropertyAttributes attrs = NONE;
« src/lookup.cc ('K') | « src/lookup.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698