builtins-arguments-gen.h 2.42 KB
Newer Older
1 2 3 4
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7
#ifndef V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_
#define V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_

8
#include "src/code-stub-assembler.h"
9
#include "torque-generated/builtins-arguments-from-dsl-gen.h"
10 11 12 13 14 15 16 17

namespace v8 {
namespace internal {

typedef compiler::Node Node;
typedef compiler::CodeAssemblerState CodeAssemblerState;
typedef compiler::CodeAssemblerLabel CodeAssemblerLabel;

18 19
class ArgumentsBuiltinsAssembler : public CodeStubAssembler,
                                   public ArgumentsBuiltinsFromDSLAssembler {
20 21
 public:
  explicit ArgumentsBuiltinsAssembler(CodeAssemblerState* state)
22
      : CodeStubAssembler(state), ArgumentsBuiltinsFromDSLAssembler(state) {}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

  Node* EmitFastNewStrictArguments(Node* context, Node* function);
  Node* EmitFastNewSloppyArguments(Node* context, Node* function);
  Node* EmitFastNewRestParameter(Node* context, Node* function);

 private:
  // 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);

  // 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 same underlying logic, which is encapsulated by this function. It
  // allocates an arguments-like object of size |base_size| with the map |map|,
  // 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(Node* map, Node* frame_ptr,
                                          Node* arg_count, Node* first_arg,
                                          Node* rest_count,
                                          ParameterMode param_mode,
                                          int base_size);
};

}  // namespace internal
}  // namespace v8
54 55

#endif  // V8_BUILTINS_BUILTINS_ARGUMENTS_GEN_H_