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