Commit 812f2420 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[CSA] Type AllocateFixedArray users

Type users of AllocateFixedArray with intptr parameters.

Bug: v8:7796
Change-Id: I4b155fb3fcb90fe66a3c20a24f0cea678a5d85bc
Reviewed-on: https://chromium-review.googlesource.com/1078347
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53436}
parent ca677531
......@@ -224,14 +224,12 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructDoubleVarargs(
Label if_holey_double(this), if_packed_double(this), if_done(this);
const ElementsKind new_kind = PACKED_ELEMENTS;
const ParameterMode mode = INTPTR_PARAMETERS;
const WriteBarrierMode barrier_mode = UPDATE_WRITE_BARRIER;
Node* intptr_length = ChangeInt32ToIntPtr(length);
TNode<IntPtrT> intptr_length = ChangeInt32ToIntPtr(length);
// Allocate a new FixedArray of Objects.
Node* new_elements =
AllocateFixedArray(new_kind, intptr_length, mode,
CodeStubAssembler::kAllowLargeObjectAllocation);
TNode<FixedArray> new_elements = AllocateFixedArray(
new_kind, intptr_length, CodeStubAssembler::kAllowLargeObjectAllocation);
Branch(Word32Equal(kind, Int32Constant(HOLEY_DOUBLE_ELEMENTS)),
&if_holey_double, &if_packed_double);
......
......@@ -2031,8 +2031,8 @@ TNode<Object> WeakCollectionsBuiltinsAssembler::AllocateTable(
// See HashTable::NewInternal().
TNode<IntPtrT> length = KeyIndexFromEntry(capacity);
TNode<FixedArray> table = AllocateFixedArray(
HOLEY_ELEMENTS, length, INTPTR_PARAMETERS, kAllowLargeObjectAllocation);
TNode<FixedArray> table =
AllocateFixedArray(HOLEY_ELEMENTS, length, kAllowLargeObjectAllocation);
Heap::RootListIndex map_root_index =
static_cast<Heap::RootListIndex>(ObjectHashTableShape::GetMapRootIndex());
......
......@@ -121,11 +121,10 @@ TF_BUILTIN(FastFunctionPrototypeBind, CodeStubAssembler) {
Label empty_arguments(this);
Label arguments_done(this, &argument_array);
GotoIf(Uint32LessThanOrEqual(argc, Int32Constant(1)), &empty_arguments);
Node* elements_length =
ChangeUint32ToWord(Unsigned(Int32Sub(argc, Int32Constant(1))));
Node* elements =
AllocateFixedArray(PACKED_ELEMENTS, elements_length, INTPTR_PARAMETERS,
kAllowLargeObjectAllocation);
TNode<IntPtrT> elements_length =
Signed(ChangeUint32ToWord(Unsigned(Int32Sub(argc, Int32Constant(1)))));
Node* elements = AllocateFixedArray(PACKED_ELEMENTS, elements_length,
kAllowLargeObjectAllocation);
VARIABLE(index, MachineType::PointerRepresentation());
index.Bind(IntPtrConstant(0));
VariableList foreach_vars({&index}, zone());
......
......@@ -266,7 +266,7 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
TNode<Context> context, TNode<JSObject> object,
Label* if_call_runtime_with_fast_path, Label* if_no_properties,
CollectType collect_type) {
Node* native_context = LoadNativeContext(context);
TNode<Context> native_context = LoadNativeContext(context);
TNode<Map> array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
TNode<Map> map = LoadMap(object);
......@@ -274,9 +274,9 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
Label if_has_enum_cache(this), if_not_has_enum_cache(this),
collect_entries(this);
Node* object_enum_length =
DecodeWordFromWord32<Map::EnumLengthBits>(bit_field3);
Node* has_enum_cache = WordNotEqual(
TNode<IntPtrT> object_enum_length =
Signed(DecodeWordFromWord32<Map::EnumLengthBits>(bit_field3));
TNode<BoolT> has_enum_cache = WordNotEqual(
object_enum_length, IntPtrConstant(kInvalidEnumCacheSentinel));
// In case, we found enum_cache in object,
......@@ -292,9 +292,8 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
BIND(&if_has_enum_cache);
{
GotoIf(WordEqual(object_enum_length, IntPtrConstant(0)), if_no_properties);
TNode<FixedArray> values_or_entries = TNode<FixedArray>::UncheckedCast(
AllocateFixedArray(PACKED_ELEMENTS, object_enum_length,
INTPTR_PARAMETERS, kAllowLargeObjectAllocation));
TNode<FixedArray> values_or_entries = AllocateFixedArray(
PACKED_ELEMENTS, object_enum_length, kAllowLargeObjectAllocation);
// If in case we have enum_cache,
// we can't detect accessor of object until loop through descriptors.
......@@ -342,8 +341,7 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
// the next descriptor.
GotoIfNot(IsPropertyEnumerable(details), &next_descriptor);
VARIABLE(var_property_value, MachineRepresentation::kTagged,
UndefinedConstant());
TVARIABLE(Object, var_property_value, UndefinedConstant());
TNode<IntPtrT> descriptor_name_index = ToKeyIndex<DescriptorArray>(
Unsigned(TruncateIntPtrToInt32(var_descriptor_number.value())));
......@@ -353,7 +351,7 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
&var_property_value);
// If kind is "value", append value to properties.
Node* value = var_property_value.value();
TNode<Object> value = var_property_value.value();
if (collect_type == CollectType::kEntries) {
// Let entry be CreateArrayFromList(« key, value »).
......@@ -364,7 +362,7 @@ TNode<JSArray> ObjectEntriesValuesBuiltinsAssembler::FastGetOwnValuesOrEntries(
IntPtrConstant(2));
StoreFixedArrayElement(elements, 0, next_key, SKIP_WRITE_BARRIER);
StoreFixedArrayElement(elements, 1, value, SKIP_WRITE_BARRIER);
value = array;
value = TNode<JSArray>::UncheckedCast(array);
}
StoreFixedArrayElement(values_or_entries, var_result_index.value(),
......
......@@ -2023,9 +2023,9 @@ TF_BUILTIN(PromiseAll, PromiseBuiltinsAssembler) {
}
TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
Node* const value = Parameter(Descriptor::kValue);
Node* const context = Parameter(Descriptor::kContext);
Node* const function = LoadFromFrame(StandardFrameConstants::kFunctionOffset);
TNode<Object> value = CAST(Parameter(Descriptor::kValue));
TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Node* function = LoadFromFrame(StandardFrameConstants::kFunctionOffset);
Label already_called(this, Label::kDeferred), resolve_promise(this);
......@@ -2037,22 +2037,22 @@ TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
GotoIf(IsNativeContext(context), &already_called);
CSA_ASSERT(this, SmiEqual(LoadFixedArrayBaseLength(context),
SmiConstant(kPromiseAllResolveElementLength)));
Node* const native_context = LoadNativeContext(context);
TNode<Context> native_context = LoadNativeContext(context);
StoreObjectField(function, JSFunction::kContextOffset, native_context);
// Determine the index from the {function}.
Label unreachable(this, Label::kDeferred);
STATIC_ASSERT(PropertyArray::kNoHashSentinel == 0);
Node* const identity_hash =
TNode<IntPtrT> identity_hash =
LoadJSReceiverIdentityHash(function, &unreachable);
CSA_ASSERT(this, IntPtrGreaterThan(identity_hash, IntPtrConstant(0)));
Node* const index = IntPtrSub(identity_hash, IntPtrConstant(1));
TNode<IntPtrT> index = IntPtrSub(identity_hash, IntPtrConstant(1));
// Check if we need to grow the [[ValuesArray]] to store {value} at {index}.
Node* const values_array =
LoadContextElement(context, kPromiseAllResolveElementValuesArraySlot);
Node* const elements = LoadElements(values_array);
Node* const values_length =
TNode<JSArray> values_array = CAST(
LoadContextElement(context, kPromiseAllResolveElementValuesArraySlot));
TNode<FixedArray> elements = CAST(LoadElements(values_array));
TNode<IntPtrT> values_length =
LoadAndUntagObjectField(values_array, JSArray::kLengthOffset);
Label if_inbounds(this), if_outofbounds(this), done(this);
Branch(IntPtrLessThan(index, values_length), &if_inbounds, &if_outofbounds);
......@@ -2060,8 +2060,8 @@ TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
BIND(&if_outofbounds);
{
// Check if we need to grow the backing store.
Node* const new_length = IntPtrAdd(index, IntPtrConstant(1));
Node* const elements_length =
TNode<IntPtrT> new_length = IntPtrAdd(index, IntPtrConstant(1));
TNode<IntPtrT> elements_length =
LoadAndUntagObjectField(elements, FixedArray::kLengthOffset);
Label if_grow(this, Label::kDeferred), if_nogrow(this);
Branch(IntPtrLessThan(index, elements_length), &if_nogrow, &if_grow);
......@@ -2069,14 +2069,14 @@ TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
BIND(&if_grow);
{
// We need to grow the backing store to fit the {index} as well.
Node* const new_elements_length =
TNode<IntPtrT> new_elements_length =
IntPtrMin(CalculateNewElementsCapacity(new_length),
IntPtrConstant(PropertyArray::HashField::kMax + 1));
CSA_ASSERT(this, IntPtrLessThan(index, new_elements_length));
CSA_ASSERT(this, IntPtrLessThan(elements_length, new_elements_length));
Node* const new_elements = AllocateFixedArray(
PACKED_ELEMENTS, new_elements_length, INTPTR_PARAMETERS,
AllocationFlag::kAllowLargeObjectAllocation);
TNode<FixedArray> new_elements =
AllocateFixedArray(PACKED_ELEMENTS, new_elements_length,
AllocationFlag::kAllowLargeObjectAllocation);
CopyFixedArrayElements(PACKED_ELEMENTS, elements, PACKED_ELEMENTS,
new_elements, elements_length,
new_elements_length);
......@@ -2118,9 +2118,9 @@ TF_BUILTIN(PromiseAllResolveElementClosure, PromiseBuiltinsAssembler) {
Return(UndefinedConstant());
BIND(&resolve_promise);
Node* const capability =
LoadContextElement(context, kPromiseAllResolveElementCapabilitySlot);
Node* const resolve =
TNode<PromiseCapability> capability = CAST(
LoadContextElement(context, kPromiseAllResolveElementCapabilitySlot));
TNode<Object> resolve =
LoadObjectField(capability, PromiseCapability::kResolveOffset);
CallJS(CodeFactory::Call(isolate(), ConvertReceiverMode::kNullOrUndefined),
context, resolve, UndefinedConstant(), values_array);
......
......@@ -1821,9 +1821,8 @@ TNode<JSArray> StringBuiltinsAssembler::StringToArray(
ToDirectStringAssembler to_direct(state(), subject_string);
to_direct.TryToDirect(&call_runtime);
TNode<FixedArray> elements =
AllocateFixedArray(PACKED_ELEMENTS, length_smi,
AllocationFlag::kAllowLargeObjectAllocation);
TNode<FixedArray> elements = AllocateFixedArray(
PACKED_ELEMENTS, length, AllocationFlag::kAllowLargeObjectAllocation);
// Don't allocate anything while {string_data} is live!
TNode<RawPtrT> string_data = UncheckedCast<RawPtrT>(
to_direct.PointerToData(&fill_thehole_and_call_runtime));
......
......@@ -3089,11 +3089,11 @@ Node* CodeStubAssembler::AllocateOrderedHashTable() {
// Allocate the table and add the proper map.
const ElementsKind elements_kind = HOLEY_ELEMENTS;
Node* const length_intptr = IntPtrConstant(kFixedArrayLength);
Node* const fixed_array_map = LoadRoot(
static_cast<Heap::RootListIndex>(CollectionType::GetMapRootIndex()));
Node* const table =
AllocateFixedArray(elements_kind, length_intptr, INTPTR_PARAMETERS,
TNode<IntPtrT> length_intptr = IntPtrConstant(kFixedArrayLength);
TNode<Map> fixed_array_map = CAST(LoadRoot(
static_cast<Heap::RootListIndex>(CollectionType::GetMapRootIndex())));
TNode<FixedArray> table =
AllocateFixedArray(elements_kind, length_intptr,
kAllowLargeObjectAllocation, fixed_array_map);
// Initialize the OrderedHashTable fields.
......@@ -3106,7 +3106,7 @@ Node* CodeStubAssembler::AllocateOrderedHashTable() {
SmiConstant(kBucketCount), barrier_mode);
// Fill the buckets with kNotFound.
Node* const not_found = SmiConstant(CollectionType::kNotFound);
TNode<Smi> not_found = SmiConstant(CollectionType::kNotFound);
STATIC_ASSERT(CollectionType::kHashTableStartIndex ==
CollectionType::kNumberOfBucketsIndex + 1);
STATIC_ASSERT((CollectionType::kHashTableStartIndex + kBucketCount) ==
......
......@@ -115,6 +115,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
typedef base::Flags<AllocationFlag> AllocationFlags;
enum ParameterMode { SMI_PARAMETERS, INTPTR_PARAMETERS };
// On 32-bit platforms, there is a slight performance advantage to doing all
// of the array offset/index arithmetic with SMIs, since it's possible
// to save a few tag/untag operations without paying an extra expense when
......@@ -1098,15 +1099,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
AllocationFlags flags = kNone,
SloppyTNode<Map> fixed_array_map = nullptr);
TNode<FixedArray> AllocateFixedArray(ElementsKind kind, TNode<Smi> capacity,
AllocationFlags flags = kNone) {
return AllocateFixedArray(kind, capacity, SMI_PARAMETERS, flags);
}
TNode<FixedArray> AllocateFixedArray(ElementsKind kind, TNode<Smi> capacity,
TNode<Map> map,
AllocationFlags flags = kNone) {
return AllocateFixedArray(kind, capacity, SMI_PARAMETERS, flags, map);
TNode<FixedArray> AllocateFixedArray(
ElementsKind kind, TNode<IntPtrT> capacity, AllocationFlags flags,
SloppyTNode<Map> fixed_array_map = nullptr) {
return AllocateFixedArray(kind, capacity, INTPTR_PARAMETERS, flags,
fixed_array_map);
}
Node* AllocatePropertyArray(Node* capacity,
......
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