Commit d85f4972 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] Remove ParameterMode from CSA::AllocateUninitializedJSArrayWithElements

Bug: v8:9708
Change-Id: I8ae79b0a5ec43497b43fa6c98c9d33ba91fc7e59
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1917145
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64978}
parent 59a8baa9
...@@ -516,8 +516,8 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) { ...@@ -516,8 +516,8 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) {
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context); LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<Smi> array_length = SmiTag(Signed(object_enum_length)); TNode<Smi> array_length = SmiTag(Signed(object_enum_length));
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements( std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
PACKED_ELEMENTS, array_map, array_length, {}, object_enum_length, PACKED_ELEMENTS, array_map, array_length, {},
INTPTR_PARAMETERS); Signed(object_enum_length));
CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements, CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements,
object_enum_length, SKIP_WRITE_BARRIER); object_enum_length, SKIP_WRITE_BARRIER);
Return(array); Return(array);
...@@ -611,8 +611,8 @@ TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) { ...@@ -611,8 +611,8 @@ TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) {
TNode<JSArray> array; TNode<JSArray> array;
TNode<FixedArrayBase> elements; TNode<FixedArrayBase> elements;
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements( std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
PACKED_ELEMENTS, array_map, array_length, {}, object_enum_length, PACKED_ELEMENTS, array_map, array_length, {},
INTPTR_PARAMETERS); Signed(object_enum_length));
CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements, CopyFixedArrayElements(PACKED_ELEMENTS, object_enum_keys, elements,
object_enum_length, SKIP_WRITE_BARRIER); object_enum_length, SKIP_WRITE_BARRIER);
Return(array); Return(array);
......
...@@ -99,7 +99,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::AllocateRegExpResult( ...@@ -99,7 +99,7 @@ TNode<JSRegExpResult> RegExpBuiltinsAssembler::AllocateRegExpResult(
TNode<FixedArrayBase> elements; TNode<FixedArrayBase> elements;
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements( std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
elements_kind, map, length, no_allocation_site, length_intptr, elements_kind, map, length, no_allocation_site, length_intptr,
INTPTR_PARAMETERS, kAllowLargeObjectAllocation, JSRegExpResult::kSize); kAllowLargeObjectAllocation, JSRegExpResult::kSize);
// Finish result initialization. // Finish result initialization.
......
...@@ -3882,10 +3882,9 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(TNode<IntPtrT> start_address, ...@@ -3882,10 +3882,9 @@ void CodeStubAssembler::StoreFieldsNoWriteBarrier(TNode<IntPtrT> start_address,
} }
TNode<BoolT> CodeStubAssembler::IsValidFastJSArrayCapacity( TNode<BoolT> CodeStubAssembler::IsValidFastJSArrayCapacity(
Node* capacity, ParameterMode capacity_mode) { TNode<IntPtrT> capacity) {
return UncheckedCast<BoolT>( return UintPtrLessThanOrEqual(capacity,
UintPtrLessThanOrEqual(ParameterToIntPtr(capacity, capacity_mode), UintPtrConstant(JSArray::kMaxFastArrayLength));
IntPtrConstant(JSArray::kMaxFastArrayLength)));
} }
TNode<JSArray> CodeStubAssembler::AllocateJSArray( TNode<JSArray> CodeStubAssembler::AllocateJSArray(
...@@ -3909,9 +3908,8 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray( ...@@ -3909,9 +3908,8 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray(
std::pair<TNode<JSArray>, TNode<FixedArrayBase>> std::pair<TNode<JSArray>, TNode<FixedArrayBase>>
CodeStubAssembler::AllocateUninitializedJSArrayWithElements( CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
ElementsKind kind, TNode<Map> array_map, TNode<Smi> length, ElementsKind kind, TNode<Map> array_map, TNode<Smi> length,
TNode<AllocationSite> allocation_site, Node* capacity, TNode<AllocationSite> allocation_site, TNode<IntPtrT> capacity,
ParameterMode capacity_mode, AllocationFlags allocation_flags, AllocationFlags allocation_flags, int array_header_size) {
int array_header_size) {
Comment("begin allocation of JSArray with elements"); Comment("begin allocation of JSArray with elements");
CHECK_EQ(allocation_flags & ~kAllowLargeObjectAllocation, 0); CHECK_EQ(allocation_flags & ~kAllowLargeObjectAllocation, 0);
CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length));
...@@ -3922,7 +3920,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( ...@@ -3922,7 +3920,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
Label out(this), empty(this), nonempty(this); Label out(this), empty(this), nonempty(this);
int capacity_int; int capacity_int;
if (TryGetIntPtrOrSmiConstantValue(capacity, &capacity_int, capacity_mode)) { if (ToInt32Constant(capacity, &capacity_int)) {
if (capacity_int == 0) { if (capacity_int == 0) {
TNode<FixedArray> empty_array = EmptyFixedArrayConstant(); TNode<FixedArray> empty_array = EmptyFixedArrayConstant();
array = AllocateJSArray(array_map, empty_array, length, allocation_site, array = AllocateJSArray(array_map, empty_array, length, allocation_site,
...@@ -3932,8 +3930,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( ...@@ -3932,8 +3930,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
Goto(&nonempty); Goto(&nonempty);
} }
} else { } else {
Branch(SmiEqual(ParameterToTagged(capacity, capacity_mode), SmiConstant(0)), Branch(WordEqual(capacity, IntPtrConstant(0)), &empty, &nonempty);
&empty, &nonempty);
BIND(&empty); BIND(&empty);
{ {
...@@ -3956,8 +3953,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( ...@@ -3956,8 +3953,7 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
// Compute space for elements // Compute space for elements
base_size += FixedArray::kHeaderSize; base_size += FixedArray::kHeaderSize;
TNode<IntPtrT> size = TNode<IntPtrT> size = ElementOffsetFromIndex(capacity, kind, base_size);
ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size);
// For very large arrays in which the requested allocation exceeds the // For very large arrays in which the requested allocation exceeds the
// maximal size of a regular heap object, we cannot use the allocation // maximal size of a regular heap object, we cannot use the allocation
...@@ -3968,19 +3964,16 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( ...@@ -3968,19 +3964,16 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
Label next(this); Label next(this);
GotoIf(IsRegularHeapObjectSize(size), &next); GotoIf(IsRegularHeapObjectSize(size), &next);
CSA_CHECK(this, IsValidFastJSArrayCapacity(capacity, capacity_mode)); CSA_CHECK(this, IsValidFastJSArrayCapacity(capacity));
// Allocate and initialize the elements first. Full initialization is // Allocate and initialize the elements first. Full initialization is
// needed because the upcoming JSArray allocation could trigger GC. // needed because the upcoming JSArray allocation could trigger GC.
elements = elements = AllocateFixedArray(kind, capacity, allocation_flags);
AllocateFixedArray(kind, capacity, capacity_mode, allocation_flags);
if (IsDoubleElementsKind(kind)) { if (IsDoubleElementsKind(kind)) {
FillFixedDoubleArrayWithZero( FillFixedDoubleArrayWithZero(CAST(elements.value()), capacity);
CAST(elements.value()), ParameterToIntPtr(capacity, capacity_mode));
} else { } else {
FillFixedArrayWithSmiZero(CAST(elements.value()), FillFixedArrayWithSmiZero(CAST(elements.value()), capacity);
ParameterToIntPtr(capacity, capacity_mode));
} }
// The JSArray and possibly allocation memento next. Note that // The JSArray and possibly allocation memento next. Note that
...@@ -4011,8 +4004,8 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements( ...@@ -4011,8 +4004,8 @@ CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
DCHECK(RootsTable::IsImmortalImmovable(elements_map_index)); DCHECK(RootsTable::IsImmortalImmovable(elements_map_index));
StoreMapNoWriteBarrier(elements.value(), elements_map_index); StoreMapNoWriteBarrier(elements.value(), elements_map_index);
TNode<Smi> capacity_smi = ParameterToTagged(capacity, capacity_mode); CSA_ASSERT(this, WordNotEqual(capacity, IntPtrConstant(0)));
CSA_ASSERT(this, SmiGreaterThan(capacity_smi, SmiConstant(0))); TNode<Smi> capacity_smi = SmiTag(capacity);
StoreObjectFieldNoWriteBarrier(elements.value(), FixedArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(elements.value(), FixedArray::kLengthOffset,
capacity_smi); capacity_smi);
Goto(&out); Goto(&out);
...@@ -4054,8 +4047,7 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray( ...@@ -4054,8 +4047,7 @@ TNode<JSArray> CodeStubAssembler::AllocateJSArray(
TNode<FixedArrayBase> elements; TNode<FixedArrayBase> elements;
std::tie(array, elements) = AllocateUninitializedJSArrayWithElements( std::tie(array, elements) = AllocateUninitializedJSArrayWithElements(
kind, array_map, length, allocation_site, capacity, capacity_mode, kind, array_map, length, allocation_site, capacity, allocation_flags);
allocation_flags);
Label out(this), nonempty(this); Label out(this), nonempty(this);
......
...@@ -1809,8 +1809,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1809,8 +1809,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
SloppyTNode<IntPtrT> instance_size, SloppyTNode<IntPtrT> instance_size,
int start_offset = JSObject::kHeaderSize); int start_offset = JSObject::kHeaderSize);
TNode<BoolT> IsValidFastJSArrayCapacity(Node* capacity, TNode<BoolT> IsValidFastJSArrayCapacity(TNode<IntPtrT> capacity);
ParameterMode capacity_mode);
// //
// Allocate and return a JSArray with initialized header fields and its // Allocate and return a JSArray with initialized header fields and its
...@@ -1819,8 +1818,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1819,8 +1818,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
std::pair<TNode<JSArray>, TNode<FixedArrayBase>> std::pair<TNode<JSArray>, TNode<FixedArrayBase>>
AllocateUninitializedJSArrayWithElements( AllocateUninitializedJSArrayWithElements(
ElementsKind kind, TNode<Map> array_map, TNode<Smi> length, ElementsKind kind, TNode<Map> array_map, TNode<Smi> length,
TNode<AllocationSite> allocation_site, Node* capacity, TNode<AllocationSite> allocation_site, TNode<IntPtrT> capacity,
ParameterMode capacity_mode = INTPTR_PARAMETERS,
AllocationFlags allocation_flags = kNone, AllocationFlags allocation_flags = kNone,
int array_header_size = JSArray::kSize); int array_header_size = JSArray::kSize);
......
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