Commit e0973e6e authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] TNodify/Remove ParamenterMode from BuildFastArrayForEach

The array can be FixedArrayBase, PropertyArray or HeapObject. That
HeapObject has to be either a FixedArray or a PropertyArray since we
have an assert for it. However, due to how the code is structured it
is not so simple to remove HeapObject from the Union.

Drive-by: deleted unused version of BuildFastArrayForEach.

Bug: v8:9708, v8:6949
Change-Id: I980f759dad9c76f0c765622cbdda37e33709f53f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2362954Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69519}
parent 1c8c6579
...@@ -4234,8 +4234,7 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined( ...@@ -4234,8 +4234,7 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined(
[this, value](TNode<HeapObject> array, TNode<IntPtrT> offset) { [this, value](TNode<HeapObject> array, TNode<IntPtrT> offset) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset,
value); value);
}, });
INTPTR_PARAMETERS);
} }
template <typename TIndex> template <typename TIndex>
...@@ -4247,9 +4246,6 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind, ...@@ -4247,9 +4246,6 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind,
static_assert( static_assert(
std::is_same<TIndex, Smi>::value || std::is_same<TIndex, IntPtrT>::value, std::is_same<TIndex, Smi>::value || std::is_same<TIndex, IntPtrT>::value,
"Only Smi or IntPtrT from and to are allowed"); "Only Smi or IntPtrT from and to are allowed");
const ParameterMode mode =
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind)); CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind));
DCHECK(value_root_index == RootIndex::kTheHoleValue || DCHECK(value_root_index == RootIndex::kTheHoleValue ||
value_root_index == RootIndex::kUndefinedValue); value_root_index == RootIndex::kUndefinedValue);
...@@ -4273,8 +4269,7 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind, ...@@ -4273,8 +4269,7 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind,
StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset,
value); value);
} }
}, });
mode);
} }
template V8_EXPORT_PRIVATE void template V8_EXPORT_PRIVATE void
...@@ -4444,14 +4439,14 @@ void CodeStubAssembler::MoveElements(ElementsKind kind, ...@@ -4444,14 +4439,14 @@ void CodeStubAssembler::MoveElements(ElementsKind kind,
{ {
// Make a loop for the stores. // Make a loop for the stores.
BuildFastArrayForEach(elements, kind, begin, end, loop_body, BuildFastArrayForEach(elements, kind, begin, end, loop_body,
INTPTR_PARAMETERS, ForEachDirection::kForward); ForEachDirection::kForward);
Goto(&finished); Goto(&finished);
} }
BIND(&iterate_backward); BIND(&iterate_backward);
{ {
BuildFastArrayForEach(elements, kind, begin, end, loop_body, BuildFastArrayForEach(elements, kind, begin, end, loop_body,
INTPTR_PARAMETERS, ForEachDirection::kReverse); ForEachDirection::kReverse);
Goto(&finished); Goto(&finished);
} }
} }
...@@ -4531,7 +4526,7 @@ void CodeStubAssembler::CopyElements(ElementsKind kind, ...@@ -4531,7 +4526,7 @@ void CodeStubAssembler::CopyElements(ElementsKind kind,
Store(dst_elements, delta_offset, element); Store(dst_elements, delta_offset, element);
} }
}, },
INTPTR_PARAMETERS, ForEachDirection::kForward); ForEachDirection::kForward);
Goto(&finished); Goto(&finished);
} }
BIND(&finished); BIND(&finished);
...@@ -4760,8 +4755,7 @@ void CodeStubAssembler::CopyPropertyArrayValues(TNode<HeapObject> from_array, ...@@ -4760,8 +4755,7 @@ void CodeStubAssembler::CopyPropertyArrayValues(TNode<HeapObject> from_array,
StoreNoWriteBarrier(MachineRepresentation::kTagged, to_array, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, to_array, offset,
value); value);
} }
}, });
INTPTR_PARAMETERS);
#ifdef DEBUG #ifdef DEBUG
// Zap {from_array} if the copying above has made it invalid. // Zap {from_array} if the copying above has made it invalid.
...@@ -10310,16 +10304,16 @@ template TNode<UintPtrT> CodeStubAssembler::BuildFastLoop<UintPtrT>( ...@@ -10310,16 +10304,16 @@ template TNode<UintPtrT> CodeStubAssembler::BuildFastLoop<UintPtrT>(
TNode<UintPtrT> end_index, const FastLoopBody<UintPtrT>& body, TNode<UintPtrT> end_index, const FastLoopBody<UintPtrT>& body,
int increment, IndexAdvanceMode advance_mode); int increment, IndexAdvanceMode advance_mode);
template <typename TIndex>
void CodeStubAssembler::BuildFastArrayForEach( void CodeStubAssembler::BuildFastArrayForEach(
const CodeStubAssembler::VariableList& vars, Node* fixed_array, TNode<UnionT<UnionT<FixedArray, PropertyArray>, HeapObject>> array,
ElementsKind kind, Node* first_element_inclusive, ElementsKind kind, TNode<TIndex> first_element_inclusive,
Node* last_element_exclusive, const FastArrayForEachBody& body, TNode<TIndex> last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode, ForEachDirection direction) { ForEachDirection direction) {
STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
CSA_SLOW_ASSERT(this, MatchesParameterMode(first_element_inclusive, mode)); CSA_SLOW_ASSERT(this, Word32Or(IsFixedArrayWithKind(array, kind),
CSA_SLOW_ASSERT(this, MatchesParameterMode(last_element_exclusive, mode)); IsPropertyArray(array)));
CSA_SLOW_ASSERT(this, Word32Or(IsFixedArrayWithKind(fixed_array, kind),
IsPropertyArray(fixed_array)));
int32_t first_val; int32_t first_val;
bool constant_first = ToInt32Constant(first_element_inclusive, &first_val); bool constant_first = ToInt32Constant(first_element_inclusive, &first_val);
int32_t last_val; int32_t last_val;
...@@ -10333,32 +10327,29 @@ void CodeStubAssembler::BuildFastArrayForEach( ...@@ -10333,32 +10327,29 @@ void CodeStubAssembler::BuildFastArrayForEach(
TNode<IntPtrT> index = IntPtrConstant(i); TNode<IntPtrT> index = IntPtrConstant(i);
TNode<IntPtrT> offset = ElementOffsetFromIndex( TNode<IntPtrT> offset = ElementOffsetFromIndex(
index, kind, FixedArray::kHeaderSize - kHeapObjectTag); index, kind, FixedArray::kHeaderSize - kHeapObjectTag);
body(CAST(fixed_array), offset); body(array, offset);
} }
} else { } else {
for (int i = last_val - 1; i >= first_val; --i) { for (int i = last_val - 1; i >= first_val; --i) {
TNode<IntPtrT> index = IntPtrConstant(i); TNode<IntPtrT> index = IntPtrConstant(i);
TNode<IntPtrT> offset = ElementOffsetFromIndex( TNode<IntPtrT> offset = ElementOffsetFromIndex(
index, kind, FixedArray::kHeaderSize - kHeapObjectTag); index, kind, FixedArray::kHeaderSize - kHeapObjectTag);
body(CAST(fixed_array), offset); body(array, offset);
} }
} }
return; return;
} }
} }
TNode<IntPtrT> start = TNode<IntPtrT> start = ElementOffsetFromIndex(
ElementOffsetFromIndex(first_element_inclusive, kind, mode, first_element_inclusive, kind, FixedArray::kHeaderSize - kHeapObjectTag);
FixedArray::kHeaderSize - kHeapObjectTag); TNode<IntPtrT> limit = ElementOffsetFromIndex(
TNode<IntPtrT> limit = last_element_exclusive, kind, FixedArray::kHeaderSize - kHeapObjectTag);
ElementOffsetFromIndex(last_element_exclusive, kind, mode,
FixedArray::kHeaderSize - kHeapObjectTag);
if (direction == ForEachDirection::kReverse) std::swap(start, limit); if (direction == ForEachDirection::kReverse) std::swap(start, limit);
int increment = IsDoubleElementsKind(kind) ? kDoubleSize : kTaggedSize; int increment = IsDoubleElementsKind(kind) ? kDoubleSize : kTaggedSize;
BuildFastLoop<IntPtrT>( BuildFastLoop<IntPtrT>(
vars, start, limit, start, limit, [&](TNode<IntPtrT> offset) { body(array, offset); },
[&](TNode<IntPtrT> offset) { body(CAST(fixed_array), offset); },
direction == ForEachDirection::kReverse ? -increment : increment, direction == ForEachDirection::kReverse ? -increment : increment,
direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre
: IndexAdvanceMode::kPost); : IndexAdvanceMode::kPost);
......
...@@ -3219,23 +3219,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3219,23 +3219,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
using FastArrayForEachBody = using FastArrayForEachBody =
std::function<void(TNode<HeapObject> array, TNode<IntPtrT> offset)>; std::function<void(TNode<HeapObject> array, TNode<IntPtrT> offset)>;
template <typename TIndex>
void BuildFastArrayForEach( void BuildFastArrayForEach(
const CodeStubAssembler::VariableList& vars, Node* array, TNode<UnionT<UnionT<FixedArray, PropertyArray>, HeapObject>> array,
ElementsKind kind, Node* first_element_inclusive, ElementsKind kind, TNode<TIndex> first_element_inclusive,
Node* last_element_exclusive, const FastArrayForEachBody& body, TNode<TIndex> last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode = INTPTR_PARAMETERS,
ForEachDirection direction = ForEachDirection::kReverse); ForEachDirection direction = ForEachDirection::kReverse);
void BuildFastArrayForEach(
Node* array, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode = INTPTR_PARAMETERS,
ForEachDirection direction = ForEachDirection::kReverse) {
CodeStubAssembler::VariableList list(0, zone());
BuildFastArrayForEach(list, array, kind, first_element_inclusive,
last_element_exclusive, body, mode, direction);
}
template <typename TIndex> template <typename TIndex>
TNode<IntPtrT> GetArrayAllocationSize(TNode<TIndex> element_count, TNode<IntPtrT> GetArrayAllocationSize(TNode<TIndex> element_count,
ElementsKind kind, int header_size) { ElementsKind kind, int header_size) {
......
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