Commit 4a030e84 authored by Toon Verwaest's avatar Toon Verwaest

Remove receiver as parameter to Get/Has Element in the accessors.

BUG=
R=bmeurer@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#26735}
parent a7fb5ed4
......@@ -666,7 +666,7 @@ BUILTIN(ArraySlice) {
bool packed = true;
ElementsAccessor* accessor = ElementsAccessor::ForKind(kind);
for (int i = k; i < final; i++) {
if (!accessor->HasElement(object, object, i, elms)) {
if (!accessor->HasElement(object, i, elms)) {
packed = false;
break;
}
......
......@@ -587,19 +587,15 @@ class ElementsAccessorBase : public ElementsAccessor {
ElementsAccessorSubclass::ValidateImpl(holder);
}
static bool HasElementImpl(Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) {
return ElementsAccessorSubclass::GetAttributesImpl(
receiver, holder, key, backing_store) != ABSENT;
return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
backing_store) != ABSENT;
}
virtual bool HasElement(Handle<Object> receiver, Handle<JSObject> holder,
uint32_t key,
virtual bool HasElement(Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) FINAL {
return ElementsAccessorSubclass::HasElementImpl(
receiver, holder, key, backing_store);
return ElementsAccessorSubclass::HasElementImpl(holder, key, backing_store);
}
MUST_USE_RESULT virtual MaybeHandle<Object> Get(
......@@ -632,14 +628,13 @@ class ElementsAccessorBase : public ElementsAccessor {
}
MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
Handle<Object> receiver, Handle<JSObject> holder, uint32_t key,
Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) FINAL {
return ElementsAccessorSubclass::GetAttributesImpl(
receiver, holder, key, backing_store);
return ElementsAccessorSubclass::GetAttributesImpl(holder, key,
backing_store);
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -652,14 +647,13 @@ class ElementsAccessorBase : public ElementsAccessor {
}
MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair(
Handle<Object> receiver, Handle<JSObject> holder, uint32_t key,
Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) FINAL {
return ElementsAccessorSubclass::GetAccessorPairImpl(
receiver, holder, key, backing_store);
return ElementsAccessorSubclass::GetAccessorPairImpl(holder, key,
backing_store);
}
MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -766,8 +760,7 @@ class ElementsAccessorBase : public ElementsAccessor {
uint32_t extra = 0;
for (uint32_t y = 0; y < len1; y++) {
uint32_t key = ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
if (ElementsAccessorSubclass::HasElementImpl(
receiver, holder, key, from)) {
if (ElementsAccessorSubclass::HasElementImpl(holder, key, from)) {
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, value,
......@@ -804,8 +797,7 @@ class ElementsAccessorBase : public ElementsAccessor {
for (uint32_t y = 0; y < len1; y++) {
uint32_t key =
ElementsAccessorSubclass::GetKeyForIndexImpl(from, y);
if (ElementsAccessorSubclass::HasElementImpl(
receiver, holder, key, from)) {
if (ElementsAccessorSubclass::HasElementImpl(holder, key, from)) {
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION(
isolate, value,
......@@ -978,7 +970,6 @@ class FastElementsAccessor
}
static bool HasElementImpl(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -1277,7 +1268,6 @@ class TypedElementsAccessor
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -1301,9 +1291,7 @@ class TypedElementsAccessor
return obj->GetIsolate()->factory()->true_value();
}
static bool HasElementImpl(Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> backing_store) {
uint32_t capacity =
AccessorClass::GetCapacityImpl(backing_store);
......@@ -1473,7 +1461,6 @@ class DictionaryElementsAccessor
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -1487,7 +1474,6 @@ class DictionaryElementsAccessor
}
MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> store) {
......@@ -1502,9 +1488,7 @@ class DictionaryElementsAccessor
return MaybeHandle<AccessorPair>();
}
static bool HasElementImpl(Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
static bool HasElementImpl(Handle<JSObject> holder, uint32_t key,
Handle<FixedArrayBase> store) {
Handle<SeededNumberDictionary> backing_store =
Handle<SeededNumberDictionary>::cast(store);
......@@ -1574,7 +1558,6 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
}
MUST_USE_RESULT static PropertyAttributes GetAttributesImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> backing_store) {
......@@ -1585,13 +1568,12 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
} else {
// If not aliased, check the arguments.
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
return ElementsAccessor::ForArray(arguments)->GetAttributes(
receiver, obj, key, arguments);
return ElementsAccessor::ForArray(arguments)
->GetAttributes(obj, key, arguments);
}
}
MUST_USE_RESULT static MaybeHandle<AccessorPair> GetAccessorPairImpl(
Handle<Object> receiver,
Handle<JSObject> obj,
uint32_t key,
Handle<FixedArrayBase> parameters) {
......@@ -1602,8 +1584,8 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
} else {
// If not aliased, check the arguments.
Handle<FixedArray> arguments(FixedArray::cast(parameter_map->get(1)));
return ElementsAccessor::ForArray(arguments)->GetAccessorPair(
receiver, obj, key, arguments);
return ElementsAccessor::ForArray(arguments)
->GetAccessorPair(obj, key, arguments);
}
}
......@@ -1663,28 +1645,6 @@ class SloppyArgumentsElementsAccessor : public ElementsAccessorBase<
return index;
}
static bool HasElementImpl(Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> parameters) {
Handle<FixedArray> parameter_map = Handle<FixedArray>::cast(parameters);
Handle<Object> probe = GetParameterMapArg(holder, parameter_map, key);
if (!probe->IsTheHole()) {
return true;
} else {
Isolate* isolate = holder->GetIsolate();
Handle<FixedArrayBase> arguments(FixedArrayBase::cast(
Handle<FixedArray>::cast(parameter_map)->get(1)), isolate);
ElementsAccessor* accessor = ElementsAccessor::ForArray(arguments);
Handle<Object> value;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, value,
accessor->Get(receiver, holder, key, arguments),
false);
return !value->IsTheHole();
}
}
private:
static Handle<Object> GetParameterMapArg(Handle<JSObject> holder,
Handle<FixedArray> parameter_map,
......
......@@ -33,16 +33,14 @@ class ElementsAccessor {
// the ElementsKind of the ElementsAccessor. If backing_store is NULL, the
// holder->elements() is used as the backing store.
virtual bool HasElement(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
inline bool HasElement(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) {
return HasElement(receiver, holder, key, handle(holder->elements()));
return HasElement(holder, key, handle(holder->elements()));
}
// Returns the element with the specified key or undefined if there is no such
......@@ -69,16 +67,14 @@ class ElementsAccessor {
// be compatible with the ElementsKind of the ElementsAccessor. If
// backing_store is NULL, the holder->elements() is used as the backing store.
MUST_USE_RESULT virtual PropertyAttributes GetAttributes(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
MUST_USE_RESULT inline PropertyAttributes GetAttributes(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) {
return GetAttributes(receiver, holder, key, handle(holder->elements()));
return GetAttributes(holder, key, handle(holder->elements()));
}
// Returns an element's accessors, or NULL if the element does not exist or
......@@ -87,16 +83,14 @@ class ElementsAccessor {
// be compatible with the ElementsKind of the ElementsAccessor. If
// backing_store is NULL, the holder->elements() is used as the backing store.
MUST_USE_RESULT virtual MaybeHandle<AccessorPair> GetAccessorPair(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
MUST_USE_RESULT inline MaybeHandle<AccessorPair> GetAccessorPair(
Handle<Object> receiver,
Handle<JSObject> holder,
uint32_t key) {
return GetAccessorPair(receiver, holder, key, handle(holder->elements()));
return GetAccessorPair(holder, key, handle(holder->elements()));
}
// Modifies the length data property as specified for JSArrays and resizes the
......
......@@ -731,17 +731,15 @@ MaybeHandle<Object> Object::SetElementWithReceiver(
if (!done &&
js_object->elements() != isolate->heap()->empty_fixed_array()) {
ElementsAccessor* accessor = js_object->GetElementsAccessor();
PropertyAttributes attrs =
accessor->GetAttributes(receiver, js_object, index);
PropertyAttributes attrs = accessor->GetAttributes(js_object, index);
if ((attrs & READ_ONLY) != 0) {
return WriteToReadOnlyElement(isolate, receiver, index, value,
language_mode);
}
Handle<AccessorPair> accessor_pair;
if (accessor->GetAccessorPair(receiver, js_object, index)
.ToHandle(&accessor_pair)) {
return JSObject::SetElementWithCallback(
receiver, accessor_pair, index, value, js_object, language_mode);
Handle<AccessorPair> pair;
if (accessor->GetAccessorPair(js_object, index).ToHandle(&pair)) {
return JSObject::SetElementWithCallback(receiver, pair, index, value,
js_object, language_mode);
} else {
done = attrs != ABSENT;
}
......@@ -754,7 +752,7 @@ MaybeHandle<Object> Object::SetElementWithReceiver(
}
Handle<JSObject> target = Handle<JSObject>::cast(receiver);
ElementsAccessor* accessor = target->GetElementsAccessor();
PropertyAttributes attrs = accessor->GetAttributes(receiver, target, index);
PropertyAttributes attrs = accessor->GetAttributes(target, index);
if ((attrs & READ_ONLY) != 0) {
return WriteToReadOnlyElement(isolate, receiver, index, value,
language_mode);
......@@ -4372,8 +4370,8 @@ Maybe<PropertyAttributes> JSObject::GetElementAttributeFromInterceptor(
Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor(
Handle<JSObject> object, Handle<JSReceiver> receiver, uint32_t index,
bool check_prototype) {
PropertyAttributes attr = object->GetElementsAccessor()->GetAttributes(
receiver, object, index);
PropertyAttributes attr =
object->GetElementsAccessor()->GetAttributes(object, index);
if (attr != ABSENT) return maybe(attr);
// Handle [] on String objects.
......@@ -12525,7 +12523,7 @@ MaybeHandle<AccessorPair> JSObject::GetOwnElementAccessorPair(
// Check for lookup interceptor.
if (object->HasIndexedInterceptor()) return MaybeHandle<AccessorPair>();
return object->GetElementsAccessor()->GetAccessorPair(object, object, index);
return object->GetElementsAccessor()->GetAccessorPair(object, index);
}
......
......@@ -420,7 +420,7 @@ static void CollectElementIndices(Handle<JSObject> object, uint32_t range,
uint32_t length = static_cast<uint32_t>(DoubleToInt32(length_num));
ElementsAccessor* accessor = object->GetElementsAccessor();
for (uint32_t i = 0; i < length; i++) {
if (accessor->HasElement(object, object, i)) {
if (accessor->HasElement(object, i)) {
indices->Add(i);
}
}
......@@ -687,7 +687,7 @@ static bool IterateElements(Isolate* isolate, Handle<JSObject> receiver,
ElementsAccessor* accessor = receiver->GetElementsAccessor();
for (uint32_t index = 0; index < length; index++) {
HandleScope loop_scope(isolate);
if (accessor->HasElement(receiver, receiver, index)) {
if (accessor->HasElement(receiver, index)) {
Handle<Object> element;
ASSIGN_RETURN_ON_EXCEPTION_VALUE(
isolate, element, accessor->Get(receiver, receiver, index),
......@@ -979,7 +979,7 @@ RUNTIME_FUNCTION(Runtime_EstimateNumberOfElements) {
ElementsAccessor* accessor = array->GetElementsAccessor();
int holes = 0;
for (int i = 0; i < length; i += increment) {
if (!accessor->HasElement(array, array, i, elements)) {
if (!accessor->HasElement(array, i, elements)) {
++holes;
}
}
......
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