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( ...@@ -4821,16 +4821,25 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(
} }
} }
Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, template <typename TIndex>
ParameterMode mode) { TNode<TIndex> CodeStubAssembler::CalculateNewElementsCapacity(
CSA_SLOW_ASSERT(this, MatchesParameterMode(old_capacity, mode)); TNode<TIndex> old_capacity) {
Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); static_assert(
Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); std::is_same<TIndex, Smi>::value || std::is_same<TIndex, IntPtrT>::value,
Node* padding = "Only Smi or IntPtrT old_capacity is allowed");
IntPtrOrSmiConstant(JSObject::kMinAddedElementsCapacity, mode); Comment("TryGrowElementsCapacity");
return IntPtrOrSmiAdd(new_capacity, padding, mode); 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<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
TNode<HeapObject> object, TNode<FixedArrayBase> elements, ElementsKind kind, TNode<HeapObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
TNode<Smi> key, Label* bailout) { TNode<Smi> key, Label* bailout) {
...@@ -4858,7 +4867,7 @@ TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity( ...@@ -4858,7 +4867,7 @@ TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity), bailout); GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity), bailout);
// Calculate the capacity of the new backing store. // Calculate the capacity of the new backing store.
Node* new_capacity = CalculateNewElementsCapacity( TNode<TIndex> new_capacity = CalculateNewElementsCapacity(
IntPtrOrSmiAdd(key, IntPtrOrSmiConstant<TIndex>(1))); IntPtrOrSmiAdd(key, IntPtrOrSmiConstant<TIndex>(1)));
ParameterMode mode = ParameterMode mode =
......
...@@ -695,13 +695,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -695,13 +695,10 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
} }
} }
Node* WordOrSmiShr(Node* a, int shift, ParameterMode mode) { TNode<Smi> WordOrSmiShr(TNode<Smi> a, int shift) { return SmiShr(a, shift); }
if (mode == SMI_PARAMETERS) {
return SmiShr(CAST(a), shift); TNode<IntPtrT> WordOrSmiShr(TNode<IntPtrT> a, int shift) {
} else { return WordShr(a, shift);
DCHECK_EQ(INTPTR_PARAMETERS, mode);
return WordShr(a, shift);
}
} }
#define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName, Int32OpName) \ #define SMI_COMPARISON_OP(SmiOpName, IntPtrOpName, Int32OpName) \
...@@ -2229,15 +2226,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -2229,15 +2226,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ElementsKind from_kind, ElementsKind from_kind,
ElementsKind to_kind, Label* if_hole); ElementsKind to_kind, Label* if_hole);
Node* CalculateNewElementsCapacity(Node* old_capacity, ParameterMode mode); template <typename TIndex>
TNode<TIndex> CalculateNewElementsCapacity(TNode<TIndex> old_capacity);
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));
}
// Tries to grow the |elements| array of given |object| to store the |key| // 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. // 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