Commit 5f4a90ae authored by Santiago Aboy Solanes's avatar Santiago Aboy Solanes Committed by Commit Bot

[csa][cleanup] Remove ParameterMode from array allocation methods

Remove ParameterMode from:
 * AllocatePropertyArray
 * InitializePropertyArrayLength
 * GetPropertyArrayAllocationSize

Bug: v8:9708, v8:6949
Change-Id: I6b596a52bf06a0e126fa3cf2dd0e4ddedd526c52
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2310354
Commit-Queue: Santiago Aboy Solanes <solanes@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69038}
parent db6f0440
...@@ -4191,33 +4191,26 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray( ...@@ -4191,33 +4191,26 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray(
} }
void CodeStubAssembler::InitializePropertyArrayLength( void CodeStubAssembler::InitializePropertyArrayLength(
TNode<PropertyArray> property_array, Node* length, ParameterMode mode) { TNode<PropertyArray> property_array, TNode<IntPtrT> length) {
CSA_ASSERT( CSA_ASSERT(this, IntPtrGreaterThan(length, IntPtrConstant(0)));
this, IntPtrOrSmiGreaterThan(length, IntPtrOrSmiConstant(0, mode), mode)); CSA_ASSERT(this,
CSA_ASSERT( IntPtrLessThanOrEqual(
this, length, IntPtrConstant(PropertyArray::LengthField::kMax)));
IntPtrOrSmiLessThanOrEqual( StoreObjectFieldNoWriteBarrier(
length, IntPtrOrSmiConstant(PropertyArray::LengthField::kMax, mode), property_array, PropertyArray::kLengthAndHashOffset, SmiTag(length));
mode));
StoreObjectFieldNoWriteBarrier(property_array,
PropertyArray::kLengthAndHashOffset,
ParameterToTagged(length, mode));
} }
TNode<PropertyArray> CodeStubAssembler::AllocatePropertyArray( TNode<PropertyArray> CodeStubAssembler::AllocatePropertyArray(
Node* capacity_node, ParameterMode mode, AllocationFlags flags) { TNode<IntPtrT> capacity) {
CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity_node, mode)); CSA_ASSERT(this, IntPtrGreaterThan(capacity, IntPtrConstant(0)));
CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, TNode<IntPtrT> total_size = GetPropertyArrayAllocationSize(capacity);
IntPtrOrSmiConstant(0, mode), mode));
TNode<IntPtrT> total_size =
GetPropertyArrayAllocationSize(capacity_node, mode);
TNode<HeapObject> array = Allocate(total_size, flags); TNode<HeapObject> array = Allocate(total_size, kNone);
RootIndex map_index = RootIndex::kPropertyArrayMap; RootIndex map_index = RootIndex::kPropertyArrayMap;
DCHECK(RootsTable::IsImmortalImmovable(map_index)); DCHECK(RootsTable::IsImmortalImmovable(map_index));
StoreMapNoWriteBarrier(array, map_index); StoreMapNoWriteBarrier(array, map_index);
TNode<PropertyArray> property_array = CAST(array); TNode<PropertyArray> property_array = CAST(array);
InitializePropertyArrayLength(property_array, capacity_node, mode); InitializePropertyArrayLength(property_array, capacity);
return property_array; return property_array;
} }
......
...@@ -1247,7 +1247,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1247,7 +1247,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// This is only used on a newly allocated PropertyArray which // This is only used on a newly allocated PropertyArray which
// doesn't have an existing hash. // doesn't have an existing hash.
void InitializePropertyArrayLength(TNode<PropertyArray> property_array, void InitializePropertyArrayLength(TNode<PropertyArray> property_array,
Node* length, ParameterMode mode); TNode<IntPtrT> length);
// Check if the map is set for slow properties. // Check if the map is set for slow properties.
TNode<BoolT> IsDictionaryMap(SloppyTNode<Map> map); TNode<BoolT> IsDictionaryMap(SloppyTNode<Map> map);
...@@ -1933,9 +1933,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -1933,9 +1933,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return result; return result;
} }
TNode<PropertyArray> AllocatePropertyArray( TNode<PropertyArray> AllocatePropertyArray(TNode<IntPtrT> capacity);
Node* capacity, ParameterMode mode = INTPTR_PARAMETERS,
AllocationFlags flags = kNone);
// TODO(v8:9722): Return type should be JSIteratorResult // TODO(v8:9722): Return type should be JSIteratorResult
TNode<JSObject> AllocateJSIteratorResult(SloppyTNode<Context> context, TNode<JSObject> AllocateJSIteratorResult(SloppyTNode<Context> context,
...@@ -3385,9 +3383,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -3385,9 +3383,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
FixedArray::kHeaderSize); FixedArray::kHeaderSize);
} }
TNode<IntPtrT> GetPropertyArrayAllocationSize(Node* element_count, TNode<IntPtrT> GetPropertyArrayAllocationSize(TNode<IntPtrT> element_count) {
ParameterMode mode) { return GetArrayAllocationSize(element_count, PACKED_ELEMENTS,
return GetArrayAllocationSize(element_count, PACKED_ELEMENTS, mode,
PropertyArray::kHeaderSize); PropertyArray::kHeaderSize);
} }
......
...@@ -1924,13 +1924,9 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore( ...@@ -1924,13 +1924,9 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore(
TNode<HeapObject> object, TNode<IntPtrT> index) { TNode<HeapObject> object, TNode<IntPtrT> index) {
Comment("[ Extend storage"); Comment("[ Extend storage");
ParameterMode mode = OptimalParameterMode();
// TODO(gsathya): Clean up the type conversions by creating smarter
// helpers that do the correct op based on the mode.
TVARIABLE(HeapObject, var_properties); TVARIABLE(HeapObject, var_properties);
TVARIABLE(Int32T, var_encoded_hash); TVARIABLE(Int32T, var_encoded_hash);
TVARIABLE(BInt, var_length); TVARIABLE(IntPtrT, var_length);
TNode<Object> properties = TNode<Object> properties =
LoadObjectField(object, JSObject::kPropertiesOrHashOffset); LoadObjectField(object, JSObject::kPropertiesOrHashOffset);
...@@ -1944,7 +1940,7 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore( ...@@ -1944,7 +1940,7 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore(
TNode<Int32T> encoded_hash = TNode<Int32T> encoded_hash =
Word32Shl(hash, Int32Constant(PropertyArray::HashField::kShift)); Word32Shl(hash, Int32Constant(PropertyArray::HashField::kShift));
var_encoded_hash = encoded_hash; var_encoded_hash = encoded_hash;
var_length = BIntConstant(0); var_length = IntPtrConstant(0);
var_properties = EmptyFixedArrayConstant(); var_properties = EmptyFixedArrayConstant();
Goto(&extend_store); Goto(&extend_store);
} }
...@@ -1956,10 +1952,9 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore( ...@@ -1956,10 +1952,9 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore(
var_properties.value(), PropertyArray::kLengthAndHashOffset); var_properties.value(), PropertyArray::kLengthAndHashOffset);
var_encoded_hash = Word32And( var_encoded_hash = Word32And(
length_and_hash_int32, Int32Constant(PropertyArray::HashField::kMask)); length_and_hash_int32, Int32Constant(PropertyArray::HashField::kMask));
TNode<IntPtrT> length_intptr = ChangeInt32ToIntPtr( var_length = ChangeInt32ToIntPtr(
Word32And(length_and_hash_int32, Word32And(length_and_hash_int32,
Int32Constant(PropertyArray::LengthField::kMask))); Int32Constant(PropertyArray::LengthField::kMask)));
var_length = IntPtrToBInt(length_intptr);
Goto(&extend_store); Goto(&extend_store);
} }
...@@ -1973,36 +1968,31 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore( ...@@ -1973,36 +1968,31 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore(
GotoIf(UintPtrLessThan(index, ParameterToIntPtr(var_length.value())), GotoIf(UintPtrLessThan(index, ParameterToIntPtr(var_length.value())),
&done); &done);
TNode<BInt> delta = BIntConstant(JSObject::kFieldsAdded); TNode<IntPtrT> delta = IntPtrConstant(JSObject::kFieldsAdded);
TNode<BInt> new_capacity = IntPtrOrSmiAdd(var_length.value(), delta); TNode<IntPtrT> new_capacity = IntPtrAdd(var_length.value(), delta);
// Grow properties array. // Grow properties array.
DCHECK(kMaxNumberOfDescriptors + JSObject::kFieldsAdded < DCHECK(kMaxNumberOfDescriptors + JSObject::kFieldsAdded <
FixedArrayBase::GetMaxLengthForNewSpaceAllocation(PACKED_ELEMENTS)); FixedArrayBase::GetMaxLengthForNewSpaceAllocation(PACKED_ELEMENTS));
// The size of a new properties backing store is guaranteed to be small // The size of a new properties backing store is guaranteed to be small
// enough that the new backing store will be allocated in new space. // enough that the new backing store will be allocated in new space.
CSA_ASSERT(this, UintPtrOrSmiLessThan( CSA_ASSERT(this, IntPtrLessThan(new_capacity,
new_capacity, IntPtrConstant(kMaxNumberOfDescriptors +
IntPtrOrSmiConstant<BInt>(kMaxNumberOfDescriptors +
JSObject::kFieldsAdded))); JSObject::kFieldsAdded)));
TNode<PropertyArray> new_properties = TNode<PropertyArray> new_properties = AllocatePropertyArray(new_capacity);
AllocatePropertyArray(new_capacity, mode);
var_new_properties = new_properties; var_new_properties = new_properties;
FillPropertyArrayWithUndefined(new_properties, var_length.value(), FillPropertyArrayWithUndefined(new_properties, var_length.value(),
new_capacity, mode); new_capacity);
// |new_properties| is guaranteed to be in new space, so we can skip // |new_properties| is guaranteed to be in new space, so we can skip
// the write barrier. // the write barrier.
CopyPropertyArrayValues(var_properties.value(), new_properties, CopyPropertyArrayValues(var_properties.value(), new_properties,
var_length.value(), SKIP_WRITE_BARRIER, mode, var_length.value(), SKIP_WRITE_BARRIER,
DestroySource::kYes); INTPTR_PARAMETERS, DestroySource::kYes);
// TODO(gsathya): Clean up the type conversions by creating smarter TNode<Int32T> new_capacity_int32 = TruncateIntPtrToInt32(new_capacity);
// helpers that do the correct op based on the mode.
TNode<Int32T> new_capacity_int32 =
TruncateIntPtrToInt32(ParameterToIntPtr(new_capacity));
TNode<Int32T> new_length_and_hash_int32 = TNode<Int32T> new_length_and_hash_int32 =
Word32Or(var_encoded_hash.value(), new_capacity_int32); Word32Or(var_encoded_hash.value(), new_capacity_int32);
StoreObjectField(new_properties, PropertyArray::kLengthAndHashOffset, StoreObjectField(new_properties, PropertyArray::kLengthAndHashOffset,
...@@ -4066,7 +4056,7 @@ void AccessorAssembler::GenerateCloneObjectIC() { ...@@ -4066,7 +4056,7 @@ void AccessorAssembler::GenerateCloneObjectIC() {
GotoIf(IntPtrEqual(length, IntPtrConstant(0)), &allocate_object); GotoIf(IntPtrEqual(length, IntPtrConstant(0)), &allocate_object);
auto mode = INTPTR_PARAMETERS; auto mode = INTPTR_PARAMETERS;
TNode<PropertyArray> property_array = AllocatePropertyArray(length, mode); TNode<PropertyArray> property_array = AllocatePropertyArray(length);
FillPropertyArrayWithUndefined(property_array, IntPtrConstant(0), length, FillPropertyArrayWithUndefined(property_array, IntPtrConstant(0), length,
mode); mode);
CopyPropertyArrayValues(source_property_array, property_array, length, CopyPropertyArrayValues(source_property_array, property_array, length,
......
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