Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(607)

Side by Side Diff: src/heap.h

Issue 14731029: Simplifying GC heuristics, deleted old generation allocation limit. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
1540 } 1540 }
1541 1541
1542 inline Address* NewSpaceHighPromotionModeActiveAddress() { 1542 inline Address* NewSpaceHighPromotionModeActiveAddress() {
1543 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_); 1543 return reinterpret_cast<Address*>(&new_space_high_promotion_mode_active_);
1544 } 1544 }
1545 1545
1546 inline intptr_t PromotedTotalSize() { 1546 inline intptr_t PromotedTotalSize() {
1547 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize(); 1547 return PromotedSpaceSizeOfObjects() + PromotedExternalMemorySize();
1548 } 1548 }
1549 1549
1550 // True if we have reached the allocation limit in the old generation that
1551 // should force the next GC (caused normally) to be a full one.
1552 inline bool OldGenerationPromotionLimitReached() {
1553 return PromotedTotalSize() > old_gen_promotion_limit_;
1554 }
1555
1556 inline intptr_t OldGenerationSpaceAvailable() { 1550 inline intptr_t OldGenerationSpaceAvailable() {
1557 return old_gen_allocation_limit_ - PromotedTotalSize(); 1551 return old_generation_allocation_limit_ - PromotedTotalSize();
1558 } 1552 }
1559 1553
1560 inline intptr_t OldGenerationCapacityAvailable() { 1554 inline intptr_t OldGenerationCapacityAvailable() {
1561 return max_old_generation_size_ - PromotedTotalSize(); 1555 return max_old_generation_size_ - PromotedTotalSize();
1562 } 1556 }
1563 1557
1564 static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; 1558 static const intptr_t kMinimumOldGenerationAllocationLimit =
1565 static const intptr_t kMinimumAllocationLimit =
1566 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); 1559 8 * (Page::kPageSize > MB ? Page::kPageSize : MB);
1567 1560
1568 intptr_t OldGenPromotionLimit(intptr_t old_gen_size) { 1561 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size) {
1569 const int divisor = FLAG_stress_compaction ? 10 : 1562 const int divisor = FLAG_stress_compaction ? 10 :
1570 new_space_high_promotion_mode_active_ ? 1 : 3; 1563 new_space_high_promotion_mode_active_ ? 1 : 3;
1571 intptr_t limit = 1564 intptr_t limit =
1572 Max(old_gen_size + old_gen_size / divisor, kMinimumPromotionLimit); 1565 Max(old_gen_size + old_gen_size / divisor,
1566 kMinimumOldGenerationAllocationLimit);
1573 limit += new_space_.Capacity(); 1567 limit += new_space_.Capacity();
1574 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; 1568 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
1575 return Min(limit, halfway_to_the_max); 1569 return Min(limit, halfway_to_the_max);
1576 }
1577
1578 intptr_t OldGenAllocationLimit(intptr_t old_gen_size) {
1579 const int divisor = FLAG_stress_compaction ? 8 :
1580 new_space_high_promotion_mode_active_ ? 1 : 2;
1581 intptr_t limit =
1582 Max(old_gen_size + old_gen_size / divisor, kMinimumAllocationLimit);
1583 limit += new_space_.Capacity();
1584 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2;
1585 return Min(limit, halfway_to_the_max);
1586 } 1570 }
1587 1571
1588 // Implements the corresponding V8 API function. 1572 // Implements the corresponding V8 API function.
1589 bool IdleNotification(int hint); 1573 bool IdleNotification(int hint);
1590 1574
1591 // Declare all the root indices. 1575 // Declare all the root indices.
1592 enum RootListIndex { 1576 enum RootListIndex {
1593 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex, 1577 #define ROOT_INDEX_DECLARATION(type, name, camel_name) k##camel_name##RootIndex,
1594 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION) 1578 STRONG_ROOT_LIST(ROOT_INDEX_DECLARATION)
1595 #undef ROOT_INDEX_DECLARATION 1579 #undef ROOT_INDEX_DECLARATION
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 ASSERT(survived >= 0); 1629 ASSERT(survived >= 0);
1646 young_survivors_after_last_gc_ = survived; 1630 young_survivors_after_last_gc_ = survived;
1647 survived_since_last_expansion_ += survived; 1631 survived_since_last_expansion_ += survived;
1648 } 1632 }
1649 1633
1650 inline bool NextGCIsLikelyToBeFull() { 1634 inline bool NextGCIsLikelyToBeFull() {
1651 if (FLAG_gc_global) return true; 1635 if (FLAG_gc_global) return true;
1652 1636
1653 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; 1637 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true;
1654 1638
1655 intptr_t total_promoted = PromotedTotalSize(); 1639 intptr_t adjusted_allocation_limit =
1640 old_generation_allocation_limit_ - new_space_.Capacity();
1656 1641
1657 intptr_t adjusted_promotion_limit = 1642 if (PromotedTotalSize() >= adjusted_allocation_limit) return true;
1658 old_gen_promotion_limit_ - new_space_.Capacity();
1659
1660 if (total_promoted >= adjusted_promotion_limit) return true;
1661
1662 intptr_t adjusted_allocation_limit =
1663 old_gen_allocation_limit_ - new_space_.Capacity() / 5;
1664
1665 if (PromotedSpaceSizeOfObjects() >= adjusted_allocation_limit) return true;
1666 1643
1667 return false; 1644 return false;
1668 } 1645 }
1669 1646
1670
1671 void UpdateNewSpaceReferencesInExternalStringTable( 1647 void UpdateNewSpaceReferencesInExternalStringTable(
1672 ExternalStringTableUpdaterCallback updater_func); 1648 ExternalStringTableUpdaterCallback updater_func);
1673 1649
1674 void UpdateReferencesInExternalStringTable( 1650 void UpdateReferencesInExternalStringTable(
1675 ExternalStringTableUpdaterCallback updater_func); 1651 ExternalStringTableUpdaterCallback updater_func);
1676 1652
1677 void ProcessWeakReferences(WeakObjectRetainer* retainer); 1653 void ProcessWeakReferences(WeakObjectRetainer* retainer);
1678 1654
1679 void VisitExternalResources(v8::ExternalResourceVisitor* visitor); 1655 void VisitExternalResources(v8::ExternalResourceVisitor* visitor);
1680 1656
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
1985 bool disallow_allocation_failure_; 1961 bool disallow_allocation_failure_;
1986 #endif // DEBUG 1962 #endif // DEBUG
1987 1963
1988 // Indicates that the new space should be kept small due to high promotion 1964 // Indicates that the new space should be kept small due to high promotion
1989 // rates caused by the mutator allocating a lot of long-lived objects. 1965 // rates caused by the mutator allocating a lot of long-lived objects.
1990 // TODO(hpayer): change to bool if no longer accessed from generated code 1966 // TODO(hpayer): change to bool if no longer accessed from generated code
1991 intptr_t new_space_high_promotion_mode_active_; 1967 intptr_t new_space_high_promotion_mode_active_;
1992 1968
1993 // Limit that triggers a global GC on the next (normally caused) GC. This 1969 // Limit that triggers a global GC on the next (normally caused) GC. This
1994 // is checked when we have already decided to do a GC to help determine 1970 // is checked when we have already decided to do a GC to help determine
1995 // which collector to invoke. 1971 // which collector to invoke, before expanding a paged space in the old
1996 intptr_t old_gen_promotion_limit_; 1972 // generation and on every allocation in large object space.
1997 1973 intptr_t old_generation_allocation_limit_;
1998 // Limit that triggers a global GC as soon as is reasonable. This is
1999 // checked before expanding a paged space in the old generation and on
2000 // every allocation in large object space.
2001 intptr_t old_gen_allocation_limit_;
2002 1974
2003 // Used to adjust the limits that control the timing of the next GC. 1975 // Used to adjust the limits that control the timing of the next GC.
2004 intptr_t size_of_old_gen_at_last_old_space_gc_; 1976 intptr_t size_of_old_gen_at_last_old_space_gc_;
2005 1977
2006 // Limit on the amount of externally allocated memory allowed 1978 // Limit on the amount of externally allocated memory allowed
2007 // between global GCs. If reached a global GC is forced. 1979 // between global GCs. If reached a global GC is forced.
2008 intptr_t external_allocation_limit_; 1980 intptr_t external_allocation_limit_;
2009 1981
2010 // The amount of external memory registered through the API kept alive 1982 // The amount of external memory registered through the API kept alive
2011 // by global handles 1983 // by global handles
2012 intptr_t amount_of_external_allocated_memory_; 1984 intptr_t amount_of_external_allocated_memory_;
2013 1985
2014 // Caches the amount of external memory registered at the last global gc. 1986 // Caches the amount of external memory registered at the last global gc.
2015 intptr_t amount_of_external_allocated_memory_at_last_global_gc_; 1987 intptr_t amount_of_external_allocated_memory_at_last_global_gc_;
2016 1988
2017 // Indicates that an allocation has failed in the old generation since the 1989 // Indicates that an allocation has failed in the old generation since the
2018 // last GC. 1990 // last GC.
2019 int old_gen_exhausted_; 1991 bool old_gen_exhausted_;
2020 1992
2021 Object* native_contexts_list_; 1993 Object* native_contexts_list_;
2022 1994
2023 StoreBufferRebuilder store_buffer_rebuilder_; 1995 StoreBufferRebuilder store_buffer_rebuilder_;
2024 1996
2025 struct StringTypeTable { 1997 struct StringTypeTable {
2026 InstanceType type; 1998 InstanceType type;
2027 int size; 1999 int size;
2028 RootListIndex index; 2000 RootListIndex index;
2029 }; 2001 };
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
3076 AssertNoAllocation no_alloc; // i.e. no gc allowed. 3048 AssertNoAllocation no_alloc; // i.e. no gc allowed.
3077 3049
3078 private: 3050 private:
3079 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); 3051 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer);
3080 }; 3052 };
3081 #endif // DEBUG 3053 #endif // DEBUG
3082 3054
3083 } } // namespace v8::internal 3055 } } // namespace v8::internal
3084 3056
3085 #endif // V8_HEAP_H_ 3057 #endif // V8_HEAP_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698