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 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 | 812 |
813 // Finds out which space an object should get promoted to based on its type. | 813 // Finds out which space an object should get promoted to based on its type. |
814 static inline OldSpace* TargetSpace(HeapObject* object); | 814 static inline OldSpace* TargetSpace(HeapObject* object); |
815 static inline AllocationSpace TargetSpaceId(InstanceType type); | 815 static inline AllocationSpace TargetSpaceId(InstanceType type); |
816 | 816 |
817 // Sets the stub_cache_ (only used when expanding the dictionary). | 817 // Sets the stub_cache_ (only used when expanding the dictionary). |
818 static void public_set_code_stubs(NumberDictionary* value) { | 818 static void public_set_code_stubs(NumberDictionary* value) { |
819 roots_[kCodeStubsRootIndex] = value; | 819 roots_[kCodeStubsRootIndex] = value; |
820 } | 820 } |
821 | 821 |
| 822 // Support for computing object sizes for old objects during GCs. Returns |
| 823 // a function that is guaranteed to be safe for computing object sizes in |
| 824 // the current GC phase. |
| 825 static HeapObjectCallback GcSafeSizeOfOldObjectFunction() { |
| 826 return gc_safe_size_of_old_object_; |
| 827 } |
| 828 |
822 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). | 829 // Sets the non_monomorphic_cache_ (only used when expanding the dictionary). |
823 static void public_set_non_monomorphic_cache(NumberDictionary* value) { | 830 static void public_set_non_monomorphic_cache(NumberDictionary* value) { |
824 roots_[kNonMonomorphicCacheRootIndex] = value; | 831 roots_[kNonMonomorphicCacheRootIndex] = value; |
825 } | 832 } |
826 | 833 |
827 static void public_set_empty_script(Script* script) { | 834 static void public_set_empty_script(Script* script) { |
828 roots_[kEmptyScriptRootIndex] = script; | 835 roots_[kEmptyScriptRootIndex] = script; |
829 } | 836 } |
830 | 837 |
831 // Update the next script id. | 838 // Update the next script id. |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 return pair.callback == callback; | 1172 return pair.callback == callback; |
1166 } | 1173 } |
1167 GCEpilogueCallback callback; | 1174 GCEpilogueCallback callback; |
1168 GCType gc_type; | 1175 GCType gc_type; |
1169 }; | 1176 }; |
1170 static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; | 1177 static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
1171 | 1178 |
1172 static GCCallback global_gc_prologue_callback_; | 1179 static GCCallback global_gc_prologue_callback_; |
1173 static GCCallback global_gc_epilogue_callback_; | 1180 static GCCallback global_gc_epilogue_callback_; |
1174 | 1181 |
| 1182 // Support for computing object sizes during GC. |
| 1183 static HeapObjectCallback gc_safe_size_of_old_object_; |
| 1184 static int GcSafeSizeOfOldObject(HeapObject* object); |
| 1185 static int GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object); |
| 1186 |
| 1187 // Update the GC state. Called from the mark-compact collector. |
| 1188 static void MarkMapPointersAsEncoded(bool encoded) { |
| 1189 gc_safe_size_of_old_object_ = encoded |
| 1190 ? &GcSafeSizeOfOldObjectWithEncodedMap |
| 1191 : &GcSafeSizeOfOldObject; |
| 1192 } |
| 1193 |
1175 // Checks whether a global GC is necessary | 1194 // Checks whether a global GC is necessary |
1176 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1195 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
1177 | 1196 |
1178 // Performs garbage collection | 1197 // Performs garbage collection |
1179 static void PerformGarbageCollection(AllocationSpace space, | 1198 static void PerformGarbageCollection(AllocationSpace space, |
1180 GarbageCollector collector, | 1199 GarbageCollector collector, |
1181 GCTracer* tracer); | 1200 GCTracer* tracer); |
1182 | 1201 |
1183 // Allocate an uninitialized object in map space. The behavior is identical | 1202 // Allocate an uninitialized object in map space. The behavior is identical |
1184 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't | 1203 // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 Object** pointer); | 1237 Object** pointer); |
1219 | 1238 |
1220 static Address DoScavenge(ObjectVisitor* scavenge_visitor, | 1239 static Address DoScavenge(ObjectVisitor* scavenge_visitor, |
1221 Address new_space_front); | 1240 Address new_space_front); |
1222 | 1241 |
1223 // Performs a major collection in the whole heap. | 1242 // Performs a major collection in the whole heap. |
1224 static void MarkCompact(GCTracer* tracer); | 1243 static void MarkCompact(GCTracer* tracer); |
1225 | 1244 |
1226 // Code to be run before and after mark-compact. | 1245 // Code to be run before and after mark-compact. |
1227 static void MarkCompactPrologue(bool is_compacting); | 1246 static void MarkCompactPrologue(bool is_compacting); |
1228 static void MarkCompactEpilogue(bool is_compacting); | |
1229 | 1247 |
1230 // Completely clear the Instanceof cache (to stop it keeping objects alive | 1248 // Completely clear the Instanceof cache (to stop it keeping objects alive |
1231 // around a GC). | 1249 // around a GC). |
1232 static void CompletelyClearInstanceofCache() { | 1250 static void CompletelyClearInstanceofCache() { |
1233 set_instanceof_cache_map(the_hole_value()); | 1251 set_instanceof_cache_map(the_hole_value()); |
1234 set_instanceof_cache_function(the_hole_value()); | 1252 set_instanceof_cache_function(the_hole_value()); |
1235 } | 1253 } |
1236 | 1254 |
1237 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) | 1255 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING) |
1238 // Record statistics before and after garbage collection. | 1256 // Record statistics before and after garbage collection. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1310 return high_survival_rate_period_length_ > 0; | 1328 return high_survival_rate_period_length_ > 0; |
1311 } | 1329 } |
1312 | 1330 |
1313 static const int kInitialSymbolTableSize = 2048; | 1331 static const int kInitialSymbolTableSize = 2048; |
1314 static const int kInitialEvalCacheSize = 64; | 1332 static const int kInitialEvalCacheSize = 64; |
1315 | 1333 |
1316 friend class Factory; | 1334 friend class Factory; |
1317 friend class DisallowAllocationFailure; | 1335 friend class DisallowAllocationFailure; |
1318 friend class AlwaysAllocateScope; | 1336 friend class AlwaysAllocateScope; |
1319 friend class LinearAllocationScope; | 1337 friend class LinearAllocationScope; |
| 1338 friend class MarkCompactCollector; |
1320 }; | 1339 }; |
1321 | 1340 |
1322 | 1341 |
1323 class HeapStats { | 1342 class HeapStats { |
1324 public: | 1343 public: |
1325 static const int kStartMarker = 0xDECADE00; | 1344 static const int kStartMarker = 0xDECADE00; |
1326 static const int kEndMarker = 0xDECADE01; | 1345 static const int kEndMarker = 0xDECADE01; |
1327 | 1346 |
1328 int* start_marker; // 0 | 1347 int* start_marker; // 0 |
1329 int* new_space_size; // 1 | 1348 int* new_space_size; // 1 |
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1982 | 2001 |
1983 // To speed up scavenge collections new space string are kept | 2002 // To speed up scavenge collections new space string are kept |
1984 // separate from old space strings. | 2003 // separate from old space strings. |
1985 static List<Object*> new_space_strings_; | 2004 static List<Object*> new_space_strings_; |
1986 static List<Object*> old_space_strings_; | 2005 static List<Object*> old_space_strings_; |
1987 }; | 2006 }; |
1988 | 2007 |
1989 } } // namespace v8::internal | 2008 } } // namespace v8::internal |
1990 | 2009 |
1991 #endif // V8_HEAP_H_ | 2010 #endif // V8_HEAP_H_ |
OLD | NEW |