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 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1550 | 1550 |
1551 // Evacuation candidates are swept by evacuator. Needs to return a valid | 1551 // Evacuation candidates are swept by evacuator. Needs to return a valid |
1552 // result before _and_ after evacuation has finished. | 1552 // result before _and_ after evacuation has finished. |
1553 static bool ShouldBeSweptLazily(Page* p) { | 1553 static bool ShouldBeSweptLazily(Page* p) { |
1554 return !p->IsEvacuationCandidate() && | 1554 return !p->IsEvacuationCandidate() && |
1555 !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && | 1555 !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) && |
1556 !p->WasSweptPrecisely(); | 1556 !p->WasSweptPrecisely(); |
1557 } | 1557 } |
1558 | 1558 |
1559 void SetPagesToSweep(Page* first) { | 1559 void SetPagesToSweep(Page* first) { |
1560 if (first == &anchor_) first = NULL; | |
1560 first_unswept_page_ = first; | 1561 first_unswept_page_ = first; |
1561 } | 1562 } |
1562 | 1563 |
1563 bool AdvanceSweeper(intptr_t bytes_to_sweep); | 1564 bool AdvanceSweeper(intptr_t bytes_to_sweep); |
1564 | 1565 |
1565 bool IsSweepingComplete() { | 1566 bool IsSweepingComplete() { |
1566 return !first_unswept_page_->is_valid(); | 1567 return !first_unswept_page_->is_valid(); |
1567 } | 1568 } |
1568 | 1569 |
1569 Page* FirstPage() { return anchor_.next_page(); } | 1570 Page* FirstPage() { return anchor_.next_page(); } |
1570 Page* LastPage() { return anchor_.prev_page(); } | 1571 Page* LastPage() { return anchor_.prev_page(); } |
1571 | 1572 |
1572 bool IsFragmented(Page* p) { | 1573 int Fragmentation(Page* p) { |
Michael Starzinger
2011/11/24 14:43:49
A one-liner comment about the possible range of re
Erik Corry
2011/11/24 17:02:30
Done.
| |
1573 FreeList::SizeStats sizes; | 1574 FreeList::SizeStats sizes; |
1574 free_list_.CountFreeListItems(p, &sizes); | 1575 free_list_.CountFreeListItems(p, &sizes); |
1575 | 1576 |
1576 intptr_t ratio; | 1577 intptr_t ratio; |
1577 intptr_t ratio_threshold; | 1578 intptr_t ratio_threshold; |
1578 if (identity() == CODE_SPACE) { | 1579 if (identity() == CODE_SPACE) { |
1579 ratio = (sizes.medium_size_ * 10 + sizes.large_size_ * 2) * 100 / | 1580 ratio = (sizes.medium_size_ * 10 + sizes.large_size_ * 2) * 100 / |
1580 Page::kObjectAreaSize; | 1581 Page::kObjectAreaSize; |
1581 ratio_threshold = 10; | 1582 ratio_threshold = 10; |
1582 } else { | 1583 } else { |
(...skipping 14 matching lines...) Expand all Loading... | |
1597 Page::kObjectAreaSize, | 1598 Page::kObjectAreaSize, |
1598 static_cast<int>(sizes.large_size_), | 1599 static_cast<int>(sizes.large_size_), |
1599 static_cast<double>(sizes.large_size_ * 100) / | 1600 static_cast<double>(sizes.large_size_ * 100) / |
1600 Page::kObjectAreaSize, | 1601 Page::kObjectAreaSize, |
1601 static_cast<int>(sizes.huge_size_), | 1602 static_cast<int>(sizes.huge_size_), |
1602 static_cast<double>(sizes.huge_size_ * 100) / | 1603 static_cast<double>(sizes.huge_size_ * 100) / |
1603 Page::kObjectAreaSize, | 1604 Page::kObjectAreaSize, |
1604 (ratio > ratio_threshold) ? "[fragmented]" : ""); | 1605 (ratio > ratio_threshold) ? "[fragmented]" : ""); |
1605 } | 1606 } |
1606 | 1607 |
1607 return (ratio > ratio_threshold) || | 1608 if (FLAG_always_compact && sizes.Total() != Page::kObjectAreaSize) { |
1608 (FLAG_always_compact && sizes.Total() != Page::kObjectAreaSize); | 1609 return 1; |
1610 } | |
1611 if (ratio <= ratio_threshold) return 0; // Not fragmented. | |
1612 | |
1613 return static_cast<int>(ratio - ratio_threshold); | |
1609 } | 1614 } |
1610 | 1615 |
1611 void EvictEvacuationCandidatesFromFreeLists(); | 1616 void EvictEvacuationCandidatesFromFreeLists(); |
1612 | 1617 |
1613 bool CanExpand(); | 1618 bool CanExpand(); |
1614 | 1619 |
1615 protected: | 1620 protected: |
1616 // Maximum capacity of this space. | 1621 // Maximum capacity of this space. |
1617 intptr_t max_capacity_; | 1622 intptr_t max_capacity_; |
1618 | 1623 |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2623 } | 2628 } |
2624 // Must be small, since an iteration is used for lookup. | 2629 // Must be small, since an iteration is used for lookup. |
2625 static const int kMaxComments = 64; | 2630 static const int kMaxComments = 64; |
2626 }; | 2631 }; |
2627 #endif | 2632 #endif |
2628 | 2633 |
2629 | 2634 |
2630 } } // namespace v8::internal | 2635 } } // namespace v8::internal |
2631 | 2636 |
2632 #endif // V8_SPACES_H_ | 2637 #endif // V8_SPACES_H_ |
OLD | NEW |