Commit 7b526447 authored by verwaest's avatar verwaest Committed by Commit bot

Use LookupIterator in GetOldValue

BUG=v8:4137
LOG=n

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

Cr-Commit-Position: refs/heads/master@{#28973}
parent cbf91377
......@@ -11868,25 +11868,22 @@ void JSArray::Expand(Handle<JSArray> array, int required_size) {
}
// Returns false if the passed-in index is marked non-configurable,
// which will cause the ES5 truncation operation to halt, and thus
// no further old values need be collected.
// Returns false if the passed-in index is marked non-configurable, which will
// cause the truncation operation to halt, and thus no further old values need
// be collected.
static bool GetOldValue(Isolate* isolate,
Handle<JSObject> object,
uint32_t index,
List<Handle<Object> >* old_values,
List<uint32_t>* indices) {
Maybe<PropertyAttributes> maybe =
JSReceiver::GetOwnElementAttributes(object, index);
DCHECK(maybe.IsJust());
DCHECK(maybe.FromJust() != ABSENT);
if (maybe.FromJust() == DONT_DELETE) return false;
Handle<Object> value;
if (!JSObject::GetOwnElementAccessorPair(object, index).is_null()) {
value = Handle<Object>::cast(isolate->factory()->the_hole_value());
} else {
value = Object::GetElement(isolate, object, index).ToHandleChecked();
}
LookupIterator it(isolate, object, index, LookupIterator::HIDDEN);
CHECK(JSReceiver::GetPropertyAttributes(&it).IsJust());
DCHECK(it.IsFound());
if (!it.IsConfigurable()) return false;
Handle<Object> value =
it.state() == LookupIterator::ACCESSOR
? Handle<Object>::cast(isolate->factory()->the_hole_value())
: JSReceiver::GetDataProperty(&it);
old_values->Add(value);
indices->Add(index);
return true;
......@@ -12389,24 +12386,6 @@ void JSObject::EnsureCanContainElements(Handle<JSObject> object,
}
MaybeHandle<AccessorPair> JSObject::GetOwnElementAccessorPair(
Handle<JSObject> object,
uint32_t index) {
if (object->IsJSGlobalProxy()) {
PrototypeIterator iter(object->GetIsolate(), object);
if (iter.IsAtEnd()) return MaybeHandle<AccessorPair>();
DCHECK(PrototypeIterator::GetCurrent(iter)->IsJSGlobalObject());
return GetOwnElementAccessorPair(
Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)), index);
}
// Check for lookup interceptor.
if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>();
return object->GetElementsAccessor()->GetAccessorPair(object, index);
}
bool JSObject::HasFastArgumentsElements() {
Heap* heap = GetHeap();
if (!elements()->IsFixedArray()) return false;
......
......@@ -2013,9 +2013,6 @@ class JSObject: public JSReceiver {
}
// These methods do not perform access checks!
MUST_USE_RESULT static MaybeHandle<AccessorPair> GetOwnElementAccessorPair(
Handle<JSObject> object, uint32_t index);
static void UpdateAllocationSite(Handle<JSObject> object,
ElementsKind to_kind);
......
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