| 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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 } | 1407 } |
| 1408 InlineStringIsEmptyGetter(call); | 1408 InlineStringIsEmptyGetter(call); |
| 1409 return true; | 1409 return true; |
| 1410 default: | 1410 default: |
| 1411 ASSERT(recognized_kind == MethodRecognizer::kUnknown); | 1411 ASSERT(recognized_kind == MethodRecognizer::kUnknown); |
| 1412 } | 1412 } |
| 1413 return false; | 1413 return false; |
| 1414 } | 1414 } |
| 1415 | 1415 |
| 1416 | 1416 |
| 1417 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCharCodeAt( | 1417 LoadIndexedInstr* FlowGraphOptimizer::BuildStringCodeUnitAt( |
| 1418 InstanceCallInstr* call, | 1418 InstanceCallInstr* call, |
| 1419 intptr_t cid) { | 1419 intptr_t cid) { |
| 1420 Definition* str = call->ArgumentAt(0); | 1420 Definition* str = call->ArgumentAt(0); |
| 1421 Definition* index = call->ArgumentAt(1); | 1421 Definition* index = call->ArgumentAt(1); |
| 1422 AddReceiverCheck(call); | 1422 AddReceiverCheck(call); |
| 1423 InsertBefore(call, | 1423 InsertBefore(call, |
| 1424 new CheckSmiInstr(new Value(index), call->deopt_id()), | 1424 new CheckSmiInstr(new Value(index), call->deopt_id()), |
| 1425 call->env(), | 1425 call->env(), |
| 1426 Definition::kEffect); | 1426 Definition::kEffect); |
| 1427 // If both index and string are constants, then do a compile-time check. | 1427 // If both index and string are constants, then do a compile-time check. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1529 case MethodRecognizer::kInt16ArraySetIndexed: | 1529 case MethodRecognizer::kInt16ArraySetIndexed: |
| 1530 case MethodRecognizer::kUint16ArraySetIndexed: | 1530 case MethodRecognizer::kUint16ArraySetIndexed: |
| 1531 case MethodRecognizer::kInt32ArraySetIndexed: | 1531 case MethodRecognizer::kInt32ArraySetIndexed: |
| 1532 case MethodRecognizer::kUint32ArraySetIndexed: | 1532 case MethodRecognizer::kUint32ArraySetIndexed: |
| 1533 return TryInlineByteArraySetIndexed(call); | 1533 return TryInlineByteArraySetIndexed(call); |
| 1534 | 1534 |
| 1535 default: | 1535 default: |
| 1536 break; | 1536 break; |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 if ((recognized_kind == MethodRecognizer::kStringBaseCharCodeAt) && | 1539 if ((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) && |
| 1540 (ic_data.NumberOfChecks() == 1) && | 1540 (ic_data.NumberOfChecks() == 1) && |
| 1541 ((class_ids[0] == kOneByteStringCid) || | 1541 ((class_ids[0] == kOneByteStringCid) || |
| 1542 (class_ids[0] == kTwoByteStringCid))) { | 1542 (class_ids[0] == kTwoByteStringCid))) { |
| 1543 LoadIndexedInstr* instr = BuildStringCharCodeAt(call, class_ids[0]); | 1543 LoadIndexedInstr* instr = BuildStringCodeUnitAt(call, class_ids[0]); |
| 1544 ReplaceCall(call, instr); | 1544 ReplaceCall(call, instr); |
| 1545 return true; | 1545 return true; |
| 1546 } | 1546 } |
| 1547 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && | 1547 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && |
| 1548 (ic_data.NumberOfChecks() == 1) && | 1548 (ic_data.NumberOfChecks() == 1) && |
| 1549 (class_ids[0] == kOneByteStringCid)) { | 1549 (class_ids[0] == kOneByteStringCid)) { |
| 1550 // TODO(fschneider): Handle TwoByteString. | 1550 // TODO(fschneider): Handle TwoByteString. |
| 1551 LoadIndexedInstr* load_char_code = | 1551 LoadIndexedInstr* load_char_code = |
| 1552 BuildStringCharCodeAt(call, class_ids[0]); | 1552 BuildStringCodeUnitAt(call, class_ids[0]); |
| 1553 InsertBefore(call, load_char_code, NULL, Definition::kValue); | 1553 InsertBefore(call, load_char_code, NULL, Definition::kValue); |
| 1554 StringFromCharCodeInstr* char_at = | 1554 StringFromCharCodeInstr* char_at = |
| 1555 new StringFromCharCodeInstr(new Value(load_char_code), | 1555 new StringFromCharCodeInstr(new Value(load_char_code), |
| 1556 kOneByteStringCid); | 1556 kOneByteStringCid); |
| 1557 ReplaceCall(call, char_at); | 1557 ReplaceCall(call, char_at); |
| 1558 return true; | 1558 return true; |
| 1559 } | 1559 } |
| 1560 | 1560 |
| 1561 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1561 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 1562 (class_ids[0] == kSmiCid)) { | 1562 (class_ids[0] == kSmiCid)) { |
| (...skipping 2820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4383 | 4383 |
| 4384 if (FLAG_trace_constant_propagation) { | 4384 if (FLAG_trace_constant_propagation) { |
| 4385 OS::Print("\n==== After constant propagation ====\n"); | 4385 OS::Print("\n==== After constant propagation ====\n"); |
| 4386 FlowGraphPrinter printer(*graph_); | 4386 FlowGraphPrinter printer(*graph_); |
| 4387 printer.PrintBlocks(); | 4387 printer.PrintBlocks(); |
| 4388 } | 4388 } |
| 4389 } | 4389 } |
| 4390 | 4390 |
| 4391 | 4391 |
| 4392 } // namespace dart | 4392 } // namespace dart |
| OLD | NEW |