Commit 4a1691a2 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Remove ParameterMode from StoreElement

Partially TNodify the method just to get ParameterMode out of the
way. There is more TNodification needed but method is complicated
and we are now focusing on removing ParameterMode entirely.

Bug: v8:9708, v8:6949
Change-Id: I705c35e9665488a280111683c275b7292bc47576
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2374547
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69568}
parent 0c2ef444
......@@ -2891,12 +2891,10 @@ void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind, Label* bailout,
GotoIfNotNumber(value, bailout);
}
ParameterMode mode = OptimalParameterMode();
if (IsDoubleElementsKind(kind)) {
StoreElement(elements, kind, index, ChangeNumberToFloat64(CAST(value)),
mode);
StoreElement(elements, kind, index, ChangeNumberToFloat64(CAST(value)));
} else {
StoreElement(elements, kind, index, value, mode);
StoreElement(elements, kind, index, value);
}
}
......@@ -9467,11 +9465,16 @@ MachineRepresentation ElementsKindToMachineRepresentation(ElementsKind kind) {
} // namespace
template <typename TIndex>
void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind,
Node* index, Node* value,
ParameterMode mode) {
TNode<TIndex> index, Node* value) {
// TODO(v8:9708): Do we want to keep both IntPtrT and UintPtrT variants?
static_assert(std::is_same<TIndex, Smi>::value ||
std::is_same<TIndex, UintPtrT>::value ||
std::is_same<TIndex, IntPtrT>::value,
"Only Smi, UintPtrT or IntPtrT index is allowed");
if (kind == BIGINT64_ELEMENTS || kind == BIGUINT64_ELEMENTS) {
TNode<IntPtrT> offset = ElementOffsetFromIndex(index, kind, mode, 0);
TNode<IntPtrT> offset = ElementOffsetFromIndex(index, kind, 0);
TVARIABLE(UintPtrT, var_low);
// Only used on 32-bit platforms.
TVARIABLE(UintPtrT, var_high);
......@@ -9500,22 +9503,35 @@ void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind,
CSA_ASSERT(this, Word32Equal(UncheckedCast<Word32T>(value),
Word32And(Int32Constant(0xFF), value)));
}
TNode<IntPtrT> offset = ElementOffsetFromIndex(index, kind, mode, 0);
TNode<IntPtrT> offset = ElementOffsetFromIndex(index, kind, 0);
// TODO(cbruni): Add OOB check once typed.
MachineRepresentation rep = ElementsKindToMachineRepresentation(kind);
StoreNoWriteBarrier(rep, elements, offset, value);
return;
} else if (IsDoubleElementsKind(kind)) {
TNode<Float64T> value_float64 = UncheckedCast<Float64T>(value);
const ParameterMode mode =
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
StoreFixedDoubleArrayElement(CAST(elements), index, value_float64, mode);
} else {
WriteBarrierMode barrier_mode = IsSmiElementsKind(kind)
? UNSAFE_SKIP_WRITE_BARRIER
: UPDATE_WRITE_BARRIER;
const ParameterMode mode =
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
StoreFixedArrayElement(CAST(elements), index, value, barrier_mode, 0, mode);
}
}
template V8_EXPORT_PRIVATE void CodeStubAssembler::StoreElement<Smi>(
Node*, ElementsKind, TNode<Smi>, Node*);
template V8_EXPORT_PRIVATE void CodeStubAssembler::StoreElement<IntPtrT>(
Node*, ElementsKind, TNode<IntPtrT>, Node*);
template V8_EXPORT_PRIVATE void CodeStubAssembler::StoreElement<UintPtrT>(
Node*, ElementsKind, TNode<UintPtrT>, Node*);
TNode<Uint8T> CodeStubAssembler::Int32ToUint8Clamped(
TNode<Int32T> int32_value) {
Label done(this);
......@@ -9786,8 +9802,7 @@ void CodeStubAssembler::EmitElementStore(
GotoIf(IsFixedCOWArrayMap(LoadMap(elements)), bailout);
}
// TODO(ishell): introduce TryToIntPtrOrSmi() and use OptimalParameterMode().
ParameterMode parameter_mode = INTPTR_PARAMETERS;
// TODO(ishell): introduce TryToIntPtrOrSmi() and use BInt.
TNode<IntPtrT> intptr_key = TryToIntptr(key, bailout);
// TODO(rmcilroy): TNodify the converted value once this funciton and
......@@ -9828,8 +9843,7 @@ void CodeStubAssembler::EmitElementStore(
}
TNode<RawPtrT> data_ptr = LoadJSTypedArrayDataPtr(typed_array);
StoreElement(data_ptr, elements_kind, intptr_key, converted_value,
parameter_mode);
StoreElement(data_ptr, elements_kind, intptr_key, converted_value);
Goto(&done);
BIND(&update_value_and_bailout);
......@@ -9953,8 +9967,7 @@ void CodeStubAssembler::EmitElementStore(
}
CSA_ASSERT(this, Word32BinaryNot(IsFixedCOWArrayMap(LoadMap(elements))));
StoreElement(elements, elements_kind, intptr_key, converted_value,
parameter_mode);
StoreElement(elements, elements_kind, intptr_key, converted_value);
}
TNode<FixedArrayBase> CodeStubAssembler::CheckForCapacityGrow(
......
......@@ -3106,12 +3106,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// TODO(turbofan): For BIGINT64_ELEMENTS and BIGUINT64_ELEMENTS
// we pass {value} as BigInt object instead of int64_t. We should
// teach TurboFan to handle int64_t on 32-bit platforms eventually.
void StoreElement(Node* elements, ElementsKind kind, Node* index, Node* value,
ParameterMode mode);
void StoreElement(TNode<RawPtrT> elements, ElementsKind kind,
TNode<UintPtrT> index, Node* value) {
return StoreElement(elements, kind, index, value, INTPTR_PARAMETERS);
}
template <typename TIndex>
void StoreElement(Node* elements, ElementsKind kind, TNode<TIndex> index,
Node* value);
// Implements the BigInt part of
// https://tc39.github.io/proposal-bigint/#sec-numbertorawbytes,
......
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