| 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/globals.h" // Needed here to get TARGET_ARCH_XXX. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_XXX. |
| 6 | 6 |
| 7 #include "vm/flow_graph_compiler.h" | 7 #include "vm/flow_graph_compiler.h" |
| 8 | 8 |
| 9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
| 10 #include "vm/cha.h" | 10 #include "vm/cha.h" |
| (...skipping 1616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1627 } | 1627 } |
| 1628 | 1628 |
| 1629 | 1629 |
| 1630 ParallelMoveResolver::ScratchRegisterScope::~ScratchRegisterScope() { | 1630 ParallelMoveResolver::ScratchRegisterScope::~ScratchRegisterScope() { |
| 1631 if (spilled_) { | 1631 if (spilled_) { |
| 1632 resolver_->RestoreScratch(reg_); | 1632 resolver_->RestoreScratch(reg_); |
| 1633 } | 1633 } |
| 1634 } | 1634 } |
| 1635 | 1635 |
| 1636 | 1636 |
| 1637 template <typename T> | |
| 1638 static int HighestCountFirst(const T* a, const T* b) { | |
| 1639 // Negative if 'a' should sort before 'b'. | |
| 1640 return b->count - a->count; | |
| 1641 } | |
| 1642 | |
| 1643 | |
| 1644 static int LowestCidFirst(const CidRangeTarget* a, const CidRangeTarget* b) { | |
| 1645 // Negative if 'a' should sort before 'b'. | |
| 1646 return a->cid_start - b->cid_start; | |
| 1647 } | |
| 1648 | |
| 1649 | |
| 1650 // Returns 'sorted' array in decreasing count order. | |
| 1651 // The expected number of elements to sort is less than 10. | |
| 1652 void FlowGraphCompiler::SortICDataByCount( | |
| 1653 const ICData& ic_data, | |
| 1654 GrowableArray<CidRangeTarget>* sorted_arg, | |
| 1655 bool drop_smi) { | |
| 1656 GrowableArray<CidRangeTarget>& sorted = *sorted_arg; | |
| 1657 ASSERT(ic_data.NumArgsTested() == 1); | |
| 1658 const intptr_t len = ic_data.NumberOfChecks(); | |
| 1659 sorted.Clear(); | |
| 1660 | |
| 1661 for (int i = 0; i < len; i++) { | |
| 1662 intptr_t receiver_cid = ic_data.GetReceiverClassIdAt(i); | |
| 1663 if (drop_smi && (receiver_cid == kSmiCid)) continue; | |
| 1664 Function& target = Function::ZoneHandle(ic_data.GetTargetAt(i)); | |
| 1665 sorted.Add(CidRangeTarget(receiver_cid, receiver_cid, &target, | |
| 1666 ic_data.GetCountAt(i))); | |
| 1667 } | |
| 1668 sorted.Sort(LowestCidFirst); | |
| 1669 int dest = 0; | |
| 1670 | |
| 1671 // Merge adjacent ranges. | |
| 1672 for (int src = 0; src < sorted.length(); src++) { | |
| 1673 if (src > 0 && sorted[src - 1].cid_end + 1 == sorted[src].cid_start && | |
| 1674 sorted[src - 1].target->raw() == sorted[src].target->raw()) { | |
| 1675 sorted[dest - 1].cid_end++; | |
| 1676 sorted[dest - 1].count += sorted[dest].count; | |
| 1677 } else { | |
| 1678 sorted[dest++] = sorted[src]; | |
| 1679 } | |
| 1680 } | |
| 1681 | |
| 1682 sorted.SetLength(dest); | |
| 1683 sorted.Sort(HighestCountFirst); | |
| 1684 } | |
| 1685 | |
| 1686 | |
| 1687 const ICData* FlowGraphCompiler::GetOrAddInstanceCallICData( | 1637 const ICData* FlowGraphCompiler::GetOrAddInstanceCallICData( |
| 1688 intptr_t deopt_id, | 1638 intptr_t deopt_id, |
| 1689 const String& target_name, | 1639 const String& target_name, |
| 1690 const Array& arguments_descriptor, | 1640 const Array& arguments_descriptor, |
| 1691 intptr_t num_args_tested) { | 1641 intptr_t num_args_tested) { |
| 1692 if ((deopt_id_to_ic_data_ != NULL) && | 1642 if ((deopt_id_to_ic_data_ != NULL) && |
| 1693 ((*deopt_id_to_ic_data_)[deopt_id] != NULL)) { | 1643 ((*deopt_id_to_ic_data_)[deopt_id] != NULL)) { |
| 1694 const ICData* res = (*deopt_id_to_ic_data_)[deopt_id]; | 1644 const ICData* res = (*deopt_id_to_ic_data_)[deopt_id]; |
| 1695 ASSERT(res->deopt_id() == deopt_id); | 1645 ASSERT(res->deopt_id() == deopt_id); |
| 1696 ASSERT(res->target_name() == target_name.raw()); | 1646 ASSERT(res->target_name() == target_name.raw()); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2069 | 2019 |
| 2070 | 2020 |
| 2071 void FlowGraphCompiler::FrameStateClear() { | 2021 void FlowGraphCompiler::FrameStateClear() { |
| 2072 ASSERT(!is_optimizing()); | 2022 ASSERT(!is_optimizing()); |
| 2073 frame_state_.TruncateTo(0); | 2023 frame_state_.TruncateTo(0); |
| 2074 } | 2024 } |
| 2075 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) | 2025 #endif // defined(DEBUG) && !defined(TARGET_ARCH_DBC) |
| 2076 | 2026 |
| 2077 | 2027 |
| 2078 } // namespace dart | 2028 } // namespace dart |
| OLD | NEW |