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 1571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1582 | 1582 |
1583 bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1583 bool AdvanceSweeper(intptr_t bytes_to_sweep); |
1584 | 1584 |
1585 bool IsSweepingComplete() { | 1585 bool IsSweepingComplete() { |
1586 return !first_unswept_page_->is_valid(); | 1586 return !first_unswept_page_->is_valid(); |
1587 } | 1587 } |
1588 | 1588 |
1589 Page* FirstPage() { return anchor_.next_page(); } | 1589 Page* FirstPage() { return anchor_.next_page(); } |
1590 Page* LastPage() { return anchor_.prev_page(); } | 1590 Page* LastPage() { return anchor_.prev_page(); } |
1591 | 1591 |
1592 // Returns zero for pages that have so little fragmentation that it is not | 1592 void CountFreeListItems(Page* p, FreeList::SizeStats* sizes) { |
1593 // worth defragmenting them. Otherwise a positive integer that gives an | 1593 free_list_.CountFreeListItems(p, sizes); |
1594 // estimate of fragmentation on an arbitrary scale. | |
1595 int Fragmentation(Page* p) { | |
1596 FreeList::SizeStats sizes; | |
1597 free_list_.CountFreeListItems(p, &sizes); | |
1598 | |
1599 intptr_t ratio; | |
1600 intptr_t ratio_threshold; | |
1601 if (identity() == CODE_SPACE) { | |
1602 ratio = (sizes.medium_size_ * 10 + sizes.large_size_ * 2) * 100 / | |
1603 Page::kObjectAreaSize; | |
1604 ratio_threshold = 10; | |
1605 } else { | |
1606 ratio = (sizes.small_size_ * 5 + sizes.medium_size_) * 100 / | |
1607 Page::kObjectAreaSize; | |
1608 ratio_threshold = 15; | |
1609 } | |
1610 | |
1611 if (FLAG_trace_fragmentation) { | |
1612 PrintF("%p [%d]: %d (%.2f%%) %d (%.2f%%) %d (%.2f%%) %d (%.2f%%) %s\n", | |
1613 reinterpret_cast<void*>(p), | |
1614 identity(), | |
1615 static_cast<int>(sizes.small_size_), | |
1616 static_cast<double>(sizes.small_size_ * 100) / | |
1617 Page::kObjectAreaSize, | |
1618 static_cast<int>(sizes.medium_size_), | |
1619 static_cast<double>(sizes.medium_size_ * 100) / | |
1620 Page::kObjectAreaSize, | |
1621 static_cast<int>(sizes.large_size_), | |
1622 static_cast<double>(sizes.large_size_ * 100) / | |
1623 Page::kObjectAreaSize, | |
1624 static_cast<int>(sizes.huge_size_), | |
1625 static_cast<double>(sizes.huge_size_ * 100) / | |
1626 Page::kObjectAreaSize, | |
1627 (ratio > ratio_threshold) ? "[fragmented]" : ""); | |
1628 } | |
1629 | |
1630 if (FLAG_always_compact && sizes.Total() != Page::kObjectAreaSize) { | |
1631 return 1; | |
1632 } | |
1633 if (ratio <= ratio_threshold) return 0; // Not fragmented. | |
1634 | |
1635 return static_cast<int>(ratio - ratio_threshold); | |
1636 } | 1594 } |
1637 | 1595 |
1638 void EvictEvacuationCandidatesFromFreeLists(); | 1596 void EvictEvacuationCandidatesFromFreeLists(); |
1639 | 1597 |
1640 bool CanExpand(); | 1598 bool CanExpand(); |
1641 | 1599 |
1642 // Returns the number of total pages in this space. | 1600 // Returns the number of total pages in this space. |
1643 int CountTotalPages(); | 1601 int CountTotalPages(); |
1644 | 1602 |
1645 protected: | 1603 protected: |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 } | 2614 } |
2657 // Must be small, since an iteration is used for lookup. | 2615 // Must be small, since an iteration is used for lookup. |
2658 static const int kMaxComments = 64; | 2616 static const int kMaxComments = 64; |
2659 }; | 2617 }; |
2660 #endif | 2618 #endif |
2661 | 2619 |
2662 | 2620 |
2663 } } // namespace v8::internal | 2621 } } // namespace v8::internal |
2664 | 2622 |
2665 #endif // V8_SPACES_H_ | 2623 #endif // V8_SPACES_H_ |
OLD | NEW |