Chromium Code Reviews| 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 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2796 cursor = flow_graph->AppendTo(cursor, length, NULL, FlowGraph::kValue); | 2796 cursor = flow_graph->AppendTo(cursor, length, NULL, FlowGraph::kValue); |
| 2797 // Bounds check. | 2797 // Bounds check. |
| 2798 cursor = flow_graph->AppendTo(cursor, | 2798 cursor = flow_graph->AppendTo(cursor, |
| 2799 new(Z) CheckArrayBoundInstr( | 2799 new(Z) CheckArrayBoundInstr( |
| 2800 new(Z) Value(length), | 2800 new(Z) Value(length), |
| 2801 new(Z) Value(index), | 2801 new(Z) Value(index), |
| 2802 call->deopt_id()), | 2802 call->deopt_id()), |
| 2803 call->env(), | 2803 call->env(), |
| 2804 FlowGraph::kEffect); | 2804 FlowGraph::kEffect); |
| 2805 | 2805 |
| 2806 // For external strings: Load backing store. | |
| 2807 if (cid == kExternalOneByteStringCid) { | |
| 2808 str = new LoadUntaggedInstr(new Value(str), | |
| 2809 ExternalOneByteString::external_data_offset()); | |
| 2810 cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue); | |
| 2811 str = new LoadUntaggedInstr( | |
| 2812 new Value(str), | |
| 2813 RawExternalOneByteString::ExternalData::data_offset()); | |
| 2814 cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue); | |
| 2815 } else if (cid == kExternalTwoByteStringCid) { | |
| 2816 str = new LoadUntaggedInstr(new Value(str), | |
| 2817 ExternalTwoByteString::external_data_offset()); | |
| 2818 cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue); | |
| 2819 str = new LoadUntaggedInstr( | |
| 2820 new Value(str), | |
| 2821 RawExternalTwoByteString::ExternalData::data_offset()); | |
| 2822 cursor = flow_graph->AppendTo(cursor, str, NULL, FlowGraph::kValue); | |
| 2823 } | |
| 2824 | |
| 2806 LoadIndexedInstr* load_indexed = new(Z) LoadIndexedInstr( | 2825 LoadIndexedInstr* load_indexed = new(Z) LoadIndexedInstr( |
| 2807 new(Z) Value(str), | 2826 new(Z) Value(str), |
| 2808 new(Z) Value(index), | 2827 new(Z) Value(index), |
| 2809 Instance::ElementSizeFor(cid), | 2828 Instance::ElementSizeFor(cid), |
| 2810 cid, | 2829 cid, |
| 2811 Thread::kNoDeoptId, | 2830 Thread::kNoDeoptId, |
| 2812 call->token_pos()); | 2831 call->token_pos()); |
| 2813 | 2832 |
| 2814 cursor = flow_graph->AppendTo(cursor, load_indexed, NULL, FlowGraph::kValue); | 2833 cursor = flow_graph->AppendTo(cursor, load_indexed, NULL, FlowGraph::kValue); |
| 2815 ASSERT(cursor == load_indexed); | 2834 ASSERT(cursor == load_indexed); |
| 2816 return load_indexed; | 2835 return load_indexed; |
| 2817 } | 2836 } |
| 2818 | 2837 |
| 2819 | 2838 |
| 2820 static bool InlineStringBaseCharAt( | 2839 static bool InlineStringBaseCharAt( |
| 2821 FlowGraph* flow_graph, | 2840 FlowGraph* flow_graph, |
| 2822 Instruction* call, | 2841 Instruction* call, |
| 2823 intptr_t cid, | 2842 intptr_t cid, |
| 2824 TargetEntryInstr** entry, | 2843 TargetEntryInstr** entry, |
| 2825 Definition** last) { | 2844 Definition** last) { |
| 2826 // TODO(johnmccutchan): Handle external strings in PrepareInlineStringIndexOp. | 2845 if ((cid != kOneByteStringCid) && (cid != kExternalOneByteStringCid)) { |
| 2827 if (RawObject::IsExternalStringClassId(cid) || cid != kOneByteStringCid) { | |
| 2828 return false; | 2846 return false; |
| 2829 } | 2847 } |
| 2830 Definition* str = call->ArgumentAt(0); | 2848 Definition* str = call->ArgumentAt(0); |
| 2831 Definition* index = call->ArgumentAt(1); | 2849 Definition* index = call->ArgumentAt(1); |
| 2832 | 2850 |
| 2833 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), | 2851 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), |
| 2834 call->GetBlock()->try_index()); | 2852 call->GetBlock()->try_index()); |
| 2835 (*entry)->InheritDeoptTarget(Z, call); | 2853 (*entry)->InheritDeoptTarget(Z, call); |
| 2836 | 2854 |
| 2837 *last = PrepareInlineStringIndexOp(flow_graph, call, cid, str, index, *entry); | 2855 *last = PrepareInlineStringIndexOp(flow_graph, call, cid, str, index, *entry); |
| 2838 | 2856 |
| 2839 StringFromCharCodeInstr* char_at = new(Z) StringFromCharCodeInstr( | 2857 OneByteStringFromCharCodeInstr* char_at = |
| 2840 new(Z) Value(*last), cid); | 2858 new(Z) OneByteStringFromCharCodeInstr(new(Z) Value(*last)); |
| 2841 | 2859 |
| 2842 flow_graph->AppendTo(*last, char_at, NULL, FlowGraph::kValue); | 2860 flow_graph->AppendTo(*last, char_at, NULL, FlowGraph::kValue); |
| 2843 *last = char_at; | 2861 *last = char_at; |
| 2844 | 2862 |
| 2845 return true; | 2863 return true; |
| 2846 } | 2864 } |
| 2847 | 2865 |
| 2848 | 2866 |
| 2849 static bool InlineStringCodeUnitAt( | 2867 static bool InlineStringCodeUnitAt( |
| 2850 FlowGraph* flow_graph, | 2868 FlowGraph* flow_graph, |
| 2851 Instruction* call, | 2869 Instruction* call, |
| 2852 intptr_t cid, | 2870 intptr_t cid, |
| 2853 TargetEntryInstr** entry, | 2871 TargetEntryInstr** entry, |
| 2854 Definition** last) { | 2872 Definition** last) { |
| 2855 // TODO(johnmccutchan): Handle external strings in PrepareInlineStringIndexOp. | 2873 // TODO(johnmccutchan): Handle external strings in PrepareInlineStringIndexOp. |
| 2856 if (RawObject::IsExternalStringClassId(cid)) { | 2874 if (RawObject::IsExternalStringClassId(cid)) { |
|
Vyacheslav Egorov (Google)
2016/05/10 15:21:57
This would just return false for external strings
Florian Schneider
2016/05/10 15:51:52
Done.
| |
| 2857 return false; | 2875 return false; |
| 2858 } | 2876 } |
| 2859 | 2877 |
| 2860 Definition* str = call->ArgumentAt(0); | 2878 Definition* str = call->ArgumentAt(0); |
| 2861 Definition* index = call->ArgumentAt(1); | 2879 Definition* index = call->ArgumentAt(1); |
| 2862 | 2880 |
| 2863 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), | 2881 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), |
| 2864 call->GetBlock()->try_index()); | 2882 call->GetBlock()->try_index()); |
| 2865 (*entry)->InheritDeoptTarget(Z, call); | 2883 (*entry)->InheritDeoptTarget(Z, call); |
| 2866 | 2884 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3090 kTypedDataFloat32x4ArrayCid, | 3108 kTypedDataFloat32x4ArrayCid, |
| 3091 entry, last); | 3109 entry, last); |
| 3092 case MethodRecognizer::kByteArrayBaseSetInt32x4: | 3110 case MethodRecognizer::kByteArrayBaseSetInt32x4: |
| 3093 if (!ShouldInlineSimd()) { | 3111 if (!ShouldInlineSimd()) { |
| 3094 return false; | 3112 return false; |
| 3095 } | 3113 } |
| 3096 return InlineByteArrayBaseStore(flow_graph, target, call, receiver, | 3114 return InlineByteArrayBaseStore(flow_graph, target, call, receiver, |
| 3097 receiver_cid, | 3115 receiver_cid, |
| 3098 kTypedDataInt32x4ArrayCid, | 3116 kTypedDataInt32x4ArrayCid, |
| 3099 entry, last); | 3117 entry, last); |
| 3100 case MethodRecognizer::kStringBaseCodeUnitAt: | 3118 case MethodRecognizer::kOneByteStringCodeUnitAt: |
| 3119 case MethodRecognizer::kTwoByteStringCodeUnitAt: | |
| 3120 case MethodRecognizer::kExternalOneByteStringCodeUnitAt: | |
| 3121 case MethodRecognizer::kExternalTwoByteStringCodeUnitAt: | |
| 3101 return InlineStringCodeUnitAt( | 3122 return InlineStringCodeUnitAt( |
| 3102 flow_graph, call, receiver_cid, entry, last); | 3123 flow_graph, call, receiver_cid, entry, last); |
| 3103 case MethodRecognizer::kStringBaseCharAt: | 3124 case MethodRecognizer::kStringBaseCharAt: |
| 3104 return InlineStringBaseCharAt( | 3125 return InlineStringBaseCharAt( |
| 3105 flow_graph, call, receiver_cid, entry, last); | 3126 flow_graph, call, receiver_cid, entry, last); |
| 3106 case MethodRecognizer::kDoubleAdd: | 3127 case MethodRecognizer::kDoubleAdd: |
| 3107 return InlineDoubleOp(flow_graph, Token::kADD, call, entry, last); | 3128 return InlineDoubleOp(flow_graph, Token::kADD, call, entry, last); |
| 3108 case MethodRecognizer::kDoubleSub: | 3129 case MethodRecognizer::kDoubleSub: |
| 3109 return InlineDoubleOp(flow_graph, Token::kSUB, call, entry, last); | 3130 return InlineDoubleOp(flow_graph, Token::kSUB, call, entry, last); |
| 3110 case MethodRecognizer::kDoubleMul: | 3131 case MethodRecognizer::kDoubleMul: |
| 3111 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); | 3132 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); |
| 3112 case MethodRecognizer::kDoubleDiv: | 3133 case MethodRecognizer::kDoubleDiv: |
| 3113 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); | 3134 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); |
| 3114 default: | 3135 default: |
| 3115 return false; | 3136 return false; |
| 3116 } | 3137 } |
| 3117 } | 3138 } |
| 3118 | 3139 |
| 3119 | 3140 |
| 3120 } // namespace dart | 3141 } // namespace dart |
| OLD | NEW |