OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1554 } | 1554 } |
1555 | 1555 |
1556 inline Address* NewSpaceHighPromotionModeActiveAddress() { | 1556 inline Address* NewSpaceHighPromotionModeActiveAddress() { |
1557 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); | 1557 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); |
1558 } | 1558 } |
1559 | 1559 |
1560 inline intptr_t PromotedTotalSize() { | 1560 inline intptr_t PromotedTotalSize() { |
1561 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); | 1561 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); |
1562 } | 1562 } |
1563 | 1563 |
| 1564 // True if we have reached the allocation limit in the old generation that |
| 1565 // should force the next GC (caused normally) to be a full one. |
| 1566 inline bool OldGenerationPromotionLimitReached() { |
| 1567 return PromotedTotalSize() > old_gen_promotion_limit_; |
| 1568 } |
| 1569 |
1564 inline intptr_t OldGenerationSpaceAvailable() { | 1570 inline intptr_t OldGenerationSpaceAvailable() { |
1565 return old_generation_allocation_limit_ - PromotedTotalSize(); | 1571 return old_gen_allocation_limit_ - PromotedTotalSize(); |
1566 } | 1572 } |
1567 | 1573 |
1568 inline intptr_t OldGenerationCapacityAvailable() { | 1574 inline intptr_t OldGenerationCapacityAvailable() { |
1569 return max_old_generation_size_ - PromotedTotalSize(); | 1575 return max_old_generation_size_ - PromotedTotalSize(); |
1570 } | 1576 } |
1571 | 1577 |
1572 static const intptr_t kMinimumOldGenerationAllocationLimit = | 1578 static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; |
| 1579 static const intptr_t kMinimumAllocationLimit = |
1573 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | 1580 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
1574 | 1581 |
1575 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) { | 1582 intptr_t OldGenPromotionLimit(intptr_t old_gen_size) { |
1576 const int divisor = FLAG_stress_compaction ? 10 : | 1583 const int divisor = FLAG_stress_compaction ? 10 : |
1577 new_space_high_promotion_mode_active_ ? 1 : 3; | 1584 new_space_high_promotion_mode_active_ ? 1 : 3; |
1578 intptr_t limit = | 1585 intptr_t limit = |
1579 Max(old_gen_size + old_gen_size / divisor, | 1586 Max(old_gen_size + old_gen_size / divisor, kMinimumPromotionLimit); |
1580 kMinimumOldGenerationAllocationLimit); | |
1581 limit += new_space_.Capacity(); | 1587 limit += new_space_.Capacity(); |
1582 // TODO(hpayer): Can be removed when when pretenuring is supported for all | 1588 // TODO(hpayer): Can be removed when when pretenuring is supported for all |
1583 // allocation sites. | 1589 // allocation sites. |
| 1590 if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) { |
| 1591 limit *= 2; |
| 1592 } |
| 1593 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 1594 return Min(limit, halfway_to_the_max); |
| 1595 } |
| 1596 |
| 1597 intptr_t OldGenAllocationLimit(intptr_t old_gen_size) { |
| 1598 const int divisor = FLAG_stress_compaction ? 8 : |
| 1599 new_space_high_promotion_mode_active_ ? 1 : 2; |
| 1600 intptr_t limit = |
| 1601 Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit); |
| 1602 limit += new_space_.Capacity(); |
| 1603 // TODO(hpayer): Can be removed when when pretenuring is supported for all |
| 1604 // allocation sites. |
1584 if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) { | 1605 if (IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend()) { |
1585 limit *= 2; | 1606 limit *= 2; |
1586 } | 1607 } |
1587 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 1608 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
1588 return Min(limit, halfway_to_the_max); | 1609 return Min(limit, halfway_to_the_max); |
1589 } | 1610 } |
1590 | 1611 |
1591 // Implements the corresponding V8 API function. | 1612 // Implements the corresponding V8 API function. |
1592 bool IdleNotification(int hint); | 1613 bool IdleNotification(int hint); |
1593 | 1614 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1651 ASSERT(survived >= 0); | 1672 ASSERT(survived >= 0); |
1652 young_survivors_after_last_gc_ = survived; | 1673 young_survivors_after_last_gc_ = survived; |
1653 survived_since_last_expansion_ += survived; | 1674 survived_since_last_expansion_ += survived; |
1654 } | 1675 } |
1655 | 1676 |
1656 inline bool NextGCIsLikelyToBeFull() { | 1677 inline bool NextGCIsLikelyToBeFull() { |
1657 if (FLAG_gc_global) return true; | 1678 if (FLAG_gc_global) return true; |
1658 | 1679 |
1659 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; | 1680 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; |
1660 | 1681 |
| 1682 intptr_t total_promoted = PromotedTotalSize(); |
| 1683 |
| 1684 intptr_t adjusted_promotion_limit = |
| 1685 old_gen_promotion_limit_ - new_space_.Capacity(); |
| 1686 |
| 1687 if (total_promoted >= adjusted_promotion_limit) return true; |
| 1688 |
1661 intptr_t adjusted_allocation_limit = | 1689 intptr_t adjusted_allocation_limit = |
1662 old_generation_allocation_limit_ - new_space_.Capacity(); | 1690 old_gen_allocation_limit_ - new_space_.Capacity() / 5; |
1663 | 1691 |
1664 if (PromotedTotalSize() >= adjusted_allocation_limit) return true; | 1692 if (PromotedSpaceSizeOfObjects() >= adjusted_allocation_limit) return true; |
1665 | 1693 |
1666 return false; | 1694 return false; |
1667 } | 1695 } |
1668 | 1696 |
| 1697 |
1669 void UpdateNewSpaceReferencesInExternalStringTable( | 1698 void UpdateNewSpaceReferencesInExternalStringTable( |
1670 ExternalStringTableUpdaterCallback updater_func); | 1699 ExternalStringTableUpdaterCallback updater_func); |
1671 | 1700 |
1672 void UpdateReferencesInExternalStringTable( | 1701 void UpdateReferencesInExternalStringTable( |
1673 ExternalStringTableUpdaterCallback updater_func); | 1702 ExternalStringTableUpdaterCallback updater_func); |
1674 | 1703 |
1675 void ProcessWeakReferences(WeakObjectRetainer* retainer); | 1704 void ProcessWeakReferences(WeakObjectRetainer* retainer); |
1676 | 1705 |
1677 void VisitExternalResources(v8::ExternalResourceVisitor* visitor); | 1706 void VisitExternalResources(v8::ExternalResourceVisitor* visitor); |
1678 | 1707 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1983 bool disallow_allocation_failure_; | 2012 bool disallow_allocation_failure_; |
1984 #endif // DEBUG | 2013 #endif // DEBUG |
1985 | 2014 |
1986 // Indicates that the new space should be kept small due to high promotion | 2015 // Indicates that the new space should be kept small due to high promotion |
1987 // rates caused by the mutator allocating a lot of long-lived objects. | 2016 // rates caused by the mutator allocating a lot of long-lived objects. |
1988 // TODO(hpayer): change to bool if no longer accessed from generated code | 2017 // TODO(hpayer): change to bool if no longer accessed from generated code |
1989 intptr_t new_space_high_promotion_mode_active_; | 2018 intptr_t new_space_high_promotion_mode_active_; |
1990 | 2019 |
1991 // Limit that triggers a global GC on the next (normally caused) GC. This | 2020 // Limit that triggers a global GC on the next (normally caused) GC. This |
1992 // is checked when we have already decided to do a GC to help determine | 2021 // is checked when we have already decided to do a GC to help determine |
1993 // which collector to invoke, before expanding a paged space in the old | 2022 // which collector to invoke. |
1994 // generation and on every allocation in large object space. | 2023 intptr_t old_gen_promotion_limit_; |
1995 intptr_t old_generation_allocation_limit_; | 2024 |
| 2025 // Limit that triggers a global GC as soon as is reasonable. This is |
| 2026 // checked before expanding a paged space in the old generation and on |
| 2027 // every allocation in large object space. |
| 2028 intptr_t old_gen_allocation_limit_; |
1996 | 2029 |
1997 // Used to adjust the limits that control the timing of the next GC. | 2030 // Used to adjust the limits that control the timing of the next GC. |
1998 intptr_t size_of_old_gen_at_last_old_space_gc_; | 2031 intptr_t size_of_old_gen_at_last_old_space_gc_; |
1999 | 2032 |
2000 // Limit on the amount of externally allocated memory allowed | 2033 // Limit on the amount of externally allocated memory allowed |
2001 // between global GCs. If reached a global GC is forced. | 2034 // between global GCs. If reached a global GC is forced. |
2002 intptr_t external_allocation_limit_; | 2035 intptr_t external_allocation_limit_; |
2003 | 2036 |
2004 // The amount of external memory registered through the API kept alive | 2037 // The amount of external memory registered through the API kept alive |
2005 // by global handles | 2038 // by global handles |
2006 intptr_t amount_of_external_allocated_memory_; | 2039 intptr_t amount_of_external_allocated_memory_; |
2007 | 2040 |
2008 // Caches the amount of external memory registered at the last global gc. | 2041 // Caches the amount of external memory registered at the last global gc. |
2009 intptr_t amount_of_external_allocated_memory_at_last_global_gc_; | 2042 intptr_t amount_of_external_allocated_memory_at_last_global_gc_; |
2010 | 2043 |
2011 // Indicates that an allocation has failed in the old generation since the | 2044 // Indicates that an allocation has failed in the old generation since the |
2012 // last GC. | 2045 // last GC. |
2013 bool old_gen_exhausted_; | 2046 int old_gen_exhausted_; |
2014 | 2047 |
2015 Object* native_contexts_list_; | 2048 Object* native_contexts_list_; |
2016 | 2049 |
2017 StoreBufferRebuilder store_buffer_rebuilder_; | 2050 StoreBufferRebuilder store_buffer_rebuilder_; |
2018 | 2051 |
2019 struct StringTypeTable { | 2052 struct StringTypeTable { |
2020 InstanceType type; | 2053 InstanceType type; |
2021 int size; | 2054 int size; |
2022 RootListIndex index; | 2055 RootListIndex index; |
2023 }; | 2056 }; |
(...skipping 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3074 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 3107 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
3075 | 3108 |
3076 private: | 3109 private: |
3077 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 3110 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
3078 }; | 3111 }; |
3079 #endif // DEBUG | 3112 #endif // DEBUG |
3080 | 3113 |
3081 } } // namespace v8::internal | 3114 } } // namespace v8::internal |
3082 | 3115 |
3083 #endif // V8_HEAP_H_ | 3116 #endif // V8_HEAP_H_ |
OLD | NEW |