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 :
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 : MaybeHandle<FeedbackVector> feedback_vector,
38 : Handle<Context> native_context, Zone* zone)
39 : : AdvancedReducer(editor),
40 : dependencies_(dependencies),
41 : jsgraph_(jsgraph),
42 : feedback_vector_(feedback_vector),
43 : native_context_(native_context),
44 395343 : zone_(zone) {}
45 395343 : ~JSCreateLowering() final {}
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 ReduceJSCreateIterResultObject(Node* node);
54 : Reduction ReduceJSCreateKeyValueArray(Node* node);
55 : Reduction ReduceJSCreateLiteral(Node* node);
56 : Reduction ReduceJSCreateFunctionContext(Node* node);
57 : Reduction ReduceJSCreateWithContext(Node* node);
58 : Reduction ReduceJSCreateCatchContext(Node* node);
59 : Reduction ReduceJSCreateBlockContext(Node* node);
60 : Reduction ReduceNewArray(Node* node, Node* length, int capacity,
61 : Handle<AllocationSite> site);
62 : Reduction ReduceNewArray(Node* node, std::vector<Node*> values,
63 : Handle<AllocationSite> site);
64 :
65 : Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
66 : Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
67 : int start_index);
68 : Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
69 : Node* context, Handle<SharedFunctionInfo>,
70 : bool* has_aliased_arguments);
71 : Node* AllocateElements(Node* effect, Node* control,
72 : ElementsKind elements_kind, int capacity,
73 : PretenureFlag pretenure);
74 : Node* AllocateElements(Node* effect, Node* control,
75 : ElementsKind elements_kind,
76 : std::vector<Node*> const& values,
77 : PretenureFlag pretenure);
78 : Node* AllocateFastLiteral(Node* effect, Node* control,
79 : Handle<JSObject> boilerplate,
80 : AllocationSiteUsageContext* site_context);
81 : Node* AllocateFastLiteralElements(Node* effect, Node* control,
82 : Handle<JSObject> boilerplate,
83 : PretenureFlag pretenure,
84 : AllocationSiteUsageContext* site_context);
85 :
86 : Reduction ReduceNewArrayToStubCall(Node* node, Handle<AllocationSite> site);
87 :
88 : // Infers the FeedbackVector to use for a given {node}.
89 : MaybeHandle<FeedbackVector> GetSpecializationFeedbackVector(Node* node);
90 :
91 : Factory* factory() const;
92 : Graph* graph() const;
93 : JSGraph* jsgraph() const { return jsgraph_; }
94 : Isolate* isolate() const;
95 : Handle<Context> native_context() const { return native_context_; }
96 : JSOperatorBuilder* javascript() const;
97 : CommonOperatorBuilder* common() const;
98 : SimplifiedOperatorBuilder* simplified() const;
99 : MachineOperatorBuilder* machine() const;
100 : CompilationDependencies* dependencies() const { return dependencies_; }
101 : Zone* zone() const { return zone_; }
102 :
103 : CompilationDependencies* const dependencies_;
104 : JSGraph* const jsgraph_;
105 : MaybeHandle<FeedbackVector> const feedback_vector_;
106 : Handle<Context> const native_context_;
107 : Zone* const zone_;
108 : };
109 :
110 : } // namespace compiler
111 : } // namespace internal
112 : } // namespace v8
113 :
114 : #endif // V8_COMPILER_JS_CREATE_LOWERING_H_
|