Commit d0183446 authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Remove ParameterMode from CalculateNewElementsCapacity

Drive-by: Also from WordOrSmiShr

Bug: v8:9708, v8:6949
Change-Id: Ic00b91988abf2120b433809dac3871eb887b8484
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2339614Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69295}
parent 07815e87
......@@ -4821,16 +4821,25 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(
}
}
Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity,
ParameterMode mode) {
CSA_SLOW_ASSERT(this, MatchesParameterMode(old_capacity, mode));
Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode);
Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode);
Node* padding =
IntPtrOrSmiConstant(JSObject::kMinAddedElementsCapacity, mode);
return IntPtrOrSmiAdd(new_capacity, padding, mode);
template <typename TIndex>
TNode<TIndex> CodeStubAssembler::CalculateNewElementsCapacity(
TNode<TIndex> old_capacity) {
static_assert(
std::is_same<TIndex, Smi>::value || std::is_same<TIndex, IntPtrT>::value,
"Only Smi or IntPtrT old_capacity is allowed");
Comment("TryGrowElementsCapacity");
TNode<TIndex> half_old_capacity = WordOrSmiShr(old_capacity, 1);
TNode<TIndex> new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity);
TNode<TIndex> padding =
IntPtrOrSmiConstant<TIndex>(JSObject::kMinAddedElementsCapacity);
return IntPtrOrSmiAdd(new_capacity, padding);
}
template V8_EXPORT_PRIVATE TNode<IntPtrT>
CodeStubAssembler::CalculateNewElementsCapacity<IntPtrT>(TNode<IntPtrT>);
template V8_EXPORT_PRIVATE TNode<Smi>
CodeStubAssembler::CalculateNewElementsCapacity<Smi>(TNode<Smi>);
TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
TNode<HeapObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
TNode<Smi> key, Label* bailout) {
......@@ -4858,7 +4867,7 @@ TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity), bailout);
// Calculate the capacity of the new backing store.
Node* new_capacity = CalculateNewElementsCapacity(
TNode<TIndex> new_capacity = CalculateNewElementsCapacity(
IntPtrOrSmiAdd(key, IntPtrOrSmiConstant<TIndex>(1)));
ParameterMode mode =
......
......@@ -695,14 +695,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
}
}
Node* WordOrSmiShr(Node* a, int shift, ParameterMode mode) {
if (mode == SMI_PARAMETERS) {
return SmiShr(CAST(a), shift);
} else {
DCHECK_EQ(INTPTR_PARAMETERS, mode);
TNode<Smi> WordOrSmiShr(TNode<Smi> a, int shift) { return SmiShr(a, shift); }
TNode<IntPtrT> WordOrSmiShr(TNode<IntPtrT> a, int shift) {
return WordShr(a, shift);
}
}
#define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName, Int32OpName) \
TNode<BoolT> SmiOpName(TNode<Smi> a, TNode<Smi> b) { \
......@@ -2229,15 +2226,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ElementsKind from_kind,
ElementsKind to_kind, Label* if_hole);
Node* CalculateNewElementsCapacity(Node* old_capacity, ParameterMode mode);
TNode<Smi> CalculateNewElementsCapacity(TNode<Smi> old_capacity) {
return CAST(CalculateNewElementsCapacity(old_capacity, SMI_PARAMETERS));
}
TNode<IntPtrT> CalculateNewElementsCapacity(TNode<IntPtrT> old_capacity) {
return UncheckedCast<IntPtrT>(
CalculateNewElementsCapacity(old_capacity, INTPTR_PARAMETERS));
}
template <typename TIndex>
TNode<TIndex> CalculateNewElementsCapacity(TNode<TIndex> old_capacity);
// Tries to grow the |elements| array of given |object| to store the |key|
// or bails out if the growing gap is too big. Returns new elements.
......
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