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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1037 // Performs garbage collection operation. | 1037 // Performs garbage collection operation. |
1038 // Returns whether there is a chance that another major GC could | 1038 // Returns whether there is a chance that another major GC could |
1039 // collect more garbage. | 1039 // collect more garbage. |
1040 inline bool CollectGarbage(AllocationSpace space, | 1040 inline bool CollectGarbage(AllocationSpace space, |
1041 const char* gc_reason = NULL); | 1041 const char* gc_reason = NULL); |
1042 | 1042 |
1043 static const int kNoGCFlags = 0; | 1043 static const int kNoGCFlags = 0; |
1044 static const int kMakeHeapIterableMask = 1; | 1044 static const int kMakeHeapIterableMask = 1; |
1045 static const int kReduceMemoryFootprintMask = 2; | 1045 static const int kReduceMemoryFootprintMask = 2; |
1046 | 1046 |
1047 inline bool AbortIncrementalMarkingAndCollectGarbage( | |
Michael Starzinger
2012/03/07 15:52:42
Could we make this a static helper method in heap.
ulan
2012/03/07 16:04:30
Done.
| |
1048 AllocationSpace space, const char* gc_reason = NULL) { | |
1049 mark_compact_collector()->SetFlags(kMakeHeapIterableMask); | |
1050 bool result = CollectGarbage(space, gc_reason); | |
1051 mark_compact_collector()->SetFlags(kNoGCFlags); | |
1052 return result; | |
1053 } | |
1054 | |
1047 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is | 1055 // Performs a full garbage collection. If (flags & kMakeHeapIterableMask) is |
1048 // non-zero, then the slower precise sweeper is used, which leaves the heap | 1056 // non-zero, then the slower precise sweeper is used, which leaves the heap |
1049 // in a state where we can iterate over the heap visiting all objects. | 1057 // in a state where we can iterate over the heap visiting all objects. |
1050 void CollectAllGarbage(int flags, const char* gc_reason = NULL); | 1058 void CollectAllGarbage(int flags, const char* gc_reason = NULL); |
1051 | 1059 |
1052 // Last hope GC, should try to squeeze as much as possible. | 1060 // Last hope GC, should try to squeeze as much as possible. |
1053 void CollectAllAvailableGarbage(const char* gc_reason = NULL); | 1061 void CollectAllAvailableGarbage(const char* gc_reason = NULL); |
1054 | 1062 |
1055 // Check whether the heap is currently iterable. | 1063 // Check whether the heap is currently iterable. |
1056 bool IsHeapIterable(); | 1064 bool IsHeapIterable(); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1335 // True if we have reached the allocation limit in the old generation that | 1343 // True if we have reached the allocation limit in the old generation that |
1336 // should force the next GC (caused normally) to be a full one. | 1344 // should force the next GC (caused normally) to be a full one. |
1337 inline bool OldGenerationPromotionLimitReached() { | 1345 inline bool OldGenerationPromotionLimitReached() { |
1338 return PromotedTotalSize() > old_gen_promotion_limit_; | 1346 return PromotedTotalSize() > old_gen_promotion_limit_; |
1339 } | 1347 } |
1340 | 1348 |
1341 inline intptr_t OldGenerationSpaceAvailable() { | 1349 inline intptr_t OldGenerationSpaceAvailable() { |
1342 return old_gen_allocation_limit_ - PromotedTotalSize(); | 1350 return old_gen_allocation_limit_ - PromotedTotalSize(); |
1343 } | 1351 } |
1344 | 1352 |
1353 inline intptr_t OldGenerationCapacityAvailable() { | |
1354 return max_old_generation_size_ - PromotedTotalSize(); | |
1355 } | |
1356 | |
1345 static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; | 1357 static const intptr_t kMinimumPromotionLimit = 5 * Page::kPageSize; |
1346 static const intptr_t kMinimumAllocationLimit = | 1358 static const intptr_t kMinimumAllocationLimit = |
1347 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); | 1359 8 * (Page::kPageSize > MB ? Page::kPageSize : MB); |
1348 | 1360 |
1349 // When we sweep lazily we initially guess that there is no garbage on the | 1361 // When we sweep lazily we initially guess that there is no garbage on the |
1350 // heap and set the limits for the next GC accordingly. As we sweep we find | 1362 // heap and set the limits for the next GC accordingly. As we sweep we find |
1351 // out that some of the pages contained garbage and we have to adjust | 1363 // out that some of the pages contained garbage and we have to adjust |
1352 // downwards the size of the heap. This means the limits that control the | 1364 // downwards the size of the heap. This means the limits that control the |
1353 // timing of the next GC also need to be adjusted downwards. | 1365 // timing of the next GC also need to be adjusted downwards. |
1354 void LowerOldGenLimits(intptr_t adjustment) { | 1366 void LowerOldGenLimits(intptr_t adjustment) { |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2661 AssertNoAllocation no_alloc; // i.e. no gc allowed. | 2673 AssertNoAllocation no_alloc; // i.e. no gc allowed. |
2662 | 2674 |
2663 private: | 2675 private: |
2664 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2676 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
2665 }; | 2677 }; |
2666 #endif // DEBUG || LIVE_OBJECT_LIST | 2678 #endif // DEBUG || LIVE_OBJECT_LIST |
2667 | 2679 |
2668 } } // namespace v8::internal | 2680 } } // namespace v8::internal |
2669 | 2681 |
2670 #endif // V8_HEAP_H_ | 2682 #endif // V8_HEAP_H_ |
OLD | NEW |