OLD | NEW |
1 // Copyright 2006-2008 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 |
11 // with the distribution. | 11 // with the distribution. |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ | 107 V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \ |
108 V(Code, js_entry_code, JsEntryCode) \ | 108 V(Code, js_entry_code, JsEntryCode) \ |
109 V(Code, js_construct_entry_code, JsConstructEntryCode) \ | 109 V(Code, js_construct_entry_code, JsConstructEntryCode) \ |
110 V(Code, c_entry_code, CEntryCode) \ | 110 V(Code, c_entry_code, CEntryCode) \ |
111 V(FixedArray, number_string_cache, NumberStringCache) \ | 111 V(FixedArray, number_string_cache, NumberStringCache) \ |
112 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ | 112 V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \ |
113 V(FixedArray, natives_source_cache, NativesSourceCache) \ | 113 V(FixedArray, natives_source_cache, NativesSourceCache) \ |
114 V(Object, last_script_id, LastScriptId) \ | 114 V(Object, last_script_id, LastScriptId) \ |
115 V(Script, empty_script, EmptyScript) \ | 115 V(Script, empty_script, EmptyScript) \ |
116 V(Smi, real_stack_limit, RealStackLimit) \ | 116 V(Smi, real_stack_limit, RealStackLimit) \ |
| 117 V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \ |
117 | 118 |
118 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP | 119 #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP |
119 #define STRONG_ROOT_LIST(V) \ | 120 #define STRONG_ROOT_LIST(V) \ |
120 UNCONDITIONAL_STRONG_ROOT_LIST(V) \ | 121 UNCONDITIONAL_STRONG_ROOT_LIST(V) \ |
121 V(Code, re_c_entry_code, RegExpCEntryCode) | 122 V(Code, re_c_entry_code, RegExpCEntryCode) |
122 #else | 123 #else |
123 #define STRONG_ROOT_LIST(V) UNCONDITIONAL_STRONG_ROOT_LIST(V) | 124 #define STRONG_ROOT_LIST(V) UNCONDITIONAL_STRONG_ROOT_LIST(V) |
124 #endif | 125 #endif |
125 | 126 |
126 #define ROOT_LIST(V) \ | 127 #define ROOT_LIST(V) \ |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 // Converts the given boolean condition to JavaScript boolean value. | 680 // Converts the given boolean condition to JavaScript boolean value. |
680 static Object* ToBoolean(bool condition) { | 681 static Object* ToBoolean(bool condition) { |
681 return condition ? true_value() : false_value(); | 682 return condition ? true_value() : false_value(); |
682 } | 683 } |
683 | 684 |
684 // Code that should be run before and after each GC. Includes some | 685 // Code that should be run before and after each GC. Includes some |
685 // reporting/verification activities when compiled with DEBUG set. | 686 // reporting/verification activities when compiled with DEBUG set. |
686 static void GarbageCollectionPrologue(); | 687 static void GarbageCollectionPrologue(); |
687 static void GarbageCollectionEpilogue(); | 688 static void GarbageCollectionEpilogue(); |
688 | 689 |
| 690 enum CollectionPolicy { NORMAL, AGGRESSIVE }; |
| 691 |
689 // Performs garbage collection operation. | 692 // Performs garbage collection operation. |
690 // Returns whether required_space bytes are available after the collection. | 693 // Returns whether required_space bytes are available after the collection. |
691 static bool CollectGarbage(int required_space, AllocationSpace space); | 694 static bool CollectGarbage(int required_space, |
| 695 AllocationSpace space, |
| 696 CollectionPolicy collectionPolicy = NORMAL); |
692 | 697 |
693 // Performs a full garbage collection. Force compaction if the | 698 // Performs a full garbage collection. Force compaction if the |
694 // parameter is true. | 699 // parameter is true. |
695 static void CollectAllGarbage(bool force_compaction); | 700 static void CollectAllGarbage(bool force_compaction, |
| 701 CollectionPolicy collectionPolicy = NORMAL); |
| 702 |
| 703 // Last hope GC, should try to squeeze as much as possible. |
| 704 static void CollectAllAvailableGarbage(); |
696 | 705 |
697 // Notify the heap that a context has been disposed. | 706 // Notify the heap that a context has been disposed. |
698 static int NotifyContextDisposed() { return ++contexts_disposed_; } | 707 static int NotifyContextDisposed() { return ++contexts_disposed_; } |
699 | 708 |
700 // Utility to invoke the scavenger. This is needed in test code to | 709 // Utility to invoke the scavenger. This is needed in test code to |
701 // ensure correct callback for weak global handles. | 710 // ensure correct callback for weak global handles. |
702 static void PerformScavenge(); | 711 static void PerformScavenge(); |
703 | 712 |
704 #ifdef DEBUG | 713 #ifdef DEBUG |
705 // Utility used with flag gc-greedy. | 714 // 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) { | 1215 static void MarkMapPointersAsEncoded(bool encoded) { |
1207 gc_safe_size_of_old_object_ = encoded | 1216 gc_safe_size_of_old_object_ = encoded |
1208 ? &GcSafeSizeOfOldObjectWithEncodedMap | 1217 ? &GcSafeSizeOfOldObjectWithEncodedMap |
1209 : &GcSafeSizeOfOldObject; | 1218 : &GcSafeSizeOfOldObject; |
1210 } | 1219 } |
1211 | 1220 |
1212 // Checks whether a global GC is necessary | 1221 // Checks whether a global GC is necessary |
1213 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1222 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
1214 | 1223 |
1215 // Performs garbage collection | 1224 // Performs garbage collection |
1216 static void PerformGarbageCollection(AllocationSpace space, | 1225 static void PerformGarbageCollection(GarbageCollector collector, |
1217 GarbageCollector collector, | 1226 GCTracer* tracer, |
1218 GCTracer* tracer); | 1227 CollectionPolicy collectionPolicy); |
| 1228 |
| 1229 static const int kMinimumPromotionLimit = 2 * MB; |
| 1230 static const int kMinimumAllocationLimit = 8 * MB; |
| 1231 |
| 1232 inline static void UpdateOldSpaceLimits(); |
1219 | 1233 |
1220 // Allocate an uninitialized object in map space. The behavior is identical | 1234 // 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 | 1235 // 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 | 1236 // have to test the allocation space argument and (b) can reduce code size |
1223 // (since both AllocateRaw and AllocateRawMap are inlined). | 1237 // (since both AllocateRaw and AllocateRawMap are inlined). |
1224 MUST_USE_RESULT static inline Object* AllocateRawMap(); | 1238 MUST_USE_RESULT static inline Object* AllocateRawMap(); |
1225 | 1239 |
1226 // Allocate an uninitialized object in the global property cell space. | 1240 // Allocate an uninitialized object in the global property cell space. |
1227 MUST_USE_RESULT static inline Object* AllocateRawCell(); | 1241 MUST_USE_RESULT static inline Object* AllocateRawCell(); |
1228 | 1242 |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2020 | 2034 |
2021 // To speed up scavenge collections new space string are kept | 2035 // To speed up scavenge collections new space string are kept |
2022 // separate from old space strings. | 2036 // separate from old space strings. |
2023 static List<Object*> new_space_strings_; | 2037 static List<Object*> new_space_strings_; |
2024 static List<Object*> old_space_strings_; | 2038 static List<Object*> old_space_strings_; |
2025 }; | 2039 }; |
2026 | 2040 |
2027 } } // namespace v8::internal | 2041 } } // namespace v8::internal |
2028 | 2042 |
2029 #endif // V8_HEAP_H_ | 2043 #endif // V8_HEAP_H_ |
OLD | NEW |