Commit 34a011f8 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[CSA][cleanup] TNodify FastArrayForEachBody

Used to be named FastFixedArrayForEachBody. Rename to remove the 'fixed'
part since it can also be a PropertyArray (i.e not a FixedArray).

Rename BuildFastFixedArrayForEach to also remove the 'fixed'.

Bug: v8:10506, v8:6949
Change-Id: I840edf802d334b9ca930f3022553c476e2dca34a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2202910Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67886}
parent 8d3cca97
...@@ -4289,9 +4289,9 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined( ...@@ -4289,9 +4289,9 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined(
CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode)); CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode));
ElementsKind kind = PACKED_ELEMENTS; ElementsKind kind = PACKED_ELEMENTS;
TNode<Oddball> value = UndefinedConstant(); TNode<Oddball> value = UndefinedConstant();
BuildFastFixedArrayForEach( BuildFastArrayForEach(
array, kind, from_node, to_node, array, kind, from_node, to_node,
[this, value](Node* array, Node* offset) { [this, value](TNode<HeapObject> array, TNode<IntPtrT> offset) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged, array, offset,
value); value);
}, },
...@@ -4317,9 +4317,10 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind, ...@@ -4317,9 +4317,10 @@ void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind,
float_value = LoadHeapNumberValue(CAST(value)); float_value = LoadHeapNumberValue(CAST(value));
} }
BuildFastFixedArrayForEach( BuildFastArrayForEach(
array, kind, from_node, to_node, array, kind, from_node, to_node,
[this, value, float_value, kind](Node* array, Node* offset) { [this, value, float_value, kind](TNode<HeapObject> array,
TNode<IntPtrT> offset) {
if (IsDoubleElementsKind(kind)) { if (IsDoubleElementsKind(kind)) {
StoreNoWriteBarrier(MachineRepresentation::kFloat64, array, offset, StoreNoWriteBarrier(MachineRepresentation::kFloat64, array, offset,
float_value); float_value);
...@@ -4477,7 +4478,7 @@ void CodeStubAssembler::MoveElements(ElementsKind kind, ...@@ -4477,7 +4478,7 @@ void CodeStubAssembler::MoveElements(ElementsKind kind,
const TNode<IntPtrT> delta = const TNode<IntPtrT> delta =
IntPtrMul(IntPtrSub(dst_index, begin), IntPtrMul(IntPtrSub(dst_index, begin),
IntPtrConstant(ElementsKindToByteSize(kind))); IntPtrConstant(ElementsKindToByteSize(kind)));
auto loop_body = [&](Node* array, Node* offset) { auto loop_body = [&](TNode<HeapObject> array, TNode<IntPtrT> offset) {
const TNode<AnyTaggedT> element = Load<AnyTaggedT>(array, offset); const TNode<AnyTaggedT> element = Load<AnyTaggedT>(array, offset);
const TNode<WordT> delta_offset = IntPtrAdd(offset, delta); const TNode<WordT> delta_offset = IntPtrAdd(offset, delta);
Store(array, delta_offset, element); Store(array, delta_offset, element);
...@@ -4490,17 +4491,15 @@ void CodeStubAssembler::MoveElements(ElementsKind kind, ...@@ -4490,17 +4491,15 @@ void CodeStubAssembler::MoveElements(ElementsKind kind,
BIND(&iterate_forward); BIND(&iterate_forward);
{ {
// Make a loop for the stores. // Make a loop for the stores.
BuildFastFixedArrayForEach(elements, kind, begin, end, loop_body, BuildFastArrayForEach(elements, kind, begin, end, loop_body,
INTPTR_PARAMETERS, INTPTR_PARAMETERS, ForEachDirection::kForward);
ForEachDirection::kForward);
Goto(&finished); Goto(&finished);
} }
BIND(&iterate_backward); BIND(&iterate_backward);
{ {
BuildFastFixedArrayForEach(elements, kind, begin, end, loop_body, BuildFastArrayForEach(elements, kind, begin, end, loop_body,
INTPTR_PARAMETERS, INTPTR_PARAMETERS, ForEachDirection::kReverse);
ForEachDirection::kReverse);
Goto(&finished); Goto(&finished);
} }
} }
...@@ -4568,9 +4567,9 @@ void CodeStubAssembler::CopyElements(ElementsKind kind, ...@@ -4568,9 +4567,9 @@ void CodeStubAssembler::CopyElements(ElementsKind kind,
const TNode<IntPtrT> delta = const TNode<IntPtrT> delta =
IntPtrMul(IntPtrSub(dst_index, src_index), IntPtrMul(IntPtrSub(dst_index, src_index),
IntPtrConstant(ElementsKindToByteSize(kind))); IntPtrConstant(ElementsKindToByteSize(kind)));
BuildFastFixedArrayForEach( BuildFastArrayForEach(
src_elements, kind, begin, end, src_elements, kind, begin, end,
[&](Node* array, Node* offset) { [&](TNode<HeapObject> array, TNode<IntPtrT> offset) {
const TNode<AnyTaggedT> element = Load<AnyTaggedT>(array, offset); const TNode<AnyTaggedT> element = Load<AnyTaggedT>(array, offset);
const TNode<WordT> delta_offset = IntPtrAdd(offset, delta); const TNode<WordT> delta_offset = IntPtrAdd(offset, delta);
if (write_barrier == SKIP_WRITE_BARRIER) { if (write_barrier == SKIP_WRITE_BARRIER) {
...@@ -4800,10 +4799,10 @@ void CodeStubAssembler::CopyPropertyArrayValues(TNode<HeapObject> from_array, ...@@ -4800,10 +4799,10 @@ void CodeStubAssembler::CopyPropertyArrayValues(TNode<HeapObject> from_array,
Node* start = IntPtrOrSmiConstant(0, mode); Node* start = IntPtrOrSmiConstant(0, mode);
ElementsKind kind = PACKED_ELEMENTS; ElementsKind kind = PACKED_ELEMENTS;
BuildFastFixedArrayForEach( BuildFastArrayForEach(
from_array, kind, start, property_count, from_array, kind, start, property_count,
[this, to_array, needs_write_barrier, destroy_source](Node* array, [this, to_array, needs_write_barrier, destroy_source](
Node* offset) { TNode<HeapObject> array, TNode<IntPtrT> offset) {
TNode<AnyTaggedT> value = Load<AnyTaggedT>(array, offset); TNode<AnyTaggedT> value = Load<AnyTaggedT>(array, offset);
if (destroy_source == DestroySource::kNo) { if (destroy_source == DestroySource::kNo) {
...@@ -10321,10 +10320,10 @@ template TNode<UintPtrT> CodeStubAssembler::BuildFastLoop<UintPtrT>( ...@@ -10321,10 +10320,10 @@ 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);
void CodeStubAssembler::BuildFastFixedArrayForEach( void CodeStubAssembler::BuildFastArrayForEach(
const CodeStubAssembler::VariableList& vars, Node* fixed_array, const CodeStubAssembler::VariableList& vars, Node* fixed_array,
ElementsKind kind, Node* first_element_inclusive, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive, const FastFixedArrayForEachBody& body, Node* last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode, ForEachDirection direction) { ParameterMode mode, 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, MatchesParameterMode(first_element_inclusive, mode));
...@@ -10344,14 +10343,14 @@ void CodeStubAssembler::BuildFastFixedArrayForEach( ...@@ -10344,14 +10343,14 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
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(fixed_array, offset); body(CAST(fixed_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(fixed_array, offset); body(CAST(fixed_array), offset);
} }
} }
return; return;
...@@ -10369,7 +10368,7 @@ void CodeStubAssembler::BuildFastFixedArrayForEach( ...@@ -10369,7 +10368,7 @@ void CodeStubAssembler::BuildFastFixedArrayForEach(
int increment = IsDoubleElementsKind(kind) ? kDoubleSize : kTaggedSize; int increment = IsDoubleElementsKind(kind) ? kDoubleSize : kTaggedSize;
BuildFastLoop<IntPtrT>( BuildFastLoop<IntPtrT>(
vars, start, limit, vars, start, limit,
[&](TNode<IntPtrT> offset) { body(fixed_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);
......
...@@ -3523,23 +3523,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3523,23 +3523,23 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
enum class ForEachDirection { kForward, kReverse }; enum class ForEachDirection { kForward, kReverse };
using FastFixedArrayForEachBody = using FastArrayForEachBody =
std::function<void(Node* fixed_array, Node* offset)>; std::function<void(TNode<HeapObject> array, TNode<IntPtrT> offset)>;
void BuildFastFixedArrayForEach( void BuildFastArrayForEach(
const CodeStubAssembler::VariableList& vars, Node* fixed_array, const CodeStubAssembler::VariableList& vars, Node* array,
ElementsKind kind, Node* first_element_inclusive, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive, const FastFixedArrayForEachBody& body, Node* last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode = INTPTR_PARAMETERS, ParameterMode mode = INTPTR_PARAMETERS,
ForEachDirection direction = ForEachDirection::kReverse); ForEachDirection direction = ForEachDirection::kReverse);
void BuildFastFixedArrayForEach( void BuildFastArrayForEach(
Node* fixed_array, ElementsKind kind, Node* first_element_inclusive, Node* array, ElementsKind kind, Node* first_element_inclusive,
Node* last_element_exclusive, const FastFixedArrayForEachBody& body, Node* last_element_exclusive, const FastArrayForEachBody& body,
ParameterMode mode = INTPTR_PARAMETERS, ParameterMode mode = INTPTR_PARAMETERS,
ForEachDirection direction = ForEachDirection::kReverse) { ForEachDirection direction = ForEachDirection::kReverse) {
CodeStubAssembler::VariableList list(0, zone()); CodeStubAssembler::VariableList list(0, zone());
BuildFastFixedArrayForEach(list, fixed_array, kind, first_element_inclusive, BuildFastArrayForEach(list, array, kind, first_element_inclusive,
last_element_exclusive, body, mode, direction); last_element_exclusive, body, mode, direction);
} }
......
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