OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 | 1090 |
1091 inline intptr_t OldGenerationCapacityAvailable() { | 1091 inline intptr_t OldGenerationCapacityAvailable() { |
1092 return max_old_generation_size_ - PromotedTotalSize(); | 1092 return max_old_generation_size_ - PromotedTotalSize(); |
1093 } | 1093 } |
1094 | 1094 |
1095 static const intptr_t kMinimumOldGenerationAllocationLimit = | 1095 static const intptr_t kMinimumOldGenerationAllocationLimit = |
1096 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | 1096 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
1097 | 1097 |
1098 static const int kInitalOldGenerationLimitFactor = 2; | 1098 static const int kInitalOldGenerationLimitFactor = 2; |
1099 | 1099 |
1100 static const intptr_t kDefaultMaxOldGenSize = 700ul * (kPointerSize / 4) * MB; | |
1101 | |
1100 #if V8_OS_ANDROID | 1102 #if V8_OS_ANDROID |
1101 // Don't apply pointer multiplier on Android since it has no swap space and | 1103 // Don't apply pointer multiplier on Android since it has no swap space and |
1102 // should instead adapt it's heap size based on available physical memory. | 1104 // should instead adapt it's heap size based on available physical memory. |
1103 static const int kPointerMultiplier = 1; | 1105 static const int kPointerMultiplier = 1; |
1104 #else | 1106 #else |
1105 static const int kPointerMultiplier = i::kPointerSize / 4; | 1107 static const int kPointerMultiplier = i::kPointerSize / 4; |
1106 #endif | 1108 #endif |
1107 | 1109 |
1108 // The new space size has to be a power of 2. Sizes are in MB. | 1110 // The new space size has to be a power of 2. Sizes are in MB. |
1109 static const int kMaxSemiSpaceSizeLowMemoryDevice = 1 * kPointerMultiplier; | 1111 static const int kMaxSemiSpaceSizeLowMemoryDevice = 1 * kPointerMultiplier; |
(...skipping 12 matching lines...) Expand all Loading... | |
1122 // The executable size has to be a multiple of Page::kPageSize. | 1124 // The executable size has to be a multiple of Page::kPageSize. |
1123 // Sizes are in MB. | 1125 // Sizes are in MB. |
1124 static const int kMaxExecutableSizeLowMemoryDevice = 96 * kPointerMultiplier; | 1126 static const int kMaxExecutableSizeLowMemoryDevice = 96 * kPointerMultiplier; |
1125 static const int kMaxExecutableSizeMediumMemoryDevice = | 1127 static const int kMaxExecutableSizeMediumMemoryDevice = |
1126 192 * kPointerMultiplier; | 1128 192 * kPointerMultiplier; |
1127 static const int kMaxExecutableSizeHighMemoryDevice = | 1129 static const int kMaxExecutableSizeHighMemoryDevice = |
1128 256 * kPointerMultiplier; | 1130 256 * kPointerMultiplier; |
1129 static const int kMaxExecutableSizeHugeMemoryDevice = | 1131 static const int kMaxExecutableSizeHugeMemoryDevice = |
1130 256 * kPointerMultiplier; | 1132 256 * kPointerMultiplier; |
1131 | 1133 |
1132 intptr_t OldGenerationAllocationLimit(intptr_t old_gen_size, | 1134 void SetOldGenerationAllocationLimit(intptr_t old_gen_size, |
1133 int freed_global_handles); | 1135 int freed_global_handles, |
1136 bool weak_callbacks_completed); | |
1134 | 1137 |
1135 // Indicates whether inline bump-pointer allocation has been disabled. | 1138 // Indicates whether inline bump-pointer allocation has been disabled. |
1136 bool inline_allocation_disabled() { return inline_allocation_disabled_; } | 1139 bool inline_allocation_disabled() { return inline_allocation_disabled_; } |
1137 | 1140 |
1138 // Switch whether inline bump-pointer allocation should be used. | 1141 // Switch whether inline bump-pointer allocation should be used. |
1139 void EnableInlineAllocation(); | 1142 void EnableInlineAllocation(); |
1140 void DisableInlineAllocation(); | 1143 void DisableInlineAllocation(); |
1141 | 1144 |
1142 // Implements the corresponding V8 API function. | 1145 // Implements the corresponding V8 API function. |
1143 bool IdleNotification(double deadline_in_seconds); | 1146 bool IdleNotification(double deadline_in_seconds); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1237 } | 1240 } |
1238 | 1241 |
1239 inline bool NextGCIsLikelyToBeFull() { | 1242 inline bool NextGCIsLikelyToBeFull() { |
1240 if (FLAG_gc_global) return true; | 1243 if (FLAG_gc_global) return true; |
1241 | 1244 |
1242 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; | 1245 if (FLAG_stress_compaction && (gc_count_ & 1) != 0) return true; |
1243 | 1246 |
1244 intptr_t adjusted_allocation_limit = | 1247 intptr_t adjusted_allocation_limit = |
1245 old_generation_allocation_limit_ - new_space_.Capacity(); | 1248 old_generation_allocation_limit_ - new_space_.Capacity(); |
1246 | 1249 |
1247 if (PromotedTotalSize() >= adjusted_allocation_limit) return true; | 1250 if (PromotedTotalSize() >= adjusted_allocation_limit) { |
1251 if (FLAG_trace_gc_verbose) { | |
1252 PrintF("Next GC likely to be full: We are at %" V8_PTR_PREFIX | |
1253 "dMbytes out of %" V8_PTR_PREFIX "dMbytes\n", | |
1254 PromotedTotalSize() >> 20, | |
1255 old_generation_allocation_limit_ >> 20); | |
1256 } | |
1257 return true; | |
1258 } | |
1259 | |
1260 if (CommittedOldGenerationMemory() >= | |
1261 old_generation_committed_memory_limit_) { | |
1262 if (FLAG_trace_gc_verbose) { | |
1263 PrintF("Next GC likely to be full: We are at %" V8_PTR_PREFIX | |
1264 "dMbytes committed out of %" V8_PTR_PREFIX "dMbytes\n", | |
1265 CommittedOldGenerationMemory() >> 20, | |
1266 old_generation_committed_memory_limit_ >> 20); | |
1267 } | |
1268 return true; | |
1269 } | |
1248 | 1270 |
1249 return false; | 1271 return false; |
1250 } | 1272 } |
1251 | 1273 |
1252 void UpdateNewSpaceReferencesInExternalStringTable( | 1274 void UpdateNewSpaceReferencesInExternalStringTable( |
1253 ExternalStringTableUpdaterCallback updater_func); | 1275 ExternalStringTableUpdaterCallback updater_func); |
1254 | 1276 |
1255 void UpdateReferencesInExternalStringTable( | 1277 void UpdateReferencesInExternalStringTable( |
1256 ExternalStringTableUpdaterCallback updater_func); | 1278 ExternalStringTableUpdaterCallback updater_func); |
1257 | 1279 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1316 // Returns the current sweep generation. | 1338 // Returns the current sweep generation. |
1317 int sweep_generation() { return sweep_generation_; } | 1339 int sweep_generation() { return sweep_generation_; } |
1318 | 1340 |
1319 bool concurrent_sweeping_enabled() { return concurrent_sweeping_enabled_; } | 1341 bool concurrent_sweeping_enabled() { return concurrent_sweeping_enabled_; } |
1320 | 1342 |
1321 inline Isolate* isolate(); | 1343 inline Isolate* isolate(); |
1322 | 1344 |
1323 void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags); | 1345 void CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags); |
1324 void CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags); | 1346 void CallGCEpilogueCallbacks(GCType gc_type, GCCallbackFlags flags); |
1325 | 1347 |
1326 inline bool OldGenerationAllocationLimitReached(); | 1348 inline bool OldGenerationAllocationLimitReached(); |
ulan
2015/03/26 08:28:55
To be consistent, we need similar predicate for co
| |
1327 | 1349 |
1328 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { | 1350 inline void DoScavengeObject(Map* map, HeapObject** slot, HeapObject* obj) { |
1329 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); | 1351 scavenging_visitors_table_.GetVisitor(map)(map, slot, obj); |
1330 } | 1352 } |
1331 | 1353 |
1332 void QueueMemoryChunkForFree(MemoryChunk* chunk); | 1354 void QueueMemoryChunkForFree(MemoryChunk* chunk); |
1333 void FreeQueuedChunks(); | 1355 void FreeQueuedChunks(); |
1334 | 1356 |
1335 int gc_count() const { return gc_count_; } | 1357 int gc_count() const { return gc_count_; } |
1336 | 1358 |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1628 #ifdef DEBUG | 1650 #ifdef DEBUG |
1629 // If the --gc-interval flag is set to a positive value, this | 1651 // If the --gc-interval flag is set to a positive value, this |
1630 // variable holds the value indicating the number of allocations | 1652 // variable holds the value indicating the number of allocations |
1631 // remain until the next failure and garbage collection. | 1653 // remain until the next failure and garbage collection. |
1632 int allocation_timeout_; | 1654 int allocation_timeout_; |
1633 #endif // DEBUG | 1655 #endif // DEBUG |
1634 | 1656 |
1635 // Limit that triggers a global GC on the next (normally caused) GC. This | 1657 // Limit that triggers a global GC on the next (normally caused) GC. This |
1636 // is checked when we have already decided to do a GC to help determine | 1658 // is checked when we have already decided to do a GC to help determine |
1637 // which collector to invoke, before expanding a paged space in the old | 1659 // which collector to invoke, before expanding a paged space in the old |
1638 // generation and on every allocation in large object space. | 1660 // generation and on every allocation in large object space. This only |
1661 // measures objects, so it may be underreporting if we have fragmentation. | |
1639 intptr_t old_generation_allocation_limit_; | 1662 intptr_t old_generation_allocation_limit_; |
1640 | 1663 |
1664 // As above, but counts pages, not objects, so is more likely to trigger | |
1665 // when we have fragmentation. | |
1666 intptr_t old_generation_committed_memory_limit_; | |
1667 | |
1641 // Indicates that an allocation has failed in the old generation since the | 1668 // Indicates that an allocation has failed in the old generation since the |
1642 // last GC. | 1669 // last GC. |
1643 bool old_gen_exhausted_; | 1670 bool old_gen_exhausted_; |
1644 | 1671 |
1645 // Indicates that inline bump-pointer allocation has been globally disabled | 1672 // Indicates that inline bump-pointer allocation has been globally disabled |
1646 // for all spaces. This is used to disable allocations in generated code. | 1673 // for all spaces. This is used to disable allocations in generated code. |
1647 bool inline_allocation_disabled_; | 1674 bool inline_allocation_disabled_; |
1648 | 1675 |
1649 // Weak list heads, threaded through the objects. | 1676 // Weak list heads, threaded through the objects. |
1650 // List heads are initialized lazily and contain the undefined_value at start. | 1677 // List heads are initialized lazily and contain the undefined_value at start. |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2063 void ConfigureInitialOldGenerationSize(); | 2090 void ConfigureInitialOldGenerationSize(); |
2064 | 2091 |
2065 void SelectScavengingVisitorsTable(); | 2092 void SelectScavengingVisitorsTable(); |
2066 | 2093 |
2067 void IdleMarkCompact(const char* message); | 2094 void IdleMarkCompact(const char* message); |
2068 | 2095 |
2069 bool TryFinalizeIdleIncrementalMarking( | 2096 bool TryFinalizeIdleIncrementalMarking( |
2070 double idle_time_in_ms, size_t size_of_objects, | 2097 double idle_time_in_ms, size_t size_of_objects, |
2071 size_t mark_compact_speed_in_bytes_per_ms); | 2098 size_t mark_compact_speed_in_bytes_per_ms); |
2072 | 2099 |
2073 bool WorthActivatingIncrementalMarking(); | |
2074 | |
2075 void ClearObjectStats(bool clear_last_time_stats = false); | 2100 void ClearObjectStats(bool clear_last_time_stats = false); |
2076 | 2101 |
2077 inline void UpdateAllocationsHash(HeapObject* object); | 2102 inline void UpdateAllocationsHash(HeapObject* object); |
2078 inline void UpdateAllocationsHash(uint32_t value); | 2103 inline void UpdateAllocationsHash(uint32_t value); |
2079 inline void PrintAlloctionsHash(); | 2104 inline void PrintAlloctionsHash(); |
2080 | 2105 |
2081 // Object counts and used memory by InstanceType | 2106 // Object counts and used memory by InstanceType |
2082 size_t object_counts_[OBJECT_STATS_COUNT]; | 2107 size_t object_counts_[OBJECT_STATS_COUNT]; |
2083 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 2108 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
2084 size_t object_sizes_[OBJECT_STATS_COUNT]; | 2109 size_t object_sizes_[OBJECT_STATS_COUNT]; |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2618 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2643 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
2619 | 2644 |
2620 private: | 2645 private: |
2621 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2646 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2622 }; | 2647 }; |
2623 #endif // DEBUG | 2648 #endif // DEBUG |
2624 } | 2649 } |
2625 } // namespace v8::internal | 2650 } // namespace v8::internal |
2626 | 2651 |
2627 #endif // V8_HEAP_HEAP_H_ | 2652 #endif // V8_HEAP_HEAP_H_ |
OLD | NEW |