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