Line data Source code
1 : // Copyright 2017 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #ifndef V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_
6 : #define V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_
7 :
8 : #include "src/code-stub-assembler.h"
9 : #include "torque-generated/builtins-arguments-from-dsl-gen.h"
10 :
11 : namespace v8 {
12 : namespace internal {
13 :
14 : typedef compiler::Node Node;
15 : typedef compiler::CodeAssemblerState CodeAssemblerState;
16 : typedef compiler::CodeAssemblerLabel CodeAssemblerLabel;
17 :
18 336 : class ArgumentsBuiltinsAssembler : public CodeStubAssembler,
19 : public ArgumentsBuiltinsFromDSLAssembler {
20 : public:
21 : explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
22 168 : : CodeStubAssembler(state), ArgumentsBuiltinsFromDSLAssembler(state) {}
23 :
24 : Node* EmitFastNewStrictArguments(Node* context, Node* function);
25 : Node* EmitFastNewSloppyArguments(Node* context, Node* function);
26 : Node* EmitFastNewRestParameter(Node* context, Node* function);
27 :
28 : private:
29 : // Allocates an an arguments (either rest, strict or sloppy) together with the
30 : // FixedArray elements for the arguments and a parameter map (for sloppy
31 : // arguments only). A tuple is returned with pointers to the arguments object,
32 : // the elements and parameter map in the form:
33 : // <argument object, arguments FixedArray, parameter map or nullptr>
34 : std::tuple<Node*, Node*, Node*> AllocateArgumentsObject(
35 : Node* map, Node* arguments, Node* mapped_arguments,
36 : ParameterMode param_mode, int base_size);
37 :
38 : // For Rest parameters and Strict arguments, the copying of parameters from
39 : // the stack into the arguments object is straight-forward and shares much of
40 : // the same underlying logic, which is encapsulated by this function. It
41 : // allocates an arguments-like object of size |base_size| with the map |map|,
42 : // and then copies |rest_count| arguments from the stack frame pointed to by
43 : // |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| +
44 : // |rest_count|.
45 : Node* ConstructParametersObjectFromArgs(Node* map, Node* frame_ptr,
46 : Node* arg_count, Node* first_arg,
47 : Node* rest_count,
48 : ParameterMode param_mode,
49 : int base_size);
50 : };
51 :
52 : } // namespace internal
53 : } // namespace v8
54 :
55 : #endif // V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_
|