• 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/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
NON_EXPORTED_BASE(AdvancedReducer)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          zone_(zone) {}
45    ~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  
63    Node* AllocateArguments(Node* effect, Node* control, Node* frame_state);
64    Node* AllocateRestArguments(Node* effect, Node* control, Node* frame_state,
65                                int start_index);
66    Node* AllocateAliasedArguments(Node* effect, Node* control, Node* frame_state,
67                                   Node* context, Handle<SharedFunctionInfo>,
68                                   bool* has_aliased_arguments);
69    Node* AllocateElements(Node* effect, Node* control,
70                           ElementsKind elements_kind, int capacity,
71                           PretenureFlag pretenure);
72    Node* AllocateFastLiteral(Node* effect, Node* control,
73                              Handle<JSObject> boilerplate,
74                              AllocationSiteUsageContext* site_context);
75    Node* AllocateFastLiteralElements(Node* effect, Node* control,
76                                      Handle<JSObject> boilerplate,
77                                      PretenureFlag pretenure,
78                                      AllocationSiteUsageContext* site_context);
79  
80    Reduction ReduceNewArrayToStubCall(Node* node, Handle<AllocationSite> site);
81  
82    // Infers the FeedbackVector to use for a given {node}.
83    MaybeHandle<FeedbackVector> GetSpecializationFeedbackVector(Node* node);
84  
85    Factory* factory() const;
86    Graph* graph() const;
87    JSGraph* jsgraph() const { return jsgraph_; }
88    Isolate* isolate() const;
89    Handle<Context> native_context() const { return native_context_; }
90    JSOperatorBuilder* javascript() const;
91    CommonOperatorBuilder* common() const;
92    SimplifiedOperatorBuilder* simplified() const;
93    MachineOperatorBuilder* machine() const;
94    CompilationDependencies* dependencies() const { return dependencies_; }
95    Zone* zone() const { return zone_; }
96  
97    CompilationDependencies* const dependencies_;
98    JSGraph* const jsgraph_;
99    MaybeHandle<FeedbackVector> const feedback_vector_;
100    Handle<Context> const native_context_;
101    Zone* const zone_;
102  };
103  
104  }  // namespace compiler
105  }  // namespace internal
106  }  // namespace v8
107  
108  #endif  // V8_COMPILER_JS_CREATE_LOWERING_H_
109