Commit cca6ffff authored by verwaest's avatar verwaest Committed by Commit bot

Revert of Remove handle wrappers from basic elements accessors (patchset #2...

Revert of Remove handle wrappers from basic elements accessors (patchset #2 id:20001 of https://codereview.chromium.org/934173004/)

Reason for revert:
Breakage

Original issue's description:
> Remove handle wrappers from basic elements accessors
>
> BUG=
> R=yangguo@chromium.org
>
> Committed: https://crrev.com/40b7c513c696f405af0ae3e74e844d3c341bc3f2
> Cr-Commit-Position: refs/heads/master@{#26736}

TBR=yangguo@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

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

Cr-Commit-Position: refs/heads/master@{#26737}
parent 40b7c513
...@@ -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, i, *elms)) { if (!accessor->HasElement(object, i, elms)) {
packed = false; packed = false;
break; break;
} }
......
This diff is collapsed.
...@@ -32,11 +32,15 @@ class ElementsAccessor { ...@@ -32,11 +32,15 @@ class ElementsAccessor {
// in the backing store to use for the check, which must be compatible with // in the backing store to use for the check, which must be compatible with
// 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(JSObject* holder, uint32_t key, virtual bool HasElement(
FixedArrayBase* backing_store) = 0; Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
inline bool HasElement(JSObject* holder, uint32_t key) { inline bool HasElement(
return HasElement(holder, key, holder->elements()); Handle<JSObject> holder,
uint32_t key) {
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
...@@ -63,11 +67,14 @@ class ElementsAccessor { ...@@ -63,11 +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(
JSObject* holder, uint32_t key, FixedArrayBase* backing_store) = 0; Handle<JSObject> holder,
uint32_t key,
Handle<FixedArrayBase> backing_store) = 0;
MUST_USE_RESULT inline PropertyAttributes GetAttributes(JSObject* holder, MUST_USE_RESULT inline PropertyAttributes GetAttributes(
uint32_t key) { Handle<JSObject> holder,
return GetAttributes(holder, key, holder->elements()); uint32_t key) {
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
...@@ -168,7 +175,7 @@ class ElementsAccessor { ...@@ -168,7 +175,7 @@ class ElementsAccessor {
return elements_accessors_[elements_kind]; return elements_accessors_[elements_kind];
} }
static ElementsAccessor* ForArray(FixedArrayBase* array); static ElementsAccessor* ForArray(Handle<FixedArrayBase> array);
static void InitializeOncePerProcess(); static void InitializeOncePerProcess();
static void TearDown(); static void TearDown();
...@@ -176,7 +183,7 @@ class ElementsAccessor { ...@@ -176,7 +183,7 @@ class ElementsAccessor {
protected: protected:
friend class SloppyArgumentsElementsAccessor; friend class SloppyArgumentsElementsAccessor;
virtual uint32_t GetCapacity(FixedArrayBase* backing_store) = 0; virtual uint32_t GetCapacity(Handle<FixedArrayBase> backing_store) = 0;
// Element handlers distinguish between indexes and keys when they manipulate // Element handlers distinguish between indexes and keys when they manipulate
// elements. Indexes refer to elements in terms of their location in the // elements. Indexes refer to elements in terms of their location in the
......
...@@ -731,7 +731,7 @@ MaybeHandle<Object> Object::SetElementWithReceiver( ...@@ -731,7 +731,7 @@ 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 = accessor->GetAttributes(*js_object, index); PropertyAttributes attrs = accessor->GetAttributes(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);
...@@ -752,7 +752,7 @@ MaybeHandle<Object> Object::SetElementWithReceiver( ...@@ -752,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(*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);
...@@ -4371,7 +4371,7 @@ Maybe<PropertyAttributes> JSObject::GetElementAttributeWithoutInterceptor( ...@@ -4371,7 +4371,7 @@ 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 = PropertyAttributes attr =
object->GetElementsAccessor()->GetAttributes(*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.
...@@ -8254,7 +8254,7 @@ MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike( ...@@ -8254,7 +8254,7 @@ MaybeHandle<FixedArray> FixedArray::AddKeysFromArrayLike(
MaybeHandle<FixedArray> FixedArray::UnionOfKeys(Handle<FixedArray> first, MaybeHandle<FixedArray> FixedArray::UnionOfKeys(Handle<FixedArray> first,
Handle<FixedArray> second) { Handle<FixedArray> second) {
ElementsAccessor* accessor = ElementsAccessor::ForArray(*second); ElementsAccessor* accessor = ElementsAccessor::ForArray(second);
Handle<FixedArray> result; Handle<FixedArray> result;
ASSIGN_RETURN_ON_EXCEPTION( ASSIGN_RETURN_ON_EXCEPTION(
first->GetIsolate(), result, first->GetIsolate(), result,
......
...@@ -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, 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, 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, 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