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