Line data Source code
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 CompilationInfo;
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 443382 : class JSInliner final : public AdvancedReducer {
25 : public:
26 : JSInliner(Editor* editor, Zone* local_zone, CompilationInfo* info,
27 : JSGraph* jsgraph, SourcePositionTable* source_positions)
28 : : AdvancedReducer(editor),
29 : local_zone_(local_zone),
30 : info_(info),
31 : jsgraph_(jsgraph),
32 443382 : source_positions_(source_positions) {}
33 :
34 0 : 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:
44 : Zone* zone() const { return local_zone_; }
45 : CommonOperatorBuilder* common() const;
46 : JSOperatorBuilder* javascript() const;
47 : SimplifiedOperatorBuilder* simplified() const;
48 : Graph* graph() const;
49 : JSGraph* jsgraph() const { return jsgraph_; }
50 : Handle<Context> native_context() const;
51 :
52 : Zone* const local_zone_;
53 : CompilationInfo* info_;
54 : JSGraph* const jsgraph_;
55 : SourcePositionTable* const source_positions_;
56 :
57 : bool DetermineCallTarget(Node* node,
58 : Handle<SharedFunctionInfo>& shared_info_out);
59 : void DetermineCallContext(Node* node, Node*& context_out,
60 : Handle<FeedbackVector>& feedback_vector_out);
61 :
62 : Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
63 : int parameter_count, BailoutId bailout_id,
64 : FrameStateType frame_state_type,
65 : Handle<SharedFunctionInfo> shared);
66 :
67 : Reduction InlineCall(Node* call, Node* new_target, Node* context,
68 : Node* frame_state, Node* start, Node* end,
69 : Node* exception_target,
70 : const NodeVector& uncaught_subcalls);
71 : };
72 :
73 : } // namespace compiler
74 : } // namespace internal
75 : } // namespace v8
76 :
77 : #endif // V8_COMPILER_JS_INLINING_H_
|