js-create-lowering.h 5.45 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2016 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.

#ifndef V8_COMPILER_JS_CREATE_LOWERING_H_
#define V8_COMPILER_JS_CREATE_LOWERING_H_

8
#include "src/base/compiler-specific.h"
9
#include "src/common/globals.h"
10 11 12 13 14 15
#include "src/compiler/graph-reducer.h"

namespace v8 {
namespace internal {

// Forward declarations.
16
class AllocationSiteUsageContext;
17
class Factory;
18
class JSRegExp;
19 20 21 22 23

namespace compiler {

// Forward declarations.
class CommonOperatorBuilder;
24
class CompilationDependencies;
25 26 27 28
class JSGraph;
class JSOperatorBuilder;
class MachineOperatorBuilder;
class SimplifiedOperatorBuilder;
29
class SlackTrackingPrediction;
30 31

// Lowers JSCreate-level operators to fast (inline) allocations.
32 33
class V8_EXPORT_PRIVATE JSCreateLowering final
    : public NON_EXPORTED_BASE(AdvancedReducer) {
34 35
 public:
  JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
36
                   JSGraph* jsgraph, JSHeapBroker* broker, Zone* zone)
37 38
      : AdvancedReducer(editor),
        dependencies_(dependencies),
39
        jsgraph_(jsgraph),
40
        broker_(broker),
41
        zone_(zone) {}
42
  ~JSCreateLowering() final = default;
43

44 45
  const char* reducer_name() const override { return "JSCreateLowering"; }

46 47 48 49 50 51
  Reduction Reduce(Node* node) final;

 private:
  Reduction ReduceJSCreate(Node* node);
  Reduction ReduceJSCreateArguments(Node* node);
  Reduction ReduceJSCreateArray(Node* node);
52
  Reduction ReduceJSCreateArrayIterator(Node* node);
53
  Reduction ReduceJSCreateAsyncFunctionObject(Node* node);
54
  Reduction ReduceJSCreateCollectionIterator(Node* node);
55
  Reduction ReduceJSCreateBoundFunction(Node* node);
56
  Reduction ReduceJSCreateClosure(Node* node);
57
  Reduction ReduceJSCreateIterResultObject(Node* node);
58
  Reduction ReduceJSCreateStringIterator(Node* node);
59
  Reduction ReduceJSCreateKeyValueArray(Node* node);
60
  Reduction ReduceJSCreatePromise(Node* node);
61
  Reduction ReduceJSCreateLiteralArrayOrObject(Node* node);
62 63
  Reduction ReduceJSCreateEmptyLiteralObject(Node* node);
  Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
64
  Reduction ReduceJSCreateLiteralRegExp(Node* node);
65 66 67 68
  Reduction ReduceJSCreateFunctionContext(Node* node);
  Reduction ReduceJSCreateWithContext(Node* node);
  Reduction ReduceJSCreateCatchContext(Node* node);
  Reduction ReduceJSCreateBlockContext(Node* node);
69
  Reduction ReduceJSCreateGeneratorObject(Node* node);
70
  Reduction ReduceJSGetTemplateObject(Node* node);
71
  Reduction ReduceNewArray(
72
      Node* node, Node* length, MapRef initial_map, ElementsKind elements_kind,
73
      AllocationType allocation,
74 75 76
      const SlackTrackingPrediction& slack_tracking_prediction);
  Reduction ReduceNewArray(
      Node* node, Node* length, int capacity, MapRef initial_map,
77
      ElementsKind elements_kind, AllocationType allocation,
78 79 80
      const SlackTrackingPrediction& slack_tracking_prediction);
  Reduction ReduceNewArray(
      Node* node, std::vector<Node*> values, MapRef initial_map,
81
      ElementsKind elements_kind, AllocationType allocation,
82
      const SlackTrackingPrediction& slack_tracking_prediction);
83
  Reduction ReduceJSCreateObject(Node* node);
84 85 86 87 88

  Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
  Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
                              int start_index);
  Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
89 90
                                 Node* context,
                                 const SharedFunctionInfoRef& shared,
91
                                 bool* has_aliased_arguments);
92 93
  Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context,
                                 Node* arguments_frame, Node* arguments_length,
94
                                 const SharedFunctionInfoRef& shared,
95
                                 bool* has_aliased_arguments);
96 97
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, int capacity,
98
                         AllocationType allocation);
99 100
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind, Node* capacity_and_length);
101 102 103
  Node* AllocateElements(Node* effect, Node* control,
                         ElementsKind elements_kind,
                         std::vector<Node*> const& values,
104
                         AllocationType allocation);
105
  Node* AllocateFastLiteral(Node* effect, Node* control,
106
                            JSObjectRef boilerplate, AllocationType allocation);
107
  Node* AllocateFastLiteralElements(Node* effect, Node* control,
108
                                    JSObjectRef boilerplate,
109
                                    AllocationType allocation);
110
  Node* AllocateLiteralRegExp(Node* effect, Node* control,
111
                              JSRegExpRef boilerplate);
112

113 114 115
  Factory* factory() const;
  Graph* graph() const;
  JSGraph* jsgraph() const { return jsgraph_; }
116
  NativeContextRef native_context() const;
117 118 119
  CommonOperatorBuilder* common() const;
  SimplifiedOperatorBuilder* simplified() const;
  CompilationDependencies* dependencies() const { return dependencies_; }
120
  JSHeapBroker* broker() const { return broker_; }
121
  Zone* zone() const { return zone_; }
122 123 124

  CompilationDependencies* const dependencies_;
  JSGraph* const jsgraph_;
125
  JSHeapBroker* const broker_;
126
  Zone* const zone_;
127 128 129 130 131 132 133
};

}  // namespace compiler
}  // namespace internal
}  // namespace v8

#endif  // V8_COMPILER_JS_CREATE_LOWERING_H_