Commit 718c1108 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Remove ParameterMode/TNodify LoadArrayElement

Also we can do ParameterToIntPtr since this was the last use.

Bug: v8:9708, v8:6949
Change-Id: I61747205d9d747c80bd13cd98bc51d8f97946130
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2374546Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69552}
parent ff784f62
......@@ -1922,42 +1922,36 @@ TNode<IntPtrT> CodeStubAssembler::LoadArrayLength(
return LoadAndUntagWeakFixedArrayLength(array);
}
template <typename Array, typename T>
TNode<T> CodeStubAssembler::LoadArrayElement(TNode<Array> array,
int array_header_size,
Node* index_node,
int additional_offset,
ParameterMode parameter_mode,
LoadSensitivity needs_poisoning) {
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(
ParameterToIntPtr(index_node, parameter_mode),
IntPtrConstant(0)));
template <typename Array, typename TIndex, typename TValue>
TNode<TValue> CodeStubAssembler::LoadArrayElement(
TNode<Array> array, int array_header_size, TNode<TIndex> index_node,
int additional_offset, LoadSensitivity needs_poisoning) {
// 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 indices are allowed");
CSA_ASSERT(this, IntPtrGreaterThanOrEqual(ParameterToIntPtr(index_node),
IntPtrConstant(0)));
DCHECK(IsAligned(additional_offset, kTaggedSize));
int32_t header_size = array_header_size + additional_offset - kHeapObjectTag;
TNode<IntPtrT> offset = ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS,
parameter_mode, header_size);
TNode<IntPtrT> offset =
ElementOffsetFromIndex(index_node, HOLEY_ELEMENTS, header_size);
CSA_ASSERT(this, IsOffsetInBounds(offset, LoadArrayLength(array),
array_header_size));
constexpr MachineType machine_type = MachineTypeOf<T>::value;
constexpr MachineType machine_type = MachineTypeOf<TValue>::value;
// TODO(gsps): Remove the Load case once LoadFromObject supports poisoning
if (needs_poisoning == LoadSensitivity::kSafe) {
return UncheckedCast<T>(LoadFromObject(machine_type, array, offset));
return UncheckedCast<TValue>(LoadFromObject(machine_type, array, offset));
} else {
return UncheckedCast<T>(Load(machine_type, array, offset, needs_poisoning));
return UncheckedCast<TValue>(
Load(machine_type, array, offset, needs_poisoning));
}
}
template TNode<MaybeObject>
CodeStubAssembler::LoadArrayElement<TransitionArray>(TNode<TransitionArray>,
int, Node*, int,
ParameterMode,
LoadSensitivity);
template TNode<MaybeObject>
CodeStubAssembler::LoadArrayElement<DescriptorArray>(TNode<DescriptorArray>,
int, Node*, int,
ParameterMode,
LoadSensitivity);
template V8_EXPORT_PRIVATE TNode<MaybeObject>
CodeStubAssembler::LoadArrayElement<TransitionArray, IntPtrT>(
TNode<TransitionArray>, int, TNode<IntPtrT>, int, LoadSensitivity);
template <typename TIndex>
TNode<Object> CodeStubAssembler::LoadFixedArrayElement(
......@@ -1978,7 +1972,7 @@ TNode<Object> CodeStubAssembler::LoadFixedArrayElement(
}
TNode<MaybeObject> element =
LoadArrayElement(object, FixedArray::kHeaderSize, index,
additional_offset, parameter_mode, needs_poisoning);
additional_offset, needs_poisoning);
return CAST(element);
}
......@@ -2029,11 +2023,9 @@ void CodeStubAssembler::FixedArrayBoundsCheck(TNode<FixedArrayBase> array,
TNode<Object> CodeStubAssembler::LoadPropertyArrayElement(
TNode<PropertyArray> object, SloppyTNode<IntPtrT> index) {
int additional_offset = 0;
ParameterMode parameter_mode = INTPTR_PARAMETERS;
LoadSensitivity needs_poisoning = LoadSensitivity::kSafe;
return CAST(LoadArrayElement(object, PropertyArray::kHeaderSize, index,
additional_offset, parameter_mode,
needs_poisoning));
additional_offset, needs_poisoning));
}
TNode<IntPtrT> CodeStubAssembler::LoadPropertyArrayLength(
......@@ -2386,8 +2378,7 @@ TNode<Int32T> CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement(
TNode<MaybeObject> CodeStubAssembler::LoadWeakFixedArrayElement(
TNode<WeakFixedArray> object, TNode<IntPtrT> index, int additional_offset) {
return LoadArrayElement(object, WeakFixedArray::kHeaderSize, index,
additional_offset, INTPTR_PARAMETERS,
LoadSensitivity::kSafe);
additional_offset, LoadSensitivity::kSafe);
}
TNode<Float64T> CodeStubAssembler::LoadFixedDoubleArrayElement(
......@@ -7423,7 +7414,7 @@ template <typename T>
TNode<T> CodeStubAssembler::LoadDescriptorArrayElement(
TNode<DescriptorArray> object, TNode<IntPtrT> index,
int additional_offset) {
return LoadArrayElement<DescriptorArray, T>(
return LoadArrayElement<DescriptorArray, IntPtrT, T>(
object, DescriptorArray::kHeaderSize, index, additional_offset);
}
......
......@@ -338,10 +338,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<IntPtrT> ParameterToIntPtr(TNode<Smi> value) { return SmiUntag(value); }
TNode<IntPtrT> ParameterToIntPtr(TNode<IntPtrT> value) { return value; }
// TODO(v8:9708): remove once all uses are ported.
TNode<IntPtrT> ParameterToIntPtr(Node* value, ParameterMode mode) {
if (mode == SMI_PARAMETERS) value = SmiUntag(value);
return UncheckedCast<IntPtrT>(value);
TNode<IntPtrT> ParameterToIntPtr(TNode<UintPtrT> value) {
return Signed(value);
}
TNode<Smi> ParameterToTagged(TNode<Smi> value) { return value; }
......@@ -1284,11 +1282,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Array is any array-like type that has a fixed header followed by
// tagged elements.
template <typename Array, typename T = MaybeObject>
TNode<T> LoadArrayElement(
TNode<Array> array, int array_header_size, Node* index,
template <typename Array, typename TIndex, typename TValue = MaybeObject>
TNode<TValue> LoadArrayElement(
TNode<Array> array, int array_header_size, TNode<TIndex> index,
int additional_offset = 0,
ParameterMode parameter_mode = INTPTR_PARAMETERS,
LoadSensitivity needs_poisoning = LoadSensitivity::kSafe);
template <typename TIndex>
......
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