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 @@ ...@@ -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(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, bool CodeStubAssembler::IsIntPtrOrSmiConstantZero(Node* test,
ParameterMode mode) { ParameterMode mode) {
int32_t constant_test;
Smi smi_test;
if (mode == INTPTR_PARAMETERS) { if (mode == INTPTR_PARAMETERS) {
if (ToInt32Constant(test, &constant_test) && constant_test == 0) { return IsIntPtrOrSmiConstantZero(UncheckedCast<IntPtrT>(test));
return true;
}
} 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