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) {
transition_smi_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());
GotoIf(IsElementsKindGreaterThan(kind, HOLEY_SMI_ELEMENTS), &array_not_smi);
TryStoreArrayElement(HOLEY_SMI_ELEMENTS, mode, &transition_pre, elements, k,
......@@ -960,7 +960,7 @@ TF_BUILTIN(ArrayPrototypePop, CodeStubAssembler) {
StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset,
SmiTag(new_length));
Node* elements_kind = LoadMapElementsKind(LoadMap(array_receiver));
TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf(Int32LessThanOrEqual(elements_kind,
Int32Constant(TERMINAL_FAST_ELEMENTS_KIND)),
&fast_elements);
......@@ -1538,7 +1538,7 @@ TF_BUILTIN(ArrayPrototypeShift, CodeStubAssembler) {
StoreObjectFieldNoWriteBarrier(array_receiver, JSArray::kLengthOffset,
SmiTag(new_length));
Node* elements_kind = LoadMapElementsKind(LoadMap(array_receiver));
TNode<Int32T> elements_kind = LoadElementsKind(array_receiver);
GotoIf(
Int32LessThanOrEqual(elements_kind, Int32Constant(HOLEY_SMI_ELEMENTS)),
&fast_elements_smi);
......@@ -2977,7 +2977,7 @@ void ArrayIncludesIndexofAssembler::Generate(SearchVariant variant) {
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);
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
STATIC_ASSERT(HOLEY_SMI_ELEMENTS == 1);
......
......@@ -62,9 +62,8 @@ void Builtins::Generate_CallFunctionForwardVarargs(MacroAssembler* masm) {
}
void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
Node* target, Node* new_target, Node* arguments_list, Node* context) {
VARIABLE(var_elements, MachineRepresentation::kTagged);
VARIABLE(var_length, MachineRepresentation::kWord32);
TNode<Object> target, SloppyTNode<Object> new_target,
TNode<Object> arguments_list, TNode<Context> context) {
Label if_done(this), if_arguments(this), if_array(this),
if_holey_array(this, Label::kDeferred),
if_runtime(this, Label::kDeferred);
......@@ -75,7 +74,8 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
Label if_target_callable(this),
if_target_not_callable(this, Label::kDeferred);
GotoIf(TaggedIsSmi(target), &if_target_not_callable);
Branch(IsCallable(target), &if_target_callable, &if_target_not_callable);
Branch(IsCallable(CAST(target)), &if_target_callable,
&if_target_not_callable);
BIND(&if_target_not_callable);
{
CallRuntime(Runtime::kThrowApplyNonFunction, context, target);
......@@ -87,7 +87,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
Label if_target_constructor(this),
if_target_not_constructor(this, Label::kDeferred);
GotoIf(TaggedIsSmi(target), &if_target_not_constructor);
Branch(IsConstructor(target), &if_target_constructor,
Branch(IsConstructor(CAST(target)), &if_target_constructor,
&if_target_not_constructor);
BIND(&if_target_not_constructor);
{
......@@ -100,7 +100,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
Label if_new_target_constructor(this),
if_new_target_not_constructor(this, Label::kDeferred);
GotoIf(TaggedIsSmi(new_target), &if_new_target_not_constructor);
Branch(IsConstructor(new_target), &if_new_target_constructor,
Branch(IsConstructor(CAST(new_target)), &if_new_target_constructor,
&if_new_target_not_constructor);
BIND(&if_new_target_not_constructor);
{
......@@ -111,27 +111,29 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
}
GotoIf(TaggedIsSmi(arguments_list), &if_runtime);
Node* arguments_list_map = LoadMap(arguments_list);
Node* native_context = LoadNativeContext(context);
TNode<Map> arguments_list_map = LoadMap(CAST(arguments_list));
TNode<Context> native_context = LoadNativeContext(context);
// Check if {arguments_list} is an (unmodified) arguments object.
Node* sloppy_arguments_map =
LoadContextElement(native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX);
TNode<Map> sloppy_arguments_map = CAST(
LoadContextElement(native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
GotoIf(WordEqual(arguments_list_map, sloppy_arguments_map), &if_arguments);
Node* strict_arguments_map =
LoadContextElement(native_context, Context::STRICT_ARGUMENTS_MAP_INDEX);
TNode<Map> strict_arguments_map = CAST(
LoadContextElement(native_context, Context::STRICT_ARGUMENTS_MAP_INDEX));
GotoIf(WordEqual(arguments_list_map, strict_arguments_map), &if_arguments);
// Check if {arguments_list} is a fast JSArray.
Branch(IsJSArrayMap(arguments_list_map), &if_array, &if_runtime);
TVARIABLE(FixedArrayBase, var_elements);
TVARIABLE(Int32T, var_length);
BIND(&if_array);
{
// Try to extract the elements from a JSArray object.
var_elements.Bind(
LoadObjectField(arguments_list, JSArray::kElementsOffset));
var_length.Bind(LoadAndUntagToWord32ObjectField(arguments_list,
JSArray::kLengthOffset));
var_elements = LoadElements(CAST(arguments_list));
var_length =
LoadAndUntagToWord32ObjectField(arguments_list, JSArray::kLengthOffset);
// Holey arrays and double backing stores need special treatment.
STATIC_ASSERT(PACKED_SMI_ELEMENTS == 0);
......@@ -142,7 +144,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
STATIC_ASSERT(HOLEY_DOUBLE_ELEMENTS == 5);
STATIC_ASSERT(LAST_FAST_ELEMENTS_KIND == HOLEY_DOUBLE_ELEMENTS);
Node* kind = LoadMapElementsKind(arguments_list_map);
TNode<Int32T> kind = LoadMapElementsKind(arguments_list_map);
GotoIf(Int32GreaterThan(kind, Int32Constant(LAST_FAST_ELEMENTS_KIND)),
&if_runtime);
......@@ -160,26 +162,25 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
BIND(&if_arguments);
{
TNode<JSArgumentsObject> js_arguments = CAST(arguments_list);
// Try to extract the elements from an JSArgumentsObject.
Node* length =
LoadObjectField(arguments_list, JSArgumentsObject::kLengthOffset);
Node* elements =
LoadObjectField(arguments_list, JSArgumentsObject::kElementsOffset);
Node* elements_length = LoadFixedArrayBaseLength(elements);
TNode<Object> length =
LoadObjectField(js_arguments, JSArgumentsObject::kLengthOffset);
TNode<FixedArrayBase> elements = LoadElements(js_arguments);
TNode<Smi> elements_length = LoadFixedArrayBaseLength(elements);
GotoIfNot(WordEqual(length, elements_length), &if_runtime);
var_elements.Bind(elements);
var_length.Bind(SmiToInt32(length));
var_elements = elements;
var_length = SmiToInt32(CAST(length));
Goto(&if_done);
}
BIND(&if_runtime);
{
// Ask the runtime to create the list (actually a FixedArray).
Node* elements =
CallRuntime(Runtime::kCreateListFromArrayLike, context, arguments_list);
var_elements.Bind(elements);
var_length.Bind(
LoadAndUntagToWord32ObjectField(elements, FixedArray::kLengthOffset));
var_elements = CAST(CallRuntime(Runtime::kCreateListFromArrayLike, context,
arguments_list));
var_length = LoadAndUntagToWord32ObjectField(var_elements.value(),
FixedArray::kLengthOffset);
Goto(&if_done);
}
......@@ -188,10 +189,10 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
BIND(&if_done);
{
Label if_not_double(this), if_double(this);
Node* elements = var_elements.value();
Node* length = var_length.value();
Node* args_count = Int32Constant(0); // args already on the stack
TNode<Int32T> args_count = Int32Constant(0); // args already on the stack
TNode<FixedArrayBase> elements = var_elements.value();
TNode<Int32T> length = var_length.value();
Branch(IsFixedDoubleArray(elements), &if_double, &if_not_double);
BIND(&if_not_double);
......@@ -208,7 +209,7 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
{
// Kind is hardcoded here because CreateListFromArrayLike will only
// produce holey double arrays.
CallOrConstructDoubleVarargs(target, new_target, elements, length,
CallOrConstructDoubleVarargs(target, new_target, CAST(elements), length,
args_count, context,
Int32Constant(HOLEY_DOUBLE_ELEMENTS));
}
......@@ -219,8 +220,9 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithArrayLike(
// boxed as HeapNumbers, then tail calls CallVarargs/ConstructVarargs depending
// on whether {new_target} was passed.
void CallOrConstructBuiltinsAssembler::CallOrConstructDoubleVarargs(
Node* target, Node* new_target, Node* elements, Node* length,
Node* args_count, Node* context, Node* kind) {
TNode<Object> target, SloppyTNode<Object> new_target,
TNode<FixedDoubleArray> elements, TNode<Int32T> length,
TNode<Int32T> args_count, TNode<Context> context, TNode<Int32T> kind) {
Label if_holey_double(this), if_packed_double(this), if_done(this);
const ElementsKind new_kind = PACKED_ELEMENTS;
......@@ -264,18 +266,19 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructDoubleVarargs(
}
void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
Node* target, Node* new_target, Node* spread, Node* args_count,
Node* context) {
TNode<Object> target, TNode<Object> new_target, TNode<Object> spread,
TNode<Int32T> args_count, TNode<Context> context) {
Label if_smiorobject(this), if_double(this),
if_generic(this, Label::kDeferred);
VARIABLE(var_length, MachineRepresentation::kWord32);
VARIABLE(var_elements, MachineRepresentation::kTagged);
VARIABLE(var_elements_kind, MachineRepresentation::kWord32);
TVARIABLE(Int32T, var_length);
TVARIABLE(FixedArrayBase, var_elements);
TVARIABLE(Int32T, var_elements_kind);
GotoIf(TaggedIsSmi(spread), &if_generic);
Node* spread_map = LoadMap(spread);
TNode<Map> spread_map = LoadMap(CAST(spread));
GotoIfNot(IsJSArrayMap(spread_map), &if_generic);
TNode<JSArray> spread_array = CAST(spread);
// Check that we have the original Array.prototype.
GotoIfNot(IsPrototypeInitialArrayPrototype(context, spread_map), &if_generic);
......@@ -285,40 +288,40 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
// Check that the Array.prototype hasn't been modified in a way that would
// affect iteration.
Node* protector_cell = LoadRoot(Heap::kArrayIteratorProtectorRootIndex);
DCHECK(isolate()->heap()->array_iterator_protector()->IsPropertyCell());
TNode<PropertyCell> protector_cell =
CAST(LoadRoot(Heap::kArrayIteratorProtectorRootIndex));
GotoIf(WordEqual(LoadObjectField(protector_cell, PropertyCell::kValueOffset),
SmiConstant(Isolate::kProtectorInvalid)),
&if_generic);
// The fast-path accesses the {spread} elements directly.
Node* spread_kind = LoadMapElementsKind(spread_map);
var_elements_kind.Bind(spread_kind);
var_length.Bind(
LoadAndUntagToWord32ObjectField(spread, JSArray::kLengthOffset));
var_elements.Bind(LoadObjectField(spread, JSArray::kElementsOffset));
// Check elements kind of {spread}.
GotoIf(Int32LessThan(spread_kind, Int32Constant(PACKED_DOUBLE_ELEMENTS)),
&if_smiorobject);
Branch(Int32GreaterThan(spread_kind, Int32Constant(LAST_FAST_ELEMENTS_KIND)),
&if_generic, &if_double);
{
// The fast-path accesses the {spread} elements directly.
TNode<Int32T> spread_kind = LoadMapElementsKind(spread_map);
var_elements_kind = spread_kind;
var_length =
LoadAndUntagToWord32ObjectField(spread_array, JSArray::kLengthOffset);
var_elements = LoadElements(spread_array);
// Check elements kind of {spread}.
GotoIf(Int32LessThan(spread_kind, Int32Constant(PACKED_DOUBLE_ELEMENTS)),
&if_smiorobject);
Branch(
Int32GreaterThan(spread_kind, Int32Constant(LAST_FAST_ELEMENTS_KIND)),
&if_generic, &if_double);
}
BIND(&if_generic);
{
Label if_iterator_fn_not_callable(this, Label::kDeferred);
Node* iterator_fn = GetProperty(context, spread, IteratorSymbolConstant());
GotoIf(TaggedIsSmi(iterator_fn), &if_iterator_fn_not_callable);
GotoIfNot(IsCallable(iterator_fn), &if_iterator_fn_not_callable);
Node* list =
CallBuiltin(Builtins::kIterableToList, context, spread, iterator_fn);
CSA_ASSERT(this, IsJSArray(list));
Node* list_kind = LoadMapElementsKind(LoadMap(list));
var_length.Bind(
LoadAndUntagToWord32ObjectField(list, JSArray::kLengthOffset));
var_elements.Bind(LoadObjectField(list, JSArray::kElementsOffset));
var_elements_kind.Bind(list_kind);
Branch(Int32LessThan(list_kind, Int32Constant(PACKED_DOUBLE_ELEMENTS)),
TNode<Object> iterator_fn =
GetProperty(context, spread, IteratorSymbolConstant());
GotoIfNot(TaggedIsCallable(iterator_fn), &if_iterator_fn_not_callable);
TNode<JSArray> list = CAST(
CallBuiltin(Builtins::kIterableToList, context, spread, iterator_fn));
var_length = LoadAndUntagToWord32ObjectField(list, JSArray::kLengthOffset);
var_elements = LoadElements(list);
var_elements_kind = LoadElementsKind(list);
Branch(Int32LessThan(var_elements_kind.value(),
Int32Constant(PACKED_DOUBLE_ELEMENTS)),
&if_smiorobject, &if_double);
BIND(&if_iterator_fn_not_callable);
......@@ -327,8 +330,8 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
BIND(&if_smiorobject);
{
Node* const elements = var_elements.value();
Node* const length = var_length.value();
TNode<FixedArrayBase> elements = var_elements.value();
TNode<Int32T> length = var_length.value();
if (new_target == nullptr) {
Callable callable = CodeFactory::CallVarargs(isolate());
......@@ -342,29 +345,29 @@ void CallOrConstructBuiltinsAssembler::CallOrConstructWithSpread(
BIND(&if_double);
{
Node* const elements_kind = var_elements_kind.value();
Node* const elements = var_elements.value();
Node* const length = var_length.value();
CallOrConstructDoubleVarargs(target, new_target, elements, length,
args_count, context, elements_kind);
CallOrConstructDoubleVarargs(target, new_target, CAST(var_elements.value()),
var_length.value(), args_count, context,
var_elements_kind.value());
}
}
TF_BUILTIN(CallWithArrayLike, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(CallWithArrayLikeDescriptor::kTarget);
Node* new_target = nullptr;
Node* arguments_list = Parameter(CallWithArrayLikeDescriptor::kArgumentsList);
Node* context = Parameter(CallWithArrayLikeDescriptor::kContext);
TNode<Object> target = CAST(Parameter(CallWithArrayLikeDescriptor::kTarget));
SloppyTNode<Object> new_target = nullptr;
TNode<Object> arguments_list =
CAST(Parameter(CallWithArrayLikeDescriptor::kArgumentsList));
TNode<Context> context =
CAST(Parameter(CallWithArrayLikeDescriptor::kContext));
CallOrConstructWithArrayLike(target, new_target, arguments_list, context);
}
TF_BUILTIN(CallWithSpread, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(CallWithSpreadDescriptor::kTarget);
Node* new_target = nullptr;
Node* spread = Parameter(CallWithSpreadDescriptor::kSpread);
Node* args_count = Parameter(CallWithSpreadDescriptor::kArgumentsCount);
Node* context = Parameter(CallWithSpreadDescriptor::kContext);
TNode<Object> target = CAST(Parameter(CallWithSpreadDescriptor::kTarget));
SloppyTNode<Object> new_target = nullptr;
TNode<Object> spread = CAST(Parameter(CallWithSpreadDescriptor::kSpread));
TNode<Int32T> args_count = UncheckedCast<Int32T>(
Parameter(CallWithSpreadDescriptor::kArgumentsCount));
TNode<Context> context = CAST(Parameter(CallWithSpreadDescriptor::kContext));
CallOrConstructWithSpread(target, new_target, spread, args_count, context);
}
......
......@@ -15,14 +15,19 @@ class CallOrConstructBuiltinsAssembler : public CodeStubAssembler {
explicit CallOrConstructBuiltinsAssembler(compiler::CodeAssemblerState* state)
: CodeStubAssembler(state) {}
void CallOrConstructWithArrayLike(Node* target, Node* new_target,
Node* arguments_list, Node* context);
void CallOrConstructDoubleVarargs(Node* target, Node* new_target,
Node* elements, Node* length,
Node* args_count, Node* context,
Node* kind);
void CallOrConstructWithSpread(Node* target, Node* new_target, Node* spread,
Node* args_count, Node* context);
void CallOrConstructWithArrayLike(TNode<Object> target,
SloppyTNode<Object> new_target,
TNode<Object> arguments_list,
TNode<Context> context);
void CallOrConstructDoubleVarargs(TNode<Object> target,
SloppyTNode<Object> new_target,
TNode<FixedDoubleArray> elements,
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
......
......@@ -221,7 +221,7 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromFastJSArray(
TNode<Object> collection, TNode<JSArray> fast_jsarray,
Label* if_may_have_side_effects) {
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);
CSA_ASSERT(
this,
......@@ -530,7 +530,7 @@ void BaseCollectionsAssembler::LoadKeyValue(
TNode<JSArray> array = CAST(maybe_array);
TNode<Smi> length = LoadFastJSArrayLength(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);
Branch(IsFastSmiOrTaggedElementsKind(elements_kind), &if_smiorobjects,
......
......@@ -36,20 +36,28 @@ void Builtins::Generate_ConstructFunctionForwardVarargs(MacroAssembler* masm) {
}
TF_BUILTIN(ConstructWithArrayLike, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(ConstructWithArrayLikeDescriptor::kTarget);
Node* new_target = Parameter(ConstructWithArrayLikeDescriptor::kNewTarget);
Node* arguments_list =
Parameter(ConstructWithArrayLikeDescriptor::kArgumentsList);
Node* context = Parameter(ConstructWithArrayLikeDescriptor::kContext);
TNode<Object> target =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kTarget));
SloppyTNode<Object> new_target =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kNewTarget));
TNode<Object> arguments_list =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kArgumentsList));
TNode<Context> context =
CAST(Parameter(ConstructWithArrayLikeDescriptor::kContext));
CallOrConstructWithArrayLike(target, new_target, arguments_list, context);
}
TF_BUILTIN(ConstructWithSpread, CallOrConstructBuiltinsAssembler) {
Node* target = Parameter(ConstructWithSpreadDescriptor::kTarget);
Node* new_target = Parameter(ConstructWithSpreadDescriptor::kNewTarget);
Node* spread = Parameter(ConstructWithSpreadDescriptor::kSpread);
Node* args_count = Parameter(ConstructWithSpreadDescriptor::kArgumentsCount);
Node* context = Parameter(ConstructWithSpreadDescriptor::kContext);
TNode<Object> target =
CAST(Parameter(ConstructWithSpreadDescriptor::kTarget));
SloppyTNode<Object> new_target =
CAST(Parameter(ConstructWithSpreadDescriptor::kNewTarget));
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);
}
......
......@@ -589,8 +589,8 @@ void TypedArrayBuiltinsAssembler::ConstructByArrayLike(
BIND(&fill);
GotoIf(SmiEqual(length, SmiConstant(0)), &done);
TNode<Int32T> holder_kind = LoadMapElementsKind(LoadMap(holder));
TNode<Int32T> source_kind = LoadMapElementsKind(LoadMap(array_like));
TNode<Int32T> holder_kind = LoadElementsKind(holder);
TNode<Int32T> source_kind = LoadElementsKind(array_like);
GotoIf(Word32Equal(holder_kind, source_kind), &fast_copy);
// Copy using the elements accessor.
......@@ -854,11 +854,6 @@ TNode<Word32T> TypedArrayBuiltinsAssembler::IsBigInt64ElementsKind(
Word32Equal(kind, Int32Constant(BIGUINT64_ELEMENTS)));
}
TNode<Word32T> TypedArrayBuiltinsAssembler::LoadElementsKind(
TNode<JSTypedArray> typed_array) {
return LoadMapElementsKind(LoadMap(typed_array));
}
TNode<IntPtrT> TypedArrayBuiltinsAssembler::GetTypedArrayElementSize(
TNode<Word32T> elements_kind) {
TVARIABLE(IntPtrT, element_size);
......@@ -1105,7 +1100,7 @@ void TypedArrayBuiltinsAssembler::SetJSArraySource(
};
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,
arraysize(values));
}
......@@ -1528,7 +1523,7 @@ TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) {
// performance.
BIND(&if_receiverisheapobject);
Node* elements_kind =
Int32Sub(LoadMapElementsKind(LoadMap(receiver)),
Int32Sub(LoadElementsKind(receiver),
Int32Constant(FIRST_FIXED_TYPED_ARRAY_ELEMENTS_KIND));
Switch(elements_kind, &return_undefined, elements_kinds, elements_kind_labels,
kTypedElementsKindCount);
......
......@@ -67,9 +67,6 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
// Returns true if kind is either BIGINT64_ELEMENTS or BIGUINT64_ELEMENTS.
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.
TNode<IntPtrT> GetTypedArrayElementSize(TNode<Word32T> elements_kind);
......
......@@ -1428,7 +1428,7 @@ TNode<Number> CodeStubAssembler::LoadJSArrayLength(SloppyTNode<JSArray> array) {
TNode<Smi> CodeStubAssembler::LoadFastJSArrayLength(
SloppyTNode<JSArray> 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.
CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length));
return UncheckedCast<Smi>(length);
......@@ -1495,6 +1495,11 @@ TNode<Int32T> CodeStubAssembler::LoadMapElementsKind(SloppyTNode<Map> map) {
return Signed(DecodeWord32<Map::ElementsKindBits>(bit_field2));
}
TNode<Int32T> CodeStubAssembler::LoadElementsKind(
SloppyTNode<HeapObject> object) {
return LoadMapElementsKind(LoadMap(object));
}
TNode<DescriptorArray> CodeStubAssembler::LoadMapDescriptors(
SloppyTNode<Map> map) {
CSA_SLOW_ASSERT(this, IsMap(map));
......
......@@ -623,6 +623,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
TNode<Int32T> LoadMapInstanceType(SloppyTNode<Map> map);
// Load the ElementsKind of a map.
TNode<Int32T> LoadMapElementsKind(SloppyTNode<Map> map);
TNode<Int32T> LoadElementsKind(SloppyTNode<HeapObject> map);
// Load the instance descriptors of a map.
TNode<DescriptorArray> LoadMapDescriptors(SloppyTNode<Map> 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