Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: runtime/vm/flow_graph_inliner.cc

Issue 1961393002: VM: Optimized code for all of [External]{One|Two}ByteString::codeUnitAt. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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.
2856 if (RawObject::IsExternalStringClassId(cid)) {
2857 return false;
2858 }
2859
2860 Definition* str = call->ArgumentAt(0); 2873 Definition* str = call->ArgumentAt(0);
2861 Definition* index = call->ArgumentAt(1); 2874 Definition* index = call->ArgumentAt(1);
2862 2875
2863 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(), 2876 *entry = new(Z) TargetEntryInstr(flow_graph->allocate_block_id(),
2864 call->GetBlock()->try_index()); 2877 call->GetBlock()->try_index());
2865 (*entry)->InheritDeoptTarget(Z, call); 2878 (*entry)->InheritDeoptTarget(Z, call);
2866 2879
2867 *last = PrepareInlineStringIndexOp(flow_graph, call, cid, str, index, *entry); 2880 *last = PrepareInlineStringIndexOp(flow_graph, call, cid, str, index, *entry);
2868 2881
2869 return true; 2882 return true;
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
3090 kTypedDataFloat32x4ArrayCid, 3103 kTypedDataFloat32x4ArrayCid,
3091 entry, last); 3104 entry, last);
3092 case MethodRecognizer::kByteArrayBaseSetInt32x4: 3105 case MethodRecognizer::kByteArrayBaseSetInt32x4:
3093 if (!ShouldInlineSimd()) { 3106 if (!ShouldInlineSimd()) {
3094 return false; 3107 return false;
3095 } 3108 }
3096 return InlineByteArrayBaseStore(flow_graph, target, call, receiver, 3109 return InlineByteArrayBaseStore(flow_graph, target, call, receiver,
3097 receiver_cid, 3110 receiver_cid,
3098 kTypedDataInt32x4ArrayCid, 3111 kTypedDataInt32x4ArrayCid,
3099 entry, last); 3112 entry, last);
3100 case MethodRecognizer::kStringBaseCodeUnitAt: 3113 case MethodRecognizer::kOneByteStringCodeUnitAt:
3114 case MethodRecognizer::kTwoByteStringCodeUnitAt:
3115 case MethodRecognizer::kExternalOneByteStringCodeUnitAt:
3116 case MethodRecognizer::kExternalTwoByteStringCodeUnitAt:
3101 return InlineStringCodeUnitAt( 3117 return InlineStringCodeUnitAt(
3102 flow_graph, call, receiver_cid, entry, last); 3118 flow_graph, call, receiver_cid, entry, last);
3103 case MethodRecognizer::kStringBaseCharAt: 3119 case MethodRecognizer::kStringBaseCharAt:
3104 return InlineStringBaseCharAt( 3120 return InlineStringBaseCharAt(
3105 flow_graph, call, receiver_cid, entry, last); 3121 flow_graph, call, receiver_cid, entry, last);
3106 case MethodRecognizer::kDoubleAdd: 3122 case MethodRecognizer::kDoubleAdd:
3107 return InlineDoubleOp(flow_graph, Token::kADD, call, entry, last); 3123 return InlineDoubleOp(flow_graph, Token::kADD, call, entry, last);
3108 case MethodRecognizer::kDoubleSub: 3124 case MethodRecognizer::kDoubleSub:
3109 return InlineDoubleOp(flow_graph, Token::kSUB, call, entry, last); 3125 return InlineDoubleOp(flow_graph, Token::kSUB, call, entry, last);
3110 case MethodRecognizer::kDoubleMul: 3126 case MethodRecognizer::kDoubleMul:
3111 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last); 3127 return InlineDoubleOp(flow_graph, Token::kMUL, call, entry, last);
3112 case MethodRecognizer::kDoubleDiv: 3128 case MethodRecognizer::kDoubleDiv:
3113 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last); 3129 return InlineDoubleOp(flow_graph, Token::kDIV, call, entry, last);
3114 default: 3130 default:
3115 return false; 3131 return false;
3116 } 3132 }
3117 } 3133 }
3118 3134
3119 3135
3120 } // namespace dart 3136 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/constant_propagator.cc ('k') | runtime/vm/flow_graph_type_propagator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698