OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/flow_graph_inliner.h" | 5 #include "vm/flow_graph_inliner.h" |
6 | 6 |
7 #include "vm/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
8 #include "vm/block_scheduler.h" | 8 #include "vm/block_scheduler.h" |
9 #include "vm/branch_optimizer.h" | 9 #include "vm/branch_optimizer.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 DEFINE_FLAG(int, max_inlined_per_depth, 500, | 56 DEFINE_FLAG(int, max_inlined_per_depth, 500, |
57 "Max. number of inlined calls per depth"); | 57 "Max. number of inlined calls per depth"); |
58 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); | 58 DEFINE_FLAG(bool, print_inlining_tree, false, "Print inlining tree"); |
59 DEFINE_FLAG(bool, enable_inlining_annotations, false, | 59 DEFINE_FLAG(bool, enable_inlining_annotations, false, |
60 "Enable inlining annotations"); | 60 "Enable inlining annotations"); |
61 | 61 |
62 DECLARE_FLAG(bool, compiler_stats); | 62 DECLARE_FLAG(bool, compiler_stats); |
63 DECLARE_FLAG(int, max_deoptimization_counter_threshold); | 63 DECLARE_FLAG(int, max_deoptimization_counter_threshold); |
64 DECLARE_FLAG(bool, print_flow_graph); | 64 DECLARE_FLAG(bool, print_flow_graph); |
65 DECLARE_FLAG(bool, print_flow_graph_optimized); | 65 DECLARE_FLAG(bool, print_flow_graph_optimized); |
| 66 DECLARE_FLAG(bool, support_externalizable_strings); |
66 DECLARE_FLAG(bool, verify_compiler); | 67 DECLARE_FLAG(bool, verify_compiler); |
67 | 68 |
68 // Quick access to the current zone. | 69 // Quick access to the current zone. |
69 #define Z (zone()) | 70 #define Z (zone()) |
70 #define I (isolate()) | 71 #define I (isolate()) |
71 | 72 |
72 #define TRACE_INLINING(statement) \ | 73 #define TRACE_INLINING(statement) \ |
73 do { \ | 74 do { \ |
74 if (trace_inlining()) statement; \ | 75 if (trace_inlining()) statement; \ |
75 } while (false) | 76 } while (false) |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 InlineInstanceCalls(); | 584 InlineInstanceCalls(); |
584 InlineStaticCalls(); | 585 InlineStaticCalls(); |
585 InlineClosureCalls(); | 586 InlineClosureCalls(); |
586 // Increment the inlining depths. Checked before subsequent inlining. | 587 // Increment the inlining depths. Checked before subsequent inlining. |
587 ++inlining_depth_; | 588 ++inlining_depth_; |
588 if (inlined_recursive_call_) { | 589 if (inlined_recursive_call_) { |
589 ++inlining_recursion_depth_; | 590 ++inlining_recursion_depth_; |
590 inlined_recursive_call_ = false; | 591 inlined_recursive_call_ = false; |
591 } | 592 } |
592 } | 593 } |
| 594 |
593 collected_call_sites_ = NULL; | 595 collected_call_sites_ = NULL; |
594 inlining_call_sites_ = NULL; | 596 inlining_call_sites_ = NULL; |
595 } | 597 } |
596 | 598 |
597 bool inlined() const { return inlined_; } | 599 bool inlined() const { return inlined_; } |
598 | 600 |
599 double GrowthFactor() const { | 601 double GrowthFactor() const { |
600 return static_cast<double>(inlined_size_) / | 602 return static_cast<double>(inlined_size_) / |
601 static_cast<double>(initial_size_); | 603 static_cast<double>(initial_size_); |
602 } | 604 } |
(...skipping 2163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2766 // Load the length of the string. | 2768 // Load the length of the string. |
2767 // Treat length loads as mutable (i.e. affected by side effects) to avoid | 2769 // Treat length loads as mutable (i.e. affected by side effects) to avoid |
2768 // hoisting them since we can't hoist the preceding class-check. This | 2770 // hoisting them since we can't hoist the preceding class-check. This |
2769 // is because of externalization of strings that affects their class-id. | 2771 // is because of externalization of strings that affects their class-id. |
2770 LoadFieldInstr* length = new(Z) LoadFieldInstr( | 2772 LoadFieldInstr* length = new(Z) LoadFieldInstr( |
2771 new(Z) Value(str), | 2773 new(Z) Value(str), |
2772 String::length_offset(), | 2774 String::length_offset(), |
2773 Type::ZoneHandle(Z, Type::SmiType()), | 2775 Type::ZoneHandle(Z, Type::SmiType()), |
2774 str->token_pos()); | 2776 str->token_pos()); |
2775 length->set_result_cid(kSmiCid); | 2777 length->set_result_cid(kSmiCid); |
| 2778 length->set_is_immutable(!FLAG_support_externalizable_strings); |
2776 length->set_recognized_kind(MethodRecognizer::kStringBaseLength); | 2779 length->set_recognized_kind(MethodRecognizer::kStringBaseLength); |
2777 | 2780 |
2778 cursor = flow_graph->AppendTo(cursor, length, NULL, FlowGraph::kValue); | 2781 cursor = flow_graph->AppendTo(cursor, length, NULL, FlowGraph::kValue); |
2779 // Bounds check. | 2782 // Bounds check. |
2780 cursor = flow_graph->AppendTo(cursor, | 2783 cursor = flow_graph->AppendTo(cursor, |
2781 new(Z) CheckArrayBoundInstr( | 2784 new(Z) CheckArrayBoundInstr( |
2782 new(Z) Value(length), | 2785 new(Z) Value(length), |
2783 new(Z) Value(index), | 2786 new(Z) Value(index), |
2784 call->deopt_id()), | 2787 call->deopt_id()), |
2785 call->env(), | 2788 call->env(), |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3088 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); | 3091 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
3089 case MethodRecognizer::kDoubleDiv: | 3092 case MethodRecognizer::kDoubleDiv: |
3090 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3093 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
3091 default: | 3094 default: |
3092 return false; | 3095 return false; |
3093 } | 3096 } |
3094 } | 3097 } |
3095 | 3098 |
3096 | 3099 |
3097 } // namespace dart | 3100 } // namespace dart |
OLD | NEW |