Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 if (free_pos[max_reg].InstructionIndex() == 0) { | 1781 if (free_pos[max_reg].InstructionIndex() == 0) { |
| 1782 return false; | 1782 return false; |
| 1783 } else if (free_pos[max_reg].Value() >= current->End().Value()) { | 1783 } else if (free_pos[max_reg].Value() >= current->End().Value()) { |
| 1784 TraceAlloc("Assigning reg %d to live range %d\n", max_reg, current->id()); | 1784 TraceAlloc("Assigning reg %d to live range %d\n", max_reg, current->id()); |
| 1785 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); | 1785 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); |
| 1786 } else { | 1786 } else { |
| 1787 // Split the interval at the nearest gap and never split an interval at its | 1787 // Split the interval at the nearest gap and never split an interval at its |
| 1788 // start position. | 1788 // start position. |
| 1789 LifetimePosition pos = | 1789 LifetimePosition pos = free_pos[max_reg]; |
|
fschneider
2010/12/07 14:47:08
Fix the comment above.
| |
| 1790 LifetimePosition::FromInstructionIndex( | |
| 1791 chunk_->NearestGapPos(free_pos[max_reg].InstructionIndex())); | |
| 1792 if (pos.Value() <= current->Start().Value()) return false; | 1790 if (pos.Value() <= current->Start().Value()) return false; |
| 1793 LiveRange* second_range = Split(current, pos); | 1791 LiveRange* second_range = Split(current, pos); |
| 1794 AddToUnhandledSorted(second_range); | 1792 AddToUnhandledSorted(second_range); |
| 1795 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); | 1793 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); |
| 1796 } | 1794 } |
| 1797 | 1795 |
| 1798 return true; | 1796 return true; |
| 1799 } | 1797 } |
| 1800 | 1798 |
| 1801 | 1799 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1864 | 1862 |
| 1865 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); | 1863 current->set_assigned_register(max_reg, mode_ == XMM_REGISTERS); |
| 1866 SplitAndSpillIntersecting(current); | 1864 SplitAndSpillIntersecting(current); |
| 1867 } | 1865 } |
| 1868 } | 1866 } |
| 1869 | 1867 |
| 1870 | 1868 |
| 1871 void LAllocator::SplitAndSpillIntersecting(LiveRange* current) { | 1869 void LAllocator::SplitAndSpillIntersecting(LiveRange* current) { |
| 1872 ASSERT(current->HasRegisterAssigned()); | 1870 ASSERT(current->HasRegisterAssigned()); |
| 1873 int reg = current->assigned_register(); | 1871 int reg = current->assigned_register(); |
| 1874 LifetimePosition split_pos = | 1872 LifetimePosition split_pos = current->Start(); |
| 1875 LifetimePosition::FromInstructionIndex( | |
| 1876 chunk_->NearestGapPos(current->Start().InstructionIndex())); | |
| 1877 for (int i = 0; i < active_live_ranges_.length(); ++i) { | 1873 for (int i = 0; i < active_live_ranges_.length(); ++i) { |
| 1878 LiveRange* range = active_live_ranges_[i]; | 1874 LiveRange* range = active_live_ranges_[i]; |
| 1879 if (range->assigned_register() == reg) { | 1875 if (range->assigned_register() == reg) { |
| 1880 UsePosition* next_pos = range->NextRegisterPosition(current->Start()); | 1876 UsePosition* next_pos = range->NextRegisterPosition(current->Start()); |
| 1881 if (next_pos == NULL) { | 1877 if (next_pos == NULL) { |
| 1882 SplitAndSpill(range, split_pos); | 1878 SplitAndSpill(range, split_pos); |
| 1883 } else { | 1879 } else { |
| 1884 SplitAndSpill(range, split_pos, next_pos->pos()); | 1880 SplitAndSpill(range, split_pos, next_pos->pos()); |
| 1885 } | 1881 } |
| 1886 ActiveToHandled(range); | 1882 ActiveToHandled(range); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2005 Spill(tail_part); | 2001 Spill(tail_part); |
| 2006 ASSERT(third_part != tail_part); | 2002 ASSERT(third_part != tail_part); |
| 2007 AddToUnhandledSorted(third_part); | 2003 AddToUnhandledSorted(third_part); |
| 2008 } else { | 2004 } else { |
| 2009 AddToUnhandledSorted(tail_part); | 2005 AddToUnhandledSorted(tail_part); |
| 2010 } | 2006 } |
| 2011 } | 2007 } |
| 2012 | 2008 |
| 2013 | 2009 |
| 2014 void LAllocator::SplitAndSpill(LiveRange* range, LifetimePosition at) { | 2010 void LAllocator::SplitAndSpill(LiveRange* range, LifetimePosition at) { |
| 2015 at = LifetimePosition::FromInstructionIndex( | |
| 2016 chunk_->NearestGapPos(at.InstructionIndex())); | |
| 2017 LiveRange* second_part = Split(range, at); | 2011 LiveRange* second_part = Split(range, at); |
| 2018 Spill(second_part); | 2012 Spill(second_part); |
| 2019 } | 2013 } |
| 2020 | 2014 |
| 2021 | 2015 |
| 2022 void LAllocator::Spill(LiveRange* range) { | 2016 void LAllocator::Spill(LiveRange* range) { |
| 2023 ASSERT(!range->IsSpilled()); | 2017 ASSERT(!range->IsSpilled()); |
| 2024 TraceAlloc("Spilling live range %d\n", range->id()); | 2018 TraceAlloc("Spilling live range %d\n", range->id()); |
| 2025 LiveRange* first = range->TopLevel(); | 2019 LiveRange* first = range->TopLevel(); |
| 2026 | 2020 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 2046 LiveRange* current = live_ranges()->at(i); | 2040 LiveRange* current = live_ranges()->at(i); |
| 2047 if (current != NULL) current->Verify(); | 2041 if (current != NULL) current->Verify(); |
| 2048 } | 2042 } |
| 2049 } | 2043 } |
| 2050 | 2044 |
| 2051 | 2045 |
| 2052 #endif | 2046 #endif |
| 2053 | 2047 |
| 2054 | 2048 |
| 2055 } } // namespace v8::internal | 2049 } } // namespace v8::internal |
| OLD | NEW |