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 CompilationDependencies;
18 : class Factory;
19 : class JSRegExp;
20 :
21 : namespace compiler {
22 :
23 : // Forward declarations.
24 : class CommonOperatorBuilder;
25 : class JSGraph;
26 : class JSOperatorBuilder;
27 : class MachineOperatorBuilder;
28 : class SimplifiedOperatorBuilder;
29 :
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,
37 : Handle<Context> native_context, Zone* zone)
38 : : AdvancedReducer(editor),
39 : dependencies_(dependencies),
40 : jsgraph_(jsgraph),
41 : native_context_(native_context),
42 443389 : zone_(zone) {}
43 443389 : ~JSCreateLowering() final {}
44 :
45 0 : const char* reducer_name() const override { return "JSCreateLowering"; }
46 :
47 : Reduction Reduce(Node* node) final;
48 :
49 : private:
50 : Reduction ReduceJSCreate(Node* node);
51 : Reduction ReduceJSCreateArguments(Node* node);
52 : Reduction ReduceJSCreateArray(Node* node);
53 : Reduction ReduceJSCreateBoundFunction(Node* node);
54 : Reduction ReduceJSCreateClosure(Node* node);
55 : Reduction ReduceJSCreateIterResultObject(Node* node);
56 : Reduction ReduceJSCreateKeyValueArray(Node* node);
57 : Reduction ReduceJSCreateLiteralArrayOrObject(Node* node);
58 : Reduction ReduceJSCreateEmptyLiteralObject(Node* node);
59 : Reduction ReduceJSCreateEmptyLiteralArray(Node* node);
60 : Reduction ReduceJSCreateLiteralRegExp(Node* node);
61 : Reduction ReduceJSCreateFunctionContext(Node* node);
62 : Reduction ReduceJSCreateWithContext(Node* node);
63 : Reduction ReduceJSCreateCatchContext(Node* node);
64 : Reduction ReduceJSCreateBlockContext(Node* node);
65 : Reduction ReduceJSCreateGeneratorObject(Node* node);
66 : Reduction ReduceNewArray(Node* node, Node* length, Handle<Map> initial_map,
67 : PretenureFlag pretenure);
68 : Reduction ReduceNewArray(Node* node, Node* length, int capacity,
69 : Handle<Map> initial_map, PretenureFlag pretenure);
70 : Reduction ReduceNewArray(Node* node, std::vector<Node*> values,
71 : Handle<Map> initial_map, PretenureFlag pretenure);
72 :
73 : Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
74 : Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
75 : int start_index);
76 : Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
77 : Node* context, Handle<SharedFunctionInfo>,
78 : bool* has_aliased_arguments);
79 : Node* AllocateAliasedArguments(Node* effect, Node* control, Node* context,
80 : Node* arguments_frame, Node* arguments_length,
81 : Handle<SharedFunctionInfo>,
82 : bool* has_aliased_arguments);
83 : Node* AllocateElements(Node* effect, Node* control,
84 : ElementsKind elements_kind, int capacity,
85 : PretenureFlag pretenure);
86 : Node* AllocateElements(Node* effect, Node* control,
87 : ElementsKind elements_kind, Node* capacity_and_length);
88 : Node* AllocateElements(Node* effect, Node* control,
89 : ElementsKind elements_kind,
90 : std::vector<Node*> const& values,
91 : PretenureFlag pretenure);
92 : Node* AllocateFastLiteral(Node* effect, Node* control,
93 : Handle<JSObject> boilerplate,
94 : AllocationSiteUsageContext* site_context);
95 : Node* AllocateFastLiteralElements(Node* effect, Node* control,
96 : Handle<JSObject> boilerplate,
97 : PretenureFlag pretenure,
98 : AllocationSiteUsageContext* site_context);
99 : Node* AllocateLiteralRegExp(Node* effect, Node* control,
100 : Handle<JSRegExp> boilerplate);
101 :
102 : Reduction ReduceNewArrayToStubCall(Node* node, Handle<AllocationSite> site);
103 :
104 : Factory* factory() const;
105 : Graph* graph() const;
106 : JSGraph* jsgraph() const { return jsgraph_; }
107 : Isolate* isolate() const;
108 : Handle<Context> native_context() const { return native_context_; }
109 : CommonOperatorBuilder* common() const;
110 : SimplifiedOperatorBuilder* simplified() const;
111 : CompilationDependencies* dependencies() const { return dependencies_; }
112 : Zone* zone() const { return zone_; }
113 :
114 : CompilationDependencies* const dependencies_;
115 : JSGraph* const jsgraph_;
116 : Handle<Context> const native_context_;
117 : Zone* const zone_;
118 : };
119 :
120 : } // namespace compiler
121 : } // namespace internal
122 : } // namespace v8
123 :
124 : #endif // V8_COMPILER_JS_CREATE_LOWERING_H_
|