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
This diff is collapsed.
......@@ -10,7 +10,7 @@
namespace v8 {
namespace internal {
using Node = compiler::Node;
// TODO(v8:9396): these declarations pollute the v8::internal scope.
using CodeAssemblerState = compiler::CodeAssemblerState;
using CodeAssemblerLabel = compiler::CodeAssemblerLabel;
......@@ -19,19 +19,25 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
: CodeStubAssembler(state) {}
Node* EmitFastNewStrictArguments(Node* context, Node* function);
Node* EmitFastNewSloppyArguments(Node* context, Node* function);
Node* EmitFastNewRestParameter(Node* context, Node* function);
TNode<JSObject> EmitFastNewStrictArguments(TNode<Context> context,
TNode<JSFunction> function);
TNode<JSObject> EmitFastNewSloppyArguments(TNode<Context> context,
TNode<JSFunction> function);
TNode<JSObject> EmitFastNewRestParameter(TNode<Context> context,
TNode<JSFunction> function);
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
// FixedArray elements for the arguments and a parameter map (for sloppy
// arguments only). A tuple is returned with pointers to the arguments object,
// the elements and parameter map in the form:
// <argument object, arguments FixedArray, parameter map or nullptr>
std::tuple<Node*, Node*, Node*> AllocateArgumentsObject(
Node* map, Node* arguments, Node* mapped_arguments,
ParameterMode param_mode, int base_size);
// arguments only, or empty TNode<> otherwise).
ArgumentsAllocationResult AllocateArgumentsObject(
TNode<Map> map, TNode<BInt> arguments, TNode<BInt> mapped_arguments,
int base_size);
// For Rest parameters and Strict arguments, the copying of parameters from
// the stack into the arguments object is straight-forward and shares much of
......@@ -40,10 +46,9 @@ class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
// and then copies |rest_count| arguments from the stack frame pointed to by
// |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| +
// |rest_count|.
Node* ConstructParametersObjectFromArgs(
TNode<JSObject> ConstructParametersObjectFromArgs(
TNode<Map> map, TNode<RawPtrT> frame_ptr, TNode<BInt> arg_count,
TNode<BInt> first_arg, TNode<BInt> rest_count, ParameterMode param_mode,
int base_size);
TNode<BInt> first_arg, TNode<BInt> rest_count, int base_size);
};
} // namespace internal
......
......@@ -424,19 +424,29 @@ Node* CodeStubAssembler::IntPtrOrSmiConstant(int value, ParameterMode mode) {
}
}
bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(TNode<Smi> test) {
Smi smi_test;
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) {
return true;
}
return false;
}
bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test,
ParameterMode mode) {
int32_t constant_test;
Smi smi_test;
if (mode == INTPTR_PARAMETERS) {
if (ToInt32Constant(test, &constant_test) && constant_test == 0) {
return true;
}
return IsIntPtrOrSmiConstantZero(UncheckedCast<IntPtrT>(test));
} else {
DCHECK_EQ(mode, SMI_PARAMETERS);
if (ToSmiConstant(test, &smi_test) && smi_test.value() == 0) {
return true;
}
return IsIntPtrOrSmiConstantZero(UncheckedCast<Smi>(test));
}
return false;
}
......
......@@ -548,7 +548,11 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
// TODO(v8:9708): remove once all uses are ported.
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 TryGetIntPtrOrSmiConstantValue(Node* maybe_constant, int* value,
ParameterMode mode);
......
......@@ -2851,9 +2851,9 @@ IGNITION_HANDLER(CreateMappedArguments, InterpreterAssembler) {
// Creates a new unmapped arguments object.
IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) {
TNode<Context> context = GetContext();
TNode<Object> closure = LoadRegister(Register::function_closure());
TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure()));
ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result =
TNode<JSObject> result =
builtins_assembler.EmitFastNewStrictArguments(context, closure);
SetAccumulator(result);
Dispatch();
......@@ -2863,10 +2863,11 @@ IGNITION_HANDLER(CreateUnmappedArguments, InterpreterAssembler) {
//
// Creates a new rest parameter array.
IGNITION_HANDLER(CreateRestParameter, InterpreterAssembler) {
TNode<Object> closure = LoadRegister(Register::function_closure());
TNode<JSFunction> closure = CAST(LoadRegister(Register::function_closure()));
TNode<Context> context = GetContext();
ArgumentsBuiltinsAssembler builtins_assembler(state());
Node* result = builtins_assembler.EmitFastNewRestParameter(context, closure);
TNode<JSObject> result =
builtins_assembler.EmitFastNewRestParameter(context, closure);
SetAccumulator(result);
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