Line data Source code
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/compiler/graph-reducer.h"
10 : #include "src/globals.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
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 464174 : zone_(zone) {}
42 928340 : ~JSCreateLowering() final = default;
43 :
44 18 : 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 ReduceNewArray(
71 : Node* node, Node* length, MapRef initial_map, ElementsKind elements_kind,
72 : AllocationType allocation,
73 : const SlackTrackingPrediction& slack_tracking_prediction);
74 : Reduction ReduceNewArray(
75 : Node* node, Node* length, int capacity, MapRef initial_map,
76 : ElementsKind elements_kind, AllocationType allocation,
77 : const SlackTrackingPrediction& slack_tracking_prediction);
78 : Reduction ReduceNewArray(
79 : Node* node, std::vector<Node*> values, MapRef initial_map,
80 : ElementsKind elements_kind, AllocationType allocation,
81 : const SlackTrackingPrediction& slack_tracking_prediction);
82 : Reduction ReduceJSCreateObject(Node* node);
83 :
84 : Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
85 : Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
86 : int start_index);
87 : Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
88 : Node* context,
89 : const SharedFunctionInfoRef& shared,
90 : bool* has_aliased_arguments);
91 : Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context,
92 : Node* arguments_frame, Node* arguments_length,
93 : const SharedFunctionInfoRef& shared,
94 : bool* has_aliased_arguments);
95 : Node* AllocateElements(Node* effect, Node* control,
96 : ElementsKind elements_kind, int capacity,
97 : AllocationType allocation);
98 : Node* AllocateElements(Node* effect, Node* control,
99 : ElementsKind elements_kind, Node* capacity_and_length);
100 : Node* AllocateElements(Node* effect, Node* control,
101 : ElementsKind elements_kind,
102 : std::vector<Node*> const& values,
103 : AllocationType allocation);
104 : Node* AllocateFastLiteral(Node* effect, Node* control,
105 : JSObjectRef boilerplate, AllocationType allocation);
106 : Node* AllocateFastLiteralElements(Node* effect, Node* control,
107 : JSObjectRef boilerplate,
108 : AllocationType allocation);
109 : Node* AllocateLiteralRegExp(Node* effect, Node* control,
110 : JSRegExpRef boilerplate);
111 :
112 : Factory* factory() const;
113 : Graph* graph() const;
114 : JSGraph* jsgraph() const { return jsgraph_; }
115 : NativeContextRef native_context() const;
116 : CommonOperatorBuilder* common() const;
117 : SimplifiedOperatorBuilder* simplified() const;
118 : CompilationDependencies* dependencies() const { return dependencies_; }
119 : JSHeapBroker* broker() const { return broker_; }
120 : Zone* zone() const { return zone_; }
121 :
122 : CompilationDependencies* const dependencies_;
123 : JSGraph* const jsgraph_;
124 : JSHeapBroker* const broker_;
125 : Zone* const zone_;
126 : };
127 :
128 : } // namespace compiler
129 : } // namespace internal
130 : } // namespace v8
131 :
132 : #endif // V8_COMPILER_JS_CREATE_LOWERING_H_
|