• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_INLINING_H_
6 #define V8_COMPILER_JS_INLINING_H_
7 
8 #include "src/compiler/graph-reducer.h"
9 #include "src/compiler/js-graph.h"
10 
11 namespace v8 {
12 namespace internal {
13 
14 class BailoutId;
15 class OptimizedCompilationInfo;
16 
17 namespace compiler {
18 
19 class SourcePositionTable;
20 
21 // The JSInliner provides the core graph inlining machinery. Note that this
22 // class only deals with the mechanics of how to inline one graph into another,
23 // heuristics that decide what and how much to inline are beyond its scope.
24 class JSInliner final : public AdvancedReducer {
25  public:
JSInliner(Editor * editor,Zone * local_zone,OptimizedCompilationInfo * info,JSGraph * jsgraph,SourcePositionTable * source_positions)26   JSInliner(Editor* editor, Zone* local_zone, OptimizedCompilationInfo* info,
27             JSGraph* jsgraph, SourcePositionTable* source_positions)
28       : AdvancedReducer(editor),
29         local_zone_(local_zone),
30         info_(info),
31         jsgraph_(jsgraph),
32         source_positions_(source_positions) {}
33 
reducer_name()34   const char* reducer_name() const override { return "JSInliner"; }
35 
36   // Reducer interface, eagerly inlines everything.
37   Reduction Reduce(Node* node) final;
38 
39   // Can be used by inlining heuristics or by testing code directly, without
40   // using the above generic reducer interface of the inlining machinery.
41   Reduction ReduceJSCall(Node* node);
42 
43  private:
zone()44   Zone* zone() const { return local_zone_; }
45   CommonOperatorBuilder* common() const;
46   JSOperatorBuilder* javascript() const;
47   SimplifiedOperatorBuilder* simplified() const;
48   Graph* graph() const;
jsgraph()49   JSGraph* jsgraph() const { return jsgraph_; }
isolate()50   Isolate* isolate() const { return jsgraph_->isolate(); }
51   Handle<Context> native_context() const;
52 
53   Zone* const local_zone_;
54   OptimizedCompilationInfo* info_;
55   JSGraph* const jsgraph_;
56   SourcePositionTable* const source_positions_;
57 
58   bool DetermineCallTarget(Node* node,
59                            Handle<SharedFunctionInfo>& shared_info_out);
60   void DetermineCallContext(Node* node, Node*& context_out,
61                             Handle<FeedbackVector>& feedback_vector_out);
62 
63   Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
64                                    int parameter_count, BailoutId bailout_id,
65                                    FrameStateType frame_state_type,
66                                    Handle<SharedFunctionInfo> shared);
67 
68   Reduction InlineCall(Node* call, Node* new_target, Node* context,
69                        Node* frame_state, Node* start, Node* end,
70                        Node* exception_target,
71                        const NodeVector& uncaught_subcalls);
72 };
73 
74 }  // namespace compiler
75 }  // namespace internal
76 }  // namespace v8
77 
78 #endif  // V8_COMPILER_JS_INLINING_H_
79