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_optimizer.h" | 5 #include "vm/flow_graph_optimizer.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 } | 1249 } |
1250 InlineStringIsEmptyGetter(call); | 1250 InlineStringIsEmptyGetter(call); |
1251 return true; | 1251 return true; |
1252 default: | 1252 default: |
1253 ASSERT(recognized_kind == MethodRecognizer::kUnknown); | 1253 ASSERT(recognized_kind == MethodRecognizer::kUnknown); |
1254 } | 1254 } |
1255 return false; | 1255 return false; |
1256 } | 1256 } |
1257 | 1257 |
1258 | 1258 |
1259 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCharCodeAt( | 1259 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCodeUnitAt( |
1260 InstanceCallInstr* call, | 1260 InstanceCallInstr* call, |
1261 intptr_t cid) { | 1261 intptr_t cid) { |
1262 Definition* str = call->ArgumentAt(0); | 1262 Definition* str = call->ArgumentAt(0); |
1263 Definition* index = call->ArgumentAt(1); | 1263 Definition* index = call->ArgumentAt(1); |
1264 AddReceiverCheck(call); | 1264 AddReceiverCheck(call); |
1265 InsertBefore(call, | 1265 InsertBefore(call, |
1266 new CheckSmiInstr(new Value(index), call->deopt_id()), | 1266 new CheckSmiInstr(new Value(index), call->deopt_id()), |
1267 call->env(), | 1267 call->env(), |
1268 Definition::kEffect); | 1268 Definition::kEffect); |
1269 // If both index and string are constants, then do a compile-time check. | 1269 // If both index and string are constants, then do a compile-time check. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1357 case MethodRecognizer::kExternalUint8ClampedArrayGetIndexed: | 1357 case MethodRecognizer::kExternalUint8ClampedArrayGetIndexed: |
1358 case MethodRecognizer::kInt16ArrayGetIndexed: | 1358 case MethodRecognizer::kInt16ArrayGetIndexed: |
1359 case MethodRecognizer::kUint16ArrayGetIndexed: | 1359 case MethodRecognizer::kUint16ArrayGetIndexed: |
1360 case MethodRecognizer::kInt32ArrayGetIndexed: | 1360 case MethodRecognizer::kInt32ArrayGetIndexed: |
1361 case MethodRecognizer::kUint32ArrayGetIndexed: | 1361 case MethodRecognizer::kUint32ArrayGetIndexed: |
1362 return TryReplaceWithLoadIndexed(call); | 1362 return TryReplaceWithLoadIndexed(call); |
1363 default: | 1363 default: |
1364 break; | 1364 break; |
1365 } | 1365 } |
1366 | 1366 |
1367 if ((recognized_kind == MethodRecognizer::kStringBaseCharCodeAt) && | 1367 if ((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) && |
1368 (ic_data.NumberOfChecks() == 1) && | 1368 (ic_data.NumberOfChecks() == 1) && |
1369 ((class_ids[0] == kOneByteStringCid) || | 1369 ((class_ids[0] == kOneByteStringCid) || |
1370 (class_ids[0] == kTwoByteStringCid))) { | 1370 (class_ids[0] == kTwoByteStringCid))) { |
1371 LoadIndexedInstr* instr = BuildStringCharCodeAt(call, class_ids[0]); | 1371 LoadIndexedInstr* instr = BuildStringCodeUnitAt(call, class_ids[0]); |
1372 ReplaceCall(call, instr); | 1372 ReplaceCall(call, instr); |
1373 return true; | 1373 return true; |
1374 } | 1374 } |
1375 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && | 1375 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && |
1376 (ic_data.NumberOfChecks() == 1) && | 1376 (ic_data.NumberOfChecks() == 1) && |
1377 (class_ids[0] == kOneByteStringCid)) { | 1377 (class_ids[0] == kOneByteStringCid)) { |
1378 // TODO(fschneider): Handle TwoByteString. | 1378 // TODO(fschneider): Handle TwoByteString. |
1379 LoadIndexedInstr* load_char_code = | 1379 LoadIndexedInstr* load_char_code = |
1380 BuildStringCharCodeAt(call, class_ids[0]); | 1380 BuildStringCodeUnitAt(call, class_ids[0]); |
1381 InsertBefore(call, load_char_code, NULL, Definition::kValue); | 1381 InsertBefore(call, load_char_code, NULL, Definition::kValue); |
1382 StringFromCharCodeInstr* char_at = | 1382 StringFromCharCodeInstr* char_at = |
1383 new StringFromCharCodeInstr(new Value(load_char_code), | 1383 new StringFromCharCodeInstr(new Value(load_char_code), |
1384 kOneByteStringCid); | 1384 kOneByteStringCid); |
1385 ReplaceCall(call, char_at); | 1385 ReplaceCall(call, char_at); |
1386 return true; | 1386 return true; |
1387 } | 1387 } |
1388 | 1388 |
1389 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1389 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
1390 (class_ids[0] == kSmiCid)) { | 1390 (class_ids[0] == kSmiCid)) { |
(...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4186 | 4186 |
4187 if (FLAG_trace_constant_propagation) { | 4187 if (FLAG_trace_constant_propagation) { |
4188 OS::Print("\n==== After constant propagation ====\n"); | 4188 OS::Print("\n==== After constant propagation ====\n"); |
4189 FlowGraphPrinter printer(*graph_); | 4189 FlowGraphPrinter printer(*graph_); |
4190 printer.PrintBlocks(); | 4190 printer.PrintBlocks(); |
4191 } | 4191 } |
4192 } | 4192 } |
4193 | 4193 |
4194 | 4194 |
4195 } // namespace dart | 4195 } // namespace dart |
OLD | NEW |