Commit c6d5b696 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[csa] Type builtins-call-gen.cc

Drive-by-fix:
- Add CSA::LoadElementsKind helper

Bug: v8:7796
Change-Id: Icbf81effdd42efa7f8ec56f8d1a40c331c7a25e4
Reviewed-on: https://chromium-review.googlesource.com/1078849
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53472}
parent 60c46384
...@@ -246,7 +246,7 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) { ...@@ -246,7 +246,7 @@ Node* ArrayBuiltinsAssembler::FindProcessor(Node* k_value, Node* k) {
transition_smi_double(this); transition_smi_double(this);
Label array_not_smi(this), array_fast(this), array_double(this); Label array_not_smi(this), array_fast(this), array_double(this);
Node* kind = LoadMapElementsKind(LoadMap(a())); TNode<Int32T> kind = LoadElementsKind(a());
Node* elements = LoadElements(a()); Node* elements = LoadElements(a());
GotoIf(IsElementsKindGreaterThan(kind, HOLEY_SMI_ELEMENTS), &array_not_smi); GotoIf(IsElementsKindGreaterThan(kind, HOLEY_SMI_ELEMENTS), &array_not_smi);
TryStoreArrayElement(HOLEY_SMI_ELEMENTS, mode, &transition_pre, elements, k, TryStoreArrayElement(HOLEY_SMI_ELEMENTS, mode, &transition_pre, elements, k,
...@@ -960,7 +960,7 @@ TF_BUILTIN(ArrayPrototypePop, CodeStubAssembler) { ...@@ -960,7 +960,7 @@ TF_BUILTIN(ArrayPrototypePop, CodeStubAssembler) {
StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset,
SmiTag(new_length)); SmiTag(new_length));
Node* elements_kind = LoadMapElementsKind(LoadMap(array_receiver)); TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf(Int32LessThanOrEqual(elements_kind, GotoIf(Int32LessThanOrEqual(elements_kind,
Int32Constant(TERMINAL_FAST_ELEMENTS_KIND)), Int32Constant(TERMINAL_FAST_ELEMENTS_KIND)),
&fast_elements); &fast_elements);
...@@ -1538,7 +1538,7 @@ TF_BUILTIN(ArrayPrototypeShift, CodeStubAssembler) { ...@@ -1538,7 +1538,7 @@ TF_BUILTIN(ArrayPrototypeShift, CodeStubAssembler) {
StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset,
SmiTag(new_length)); SmiTag(new_length));
Node* elements_kind = LoadMapElementsKind(LoadMap(array_receiver)); TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf( GotoIf(
Int32LessThanOrEqual(elements_kind, Int32Constant(HOLEY_SMI_ELEMENTS)), Int32LessThanOrEqual(elements_kind, Int32Constant(HOLEY_SMI_ELEMENTS)),
&fast_elements_smi); &fast_elements_smi);
...@@ -2977,7 +2977,7 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) { ...@@ -2977,7 +2977,7 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
Label if_smiorobjects(this), if_packed_doubles(this), if_holey_doubles(this); Label if_smiorobjects(this), if_packed_doubles(this), if_holey_doubles(this);
Node* elements_kind = LoadMapElementsKind(LoadMap(array)); TNode<Int32T> elements_kind = LoadElementsKind(array);
Node* elements = LoadElements(array); Node* elements = LoadElements(array);
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0); STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1); STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
......
This diff is collapsed.
...@@ -15,14 +15,19 @@ class CallOrConstructBuiltinsAssembler : public CodeStubAssembler { ...@@ -15,14 +15,19 @@ class CallOrConstructBuiltinsAssembler : public CodeStubAssembler {
explicit CallOrConstructBuiltinsAssembler(compiler::CodeAssemblerState* state) explicit CallOrConstructBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
void CallOrConstructWithArrayLike(Node* target, Node* new_target, void CallOrConstructWithArrayLike(TNode<Object> target,
Node* arguments_list, Node* context); SloppyTNode<Object> new_target,
void CallOrConstructDoubleVarargs(Node* target, Node* new_target, TNode<Object> arguments_list,
Node* elements, Node* length, TNode<Context> context);
Node* args_count, Node* context, void CallOrConstructDoubleVarargs(TNode<Object> target,
Node* kind); SloppyTNode<Object> new_target,
void CallOrConstructWithSpread(Node* target, Node* new_target, Node* spread, TNode<FixedDoubleArray> elements,
Node* args_count, Node* context); TNode<Int32T> length,
TNode<Int32T> args_count,
TNode<Context> context, TNode<Int32T> kind);
void CallOrConstructWithSpread(TNode<Object> target, TNode<Object> new_target,
TNode<Object> spread, TNode<Int32T> args_count,
TNode<Context> context);
}; };
} // namespace internal } // namespace internal
......
...@@ -221,7 +221,7 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromFastJSArray( ...@@ -221,7 +221,7 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromFastJSArray(
TNode<Object> collection, TNode<JSArray> fast_jsarray, TNode<Object> collection, TNode<JSArray> fast_jsarray,
Label* if_may_have_side_effects) { Label* if_may_have_side_effects) {
TNode<FixedArrayBase> elements = LoadElements(fast_jsarray); TNode<FixedArrayBase> elements = LoadElements(fast_jsarray);
TNode<Int32T> elements_kind = LoadMapElementsKind(LoadMap(fast_jsarray)); TNode<Int32T> elements_kind = LoadElementsKind(fast_jsarray);
TNode<JSFunction> add_func = GetInitialAddFunction(variant, native_context); TNode<JSFunction> add_func = GetInitialAddFunction(variant, native_context);
CSA_ASSERT( CSA_ASSERT(
this, this,
...@@ -530,7 +530,7 @@ void BaseCollectionsAssembler::LoadKeyValue( ...@@ -530,7 +530,7 @@ void BaseCollectionsAssembler::LoadKeyValue(
TNode<JSArray> array = CAST(maybe_array); TNode<JSArray> array = CAST(maybe_array);
TNode<Smi> length = LoadFastJSArrayLength(array); TNode<Smi> length = LoadFastJSArrayLength(array);
TNode<FixedArrayBase> elements = LoadElements(array); TNode<FixedArrayBase> elements = LoadElements(array);
TNode<Int32T> elements_kind = LoadMapElementsKind(LoadMap(array)); TNode<Int32T> elements_kind = LoadElementsKind(array);
Label if_smiorobjects(this), if_doubles(this); Label if_smiorobjects(this), if_doubles(this);
Branch(IsFastSmiOrTaggedElementsKind(elements_kind), &if_smiorobjects, Branch(IsFastSmiOrTaggedElementsKind(elements_kind), &if_smiorobjects,
......
...@@ -36,20 +36,28 @@ void Builtins::Generate_ConstructFunctionForwardVarargs(MacroAssembler* masm) { ...@@ -36,20 +36,28 @@ void Builtins::Generate_ConstructFunctionForwardVarargs(MacroAssembler* masm) {
} }
TF_BUILTIN(ConstructWithArrayLike, CallOrConstructBuiltinsAssembler) { TF_BUILTIN(ConstructWithArrayLike, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(ConstructWithArrayLikeDescriptor::kTarget); TNode<Object> target =
Node* new_target = Parameter(ConstructWithArrayLikeDescriptor::kNewTarget); CAST(Parameter(ConstructWithArrayLikeDescriptor::kTarget));
Node* arguments_list = SloppyTNode<Object> new_target =
Parameter(ConstructWithArrayLikeDescriptor::kArgumentsList); CAST(Parameter(ConstructWithArrayLikeDescriptor::kNewTarget));
Node* context = Parameter(ConstructWithArrayLikeDescriptor::kContext); TNode<Object> arguments_list =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kArgumentsList));
TNode<Context> context =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kContext));
CallOrConstructWithArrayLike(target, new_target, arguments_list, context); CallOrConstructWithArrayLike(target, new_target, arguments_list, context);
} }
TF_BUILTIN(ConstructWithSpread, CallOrConstructBuiltinsAssembler) { TF_BUILTIN(ConstructWithSpread, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(ConstructWithSpreadDescriptor::kTarget); TNode<Object> target =
Node* new_target = Parameter(ConstructWithSpreadDescriptor::kNewTarget); CAST(Parameter(ConstructWithSpreadDescriptor::kTarget));
Node* spread = Parameter(ConstructWithSpreadDescriptor::kSpread); SloppyTNode<Object> new_target =
Node* args_count = Parameter(ConstructWithSpreadDescriptor::kArgumentsCount); CAST(Parameter(ConstructWithSpreadDescriptor::kNewTarget));
Node* context = Parameter(ConstructWithSpreadDescriptor::kContext); TNode<Object> spread =
CAST(Parameter(ConstructWithSpreadDescriptor::kSpread));
TNode<Int32T> args_count = UncheckedCast<Int32T>(
Parameter(ConstructWithSpreadDescriptor::kArgumentsCount));
TNode<Context> context =
CAST(Parameter(ConstructWithSpreadDescriptor::kContext));
CallOrConstructWithSpread(target, new_target, spread, args_count, context); CallOrConstructWithSpread(target, new_target, spread, args_count, context);
} }
......
...@@ -589,8 +589,8 @@ void TypedArrayBuiltinsAssembler::ConstructByArrayLike( ...@@ -589,8 +589,8 @@ void TypedArrayBuiltinsAssembler::ConstructByArrayLike(
BIND(&fill); BIND(&fill);
GotoIf(SmiEqual(length, SmiConstant(0)), &done); GotoIf(SmiEqual(length, SmiConstant(0)), &done);
TNode<Int32T> holder_kind = LoadMapElementsKind(LoadMap(holder)); TNode<Int32T> holder_kind = LoadElementsKind(holder);
TNode<Int32T> source_kind = LoadMapElementsKind(LoadMap(array_like)); TNode<Int32T> source_kind = LoadElementsKind(array_like);
GotoIf(Word32Equal(holder_kind, source_kind), &fast_copy); GotoIf(Word32Equal(holder_kind, source_kind), &fast_copy);
// Copy using the elements accessor. // Copy using the elements accessor.
...@@ -854,11 +854,6 @@ TNode<Word32T> TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind( ...@@ -854,11 +854,6 @@ TNode<Word32T> TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(
Word32Equal(kind, Int32Constant(BIGUINT64_ELEMENTS))); Word32Equal(kind, Int32Constant(BIGUINT64_ELEMENTS)));
} }
TNode<Word32T> TypedArrayBuiltinsAssembler::LoadElementsKind(
TNode<JSTypedArray> typed_array) {
return LoadMapElementsKind(LoadMap(typed_array));
}
TNode<IntPtrT> TypedArrayBuiltinsAssembler::GetTypedArrayElementSize( TNode<IntPtrT> TypedArrayBuiltinsAssembler::GetTypedArrayElementSize(
TNode<Word32T> elements_kind) { TNode<Word32T> elements_kind) {
TVARIABLE(IntPtrT, element_size); TVARIABLE(IntPtrT, element_size);
...@@ -1105,7 +1100,7 @@ void TypedArrayBuiltinsAssembler::SetJSArraySource( ...@@ -1105,7 +1100,7 @@ void TypedArrayBuiltinsAssembler::SetJSArraySource(
}; };
STATIC_ASSERT(arraysize(values) == arraysize(labels)); STATIC_ASSERT(arraysize(values) == arraysize(labels));
TNode<Int32T> source_elements_kind = LoadMapElementsKind(LoadMap(source)); TNode<Int32T> source_elements_kind = LoadElementsKind(source);
Switch(source_elements_kind, call_runtime, values, labels, Switch(source_elements_kind, call_runtime, values, labels,
arraysize(values)); arraysize(values));
} }
...@@ -1528,7 +1523,7 @@ TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) { ...@@ -1528,7 +1523,7 @@ TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) {
// performance. // performance.
BIND(&if_receiverisheapobject); BIND(&if_receiverisheapobject);
Node* elements_kind = Node* elements_kind =
Int32Sub(LoadMapElementsKind(LoadMap(receiver)), Int32Sub(LoadElementsKind(receiver),
Int32Constant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND)); Int32Constant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND));
Switch(elements_kind, &return_undefined, elements_kinds, elements_kind_labels, Switch(elements_kind, &return_undefined, elements_kinds, elements_kind_labels,
kTypedElementsKindCount); kTypedElementsKindCount);
......
...@@ -67,9 +67,6 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler { ...@@ -67,9 +67,6 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
// Returns true if kind is either BIGINT64_ELEMENTS or BIGUINT64_ELEMENTS. // Returns true if kind is either BIGINT64_ELEMENTS or BIGUINT64_ELEMENTS.
TNode<Word32T> IsBigInt64ElementsKind(TNode<Word32T> kind); TNode<Word32T> IsBigInt64ElementsKind(TNode<Word32T> kind);
// Loads the element kind of TypedArray instance.
TNode<Word32T> LoadElementsKind(TNode<JSTypedArray> typed_array);
// Returns the byte size of an element for a TypedArray elements kind. // Returns the byte size of an element for a TypedArray elements kind.
TNode<IntPtrT> GetTypedArrayElementSize(TNode<Word32T> elements_kind); TNode<IntPtrT> GetTypedArrayElementSize(TNode<Word32T> elements_kind);
......
...@@ -1428,7 +1428,7 @@ TNode<Number> CodeStubAssembler::LoadJSArrayLength(SloppyTNode<JSArray> array) { ...@@ -1428,7 +1428,7 @@ TNode<Number> CodeStubAssembler::LoadJSArrayLength(SloppyTNode<JSArray> array) {
TNode<Smi> CodeStubAssembler::LoadFastJSArrayLength( TNode<Smi> CodeStubAssembler::LoadFastJSArrayLength(
SloppyTNode<JSArray> array) { SloppyTNode<JSArray> array) {
TNode<Object> length = LoadJSArrayLength(array); TNode<Object> length = LoadJSArrayLength(array);
CSA_ASSERT(this, IsFastElementsKind(LoadMapElementsKind(LoadMap(array)))); CSA_ASSERT(this, IsFastElementsKind(LoadElementsKind(array)));
// JSArray length is always a positive Smi for fast arrays. // JSArray length is always a positive Smi for fast arrays.
CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length));
return UncheckedCast<Smi>(length); return UncheckedCast<Smi>(length);
...@@ -1495,6 +1495,11 @@ TNode<Int32T> CodeStubAssembler::LoadMapElementsKind(SloppyTNode<Map> map) { ...@@ -1495,6 +1495,11 @@ TNode<Int32T> CodeStubAssembler::LoadMapElementsKind(SloppyTNode<Map> map) {
return Signed(DecodeWord32<Map::ElementsKindBits>(bit_field2)); return Signed(DecodeWord32<Map::ElementsKindBits>(bit_field2));
} }
TNode<Int32T> CodeStubAssembler::LoadElementsKind(
SloppyTNode<HeapObject> object) {
return LoadMapElementsKind(LoadMap(object));
}
TNode<DescriptorArray> CodeStubAssembler::LoadMapDescriptors( TNode<DescriptorArray> CodeStubAssembler::LoadMapDescriptors(
SloppyTNode<Map> map) { SloppyTNode<Map> map) {
CSA_SLOW_ASSERT(this, IsMap(map)); CSA_SLOW_ASSERT(this, IsMap(map));
......
...@@ -623,6 +623,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -623,6 +623,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Int32T> LoadMapInstanceType(SloppyTNode<Map> map); TNode<Int32T> LoadMapInstanceType(SloppyTNode<Map> map);
// Load the ElementsKind of a map. // Load the ElementsKind of a map.
TNode<Int32T> LoadMapElementsKind(SloppyTNode<Map> map); TNode<Int32T> LoadMapElementsKind(SloppyTNode<Map> map);
TNode<Int32T> LoadElementsKind(SloppyTNode<HeapObject> map);
// Load the instance descriptors of a map. // Load the instance descriptors of a map.
TNode<DescriptorArray> LoadMapDescriptors(SloppyTNode<Map> map); TNode<DescriptorArray> LoadMapDescriptors(SloppyTNode<Map> map);
// Load the prototype of a map. // Load the prototype of a map.
......
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