| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 // Converts the given boolean condition to JavaScript boolean value. | 685 // Converts the given boolean condition to JavaScript boolean value. |
| 686 static Object* ToBoolean(bool condition) { | 686 static Object* ToBoolean(bool condition) { |
| 687 return condition ? true_value() : false_value(); | 687 return condition ? true_value() : false_value(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 // Code that should be run before and after each GC. Includes some | 690 // Code that should be run before and after each GC. Includes some |
| 691 // reporting/verification activities when compiled with DEBUG set. | 691 // reporting/verification activities when compiled with DEBUG set. |
| 692 static void GarbageCollectionPrologue(); | 692 static void GarbageCollectionPrologue(); |
| 693 static void GarbageCollectionEpilogue(); | 693 static void GarbageCollectionEpilogue(); |
| 694 | 694 |
| 695 enum CollectionPolicy { NORMAL, AGGRESSIVE }; | |
| 696 | |
| 697 // Performs garbage collection operation. | 695 // Performs garbage collection operation. |
| 698 // Returns whether required_space bytes are available after the collection. | 696 // Returns whether required_space bytes are available after the collection. |
| 699 static void CollectGarbage(AllocationSpace space, | 697 static void CollectGarbage(AllocationSpace space); |
| 700 CollectionPolicy collectionPolicy = NORMAL); | |
| 701 | 698 |
| 702 // Performs a full garbage collection. Force compaction if the | 699 // Performs a full garbage collection. Force compaction if the |
| 703 // parameter is true. | 700 // parameter is true. |
| 704 static void CollectAllGarbage(bool force_compaction, | 701 static void CollectAllGarbage(bool force_compaction); |
| 705 CollectionPolicy collectionPolicy = NORMAL); | |
| 706 | |
| 707 // Last hope GC, should try to squeeze as much as possible. | |
| 708 static void CollectAllAvailableGarbage(); | |
| 709 | 702 |
| 710 // Notify the heap that a context has been disposed. | 703 // Notify the heap that a context has been disposed. |
| 711 static int NotifyContextDisposed() { return ++contexts_disposed_; } | 704 static int NotifyContextDisposed() { return ++contexts_disposed_; } |
| 712 | 705 |
| 713 // Utility to invoke the scavenger. This is needed in test code to | 706 // Utility to invoke the scavenger. This is needed in test code to |
| 714 // ensure correct callback for weak global handles. | 707 // ensure correct callback for weak global handles. |
| 715 static void PerformScavenge(); | 708 static void PerformScavenge(); |
| 716 | 709 |
| 717 #ifdef DEBUG | 710 #ifdef DEBUG |
| 718 // Utility used with flag gc-greedy. | 711 // Utility used with flag gc-greedy. |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 gc_safe_size_of_old_object_ = encoded | 1213 gc_safe_size_of_old_object_ = encoded |
| 1221 ? &GcSafeSizeOfOldObjectWithEncodedMap | 1214 ? &GcSafeSizeOfOldObjectWithEncodedMap |
| 1222 : &GcSafeSizeOfOldObject; | 1215 : &GcSafeSizeOfOldObject; |
| 1223 } | 1216 } |
| 1224 | 1217 |
| 1225 // Checks whether a global GC is necessary | 1218 // Checks whether a global GC is necessary |
| 1226 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1219 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
| 1227 | 1220 |
| 1228 // Performs garbage collection | 1221 // Performs garbage collection |
| 1229 static void PerformGarbageCollection(GarbageCollector collector, | 1222 static void PerformGarbageCollection(GarbageCollector collector, |
| 1230 GCTracer* tracer, | 1223 GCTracer* tracer); |
| 1231 CollectionPolicy collectionPolicy); | |
| 1232 | |
| 1233 static const intptr_t kMinimumPromotionLimit = 2 * MB; | |
| 1234 static const intptr_t kMinimumAllocationLimit = 8 * MB; | |
| 1235 | |
| 1236 inline static void UpdateOldSpaceLimits(); | |
| 1237 | 1224 |
| 1238 // Allocate an uninitialized object in map space. The behavior is identical | 1225 // Allocate an uninitialized object in map space. The behavior is identical |
| 1239 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't | 1226 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't |
| 1240 // have to test the allocation space argument and (b) can reduce code size | 1227 // have to test the allocation space argument and (b) can reduce code size |
| 1241 // (since both AllocateRaw and AllocateRawMap are inlined). | 1228 // (since both AllocateRaw and AllocateRawMap are inlined). |
| 1242 MUST_USE_RESULT static inline Object* AllocateRawMap(); | 1229 MUST_USE_RESULT static inline Object* AllocateRawMap(); |
| 1243 | 1230 |
| 1244 // Allocate an uninitialized object in the global property cell space. | 1231 // Allocate an uninitialized object in the global property cell space. |
| 1245 MUST_USE_RESULT static inline Object* AllocateRawCell(); | 1232 MUST_USE_RESULT static inline Object* AllocateRawCell(); |
| 1246 | 1233 |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 | 2025 |
| 2039 // To speed up scavenge collections new space string are kept | 2026 // To speed up scavenge collections new space string are kept |
| 2040 // separate from old space strings. | 2027 // separate from old space strings. |
| 2041 static List<Object*> new_space_strings_; | 2028 static List<Object*> new_space_strings_; |
| 2042 static List<Object*> old_space_strings_; | 2029 static List<Object*> old_space_strings_; |
| 2043 }; | 2030 }; |
| 2044 | 2031 |
| 2045 } } // namespace v8::internal | 2032 } } // namespace v8::internal |
| 2046 | 2033 |
| 2047 #endif // V8_HEAP_H_ | 2034 #endif // V8_HEAP_H_ |
| OLD | NEW |