• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_COMPILER_JS_CREATE_LOWERING_H_
6 #define V8_COMPILER_JS_CREATE_LOWERING_H_
7 
8 #include "src/base/compiler-specific.h"
9 #include "src/common/globals.h"
10 #include "src/compiler/graph-reducer.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 // Forward declarations.
16 class AllocationSiteUsageContext;
17 class Factory;
18 class JSRegExp;
19 
20 namespace compiler {
21 
22 // Forward declarations.
23 class CommonOperatorBuilder;
24 class CompilationDependencies;
25 class JSGraph;
26 class JSOperatorBuilder;
27 class MachineOperatorBuilder;
28 class SimplifiedOperatorBuilder;
29 class SlackTrackingPrediction;
30 
31 // Lowers JSCreate-level operators to fast (inline) allocations.
32 class V8_EXPORT_PRIVATE JSCreateLowering final
NON_EXPORTED_BASE(AdvancedReducer)33     : public NON_EXPORTED_BASE(AdvancedReducer) {
34  public:
35   JSCreateLowering(Editor* editor, CompilationDependencies* dependencies,
36                    JSGraph* jsgraph, JSHeapBroker* broker, Zone* zone)
37       : AdvancedReducer(editor),
38         dependencies_(dependencies),
39         jsgraph_(jsgraph),
40         broker_(broker),
41         zone_(zone) {}
42   ~JSCreateLowering() final = default;
43 
44   const char* reducer_name() const override { return "JSCreateLowering"; }
45 
46   Reduction Reduce(Node* node) final;
47 
48  private:
49   Reduction ReduceJSCreate(Node* node);
50   Reduction ReduceJSCreateArguments(Node* node);
51   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   Reduction ReduceJSCreateEmptyLiteralObject(Node* node);
63   Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
64   Reduction ReduceJSCreateLiteralRegExp(Node* node);
65   Reduction ReduceJSCreateFunctionContext(Node* node);
66   Reduction ReduceJSCreateWithContext(Node* node);
67   Reduction ReduceJSCreateCatchContext(Node* node);
68   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       const SlackTrackingPrediction& slack_tracking_prediction);
75   Reduction ReduceNewArray(
76       Node* node, Node* length, int capacity, MapRef initial_map,
77       ElementsKind elements_kind, AllocationType allocation,
78       const SlackTrackingPrediction& slack_tracking_prediction);
79   Reduction ReduceNewArray(
80       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   Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
86   Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
87                               int start_index);
88   Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
89                                  Node* context,
90                                  const SharedFunctionInfoRef& shared,
91                                  bool* has_aliased_arguments);
92   Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context,
93                                  Node* arguments_frame, Node* arguments_length,
94                                  const SharedFunctionInfoRef& shared,
95                                  bool* has_aliased_arguments);
96   Node* AllocateElements(Node* effect, Node* control,
97                          ElementsKind elements_kind, int capacity,
98                          AllocationType allocation);
99   Node* AllocateElements(Node* effect, Node* control,
100                          ElementsKind elements_kind, Node* capacity_and_length);
101   Node* AllocateElements(Node* effect, Node* control,
102                          ElementsKind elements_kind,
103                          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   Factory* factory() const;
114   Graph* graph() const;
115   JSGraph* jsgraph() const { return jsgraph_; }
116   NativeContextRef native_context() const;
117   CommonOperatorBuilder* common() const;
118   SimplifiedOperatorBuilder* simplified() const;
119   CompilationDependencies* dependencies() const { return dependencies_; }
120   JSHeapBroker* broker() const { return broker_; }
121   Zone* zone() const { return zone_; }
122 
123   CompilationDependencies* const dependencies_;
124   JSGraph* const jsgraph_;
125   JSHeapBroker* const broker_;
126   Zone* const zone_;
127 };
128 
129 }  // namespace compiler
130 }  // namespace internal
131 }  // namespace v8
132 
133 #endif  // V8_COMPILER_JS_CREATE_LOWERING_H_
134