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 :
10 : namespace v8 {
11 : namespace internal {
12 :
13 : typedef compiler::Node Node;
14 : typedef compiler::CodeAssemblerState CodeAssemblerState;
15 : typedef compiler::CodeAssemblerLabel CodeAssemblerLabel;
16 :
17 : class ArgumentsBuiltinsAssembler : public CodeStubAssembler {
18 : public:
19 : explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
20 93 : : CodeStubAssembler(state) {}
21 :
22 : Node* EmitFastNewStrictArguments(Node* context, Node* function);
23 : Node* EmitFastNewSloppyArguments(Node* context, Node* function);
24 : Node* EmitFastNewRestParameter(Node* context, Node* function);
25 :
26 : private:
27 : // Calculates and returns the the frame pointer, argument count and formal
28 : // parameter count to be used to access a function's parameters, taking
29 : // argument adapter frames into account. The tuple is of the form:
30 : // <frame_ptr, # parameters actually passed, formal parameter count>
31 : std::tuple<Node*, Node*, Node*> GetArgumentsFrameAndCount(Node* function,
32 : ParameterMode mode);
33 :
34 : // Allocates an an arguments (either rest, strict or sloppy) together with the
35 : // FixedArray elements for the arguments and a parameter map (for sloppy
36 : // arguments only). A tuple is returned with pointers to the arguments object,
37 : // the elements and parameter map in the form:
38 : // <argument object, arguments FixedArray, parameter map or nullptr>
39 : std::tuple<Node*, Node*, Node*> AllocateArgumentsObject(
40 : Node* map, Node* arguments, Node* mapped_arguments,
41 : ParameterMode param_mode, int base_size);
42 :
43 : // For Rest parameters and Strict arguments, the copying of parameters from
44 : // the stack into the arguments object is straight-forward and shares much of
45 : // the same underlying logic, which is encapsulated by this function. It
46 : // allocates an arguments-like object of size |base_size| with the map |map|,
47 : // and then copies |rest_count| arguments from the stack frame pointed to by
48 : // |frame_ptr| starting from |first_arg|. |arg_count| == |first_arg| +
49 : // |rest_count|.
50 : Node* ConstructParametersObjectFromArgs(Node* map, Node* frame_ptr,
51 : Node* arg_count, Node* first_arg,
52 : Node* rest_count,
53 : ParameterMode param_mode,
54 : int base_size);
55 : };
56 :
57 : } // namespace internal
58 : } // namespace v8
59 :
60 : #endif // V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_
|