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