OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_JS_INLINING_HEURISTIC_H_ | 5 #ifndef V8_COMPILER_JS_INLINING_HEURISTIC_H_ |
6 #define V8_COMPILER_JS_INLINING_HEURISTIC_H_ | 6 #define V8_COMPILER_JS_INLINING_HEURISTIC_H_ |
7 | 7 |
8 #include "src/compiler/js-inlining.h" | 8 #include "src/compiler/js-inlining.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 class JSInliningHeuristic final : public AdvancedReducer { | 14 class JSInliningHeuristic final : public AdvancedReducer { |
15 public: | 15 public: |
16 enum Mode { kRestrictedInlining, kGeneralInlining }; | 16 enum Mode { kGeneralInlining, kRestrictedInlining, kStressInlining }; |
17 JSInliningHeuristic(Editor* editor, Mode mode, Zone* local_zone, | 17 JSInliningHeuristic(Editor* editor, Mode mode, Zone* local_zone, |
18 CompilationInfo* info, JSGraph* jsgraph) | 18 CompilationInfo* info, JSGraph* jsgraph) |
19 : AdvancedReducer(editor), | 19 : AdvancedReducer(editor), |
20 mode_(mode), | 20 mode_(mode), |
21 inliner_(editor, local_zone, info, jsgraph) {} | 21 local_zone_(local_zone), |
| 22 jsgraph_(jsgraph), |
| 23 inliner_(editor, local_zone, info, jsgraph), |
| 24 candidates_(local_zone) {} |
22 | 25 |
23 Reduction Reduce(Node* node) final; | 26 Reduction Reduce(Node* node) final; |
24 | 27 |
| 28 // Processes the list of candidates gathered while the reducer was running, |
| 29 // and inlines call sites that the heuristic determines to be important. |
| 30 void ProcessCandidates(); |
| 31 |
25 private: | 32 private: |
| 33 struct Candidate { |
| 34 Handle<JSFunction> function; // The call target being inlined. |
| 35 Node* node; // The call site at which to inline. |
| 36 int calls; // Number of times the call site was hit. |
| 37 }; |
| 38 |
| 39 static bool Compare(const Candidate& left, const Candidate& right); |
| 40 void PrintCandidates(); |
| 41 |
26 Mode const mode_; | 42 Mode const mode_; |
| 43 Zone* local_zone_; |
| 44 JSGraph* jsgraph_; |
27 JSInliner inliner_; | 45 JSInliner inliner_; |
| 46 ZoneVector<Candidate> candidates_; |
28 }; | 47 }; |
29 | 48 |
30 } // namespace compiler | 49 } // namespace compiler |
31 } // namespace internal | 50 } // namespace internal |
32 } // namespace v8 | 51 } // namespace v8 |
33 | 52 |
34 #endif // V8_COMPILER_JS_INLINING_HEURISTIC_H_ | 53 #endif // V8_COMPILER_JS_INLINING_HEURISTIC_H_ |
OLD | NEW |