Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 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/js-graph.h" |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 9 | #include "src/compiler/graph-reducer.h" |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 10 | |
| 11 | namespace v8 { |
| 12 | namespace internal { |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 13 | |
| 14 | // Forward declarations. |
| 15 | class CompilationInfo; |
| 16 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 17 | namespace compiler { |
| 18 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 19 | // The JSInliner provides the core graph inlining machinery. Note that this |
| 20 | // class only deals with the mechanics of how to inline one graph into another, |
| 21 | // heuristics that decide what and how much to inline are beyond its scope. |
| 22 | class JSInliner final : public AdvancedReducer { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 23 | public: |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 24 | JSInliner(Editor* editor, Zone* local_zone, CompilationInfo* info, |
| 25 | JSGraph* jsgraph) |
| 26 | : AdvancedReducer(editor), |
| 27 | local_zone_(local_zone), |
| 28 | info_(info), |
| 29 | jsgraph_(jsgraph) {} |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 30 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 31 | // Reducer interface, eagerly inlines everything. |
| 32 | Reduction Reduce(Node* node) final; |
| 33 | |
| 34 | // Can be used by inlining heuristics or by testing code directly, without |
| 35 | // using the above generic reducer interface of the inlining machinery. |
| 36 | Reduction ReduceJSCall(Node* node, Handle<JSFunction> function); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 37 | |
| 38 | private: |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 39 | Graph* graph() const; |
| 40 | JSGraph* jsgraph() const { return jsgraph_; } |
| 41 | |
| 42 | Zone* const local_zone_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 43 | CompilationInfo* info_; |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 44 | JSGraph* const jsgraph_; |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 45 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 46 | Node* CreateArtificialFrameState(Node* node, Node* outer_frame_state, |
| 47 | int parameter_count, |
| 48 | FrameStateType frame_state_type, |
| 49 | Handle<SharedFunctionInfo> shared); |
| 50 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 51 | Node* CreateTailCallerFrameState(Node* node, Node* outer_frame_state); |
| 52 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 53 | Reduction InlineCall(Node* call, Node* new_target, Node* context, |
| 54 | Node* frame_state, Node* start, Node* end); |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 55 | }; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 56 | |
| 57 | } // namespace compiler |
| 58 | } // namespace internal |
| 59 | } // namespace v8 |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 60 | |
| 61 | #endif // V8_COMPILER_JS_INLINING_H_ |