[csa][cleanup] Remove ParameterMode/TNodify FixedArrayBoundsCheck
Bug: v8:9708, v8:6949 Change-Id: I37c54a1f55f416d27a73dd96a201ead3c36da8f2 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2379513 Reviewed-by: Ross McIlroy <rmcilroy@chromium.org> Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org> Cr-Commit-Position: refs/heads/master@{#69584}
This commit is contained in:
parent
28f0e73cc5
commit
b59e726230
@ -1965,10 +1965,8 @@ TNode<Object> CodeStubAssembler::LoadFixedArrayElement(
|
||||
CSA_ASSERT(this, IsFixedArraySubclass(object));
|
||||
CSA_ASSERT(this, IsNotWeakFixedArraySubclass(object));
|
||||
|
||||
ParameterMode parameter_mode =
|
||||
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
|
||||
if (NeedsBoundsCheck(check_bounds)) {
|
||||
FixedArrayBoundsCheck(object, index, additional_offset, parameter_mode);
|
||||
FixedArrayBoundsCheck(object, index, additional_offset);
|
||||
}
|
||||
TNode<MaybeObject> element =
|
||||
LoadArrayElement(object, FixedArray::kHeaderSize, index,
|
||||
@ -1991,33 +1989,33 @@ CodeStubAssembler::LoadFixedArrayElement<IntPtrT>(TNode<FixedArray>,
|
||||
LoadSensitivity, CheckBounds);
|
||||
|
||||
void CodeStubAssembler::FixedArrayBoundsCheck(TNode<FixedArrayBase> array,
|
||||
Node* index,
|
||||
int additional_offset,
|
||||
ParameterMode parameter_mode) {
|
||||
TNode<Smi> index,
|
||||
int additional_offset) {
|
||||
if (!FLAG_fixed_array_bounds_checks) return;
|
||||
DCHECK(IsAligned(additional_offset, kTaggedSize));
|
||||
if (parameter_mode == ParameterMode::SMI_PARAMETERS) {
|
||||
TNode<Smi> effective_index;
|
||||
Smi constant_index;
|
||||
bool index_is_constant = ToSmiConstant(index, &constant_index);
|
||||
if (index_is_constant) {
|
||||
effective_index = SmiConstant(Smi::ToInt(constant_index) +
|
||||
additional_offset / kTaggedSize);
|
||||
} else if (additional_offset != 0) {
|
||||
effective_index =
|
||||
SmiAdd(CAST(index), SmiConstant(additional_offset / kTaggedSize));
|
||||
} else {
|
||||
effective_index = CAST(index);
|
||||
}
|
||||
CSA_CHECK(this, SmiBelow(effective_index, LoadFixedArrayBaseLength(array)));
|
||||
TNode<Smi> effective_index;
|
||||
Smi constant_index;
|
||||
bool index_is_constant = ToSmiConstant(index, &constant_index);
|
||||
if (index_is_constant) {
|
||||
effective_index = SmiConstant(Smi::ToInt(constant_index) +
|
||||
additional_offset / kTaggedSize);
|
||||
} else {
|
||||
// IntPtrAdd does constant-folding automatically.
|
||||
TNode<IntPtrT> effective_index =
|
||||
IntPtrAdd(UncheckedCast<IntPtrT>(index),
|
||||
IntPtrConstant(additional_offset / kTaggedSize));
|
||||
CSA_CHECK(this, UintPtrLessThan(effective_index,
|
||||
LoadAndUntagFixedArrayBaseLength(array)));
|
||||
effective_index =
|
||||
SmiAdd(index, SmiConstant(additional_offset / kTaggedSize));
|
||||
}
|
||||
CSA_CHECK(this, SmiBelow(effective_index, LoadFixedArrayBaseLength(array)));
|
||||
}
|
||||
|
||||
void CodeStubAssembler::FixedArrayBoundsCheck(TNode<FixedArrayBase> array,
|
||||
TNode<IntPtrT> index,
|
||||
int additional_offset) {
|
||||
if (!FLAG_fixed_array_bounds_checks) return;
|
||||
DCHECK(IsAligned(additional_offset, kTaggedSize));
|
||||
// IntPtrAdd does constant-folding automatically.
|
||||
TNode<IntPtrT> effective_index =
|
||||
IntPtrAdd(index, IntPtrConstant(additional_offset / kTaggedSize));
|
||||
CSA_CHECK(this, UintPtrLessThan(effective_index,
|
||||
LoadAndUntagFixedArrayBaseLength(array)));
|
||||
}
|
||||
|
||||
TNode<Object> CodeStubAssembler::LoadPropertyArrayElement(
|
||||
@ -2765,9 +2763,7 @@ void CodeStubAssembler::StoreFixedDoubleArrayElement(
|
||||
std::is_same<TIndex, IntPtrT>::value,
|
||||
"Only Smi, UintPtrT or IntPtrT index is allowed");
|
||||
if (NeedsBoundsCheck(check_bounds)) {
|
||||
const ParameterMode mode =
|
||||
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
|
||||
FixedArrayBoundsCheck(object, index, 0, mode);
|
||||
FixedArrayBoundsCheck(object, index, 0);
|
||||
}
|
||||
TNode<IntPtrT> offset = ElementOffsetFromIndex(
|
||||
index, PACKED_DOUBLE_ELEMENTS, FixedArray::kHeaderSize - kHeapObjectTag);
|
||||
|
@ -1271,9 +1271,16 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
|
||||
TNode<MaybeObject> MakeWeak(TNode<HeapObject> value);
|
||||
|
||||
void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, Node* index,
|
||||
int additional_offset = 0,
|
||||
ParameterMode parameter_mode = INTPTR_PARAMETERS);
|
||||
void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<Smi> index,
|
||||
int additional_offset);
|
||||
|
||||
void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<IntPtrT> index,
|
||||
int additional_offset);
|
||||
|
||||
void FixedArrayBoundsCheck(TNode<FixedArrayBase> array, TNode<UintPtrT> index,
|
||||
int additional_offset) {
|
||||
FixedArrayBoundsCheck(array, Signed(index), additional_offset);
|
||||
}
|
||||
|
||||
// Array is any array-like type that has a fixed header followed by
|
||||
// tagged elements.
|
||||
@ -1519,7 +1526,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
|
||||
const ParameterMode mode =
|
||||
std::is_same<TIndex, Smi>::value ? SMI_PARAMETERS : INTPTR_PARAMETERS;
|
||||
if (NeedsBoundsCheck(check_bounds)) {
|
||||
FixedArrayBoundsCheck(array, index, additional_offset, mode);
|
||||
FixedArrayBoundsCheck(array, index, additional_offset);
|
||||
}
|
||||
StoreFixedArrayOrPropertyArrayElement(array, index, value, barrier_mode,
|
||||
additional_offset, mode);
|
||||
|
Loading…
Reference in New Issue
Block a user