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, ...@@ -2891,12 +2891,10 @@ void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind, Label* bailout,
GotoIfNotNumber(value, bailout); GotoIfNotNumber(value, bailout);
} }
ParameterMode mode = OptimalParameterMode();
if (IsDoubleElementsKind(kind)) { if (IsDoubleElementsKind(kind)) {
StoreElement(elements, kind, index, ChangeNumberToFloat64(CAST(value)), StoreElement(elements, kind, index, ChangeNumberToFloat64(CAST(value)));
mode);
} else { } else {
StoreElement(elements, kind, index, value, mode); StoreElement(elements, kind, index, value);
} }
} }
...@@ -9467,11 +9465,16 @@ MachineRepresentation ElementsKindToMachineRepresentation(ElementsKind kind) { ...@@ -9467,11 +9465,16 @@ MachineRepresentation ElementsKindToMachineRepresentation(ElementsKind kind) {
} // namespace } // namespace
template <typename TIndex>
void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind, void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind,
Node* index, Node* value, TNode<TIndex> index, Node* value) {
ParameterMode mode) { // 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) { 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); TVARIABLE(UintPtrT, var_low);
// Only used on 32-bit platforms. // Only used on 32-bit platforms.
TVARIABLE(UintPtrT, var_high); TVARIABLE(UintPtrT, var_high);
...@@ -9500,22 +9503,35 @@ void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind, ...@@ -9500,22 +9503,35 @@ void CodeStubAssembler::StoreElement(Node* elements, ElementsKind kind,
CSA_ASSERT(this, Word32Equal(UncheckedCast<Word32T>(value), CSA_ASSERT(this, Word32Equal(UncheckedCast<Word32T>(value),
Word32And(Int32Constant(0xFF), 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. // TODO(cbruni): Add OOB check once typed.
MachineRepresentation rep = ElementsKindToMachineRepresentation(kind); MachineRepresentation rep = ElementsKindToMachineRepresentation(kind);
StoreNoWriteBarrier(rep, elements, offset, value); StoreNoWriteBarrier(rep, elements, offset, value);
return; return;
} else if (IsDoubleElementsKind(kind)) { } else if (IsDoubleElementsKind(kind)) {
TNode<Float64T> value_float64 = UncheckedCast<Float64T>(value); 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); StoreFixedDoubleArrayElement(CAST(elements), index, value_float64, mode);
} else { } else {
WriteBarrierMode barrier_mode = IsSmiElementsKind(kind) WriteBarrierMode barrier_mode = IsSmiElementsKind(kind)
? UNSAFE_SKIP_WRITE_BARRIER ? UNSAFE_SKIP_WRITE_BARRIER
: UPDATE_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); 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<Uint8T> CodeStubAssembler::Int32ToUint8Clamped(
TNode<Int32T> int32_value) { TNode<Int32T> int32_value) {
Label done(this); Label done(this);
...@@ -9786,8 +9802,7 @@ void CodeStubAssembler::EmitElementStore( ...@@ -9786,8 +9802,7 @@ void CodeStubAssembler::EmitElementStore(
GotoIf(IsFixedCOWArrayMap(LoadMap(elements)), bailout); GotoIf(IsFixedCOWArrayMap(LoadMap(elements)), bailout);
} }
// TODO(ishell): introduce TryToIntPtrOrSmi() and use OptimalParameterMode(). // TODO(ishell): introduce TryToIntPtrOrSmi() and use BInt.
ParameterMode parameter_mode = INTPTR_PARAMETERS;
TNode<IntPtrT> intptr_key = TryToIntptr(key, bailout); TNode<IntPtrT> intptr_key = TryToIntptr(key, bailout);
// TODO(rmcilroy): TNodify the converted value once this funciton and // TODO(rmcilroy): TNodify the converted value once this funciton and
...@@ -9828,8 +9843,7 @@ void CodeStubAssembler::EmitElementStore( ...@@ -9828,8 +9843,7 @@ void CodeStubAssembler::EmitElementStore(
} }
TNode<RawPtrT> data_ptr = LoadJSTypedArrayDataPtr(typed_array); TNode<RawPtrT> data_ptr = LoadJSTypedArrayDataPtr(typed_array);
StoreElement(data_ptr, elements_kind, intptr_key, converted_value, StoreElement(data_ptr, elements_kind, intptr_key, converted_value);
parameter_mode);
Goto(&done); Goto(&done);
BIND(&update_value_and_bailout); BIND(&update_value_and_bailout);
...@@ -9953,8 +9967,7 @@ void CodeStubAssembler::EmitElementStore( ...@@ -9953,8 +9967,7 @@ void CodeStubAssembler::EmitElementStore(
} }
CSA_ASSERT(this, Word32BinaryNot(IsFixedCOWArrayMap(LoadMap(elements)))); CSA_ASSERT(this, Word32BinaryNot(IsFixedCOWArrayMap(LoadMap(elements))));
StoreElement(elements, elements_kind, intptr_key, converted_value, StoreElement(elements, elements_kind, intptr_key, converted_value);
parameter_mode);
} }
TNode<FixedArrayBase> CodeStubAssembler::CheckForCapacityGrow( TNode<FixedArrayBase> CodeStubAssembler::CheckForCapacityGrow(
......
...@@ -3106,12 +3106,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3106,12 +3106,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// TODO(turbofan): For BIGINT64_ELEMENTS and BIGUINT64_ELEMENTS // TODO(turbofan): For BIGINT64_ELEMENTS and BIGUINT64_ELEMENTS
// we pass {value} as BigInt object instead of int64_t. We should // we pass {value} as BigInt object instead of int64_t. We should
// teach TurboFan to handle int64_t on 32-bit platforms eventually. // teach TurboFan to handle int64_t on 32-bit platforms eventually.
void StoreElement(Node* elements, ElementsKind kind, Node* index, Node* value, template <typename TIndex>
ParameterMode mode); void StoreElement(Node* elements, ElementsKind kind, TNode<TIndex> index,
void StoreElement(TNode<RawPtrT> elements, ElementsKind kind, Node* value);
TNode<UintPtrT> index, Node* value) {
return StoreElement(elements, kind, index, value, INTPTR_PARAMETERS);
}
// Implements the BigInt part of // Implements the BigInt part of
// https://tc39.github.io/proposal-bigint/#sec-numbertorawbytes, // 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