| 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 1575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 MethodRecognizer::RecognizeKind(target); | 1586 MethodRecognizer::RecognizeKind(target); |
| 1587 | 1587 |
| 1588 if ((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) && | 1588 if ((recognized_kind == MethodRecognizer::kStringBaseCodeUnitAt) && |
| 1589 (ic_data.NumberOfChecks() == 1) && | 1589 (ic_data.NumberOfChecks() == 1) && |
| 1590 ((class_ids[0] == kOneByteStringCid) || | 1590 ((class_ids[0] == kOneByteStringCid) || |
| 1591 (class_ids[0] == kTwoByteStringCid))) { | 1591 (class_ids[0] == kTwoByteStringCid))) { |
| 1592 LoadIndexedInstr* instr = BuildStringCodeUnitAt(call, class_ids[0]); | 1592 LoadIndexedInstr* instr = BuildStringCodeUnitAt(call, class_ids[0]); |
| 1593 ReplaceCall(call, instr); | 1593 ReplaceCall(call, instr); |
| 1594 return true; | 1594 return true; |
| 1595 } | 1595 } |
| 1596 if ((recognized_kind == MethodRecognizer::kStringBaseCharAt) && | 1596 if ((class_ids[0] == kOneByteStringCid) && (ic_data.NumberOfChecks() == 1)) { |
| 1597 (ic_data.NumberOfChecks() == 1) && | 1597 if (recognized_kind == MethodRecognizer::kStringBaseCharAt) { |
| 1598 (class_ids[0] == kOneByteStringCid)) { | 1598 // TODO(fschneider): Handle TwoByteString. |
| 1599 // TODO(fschneider): Handle TwoByteString. | 1599 LoadIndexedInstr* load_char_code = |
| 1600 LoadIndexedInstr* load_char_code = | 1600 BuildStringCodeUnitAt(call, class_ids[0]); |
| 1601 BuildStringCodeUnitAt(call, class_ids[0]); | 1601 InsertBefore(call, load_char_code, NULL, Definition::kValue); |
| 1602 InsertBefore(call, load_char_code, NULL, Definition::kValue); | 1602 StringFromCharCodeInstr* char_at = |
| 1603 StringFromCharCodeInstr* char_at = | 1603 new StringFromCharCodeInstr(new Value(load_char_code), |
| 1604 new StringFromCharCodeInstr(new Value(load_char_code), | 1604 kOneByteStringCid); |
| 1605 kOneByteStringCid); | 1605 ReplaceCall(call, char_at); |
| 1606 ReplaceCall(call, char_at); | 1606 return true; |
| 1607 return true; | 1607 } |
| 1608 if (recognized_kind == MethodRecognizer::kOneByteStringSetAt) { |
| 1609 // This is an internal method, no need to check argument types nor |
| 1610 // range. |
| 1611 Definition* str = call->ArgumentAt(0); |
| 1612 Definition* index = call->ArgumentAt(1); |
| 1613 Definition* value = call->ArgumentAt(2); |
| 1614 StoreIndexedInstr* store_op = new StoreIndexedInstr( |
| 1615 new Value(str), |
| 1616 new Value(index), |
| 1617 new Value(value), |
| 1618 kNoStoreBarrier, |
| 1619 1, // Index scale |
| 1620 kOneByteStringCid, |
| 1621 call->deopt_id()); |
| 1622 ReplaceCall(call, store_op); |
| 1623 return true; |
| 1624 } |
| 1625 return false; |
| 1608 } | 1626 } |
| 1609 | 1627 |
| 1610 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && | 1628 if ((recognized_kind == MethodRecognizer::kIntegerToDouble) && |
| 1611 (ic_data.NumberOfChecks() == 1) && | 1629 (ic_data.NumberOfChecks() == 1) && |
| 1612 (class_ids[0] == kSmiCid)) { | 1630 (class_ids[0] == kSmiCid)) { |
| 1613 AddReceiverCheck(call); | 1631 AddReceiverCheck(call); |
| 1614 ReplaceCall(call, new SmiToDoubleInstr(new Value(call->ArgumentAt(0)))); | 1632 ReplaceCall(call, new SmiToDoubleInstr(new Value(call->ArgumentAt(0)))); |
| 1615 return true; | 1633 return true; |
| 1616 } | 1634 } |
| 1617 | 1635 |
| (...skipping 4509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6127 | 6145 |
| 6128 // Insert materializations at environment uses. | 6146 // Insert materializations at environment uses. |
| 6129 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 6147 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 6130 for (intptr_t i = 0; i < exits.length(); i++) { | 6148 for (intptr_t i = 0; i < exits.length(); i++) { |
| 6131 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 6149 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 6132 } | 6150 } |
| 6133 } | 6151 } |
| 6134 | 6152 |
| 6135 | 6153 |
| 6136 } // namespace dart | 6154 } // namespace dart |
| OLD | NEW |