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