Commit bb0d4eda authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[csa] TNodify builtins-arguments-gen and remove ParameterMode

Bug: v8:9708, v8:9396
Change-Id: Id957a937a6801292dd31972dd16b188951aa05c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1803350Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63780}
parent 45b05f31
...@@ -17,38 +17,34 @@ ...@@ -17,38 +17,34 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
using Node = compiler::Node; ArgumentsBuiltinsAssembler::ArgumentsAllocationResult
ArgumentsBuiltinsAssembler::AllocateArgumentsObject(
std::tuple<Node*, Node*, Node*> TNode<Map> map, TNode<BInt> arguments_count,
ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map, TNode<BInt> parameter_map_count, int base_size) {
Node* arguments_count,
Node* parameter_map_count,
ParameterMode mode,
int base_size) {
// Allocate the parameter object (either a Rest parameter object, a strict // Allocate the parameter object (either a Rest parameter object, a strict
// argument object or a sloppy arguments object) and the elements/mapped // argument object or a sloppy arguments object) and the elements/mapped
// arguments together. // arguments together.
int elements_offset = base_size; int elements_offset = base_size;
Node* element_count = arguments_count; TNode<BInt> element_count = arguments_count;
if (parameter_map_count != nullptr) { if (parameter_map_count != nullptr) {
base_size += FixedArray::kHeaderSize; base_size += FixedArray::kHeaderSize;
element_count = IntPtrOrSmiAdd(element_count, parameter_map_count, mode); element_count = IntPtrOrSmiAdd(element_count, parameter_map_count);
} }
bool empty = IsIntPtrOrSmiConstantZero(arguments_count, mode); bool empty = IsIntPtrOrSmiConstantZero(arguments_count);
DCHECK_IMPLIES(empty, parameter_map_count == nullptr); DCHECK_IMPLIES(empty, parameter_map_count == nullptr);
TNode<IntPtrT> size = TNode<IntPtrT> size =
empty ? IntPtrConstant(base_size) empty ? IntPtrConstant(base_size)
: ElementOffsetFromIndex(element_count, PACKED_ELEMENTS, mode, : ElementOffsetFromIndex(element_count, PACKED_ELEMENTS,
base_size + FixedArray::kHeaderSize); base_size + FixedArray::kHeaderSize);
TNode<HeapObject> result = Allocate(size); TNode<HeapObject> result = Allocate(size);
Comment("Initialize arguments object"); Comment("Initialize arguments object");
StoreMapNoWriteBarrier(result, map); StoreMapNoWriteBarrier(result, map);
TNode<FixedArray> empty_fixed_array = EmptyFixedArrayConstant(); TNode<FixedArray> empty_fixed_array = EmptyFixedArrayConstant();
StoreObjectField(result, JSArray::kPropertiesOrHashOffset, empty_fixed_array); StoreObjectField(result, JSArray::kPropertiesOrHashOffset, empty_fixed_array);
TNode<Smi> smi_arguments_count = ParameterToTagged(arguments_count, mode); TNode<Smi> smi_arguments_count = BIntToSmi(arguments_count);
StoreObjectFieldNoWriteBarrier(result, JSArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(result, JSArray::kLengthOffset,
smi_arguments_count); smi_arguments_count);
Node* arguments = nullptr; TNode<HeapObject> arguments;
if (!empty) { if (!empty) {
arguments = InnerAllocate(result, elements_offset); arguments = InnerAllocate(result, elements_offset);
StoreObjectFieldNoWriteBarrier(arguments, FixedArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(arguments, FixedArray::kLengthOffset,
...@@ -56,18 +52,17 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map, ...@@ -56,18 +52,17 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map,
TNode<Map> fixed_array_map = FixedArrayMapConstant(); TNode<Map> fixed_array_map = FixedArrayMapConstant();
StoreMapNoWriteBarrier(arguments, fixed_array_map); StoreMapNoWriteBarrier(arguments, fixed_array_map);
} }
Node* parameter_map = nullptr; TNode<HeapObject> parameter_map;
if (parameter_map_count != nullptr) { if (!parameter_map_count.is_null()) {
TNode<IntPtrT> parameter_map_offset = ElementOffsetFromIndex( TNode<IntPtrT> parameter_map_offset = ElementOffsetFromIndex(
arguments_count, PACKED_ELEMENTS, mode, FixedArray::kHeaderSize); arguments_count, PACKED_ELEMENTS, FixedArray::kHeaderSize);
parameter_map = InnerAllocate(CAST(arguments), parameter_map_offset); parameter_map = InnerAllocate(arguments, parameter_map_offset);
StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset, StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset,
parameter_map); parameter_map);
TNode<Map> sloppy_elements_map = SloppyArgumentsElementsMapConstant(); TNode<Map> sloppy_elements_map = SloppyArgumentsElementsMapConstant();
StoreMapNoWriteBarrier(parameter_map, sloppy_elements_map); StoreMapNoWriteBarrier(parameter_map, sloppy_elements_map);
parameter_map_count = ParameterToTagged(parameter_map_count, mode);
StoreObjectFieldNoWriteBarrier(parameter_map, FixedArray::kLengthOffset, StoreObjectFieldNoWriteBarrier(parameter_map, FixedArray::kLengthOffset,
parameter_map_count); BIntToSmi(parameter_map_count));
} else { } else {
if (empty) { if (empty) {
StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset, StoreObjectFieldNoWriteBarrier(result, JSArray::kElementsOffset,
...@@ -77,23 +72,19 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map, ...@@ -77,23 +72,19 @@ ArgumentsBuiltinsAssembler::AllocateArgumentsObject(Node* map,
arguments); arguments);
} }
} }
return std::tuple<Node*, Node*, Node*>(result, arguments, parameter_map); return {CAST(result), UncheckedCast<FixedArray>(arguments),
UncheckedCast<FixedArray>(parameter_map)};
} }
Node* ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs( TNode<JSObject> ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs(
TNode<Map> map, TNode<RawPtrT> frame_ptr, TNode<BInt> arg_count, TNode<Map> map, TNode<RawPtrT> frame_ptr, TNode<BInt> arg_count,
TNode<BInt> first_arg, TNode<BInt> rest_count, ParameterMode param_mode, TNode<BInt> first_arg, TNode<BInt> rest_count, int base_size) {
int base_size) {
DCHECK_EQ(param_mode, OptimalParameterMode());
// Allocate the parameter object (either a Rest parameter object, a strict // Allocate the parameter object (either a Rest parameter object, a strict
// argument object or a sloppy arguments object) and the elements together and // argument object or a sloppy arguments object) and the elements together and
// fill in the contents with the arguments above |formal_parameter_count|. // fill in the contents with the arguments above |formal_parameter_count|.
Node* result; ArgumentsAllocationResult alloc_result =
Node* elements; AllocateArgumentsObject(map, rest_count, {}, base_size);
Node* unused; DCHECK(alloc_result.parameter_map.is_null());
std::tie(result, elements, unused) =
AllocateArgumentsObject(map, rest_count, nullptr, param_mode, base_size);
DCHECK_NULL(unused);
CodeStubArguments arguments(this, arg_count, frame_ptr); CodeStubArguments arguments(this, arg_count, frame_ptr);
TVARIABLE(IntPtrT, offset, TVARIABLE(IntPtrT, offset,
IntPtrConstant(FixedArrayBase::kHeaderSize - kHeapObjectTag)); IntPtrConstant(FixedArrayBase::kHeaderSize - kHeapObjectTag));
...@@ -101,23 +92,22 @@ Node* ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs( ...@@ -101,23 +92,22 @@ Node* ArgumentsBuiltinsAssembler::ConstructParametersObjectFromArgs(
arguments.ForEach( arguments.ForEach(
list, list,
[&](TNode<Object> arg) { [&](TNode<Object> arg) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, StoreNoWriteBarrier(MachineRepresentation::kTagged,
offset.value(), arg); alloc_result.elements, offset.value(), arg);
Increment(&offset, kTaggedSize); Increment(&offset, kTaggedSize);
}, },
first_arg); first_arg);
return result; return alloc_result.arguments_object;
} }
Node* ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(Node* context, TNode<JSObject> ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(
Node* function) { TNode<Context> context, TNode<JSFunction> function) {
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
Node* zero = IntPtrOrSmiConstant(0, mode); TNode<BInt> zero = BIntConstant(0);
TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount( TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount(context, function);
CAST(context), UncheckedCast<JSFunction>(function));
VARIABLE(result, MachineRepresentation::kTagged); TVARIABLE(JSObject, result);
Label no_rest_parameters(this), runtime(this, Label::kDeferred), Label no_rest_parameters(this), runtime(this, Label::kDeferred),
done(this, &result); done(this, &result);
...@@ -126,33 +116,29 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(Node* context, ...@@ -126,33 +116,29 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(Node* context,
TNode<NativeContext> const native_context = LoadNativeContext(context); TNode<NativeContext> const native_context = LoadNativeContext(context);
TNode<Map> const array_map = TNode<Map> const array_map =
LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context); LoadJSArrayElementsMap(PACKED_ELEMENTS, native_context);
GotoIf(IntPtrOrSmiLessThanOrEqual(rest_count, zero, mode), GotoIf(IntPtrOrSmiLessThanOrEqual(rest_count, zero), &no_rest_parameters);
&no_rest_parameters);
GotoIfFixedArraySizeDoesntFitInNewSpace( GotoIfFixedArraySizeDoesntFitInNewSpace(
rest_count, &runtime, JSArray::kSize + FixedArray::kHeaderSize, mode); rest_count, &runtime, JSArray::kSize + FixedArray::kHeaderSize, mode);
// Allocate the Rest JSArray and the elements together and fill in the // Allocate the Rest JSArray and the elements together and fill in the
// contents with the arguments above |formal_parameter_count|. // contents with the arguments above |formal_parameter_count|.
result.Bind(ConstructParametersObjectFromArgs( result = ConstructParametersObjectFromArgs(
array_map, info.frame, info.argument_count, info.formal_parameter_count, array_map, info.frame, info.argument_count, info.formal_parameter_count,
rest_count, mode, JSArray::kSize)); rest_count, JSArray::kSize);
Goto(&done); Goto(&done);
BIND(&no_rest_parameters); BIND(&no_rest_parameters);
{ {
Node* arguments; ArgumentsAllocationResult alloc_result =
Node* elements; AllocateArgumentsObject(array_map, zero, {}, JSArray::kSize);
Node* unused; result = alloc_result.arguments_object;
std::tie(arguments, elements, unused) =
AllocateArgumentsObject(array_map, zero, nullptr, mode, JSArray::kSize);
result.Bind(arguments);
Goto(&done); Goto(&done);
} }
BIND(&runtime); BIND(&runtime);
{ {
result.Bind(CallRuntime(Runtime::kNewRestParameter, context, function)); result = CAST(CallRuntime(Runtime::kNewRestParameter, context, function));
Goto(&done); Goto(&done);
} }
...@@ -160,16 +146,15 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(Node* context, ...@@ -160,16 +146,15 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewRestParameter(Node* context,
return result.value(); return result.value();
} }
Node* ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(Node* context, TNode<JSObject> ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(
Node* function) { TNode<Context> context, TNode<JSFunction> function) {
VARIABLE(result, MachineRepresentation::kTagged); TVARIABLE(JSObject, result);
Label done(this, &result), empty(this), runtime(this, Label::kDeferred); Label done(this, &result), empty(this), runtime(this, Label::kDeferred);
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
TNode<BInt> zero = BIntConstant(0); TNode<BInt> zero = BIntConstant(0);
TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount( TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount(context, function);
CAST(context), UncheckedCast<JSFunction>(function));
GotoIfFixedArraySizeDoesntFitInNewSpace( GotoIfFixedArraySizeDoesntFitInNewSpace(
info.argument_count, &runtime, info.argument_count, &runtime,
...@@ -180,25 +165,22 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(Node* context, ...@@ -180,25 +165,22 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(Node* context,
LoadContextElement(native_context, Context::STRICT_ARGUMENTS_MAP_INDEX)); LoadContextElement(native_context, Context::STRICT_ARGUMENTS_MAP_INDEX));
GotoIf(BIntEqual(info.argument_count, zero), &empty); GotoIf(BIntEqual(info.argument_count, zero), &empty);
result.Bind(ConstructParametersObjectFromArgs( result = ConstructParametersObjectFromArgs(
map, info.frame, info.argument_count, zero, info.argument_count, mode, map, info.frame, info.argument_count, zero, info.argument_count,
JSStrictArgumentsObject::kSize)); JSStrictArgumentsObject::kSize);
Goto(&done); Goto(&done);
BIND(&empty); BIND(&empty);
{ {
Node* arguments; ArgumentsAllocationResult alloc_result =
Node* elements; AllocateArgumentsObject(map, zero, {}, JSStrictArgumentsObject::kSize);
Node* unused; result = alloc_result.arguments_object;
std::tie(arguments, elements, unused) = AllocateArgumentsObject(
map, zero, nullptr, mode, JSStrictArgumentsObject::kSize);
result.Bind(arguments);
Goto(&done); Goto(&done);
} }
BIND(&runtime); BIND(&runtime);
{ {
result.Bind(CallRuntime(Runtime::kNewStrictArguments, context, function)); result = CAST(CallRuntime(Runtime::kNewStrictArguments, context, function));
Goto(&done); Goto(&done);
} }
...@@ -206,9 +188,9 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(Node* context, ...@@ -206,9 +188,9 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewStrictArguments(Node* context,
return result.value(); return result.value();
} }
Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, TNode<JSObject> ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(
Node* function) { TNode<Context> context, TNode<JSFunction> function) {
VARIABLE(result, MachineRepresentation::kTagged); TVARIABLE(JSObject, result);
ParameterMode mode = OptimalParameterMode(); ParameterMode mode = OptimalParameterMode();
TNode<BInt> zero = BIntConstant(0); TNode<BInt> zero = BIntConstant(0);
...@@ -216,8 +198,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -216,8 +198,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
Label done(this, &result), empty(this), no_parameters(this), Label done(this, &result), empty(this), no_parameters(this),
runtime(this, Label::kDeferred); runtime(this, Label::kDeferred);
TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount( TorqueStructArgumentsInfo info = GetArgumentsFrameAndCount(context, function);
CAST(context), UncheckedCast<JSFunction>(function));
GotoIf(BIntEqual(info.argument_count, zero), &empty); GotoIf(BIntEqual(info.argument_count, zero), &empty);
...@@ -240,18 +221,18 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -240,18 +221,18 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
JSSloppyArgumentsObject::kSize + FixedArray::kHeaderSize * 2, mode); JSSloppyArgumentsObject::kSize + FixedArray::kHeaderSize * 2, mode);
TNode<NativeContext> const native_context = LoadNativeContext(context); TNode<NativeContext> const native_context = LoadNativeContext(context);
TNode<Object> const map = LoadContextElement( TNode<Map> const map = CAST(LoadContextElement(
native_context, Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX); native_context, Context::FAST_ALIASED_ARGUMENTS_MAP_INDEX));
Node* argument_object; ArgumentsAllocationResult alloc_result =
Node* elements;
Node* map_array;
std::tie(argument_object, elements, map_array) =
AllocateArgumentsObject(map, info.argument_count, parameter_map_size, AllocateArgumentsObject(map, info.argument_count, parameter_map_size,
mode, JSSloppyArgumentsObject::kSize); JSSloppyArgumentsObject::kSize);
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(alloc_result.arguments_object,
argument_object, JSSloppyArgumentsObject::kCalleeOffset, function); JSSloppyArgumentsObject::kCalleeOffset,
StoreFixedArrayElement(CAST(map_array), 0, context, SKIP_WRITE_BARRIER); function);
StoreFixedArrayElement(CAST(map_array), 1, elements, SKIP_WRITE_BARRIER); StoreFixedArrayElement(alloc_result.parameter_map, 0, context,
SKIP_WRITE_BARRIER);
StoreFixedArrayElement(alloc_result.parameter_map, 1, alloc_result.elements,
SKIP_WRITE_BARRIER);
Comment("Fill in non-mapped parameters"); Comment("Fill in non-mapped parameters");
TNode<IntPtrT> argument_offset = TNode<IntPtrT> argument_offset =
...@@ -270,8 +251,8 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -270,8 +251,8 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
Increment(&current_argument, kSystemPointerSize); Increment(&current_argument, kSystemPointerSize);
TNode<Object> arg = LoadBufferObject( TNode<Object> arg = LoadBufferObject(
ReinterpretCast<RawPtrT>(current_argument.value()), 0); ReinterpretCast<RawPtrT>(current_argument.value()), 0);
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged,
arg); alloc_result.elements, offset, arg);
return; return;
}, },
-kTaggedSize); -kTaggedSize);
...@@ -294,15 +275,15 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -294,15 +275,15 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
VariableList var_list2({&context_index}, zone()); VariableList var_list2({&context_index}, zone());
const int kParameterMapHeaderSize = FixedArray::OffsetOfElementAt(2); const int kParameterMapHeaderSize = FixedArray::OffsetOfElementAt(2);
TNode<IntPtrT> adjusted_map_array = IntPtrAdd( TNode<IntPtrT> adjusted_map_array = IntPtrAdd(
BitcastTaggedToWord(map_array), BitcastTaggedToWord(alloc_result.parameter_map),
IntPtrConstant(kParameterMapHeaderSize - FixedArray::kHeaderSize)); IntPtrConstant(kParameterMapHeaderSize - FixedArray::kHeaderSize));
TNode<IntPtrT> zero_offset = ElementOffsetFromIndex( TNode<IntPtrT> zero_offset = ElementOffsetFromIndex(
zero, PACKED_ELEMENTS, mode, FixedArray::kHeaderSize - kHeapObjectTag); zero, PACKED_ELEMENTS, mode, FixedArray::kHeaderSize - kHeapObjectTag);
BuildFastLoop<IntPtrT>( BuildFastLoop<IntPtrT>(
var_list2, mapped_offset, zero_offset, var_list2, mapped_offset, zero_offset,
[&](TNode<IntPtrT> offset) { [&](TNode<IntPtrT> offset) {
StoreNoWriteBarrier(MachineRepresentation::kTagged, elements, offset, StoreNoWriteBarrier(MachineRepresentation::kTagged,
the_hole); alloc_result.elements, offset, the_hole);
StoreNoWriteBarrier(MachineRepresentation::kTagged, StoreNoWriteBarrier(MachineRepresentation::kTagged,
adjusted_map_array, offset, adjusted_map_array, offset,
BIntToSmi(context_index.value())); BIntToSmi(context_index.value()));
...@@ -310,7 +291,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -310,7 +291,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
}, },
-kTaggedSize); -kTaggedSize);
result.Bind(argument_object); result = alloc_result.arguments_object;
Goto(&done); Goto(&done);
} }
...@@ -323,9 +304,9 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -323,9 +304,9 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
TNode<NativeContext> const native_context = LoadNativeContext(context); TNode<NativeContext> const native_context = LoadNativeContext(context);
TNode<Map> map = CAST(LoadContextElement( TNode<Map> map = CAST(LoadContextElement(
native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX)); native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
result.Bind(ConstructParametersObjectFromArgs( result = ConstructParametersObjectFromArgs(
map, info.frame, info.argument_count, zero, info.argument_count, mode, map, info.frame, info.argument_count, zero, info.argument_count,
JSSloppyArgumentsObject::kSize)); JSSloppyArgumentsObject::kSize);
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
result.value(), JSSloppyArgumentsObject::kCalleeOffset, function); result.value(), JSSloppyArgumentsObject::kCalleeOffset, function);
Goto(&done); Goto(&done);
...@@ -335,14 +316,11 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -335,14 +316,11 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
{ {
Comment("Empty JSSloppyArgumentsObject"); Comment("Empty JSSloppyArgumentsObject");
TNode<NativeContext> const native_context = LoadNativeContext(context); TNode<NativeContext> const native_context = LoadNativeContext(context);
TNode<Object> const map = TNode<Map> const map = CAST(LoadContextElement(
LoadContextElement(native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX); native_context, Context::SLOPPY_ARGUMENTS_MAP_INDEX));
Node* arguments; ArgumentsAllocationResult alloc_result =
Node* elements; AllocateArgumentsObject(map, zero, {}, JSSloppyArgumentsObject::kSize);
Node* unused; result = alloc_result.arguments_object;
std::tie(arguments, elements, unused) = AllocateArgumentsObject(
map, zero, nullptr, mode, JSSloppyArgumentsObject::kSize);
result.Bind(arguments);
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
result.value(), JSSloppyArgumentsObject::kCalleeOffset, function); result.value(), JSSloppyArgumentsObject::kCalleeOffset, function);
Goto(&done); Goto(&done);
...@@ -350,7 +328,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context, ...@@ -350,7 +328,7 @@ Node* ArgumentsBuiltinsAssembler::EmitFastNewSloppyArguments(Node* context,
BIND(&runtime); BIND(&runtime);
{ {
result.Bind(CallRuntime(Runtime::kNewSloppyArguments, context, function)); result = CAST(CallRuntime(Runtime::kNewSloppyArguments, context, function));
Goto(&done); Goto(&done);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
namespace v8 { namespace v8 {
namespace internal { namespace internal {
using Node = compiler::Node; // TODO(v8:9396): these declarations pollute the v8::internal scope.
using CodeAssemblerState = compiler::CodeAssemblerState; using CodeAssemblerState = compiler::CodeAssemblerState;
using CodeAssemblerLabel = compiler::CodeAssemblerLabel; using CodeAssemblerLabel = compiler::CodeAssemblerLabel;
...@@ -19,19 +19,25 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler { ...@@ -19,19 +19,25 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state) explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
: CodeStubAssembler(state) {} : CodeStubAssembler(state) {}
Node* EmitFastNewStrictArguments(Node* context, Node* function); TNode<JSObject> EmitFastNewStrictArguments(TNode<Context> context,
Node* EmitFastNewSloppyArguments(Node* context, Node* function); TNode<JSFunction> function);
Node* EmitFastNewRestParameter(Node* context, Node* function); TNode<JSObject> EmitFastNewSloppyArguments(TNode<Context> context,
TNode<JSFunction> function);
TNode<JSObject> EmitFastNewRestParameter(TNode<Context> context,
TNode<JSFunction> function);
private: private:
struct ArgumentsAllocationResult {
TNode<JSObject> arguments_object;
TNode<FixedArray> elements;
TNode<FixedArray> parameter_map;
};
// Allocates an an arguments (either rest, strict or sloppy) together with the // Allocates an an arguments (either rest, strict or sloppy) together with the
// FixedArray elements for the arguments and a parameter map (for sloppy // FixedArray elements for the arguments and a parameter map (for sloppy
// arguments only). A tuple is returned with pointers to the arguments object, // arguments only, or empty TNode<> otherwise).
// the elements and parameter map in the form: ArgumentsAllocationResult AllocateArgumentsObject(
// <argument object, arguments FixedArray, parameter map or nullptr> TNode<Map> map, TNode<BInt> arguments, TNode<BInt> mapped_arguments,
std::tuple<Node*, Node*, Node*> AllocateArgumentsObject( int base_size);
Node* map, Node* arguments, Node* mapped_arguments,
ParameterMode param_mode, int base_size);
// For Rest parameters and Strict arguments, the copying of parameters from // For Rest parameters and Strict arguments, the copying of parameters from
// the stack into the arguments object is straight-forward and shares much of // the stack into the arguments object is straight-forward and shares much of
...@@ -40,10 +46,9 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler { ...@@ -40,10 +46,9 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
// and then copies |rest_count| arguments from the stack frame pointed to by // and then copies |rest_count| arguments from the stack frame pointed to by
// |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| + // |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| +
// |rest_count|. // |rest_count|.
Node* ConstructParametersObjectFromArgs( TNode<JSObject> ConstructParametersObjectFromArgs(
TNode<Map> map, TNode<RawPtrT> frame_ptr, TNode<BInt> arg_count, TNode<Map> map, TNode<RawPtrT> frame_ptr, TNode<BInt> arg_count,
TNode<BInt> first_arg, TNode<BInt> rest_count, ParameterMode param_mode, TNode<BInt> first_arg, TNode<BInt> rest_count, int base_size);
int base_size);
}; };
} // namespace internal } // namespace internal
......
...@@ -424,19 +424,29 @@ Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) { ...@@ -424,19 +424,29 @@ Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) {
} }
} }
bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test, bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(TNode<Smi> test) {
ParameterMode mode) {
int32_t constant_test;
Smi smi_test; Smi smi_test;
if (mode == INTPTR_PARAMETERS) { if (ToSmiConstant(test, &smi_test) && smi_test.value() == 0) {
return true;
}
return false;
}
bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(TNode<IntPtrT> test) {
int32_t constant_test;
if (ToInt32Constant(test, &constant_test) && constant_test == 0) { if (ToInt32Constant(test, &constant_test) && constant_test == 0) {
return true; return true;
} }
return false;
}
bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test,
ParameterMode mode) {
if (mode == INTPTR_PARAMETERS) {
return IsIntPtrOrSmiConstantZero(UncheckedCast<IntPtrT>(test));
} else { } else {
DCHECK_EQ(mode, SMI_PARAMETERS); DCHECK_EQ(mode, SMI_PARAMETERS);
if (ToSmiConstant(test, &smi_test) && smi_test.value() == 0) { return IsIntPtrOrSmiConstantZero(UncheckedCast<Smi>(test));
return true;
}
} }
return false; return false;
} }
......
...@@ -548,7 +548,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler ...@@ -548,7 +548,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// TODO(v8:9708): remove once all uses are ported. // TODO(v8:9708): remove once all uses are ported.
Node* IntPtrOrSmiConstant(int value, ParameterMode mode); Node* IntPtrOrSmiConstant(int value, ParameterMode mode);
bool IsIntPtrOrSmiConstantZero(TNode<Smi> test);
bool IsIntPtrOrSmiConstantZero(TNode<IntPtrT> test);
// TODO(v8:9708): remove once all uses are ported.
bool IsIntPtrOrSmiConstantZero(Node* test, ParameterMode mode); bool IsIntPtrOrSmiConstantZero(Node* test, ParameterMode mode);
bool TryGetIntPtrOrSmiConstantValue(Node* maybe_constant, int* value, bool TryGetIntPtrOrSmiConstantValue(Node* maybe_constant, int* value,
ParameterMode mode); ParameterMode mode);
......
...@@ -2851,9 +2851,9 @@ IGNITION_HANDLER(CreateMappedArguments, InterpreterAssembler) { ...@@ -2851,9 +2851,9 @@ IGNITION_HANDLER(CreateMappedArguments, InterpreterAssembler) {
// Creates a new unmapped arguments object. // Creates a new unmapped arguments object.
IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) { IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) {
TNode<Context> context = GetContext(); TNode<Context> context = GetContext();
TNode<Object> closure = LoadRegister(Register::function_closure()); TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure()));
ArgumentsBuiltinsAssembler builtins_assembler(state()); ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result = TNode<JSObject> result =
builtins_assembler.EmitFastNewStrictArguments(context, closure); builtins_assembler.EmitFastNewStrictArguments(context, closure);
SetAccumulator(result); SetAccumulator(result);
Dispatch(); Dispatch();
...@@ -2863,10 +2863,11 @@ IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) { ...@@ -2863,10 +2863,11 @@ IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) {
// //
// Creates a new rest parameter array. // Creates a new rest parameter array.
IGNITION_HANDLER(CreateRestParameter, InterpreterAssembler) { IGNITION_HANDLER(CreateRestParameter, InterpreterAssembler) {
TNode<Object> closure = LoadRegister(Register::function_closure()); TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure()));
TNode<Context> context = GetContext(); TNode<Context> context = GetContext();
ArgumentsBuiltinsAssembler builtins_assembler(state()); ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result = builtins_assembler.EmitFastNewRestParameter(context, closure); TNode<JSObject> result =
builtins_assembler.EmitFastNewRestParameter(context, closure);
SetAccumulator(result); SetAccumulator(result);
Dispatch(); Dispatch();
} }
......
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