Commit 6968d3b4 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Tnodify FixedArray/PropertyArray functions in CSA

This changes many functions in code-stub-assembler.h to pass or return
TNode parameters rather than Node*. In general these are functions that
take ParameterMode and so optionally pass IntPtrT or Smi in a Node which
cannot be easily fixed so these parameters and are left alone.

Also move StoreFixedArrayOrPropertyArrayElement into the private section
of CodeStubAssembler's class definition.

Bug: v8:10155
Change-Id: I010a928cecf105bcf9a5e9f86a402e47733ba7f2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2059994
Commit-Queue: Dan Elphick <delphick@chromium.org>
Reviewed-by: 's avatarMythri Alle <mythria@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66340}
parent 4b1fd35b
......@@ -42,7 +42,7 @@ TF_BUILTIN(CopyFastSmiOrObjectElements, CodeStubAssembler) {
TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) {
TNode<JSObject> object = CAST(Parameter(Descriptor::kObject));
TNode<Number> key = CAST(Parameter(Descriptor::kKey));
TNode<Smi> key = CAST(Parameter(Descriptor::kKey));
Label runtime(this, Label::kDeferred);
TNode<FixedArrayBase> elements = LoadElements(object);
......@@ -57,7 +57,7 @@ TF_BUILTIN(GrowFastDoubleElements, CodeStubAssembler) {
TF_BUILTIN(GrowFastSmiOrObjectElements, CodeStubAssembler) {
TNode<JSObject> object = CAST(Parameter(Descriptor::kObject));
TNode<Number> key = CAST(Parameter(Descriptor::kKey));
TNode<Smi> key = CAST(Parameter(Descriptor::kKey));
Label runtime(this, Label::kDeferred);
TNode<FixedArrayBase> elements = LoadElements(object);
......
......@@ -502,8 +502,8 @@ TF_BUILTIN(ObjectKeys, ObjectBuiltinsAssembler) {
TNode<DescriptorArray> object_descriptors = LoadMapDescriptors(object_map);
TNode<EnumCache> object_enum_cache = LoadObjectField<EnumCache>(
object_descriptors, DescriptorArray::kEnumCacheOffset);
TNode<Object> object_enum_keys =
LoadObjectField(object_enum_cache, EnumCache::kKeysOffset);
auto object_enum_keys = LoadObjectField<FixedArrayBase>(
object_enum_cache, EnumCache::kKeysOffset);
// Allocate a JSArray and copy the elements from the {object_enum_keys}.
TNode<JSArray> array;
......@@ -598,8 +598,8 @@ TF_BUILTIN(ObjectGetOwnPropertyNames, ObjectBuiltinsAssembler) {
TNode<DescriptorArray> object_descriptors = LoadMapDescriptors(object_map);
TNode<EnumCache> object_enum_cache = CAST(
LoadObjectField(object_descriptors, DescriptorArray::kEnumCacheOffset));
TNode<Object> object_enum_keys =
LoadObjectField(object_enum_cache, EnumCache::kKeysOffset);
auto object_enum_keys = LoadObjectField<FixedArrayBase>(
object_enum_cache, EnumCache::kKeysOffset);
// Allocate a JSArray and copy the elements from the {object_enum_keys}.
TNode<NativeContext> native_context = LoadNativeContext(context);
......
......@@ -2862,8 +2862,9 @@ void CodeStubAssembler::StoreObjectFieldRoot(TNode<HeapObject> object,
}
void CodeStubAssembler::StoreFixedArrayOrPropertyArrayElement(
Node* object, Node* index_node, Node* value, WriteBarrierMode barrier_mode,
int additional_offset, ParameterMode parameter_mode) {
TNode<UnionT<FixedArray, PropertyArray>> object, Node* index_node,
TNode<Object> value, WriteBarrierMode barrier_mode, int additional_offset,
ParameterMode parameter_mode) {
CSA_SLOW_ASSERT(
this, Word32Or(IsFixedArraySubclass(object), IsPropertyArray(object)));
CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode));
......@@ -2972,8 +2973,9 @@ TNode<Int32T> CodeStubAssembler::EnsureArrayPushable(TNode<Context> context,
}
void CodeStubAssembler::PossiblyGrowElementsCapacity(
ParameterMode mode, ElementsKind kind, Node* array, Node* length,
Variable* var_elements, Node* growth, Label* bailout) {
ParameterMode mode, ElementsKind kind, TNode<HeapObject> array,
Node* length, TVariable<FixedArrayBase>* var_elements, Node* growth,
Label* bailout) {
Label fits(this, var_elements);
Node* capacity =
TaggedToParameter(LoadFixedArrayBaseLength(var_elements->value()), mode);
......@@ -2982,9 +2984,8 @@ void CodeStubAssembler::PossiblyGrowElementsCapacity(
Node* new_length = IntPtrOrSmiAdd(growth, length, mode);
GotoIfNot(IntPtrOrSmiGreaterThan(new_length, capacity, mode), &fits);
Node* new_capacity = CalculateNewElementsCapacity(new_length, mode);
var_elements->Bind(GrowElementsCapacity(array, var_elements->value(), kind,
kind, capacity, new_capacity, mode,
bailout));
*var_elements = GrowElementsCapacity(array, var_elements->value(), kind, kind,
capacity, new_capacity, mode, bailout);
Goto(&fits);
BIND(&fits);
}
......@@ -3043,17 +3044,19 @@ TNode<Smi> CodeStubAssembler::BuildAppendJSArray(ElementsKind kind,
void CodeStubAssembler::TryStoreArrayElement(ElementsKind kind,
ParameterMode mode, Label* bailout,
Node* elements, Node* index,
Node* value) {
TNode<FixedArrayBase> elements,
Node* index, TNode<Object> value) {
if (IsSmiElementsKind(kind)) {
GotoIf(TaggedIsNotSmi(value), bailout);
} else if (IsDoubleElementsKind(kind)) {
GotoIfNotNumber(CAST(value), bailout);
GotoIfNotNumber(value, bailout);
}
if (IsDoubleElementsKind(kind)) {
value = ChangeNumberToFloat64(CAST(value));
}
StoreElement(elements, kind, index, ChangeNumberToFloat64(CAST(value)),
mode);
} else {
StoreElement(elements, kind, index, value, mode);
}
}
void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind,
......@@ -3956,7 +3959,8 @@ TNode<FixedArray> CodeStubAssembler::ExtractToFixedArray(
Node* capacity, SloppyTNode<Map> source_map, ElementsKind from_kind,
AllocationFlags allocation_flags, ExtractFixedArrayFlags extract_flags,
ParameterMode parameter_mode, HoleConversionMode convert_holes,
TVariable<BoolT>* var_holes_converted, Node* source_elements_kind) {
TVariable<BoolT>* var_holes_converted,
base::Optional<TNode<Int32T>> source_elements_kind) {
DCHECK_NE(first, nullptr);
DCHECK_NE(count, nullptr);
DCHECK_NE(capacity, nullptr);
......@@ -4078,9 +4082,9 @@ TNode<FixedArray> CodeStubAssembler::ExtractToFixedArray(
// Try to use memcpy if we don't need to convert holes to undefined.
if (convert_holes == HoleConversionMode::kDontConvert &&
source_elements_kind != nullptr) {
source_elements_kind) {
// Only try memcpy if we're not copying object pointers.
GotoIfNot(IsFastSmiElementsKind(source_elements_kind),
GotoIfNot(IsFastSmiElementsKind(*source_elements_kind),
&copy_one_by_one);
const ElementsKind to_smi_kind = PACKED_SMI_ELEMENTS;
......@@ -4124,7 +4128,7 @@ TNode<FixedArray> CodeStubAssembler::ExtractToFixedArray(
}
TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedDoubleArrayFillingHoles(
Node* from_array, Node* first, Node* count, Node* capacity,
TNode<FixedArrayBase> from_array, Node* first, Node* count, Node* capacity,
Node* fixed_array_map, TVariable<BoolT>* var_holes_converted,
AllocationFlags allocation_flags, ExtractFixedArrayFlags extract_flags,
ParameterMode mode) {
......@@ -4210,9 +4214,10 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedDoubleArrayFillingHoles(
}
TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray(
Node* source, Node* first, Node* count, Node* capacity,
TNode<FixedArrayBase> source, Node* first, Node* count, Node* capacity,
ExtractFixedArrayFlags extract_flags, ParameterMode parameter_mode,
TVariable<BoolT>* var_holes_converted, Node* source_runtime_kind) {
TVariable<BoolT>* var_holes_converted,
base::Optional<TNode<Int32T>> source_runtime_kind) {
DCHECK(extract_flags & ExtractFixedArrayFlag::kFixedArrays ||
extract_flags & ExtractFixedArrayFlag::kFixedDoubleArrays);
// If we want to replace holes, ExtractFixedArrayFlag::kDontCopyCOW should not
......@@ -4290,7 +4295,7 @@ TNode<FixedArrayBase> CodeStubAssembler::ExtractFixedArray(
kind, capacity, parameter_mode, allocation_flags, source_map);
FillFixedArrayWithValue(kind, to_elements, count, capacity,
RootIndex::kTheHoleValue, parameter_mode);
CopyElements(kind, to_elements, IntPtrConstant(0), CAST(source),
CopyElements(kind, to_elements, IntPtrConstant(0), source,
ParameterToIntPtr(first, parameter_mode),
ParameterToIntPtr(count, parameter_mode));
var_result = to_elements;
......@@ -4325,9 +4330,8 @@ void CodeStubAssembler::InitializePropertyArrayLength(
ParameterToTagged(length, mode));
}
Node* CodeStubAssembler::AllocatePropertyArray(Node* capacity_node,
ParameterMode mode,
AllocationFlags flags) {
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));
......@@ -4338,17 +4342,16 @@ Node* CodeStubAssembler::AllocatePropertyArray(Node* capacity_node,
RootIndex map_index = RootIndex::kPropertyArrayMap;
DCHECK(RootsTable::IsImmortalImmovable(map_index));
StoreMapNoWriteBarrier(array, map_index);
InitializePropertyArrayLength(CAST(array), capacity_node, mode);
return array;
TNode<PropertyArray> property_array = CAST(array);
InitializePropertyArrayLength(property_array, capacity_node, mode);
return property_array;
}
void CodeStubAssembler::FillPropertyArrayWithUndefined(Node* array,
Node* from_node,
Node* to_node,
void CodeStubAssembler::FillPropertyArrayWithUndefined(
TNode<PropertyArray> array, Node* from_node, Node* to_node,
ParameterMode mode) {
CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode));
CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode));
CSA_SLOW_ASSERT(this, IsPropertyArray(array));
ElementsKind kind = PACKED_ELEMENTS;
TNode<Oddball> value = UndefinedConstant();
BuildFastFixedArrayForEach(
......@@ -4360,7 +4363,8 @@ void CodeStubAssembler::FillPropertyArrayWithUndefined(Node* array,
mode);
}
void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind, Node* array,
void CodeStubAssembler::FillFixedArrayWithValue(ElementsKind kind,
TNode<FixedArrayBase> array,
Node* from_node, Node* to_node,
RootIndex value_root_index,
ParameterMode mode) {
......@@ -4649,10 +4653,11 @@ void CodeStubAssembler::CopyElements(ElementsKind kind,
}
void CodeStubAssembler::CopyFixedArrayElements(
ElementsKind from_kind, Node* from_array, ElementsKind to_kind,
Node* to_array, Node* first_element, Node* element_count, Node* capacity,
WriteBarrierMode barrier_mode, ParameterMode mode,
HoleConversionMode convert_holes, TVariable<BoolT>* var_holes_converted) {
ElementsKind from_kind, TNode<FixedArrayBase> from_array,
ElementsKind to_kind, TNode<FixedArrayBase> to_array, Node* first_element,
Node* element_count, Node* capacity, WriteBarrierMode barrier_mode,
ParameterMode mode, HoleConversionMode convert_holes,
TVariable<BoolT>* var_holes_converted) {
DCHECK_IMPLIES(var_holes_converted != nullptr,
convert_holes == HoleConversionMode::kConvertToUndefined);
CSA_SLOW_ASSERT(this, MatchesParameterMode(element_count, mode));
......@@ -4727,10 +4732,10 @@ void CodeStubAssembler::CopyFixedArrayElements(
var_holes_converted != nullptr ? arraysize(vars) : arraysize(vars) - 1;
Label decrement(this, num_vars, vars);
Node* to_array_adjusted =
TNode<IntPtrT> to_array_adjusted =
element_offset_matches
? IntPtrSub(BitcastTaggedToWord(to_array), first_from_element_offset)
: to_array;
: ReinterpretCast<IntPtrT>(to_array);
Branch(WordEqual(var_from_offset.value(), limit_offset), &done, &decrement);
......@@ -4833,8 +4838,8 @@ TNode<FixedArray> CodeStubAssembler::HeapObjectToFixedArray(
return UncheckedCast<FixedArray>(base);
}
void CodeStubAssembler::CopyPropertyArrayValues(Node* from_array,
Node* to_array,
void CodeStubAssembler::CopyPropertyArrayValues(TNode<HeapObject> from_array,
TNode<PropertyArray> to_array,
Node* property_count,
WriteBarrierMode barrier_mode,
ParameterMode mode,
......@@ -4842,7 +4847,6 @@ void CodeStubAssembler::CopyPropertyArrayValues(Node* from_array,
CSA_SLOW_ASSERT(this, MatchesParameterMode(property_count, mode));
CSA_SLOW_ASSERT(this, Word32Or(IsPropertyArray(from_array),
IsEmptyFixedArray(from_array)));
CSA_SLOW_ASSERT(this, IsPropertyArray(to_array));
Comment("[ CopyPropertyArrayValues");
bool needs_write_barrier = barrier_mode == UPDATE_WRITE_BARRIER;
......@@ -4879,7 +4883,8 @@ void CodeStubAssembler::CopyPropertyArrayValues(Node* from_array,
if (destroy_source == DestroySource::kYes) {
Label did_zap(this);
GotoIf(IsEmptyFixedArray(from_array), &did_zap);
FillPropertyArrayWithUndefined(from_array, start, property_count, mode);
FillPropertyArrayWithUndefined(CAST(from_array), start, property_count,
mode);
Goto(&did_zap);
BIND(&did_zap);
......@@ -4928,11 +4933,9 @@ Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity,
}
TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
Node* object, Node* elements, ElementsKind kind, Node* key,
Label* bailout) {
CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
TNode<HeapObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
TNode<Smi> key, Label* bailout) {
CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, kind));
CSA_SLOW_ASSERT(this, TaggedIsSmi(key));
TNode<Smi> capacity = LoadFixedArrayBaseLength(elements);
ParameterMode mode = OptimalParameterMode();
......@@ -4942,10 +4945,9 @@ TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
}
TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
Node* object, Node* elements, ElementsKind kind, Node* key, Node* capacity,
ParameterMode mode, Label* bailout) {
TNode<HeapObject> object, TNode<FixedArrayBase> elements, ElementsKind kind,
Node* key, Node* capacity, ParameterMode mode, Label* bailout) {
Comment("TryGrowElementsCapacity");
CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, kind));
CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode));
CSA_SLOW_ASSERT(this, MatchesParameterMode(key, mode));
......@@ -4963,10 +4965,10 @@ TNode<FixedArrayBase> CodeStubAssembler::TryGrowElementsCapacity(
}
TNode<FixedArrayBase> CodeStubAssembler::GrowElementsCapacity(
Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind,
Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) {
TNode<HeapObject> object, TNode<FixedArrayBase> elements,
ElementsKind from_kind, ElementsKind to_kind, Node* capacity,
Node* new_capacity, ParameterMode mode, Label* bailout) {
Comment("[ GrowElementsCapacity");
CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, from_kind));
CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode));
CSA_SLOW_ASSERT(this, MatchesParameterMode(new_capacity, mode));
......@@ -4985,12 +4987,12 @@ TNode<FixedArrayBase> CodeStubAssembler::GrowElementsCapacity(
// Copy the elements from the old elements store to the new.
// The size-check above guarantees that the |new_elements| is allocated
// in new space so we can skip the write barrier.
CopyFixedArrayElements(from_kind, CAST(elements), to_kind, new_elements,
CopyFixedArrayElements(from_kind, elements, to_kind, new_elements,
UncheckedCast<IntPtrT>(capacity),
UncheckedCast<IntPtrT>(new_capacity),
SKIP_WRITE_BARRIER, mode);
StoreObjectField(CAST(object), JSObject::kElementsOffset, new_elements);
StoreObjectField(object, JSObject::kElementsOffset, new_elements);
Comment("] GrowElementsCapacity");
return new_elements;
}
......@@ -6049,13 +6051,13 @@ TNode<BoolT> CodeStubAssembler::IsPromiseFulfillReactionJobTask(
// TODO(jgruber): It might we worth creating an empty_double_array constant to
// simplify this case.
TNode<BoolT> CodeStubAssembler::IsFixedArrayWithKindOrEmpty(
SloppyTNode<HeapObject> object, ElementsKind kind) {
SloppyTNode<FixedArrayBase> object, ElementsKind kind) {
Label out(this);
TVARIABLE(BoolT, var_result, Int32TrueConstant());
GotoIf(IsFixedArrayWithKind(object, kind), &out);
const TNode<Smi> length = LoadFixedArrayBaseLength(CAST(object));
const TNode<Smi> length = LoadFixedArrayBaseLength(object);
GotoIf(SmiEqual(length, SmiConstant(0)), &out);
var_result = Int32FalseConstant();
......@@ -10043,20 +10045,21 @@ Node* CodeStubAssembler::CheckForCapacityGrow(
return checked_elements.value();
}
Node* CodeStubAssembler::CopyElementsOnWrite(Node* object, Node* elements,
Node* CodeStubAssembler::CopyElementsOnWrite(TNode<HeapObject> object,
TNode<FixedArrayBase> elements,
ElementsKind kind, Node* length,
ParameterMode mode,
Label* bailout) {
VARIABLE(new_elements_var, MachineRepresentation::kTagged, elements);
TVARIABLE(FixedArrayBase, new_elements_var, elements);
Label done(this);
GotoIfNot(IsFixedCOWArrayMap(LoadMap(elements)), &done);
{
Node* capacity =
TaggedToParameter(LoadFixedArrayBaseLength(elements), mode);
Node* new_elements = GrowElementsCapacity(object, elements, kind, kind,
length, capacity, mode, bailout);
new_elements_var.Bind(new_elements);
TNode<FixedArrayBase> new_elements = GrowElementsCapacity(
object, elements, kind, kind, length, capacity, mode, bailout);
new_elements_var = new_elements;
Goto(&done);
}
......
......@@ -1631,12 +1631,6 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
CheckBounds::kDebugOnly);
}
void StoreFixedArrayOrPropertyArrayElement(
Node* array, Node* index, Node* value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
int additional_offset = 0,
ParameterMode parameter_mode = INTPTR_PARAMETERS);
void StoreFixedArrayElement(
TNode<FixedArray> array, Node* index, SloppyTNode<Object> value,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
......@@ -1747,8 +1741,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
Label* bailout);
void TryStoreArrayElement(ElementsKind kind, ParameterMode mode,
Label* bailout, Node* elements, Node* index,
Node* value);
Label* bailout, TNode<FixedArrayBase> elements,
Node* index, TNode<Object> value);
// Consumes args into the array, and returns tagged new length.
TNode<Smi> BuildAppendJSArray(ElementsKind kind, TNode<JSArray> array,
CodeStubArguments* args,
......@@ -1987,8 +1981,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
return result;
}
Node* AllocatePropertyArray(Node* capacity,
ParameterMode mode = INTPTR_PARAMETERS,
TNode<PropertyArray> AllocatePropertyArray(
Node* capacity, ParameterMode mode = INTPTR_PARAMETERS,
AllocationFlags flags = kNone);
// Perform CreateArrayIterator (ES #sec-createarrayiterator).
......@@ -2010,8 +2004,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Object> originalArray,
TNode<Number> len);
void FillFixedArrayWithValue(ElementsKind kind, Node* array, Node* from_index,
Node* to_index, RootIndex value_root_index,
void FillFixedArrayWithValue(ElementsKind kind, TNode<FixedArrayBase> array,
Node* from_index, Node* to_index,
RootIndex value_root_index,
ParameterMode mode = INTPTR_PARAMETERS);
// Uses memset to effectively initialize the given FixedArray with zeroes.
......@@ -2020,8 +2015,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
void FillFixedDoubleArrayWithZero(TNode<FixedDoubleArray> array,
TNode<IntPtrT> length);
void FillPropertyArrayWithUndefined(Node* array, Node* from_index,
Node* to_index,
void FillPropertyArrayWithUndefined(TNode<PropertyArray> array,
Node* from_index, Node* to_index,
ParameterMode mode = INTPTR_PARAMETERS);
enum class DestroySource { kNo, kYes };
......@@ -2052,7 +2047,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Otherwise, specify DestroySource::kNo for operations where an Object is
// being cloned, to ensure that mutable HeapNumbers are unique between the
// source and cloned object.
void CopyPropertyArrayValues(Node* from_array, Node* to_array, Node* length,
void CopyPropertyArrayValues(TNode<HeapObject> from_array,
TNode<PropertyArray> to_array, Node* length,
WriteBarrierMode barrier_mode,
ParameterMode mode,
DestroySource destroy_source);
......@@ -2060,7 +2056,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// Copies all elements from |from_array| of |length| size to
// |to_array| of the same size respecting the elements kind.
void CopyFixedArrayElements(
ElementsKind kind, Node* from_array, Node* to_array, Node* length,
ElementsKind kind, TNode<FixedArrayBase> from_array,
TNode<FixedArrayBase> to_array, Node* length,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
ParameterMode mode = INTPTR_PARAMETERS) {
CopyFixedArrayElements(kind, from_array, kind, to_array,
......@@ -2072,9 +2069,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// zero to |to_array| of |capacity| size respecting both array's elements
// kinds.
void CopyFixedArrayElements(
ElementsKind from_kind, TNode<Object> from_array, ElementsKind to_kind,
TNode<Object> to_array, TNode<IntPtrT> element_count,
TNode<IntPtrT> capacity,
ElementsKind from_kind, TNode<FixedArrayBase> from_array,
ElementsKind to_kind, TNode<FixedArrayBase> to_array,
TNode<IntPtrT> element_count, TNode<IntPtrT> capacity,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
ParameterMode mode = INTPTR_PARAMETERS) {
CopyFixedArrayElements(from_kind, from_array, to_kind, to_array,
......@@ -2091,8 +2088,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// HoleConversionMode::kConvertToUndefined, then it must not be the case that
// IsDoubleElementsKind(to_kind).
void CopyFixedArrayElements(
ElementsKind from_kind, Node* from_array, ElementsKind to_kind,
Node* to_array, Node* first_element, Node* element_count, Node* capacity,
ElementsKind from_kind, TNode<FixedArrayBase> from_array,
ElementsKind to_kind, TNode<FixedArrayBase> to_array, Node* first_element,
Node* element_count, Node* capacity,
WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
ParameterMode mode = INTPTR_PARAMETERS,
HoleConversionMode convert_holes = HoleConversionMode::kDontConvert,
......@@ -2193,13 +2191,13 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// runtime elements kind of source to make copy faster. More specifically, it
// can skip write barriers.
TNode<FixedArrayBase> ExtractFixedArray(
Node* source, Node* first, Node* count = nullptr,
TNode<FixedArrayBase> source, Node* first, Node* count = nullptr,
Node* capacity = nullptr,
ExtractFixedArrayFlags extract_flags =
ExtractFixedArrayFlag::kAllFixedArrays,
ParameterMode parameter_mode = INTPTR_PARAMETERS,
TVariable<BoolT>* var_holes_converted = nullptr,
Node* source_elements_kind = nullptr);
base::Optional<TNode<Int32T>> source_elements_kind = base::nullopt);
TNode<FixedArrayBase> ExtractFixedArray(
TNode<FixedArrayBase> source, TNode<Smi> first, TNode<Smi> count,
......@@ -2256,7 +2254,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
ParameterMode parameter_mode = INTPTR_PARAMETERS,
HoleConversionMode convert_holes = HoleConversionMode::kDontConvert,
TVariable<BoolT>* var_holes_converted = nullptr,
Node* source_runtime_kind = nullptr);
base::Optional<TNode<Int32T>> source_runtime_kind = base::nullopt);
// Attempt to copy a FixedDoubleArray to another FixedDoubleArray. In the case
// where the source array has a hole, produce a FixedArray instead where holes
......@@ -2277,8 +2275,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// * |parameter_mode| determines the parameter mode of |first|, |count| and
// |capacity|.
TNode<FixedArrayBase> ExtractFixedDoubleArrayFillingHoles(
Node* source, Node* first, Node* count, Node* capacity, Node* source_map,
TVariable<BoolT>* var_holes_converted, AllocationFlags allocation_flags,
TNode<FixedArrayBase> source, Node* first, Node* count, Node* capacity,
Node* source_map, TVariable<BoolT>* var_holes_converted,
AllocationFlags allocation_flags,
ExtractFixedArrayFlags extract_flags =
ExtractFixedArrayFlag::kAllFixedArrays,
ParameterMode parameter_mode = INTPTR_PARAMETERS);
......@@ -2324,34 +2323,34 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// 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.
TNode<FixedArrayBase> TryGrowElementsCapacity(Node* object, Node* elements,
ElementsKind kind, Node* key,
Label* bailout);
TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object,
TNode<FixedArrayBase> elements,
ElementsKind kind,
TNode<Smi> key, Label* bailout);
// Tries to grow the |capacity|-length |elements| array of given |object|
// to store the |key| or bails out if the growing gap is too big. Returns
// new elements.
TNode<FixedArrayBase> TryGrowElementsCapacity(Node* object, Node* elements,
TNode<FixedArrayBase> TryGrowElementsCapacity(TNode<HeapObject> object,
TNode<FixedArrayBase> elements,
ElementsKind kind, Node* key,
Node* capacity,
ParameterMode mode,
Label* bailout);
// Grows elements capacity of given object. Returns new elements.
TNode<FixedArrayBase> GrowElementsCapacity(Node* object, Node* elements,
ElementsKind from_kind,
ElementsKind to_kind,
Node* capacity, Node* new_capacity,
ParameterMode mode,
Label* bailout);
TNode<FixedArrayBase> GrowElementsCapacity(
TNode<HeapObject> object, TNode<FixedArrayBase> elements,
ElementsKind from_kind, ElementsKind to_kind, Node* capacity,
Node* new_capacity, ParameterMode mode, Label* bailout);
// Given a need to grow by |growth|, allocate an appropriate new capacity
// if necessary, and return a new elements FixedArray object. Label |bailout|
// is followed for allocation failure.
void PossiblyGrowElementsCapacity(ParameterMode mode, ElementsKind kind,
Node* array, Node* length,
Variable* var_elements, Node* growth,
Label* bailout);
TNode<HeapObject> array, Node* length,
TVariable<FixedArrayBase>* var_elements,
Node* growth, Label* bailout);
// Allocation site manipulation
void InitializeAllocationMemento(TNode<HeapObject> base,
......@@ -2495,7 +2494,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<BoolT> IsFixedArraySubclass(SloppyTNode<HeapObject> object);
TNode<BoolT> IsFixedArrayWithKind(SloppyTNode<HeapObject> object,
ElementsKind kind);
TNode<BoolT> IsFixedArrayWithKindOrEmpty(SloppyTNode<HeapObject> object,
TNode<BoolT> IsFixedArrayWithKindOrEmpty(SloppyTNode<FixedArrayBase> object,
ElementsKind kind);
TNode<BoolT> IsFixedDoubleArray(SloppyTNode<HeapObject> object);
TNode<BoolT> IsFunctionWithPrototypeSlotMap(SloppyTNode<Map> map);
......@@ -3358,7 +3357,8 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<UintPtrT> length, TNode<IntPtrT> key,
Label* bailout);
Node* CopyElementsOnWrite(Node* object, Node* elements, ElementsKind kind,
Node* CopyElementsOnWrite(TNode<HeapObject> object,
TNode<FixedArrayBase> elements, ElementsKind kind,
Node* length, ParameterMode mode, Label* bailout);
void TransitionElementsKind(TNode<JSObject> object, TNode<Map> map,
......@@ -3900,6 +3900,12 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
TNode<Object> LoadRoot(RootIndex root_index) {
return CodeAssembler::LoadRoot(root_index);
}
void StoreFixedArrayOrPropertyArrayElement(
TNode<UnionT<FixedArray, PropertyArray>> array, Node* index,
TNode<Object> value, WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER,
int additional_offset = 0,
ParameterMode parameter_mode = INTPTR_PARAMETERS);
};
// template <typename TIndex>
......
......@@ -1988,7 +1988,7 @@ TNode<PropertyArray> AccessorAssembler::ExtendPropertiesBackingStore(
mode));
TNode<PropertyArray> new_properties =
CAST(AllocatePropertyArray(new_capacity, mode));
AllocatePropertyArray(new_capacity, mode);
var_new_properties = new_properties;
FillPropertyArrayWithUndefined(new_properties, var_length.value(),
......@@ -4055,17 +4055,18 @@ void AccessorAssembler::GenerateCloneObjectIC() {
GotoIf(IsEmptyFixedArray(source_properties), &allocate_object);
// This IC requires that the source object has fast properties.
CSA_SLOW_ASSERT(this, IsPropertyArray(CAST(source_properties)));
TNode<IntPtrT> length = LoadPropertyArrayLength(
UncheckedCast<PropertyArray>(source_properties));
TNode<PropertyArray> source_property_array = CAST(source_properties);
TNode<IntPtrT> length = LoadPropertyArrayLength(source_property_array);
GotoIf(IntPtrEqual(length, IntPtrConstant(0)), &allocate_object);
auto mode = INTPTR_PARAMETERS;
var_properties = CAST(AllocatePropertyArray(length, mode));
FillPropertyArrayWithUndefined(var_properties.value(), IntPtrConstant(0),
length, mode);
CopyPropertyArrayValues(source_properties, var_properties.value(), length,
TNode<PropertyArray> property_array = AllocatePropertyArray(length, mode);
FillPropertyArrayWithUndefined(property_array, IntPtrConstant(0), length,
mode);
CopyPropertyArrayValues(source_property_array, property_array, length,
SKIP_WRITE_BARRIER, mode, DestroySource::kNo);
var_properties = property_array;
}
Goto(&allocate_object);
......
......@@ -3313,8 +3313,8 @@ TEST(ExtractFixedArrayCOWForceCopy) {
CodeStubAssembler m(asm_tester.state());
CodeStubAssembler::ExtractFixedArrayFlags flags;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kAllFixedArrays;
m.Return(m.ExtractFixedArray(m.Parameter(0), m.SmiConstant(0), nullptr,
nullptr, flags,
m.Return(m.ExtractFixedArray(m.CAST(m.Parameter(0)), m.SmiConstant(0),
nullptr, nullptr, flags,
CodeStubAssembler::SMI_PARAMETERS));
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -3342,8 +3342,8 @@ TEST(ExtractFixedArraySimple) {
CodeStubAssembler::ExtractFixedArrayFlags flags;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kAllFixedArrays;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kDontCopyCOW;
m.Return(m.ExtractFixedArray(m.Parameter(0), m.Parameter(1), m.Parameter(2),
nullptr, flags,
m.Return(m.ExtractFixedArray(m.CAST(m.Parameter(0)), m.Parameter(1),
m.Parameter(2), nullptr, flags,
CodeStubAssembler::SMI_PARAMETERS));
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -3369,7 +3369,7 @@ TEST(ExtractFixedArraySimpleSmiConstant) {
CodeStubAssembler::ExtractFixedArrayFlags flags;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kAllFixedArrays;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kDontCopyCOW;
m.Return(m.ExtractFixedArray(m.Parameter(0), m.SmiConstant(1),
m.Return(m.ExtractFixedArray(m.CAST(m.Parameter(0)), m.SmiConstant(1),
m.SmiConstant(2), nullptr, flags,
CodeStubAssembler::SMI_PARAMETERS));
}
......@@ -3393,7 +3393,7 @@ TEST(ExtractFixedArraySimpleIntPtrConstant) {
CodeStubAssembler::ExtractFixedArrayFlags flags;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kAllFixedArrays;
flags |= CodeStubAssembler::ExtractFixedArrayFlag::kDontCopyCOW;
m.Return(m.ExtractFixedArray(m.Parameter(0), m.IntPtrConstant(1),
m.Return(m.ExtractFixedArray(m.CAST(m.Parameter(0)), m.IntPtrConstant(1),
m.IntPtrConstant(2), nullptr, flags,
CodeStubAssembler::INTPTR_PARAMETERS));
}
......@@ -3415,8 +3415,8 @@ TEST(ExtractFixedArraySimpleIntPtrConstantNoDoubles) {
{
CodeStubAssembler m(asm_tester.state());
m.Return(m.ExtractFixedArray(
m.Parameter(0), m.IntPtrConstant(1), m.IntPtrConstant(2), nullptr,
CodeStubAssembler::ExtractFixedArrayFlag::kFixedArrays,
m.CAST(m.Parameter(0)), m.IntPtrConstant(1), m.IntPtrConstant(2),
nullptr, CodeStubAssembler::ExtractFixedArrayFlag::kFixedArrays,
CodeStubAssembler::INTPTR_PARAMETERS));
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......@@ -3438,7 +3438,8 @@ TEST(ExtractFixedArraySimpleIntPtrParameters) {
CodeStubAssembler m(asm_tester.state());
TNode<IntPtrT> p1_untagged = m.SmiUntag(m.Parameter(1));
TNode<IntPtrT> p2_untagged = m.SmiUntag(m.Parameter(2));
m.Return(m.ExtractFixedArray(m.Parameter(0), p1_untagged, p2_untagged));
m.Return(
m.ExtractFixedArray(m.CAST(m.Parameter(0)), p1_untagged, p2_untagged));
}
FunctionTester ft(asm_tester.GenerateCode(), kNumParams);
......
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