| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_FLOW_GRAPH_INLINER_H_ | 5 #ifndef VM_FLOW_GRAPH_INLINER_H_ |
| 6 #define VM_FLOW_GRAPH_INLINER_H_ | 6 #define VM_FLOW_GRAPH_INLINER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 class Definition; | 13 class Definition; |
| 14 class Field; | 14 class Field; |
| 15 class FlowGraph; | 15 class FlowGraph; |
| 16 class Function; | 16 class Function; |
| 17 class Instruction; | 17 class Instruction; |
| 18 class TargetEntryInstr; | 18 class TargetEntryInstr; |
| 19 | 19 |
| 20 class FlowGraphInliner : ValueObject { | 20 class FlowGraphInliner : ValueObject { |
| 21 public: | 21 public: |
| 22 FlowGraphInliner(FlowGraph* flow_graph, | 22 FlowGraphInliner(FlowGraph* flow_graph, |
| 23 GrowableArray<const Function*>* inline_id_to_function, | 23 GrowableArray<const Function*>* inline_id_to_function, |
| 24 GrowableArray<TokenPosition>* inline_id_to_token_pos, |
| 24 GrowableArray<intptr_t>* caller_inline_id, | 25 GrowableArray<intptr_t>* caller_inline_id, |
| 25 bool use_speculative_inlining, | 26 bool use_speculative_inlining, |
| 26 GrowableArray<intptr_t>* inlining_black_list); | 27 GrowableArray<intptr_t>* inlining_black_list); |
| 27 | 28 |
| 28 // The flow graph is destructively updated upon inlining. | 29 // The flow graph is destructively updated upon inlining. |
| 29 void Inline(); | 30 void Inline(); |
| 30 | 31 |
| 31 // Compute graph info if it was not already computed or if 'force' is true. | 32 // Compute graph info if it was not already computed or if 'force' is true. |
| 32 static void CollectGraphInfo(FlowGraph* flow_graph, bool force = false); | 33 static void CollectGraphInfo(FlowGraph* flow_graph, bool force = false); |
| 33 static void SetInliningId(FlowGraph* flow_graph, intptr_t inlining_id); | 34 static void SetInliningId(FlowGraph* flow_graph, intptr_t inlining_id); |
| 34 | 35 |
| 35 bool AlwaysInline(const Function& function); | 36 bool AlwaysInline(const Function& function); |
| 36 | 37 |
| 37 FlowGraph* flow_graph() const { return flow_graph_; } | 38 FlowGraph* flow_graph() const { return flow_graph_; } |
| 38 intptr_t NextInlineId(const Function& function, intptr_t caller_id); | 39 intptr_t NextInlineId(const Function& function, |
| 40 TokenPosition tp, |
| 41 intptr_t caller_id); |
| 39 | 42 |
| 40 bool trace_inlining() const { return trace_inlining_; } | 43 bool trace_inlining() const { return trace_inlining_; } |
| 41 | 44 |
| 42 static bool TryInlineRecognizedMethod(FlowGraph* flow_graph, | 45 static bool TryInlineRecognizedMethod(FlowGraph* flow_graph, |
| 43 intptr_t receiver_cid, | 46 intptr_t receiver_cid, |
| 44 const Function& target, | 47 const Function& target, |
| 45 Instruction* call, | 48 Instruction* call, |
| 46 Definition* receiver, | 49 Definition* receiver, |
| 47 TokenPosition token_pos, | 50 TokenPosition token_pos, |
| 48 const ICData& ic_data, | 51 const ICData& ic_data, |
| 49 TargetEntryInstr** entry, | 52 TargetEntryInstr** entry, |
| 50 Definition** last); | 53 Definition** last); |
| 51 | 54 |
| 52 private: | 55 private: |
| 53 friend class CallSiteInliner; | 56 friend class CallSiteInliner; |
| 54 | 57 |
| 55 FlowGraph* flow_graph_; | 58 FlowGraph* flow_graph_; |
| 56 GrowableArray<const Function*>* inline_id_to_function_; | 59 GrowableArray<const Function*>* inline_id_to_function_; |
| 60 GrowableArray<TokenPosition>* inline_id_to_token_pos_; |
| 57 GrowableArray<intptr_t>* caller_inline_id_; | 61 GrowableArray<intptr_t>* caller_inline_id_; |
| 58 const bool trace_inlining_; | 62 const bool trace_inlining_; |
| 59 const bool use_speculative_inlining_; | 63 const bool use_speculative_inlining_; |
| 60 GrowableArray<intptr_t>* inlining_black_list_; | 64 GrowableArray<intptr_t>* inlining_black_list_; |
| 61 | 65 |
| 62 DISALLOW_COPY_AND_ASSIGN(FlowGraphInliner); | 66 DISALLOW_COPY_AND_ASSIGN(FlowGraphInliner); |
| 63 }; | 67 }; |
| 64 | 68 |
| 65 } // namespace dart | 69 } // namespace dart |
| 66 | 70 |
| 67 #endif // VM_FLOW_GRAPH_INLINER_H_ | 71 #endif // VM_FLOW_GRAPH_INLINER_H_ |
| OLD | NEW |