| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 | 1595 |
| 1596 bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1596 bool AdvanceSweeper(intptr_t bytes_to_sweep); |
| 1597 | 1597 |
| 1598 bool IsSweepingComplete() { | 1598 bool IsSweepingComplete() { |
| 1599 return !first_unswept_page_->is_valid(); | 1599 return !first_unswept_page_->is_valid(); |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 Page* FirstPage() { return anchor_.next_page(); } | 1602 Page* FirstPage() { return anchor_.next_page(); } |
| 1603 Page* LastPage() { return anchor_.prev_page(); } | 1603 Page* LastPage() { return anchor_.prev_page(); } |
| 1604 | 1604 |
| 1605 // Returns zero for pages that have so little fragmentation that it is not | 1605 void CountFreeListItems(Page* p, FreeList::SizeStats* sizes) { |
| 1606 // worth defragmenting them. Otherwise a positive integer that gives an | 1606 free_list_.CountFreeListItems(p, sizes); |
| 1607 // estimate of fragmentation on an arbitrary scale. | |
| 1608 int Fragmentation(Page* p) { | |
| 1609 FreeList::SizeStats sizes; | |
| 1610 free_list_.CountFreeListItems(p, &sizes); | |
| 1611 | |
| 1612 intptr_t ratio; | |
| 1613 intptr_t ratio_threshold; | |
| 1614 if (identity() == CODE_SPACE) { | |
| 1615 ratio = (sizes.medium_size_ * 10 + sizes.large_size_ * 2) * 100 / | |
| 1616 AreaSize(); | |
| 1617 ratio_threshold = 10; | |
| 1618 } else { | |
| 1619 ratio = (sizes.small_size_ * 5 + sizes.medium_size_) * 100 / | |
| 1620 AreaSize(); | |
| 1621 ratio_threshold = 15; | |
| 1622 } | |
| 1623 | |
| 1624 if (FLAG_trace_fragmentation) { | |
| 1625 PrintF("%p [%d]: %d (%.2f%%) %d (%.2f%%) %d (%.2f%%) %d (%.2f%%) %s\n", | |
| 1626 reinterpret_cast<void*>(p), | |
| 1627 identity(), | |
| 1628 static_cast<int>(sizes.small_size_), | |
| 1629 static_cast<double>(sizes.small_size_ * 100) / | |
| 1630 AreaSize(), | |
| 1631 static_cast<int>(sizes.medium_size_), | |
| 1632 static_cast<double>(sizes.medium_size_ * 100) / | |
| 1633 AreaSize(), | |
| 1634 static_cast<int>(sizes.large_size_), | |
| 1635 static_cast<double>(sizes.large_size_ * 100) / | |
| 1636 AreaSize(), | |
| 1637 static_cast<int>(sizes.huge_size_), | |
| 1638 static_cast<double>(sizes.huge_size_ * 100) / | |
| 1639 AreaSize(), | |
| 1640 (ratio > ratio_threshold) ? "[fragmented]" : ""); | |
| 1641 } | |
| 1642 | |
| 1643 if (FLAG_always_compact && sizes.Total() != AreaSize()) { | |
| 1644 return 1; | |
| 1645 } | |
| 1646 if (ratio <= ratio_threshold) return 0; // Not fragmented. | |
| 1647 | |
| 1648 return static_cast<int>(ratio - ratio_threshold); | |
| 1649 } | 1607 } |
| 1650 | 1608 |
| 1651 void EvictEvacuationCandidatesFromFreeLists(); | 1609 void EvictEvacuationCandidatesFromFreeLists(); |
| 1652 | 1610 |
| 1653 bool CanExpand(); | 1611 bool CanExpand(); |
| 1654 | 1612 |
| 1655 // Returns the number of total pages in this space. | 1613 // Returns the number of total pages in this space. |
| 1656 int CountTotalPages(); | 1614 int CountTotalPages(); |
| 1657 | 1615 |
| 1658 // Return size of allocatable area on a page in this space. | 1616 // Return size of allocatable area on a page in this space. |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2678 } | 2636 } |
| 2679 // Must be small, since an iteration is used for lookup. | 2637 // Must be small, since an iteration is used for lookup. |
| 2680 static const int kMaxComments = 64; | 2638 static const int kMaxComments = 64; |
| 2681 }; | 2639 }; |
| 2682 #endif | 2640 #endif |
| 2683 | 2641 |
| 2684 | 2642 |
| 2685 } } // namespace v8::internal | 2643 } } // namespace v8::internal |
| 2686 | 2644 |
| 2687 #endif // V8_SPACES_H_ | 2645 #endif // V8_SPACES_H_ |
| OLD | NEW |