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 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 927850 : class JSInliner final : public AdvancedReducer {
25 : public:
26 : JSInliner(Editor* editor, Zone* local_zone, OptimizedCompilationInfo* info,
27 : JSGraph* jsgraph, JSHeapBroker* broker,
28 : SourcePositionTable* source_positions)
29 : : AdvancedReducer(editor),
30 : local_zone_(local_zone),
31 : info_(info),
32 : jsgraph_(jsgraph),
33 : broker_(broker),
34 463926 : source_positions_(source_positions) {}
35 :
36 0 : const char* reducer_name() const override { return "JSInliner"; }
37 :
38 0 : Reduction Reduce(Node* node) final { UNREACHABLE(); }
39 :
40 : // Can be used by inlining heuristics or by testing code directly, without
41 : // using the above generic reducer interface of the inlining machinery.
42 : Reduction ReduceJSCall(Node* node);
43 :
44 : private:
45 : Zone* zone() const { return local_zone_; }
46 : CommonOperatorBuilder* common() const;
47 : JSOperatorBuilder* javascript() const;
48 : SimplifiedOperatorBuilder* simplified() const;
49 : Graph* graph() const;
50 : JSGraph* jsgraph() const { return jsgraph_; }
51 : // TODO(neis): Make heap broker a component of JSGraph?
52 : JSHeapBroker* broker() const { return broker_; }
53 : Isolate* isolate() const { return jsgraph_->isolate(); }
54 : Handle<Context> native_context() const;
55 :
56 : Zone* const local_zone_;
57 : OptimizedCompilationInfo* info_;
58 : JSGraph* const jsgraph_;
59 : JSHeapBroker* const broker_;
60 : SourcePositionTable* const source_positions_;
61 :
62 : bool DetermineCallTarget(Node* node,
63 : Handle<SharedFunctionInfo>& shared_info_out);
64 : void DetermineCallContext(Node* node, Node*& context_out,
65 : Handle<FeedbackVector>& feedback_vector_out);
66 :
67 : Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state,
68 : int parameter_count, BailoutId bailout_id,
69 : FrameStateType frame_state_type,
70 : Handle<SharedFunctionInfo> shared,
71 : Node* context = nullptr);
72 :
73 : Reduction InlineCall(Node* call, Node* new_target, Node* context,
74 : Node* frame_state, Node* start, Node* end,
75 : Node* exception_target,
76 : const NodeVector& uncaught_subcalls);
77 : };
78 :
79 : } // namespace compiler
80 : } // namespace internal
81 : } // namespace v8
82 :
83 : #endif // V8_COMPILER_JS_INLINING_H_
|