| 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 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 GCType gc_type; | 1245 GCType gc_type; |
| 1246 }; | 1246 }; |
| 1247 static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; | 1247 static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_; |
| 1248 | 1248 |
| 1249 static GCCallback global_gc_prologue_callback_; | 1249 static GCCallback global_gc_prologue_callback_; |
| 1250 static GCCallback global_gc_epilogue_callback_; | 1250 static GCCallback global_gc_epilogue_callback_; |
| 1251 | 1251 |
| 1252 // Support for computing object sizes during GC. | 1252 // Support for computing object sizes during GC. |
| 1253 static HeapObjectCallback gc_safe_size_of_old_object_; | 1253 static HeapObjectCallback gc_safe_size_of_old_object_; |
| 1254 static int GcSafeSizeOfOldObject(HeapObject* object); | 1254 static int GcSafeSizeOfOldObject(HeapObject* object); |
| 1255 #ifndef BASELINE_GC |
| 1255 static int GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object); | 1256 static int GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object); |
| 1257 #endif |
| 1256 | 1258 |
| 1257 // Update the GC state. Called from the mark-compact collector. | 1259 // Update the GC state. Called from the mark-compact collector. |
| 1258 static void MarkMapPointersAsEncoded(bool encoded) { | 1260 static void MarkMapPointersAsEncoded(bool encoded) { |
| 1261 #ifndef BASELINE_GC |
| 1259 gc_safe_size_of_old_object_ = encoded | 1262 gc_safe_size_of_old_object_ = encoded |
| 1260 ? &GcSafeSizeOfOldObjectWithEncodedMap | 1263 ? &GcSafeSizeOfOldObjectWithEncodedMap |
| 1261 : &GcSafeSizeOfOldObject; | 1264 : &GcSafeSizeOfOldObject; |
| 1265 #else |
| 1266 ASSERT(!encoded); |
| 1267 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject; |
| 1268 #endif |
| 1262 } | 1269 } |
| 1263 | 1270 |
| 1264 // Checks whether a global GC is necessary | 1271 // Checks whether a global GC is necessary |
| 1265 static GarbageCollector SelectGarbageCollector(AllocationSpace space); | 1272 static GarbageCollector SelectGarbageCollector(AllocationSpace space); |
| 1266 | 1273 |
| 1267 // Performs garbage collection | 1274 // Performs garbage collection |
| 1268 // Returns whether there is a chance another major GC could | 1275 // Returns whether there is a chance another major GC could |
| 1269 // collect more garbage. | 1276 // collect more garbage. |
| 1270 static bool PerformGarbageCollection(GarbageCollector collector, | 1277 static bool PerformGarbageCollection(GarbageCollector collector, |
| 1271 GCTracer* tracer); | 1278 GCTracer* tracer); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 if ((*current)->IsHeapObject()) { | 1496 if ((*current)->IsHeapObject()) { |
| 1490 HeapObject* object = HeapObject::cast(*current); | 1497 HeapObject* object = HeapObject::cast(*current); |
| 1491 ASSERT(Heap::Contains(object)); | 1498 ASSERT(Heap::Contains(object)); |
| 1492 ASSERT(object->map()->IsMap()); | 1499 ASSERT(object->map()->IsMap()); |
| 1493 } | 1500 } |
| 1494 } | 1501 } |
| 1495 } | 1502 } |
| 1496 }; | 1503 }; |
| 1497 | 1504 |
| 1498 | 1505 |
| 1506 #ifndef BASELINE_GC |
| 1499 // Visitor class to verify interior pointers in spaces that use region marks | 1507 // Visitor class to verify interior pointers in spaces that use region marks |
| 1500 // to keep track of intergenerational references. | 1508 // to keep track of intergenerational references. |
| 1501 // As VerifyPointersVisitor but also checks that dirty marks are set | 1509 // As VerifyPointersVisitor but also checks that dirty marks are set |
| 1502 // for regions covering intergenerational references. | 1510 // for regions covering intergenerational references. |
| 1503 class VerifyPointersAndDirtyRegionsVisitor: public ObjectVisitor { | 1511 class VerifyPointersAndDirtyRegionsVisitor: public ObjectVisitor { |
| 1504 public: | 1512 public: |
| 1505 void VisitPointers(Object** start, Object** end) { | 1513 void VisitPointers(Object** start, Object** end) { |
| 1506 for (Object** current = start; current < end; current++) { | 1514 for (Object** current = start; current < end; current++) { |
| 1507 if ((*current)->IsHeapObject()) { | 1515 if ((*current)->IsHeapObject()) { |
| 1508 HeapObject* object = HeapObject::cast(*current); | 1516 HeapObject* object = HeapObject::cast(*current); |
| 1509 ASSERT(Heap::Contains(object)); | 1517 ASSERT(Heap::Contains(object)); |
| 1510 ASSERT(object->map()->IsMap()); | 1518 ASSERT(object->map()->IsMap()); |
| 1511 if (Heap::InNewSpace(object)) { | 1519 if (Heap::InNewSpace(object)) { |
| 1512 ASSERT(Heap::InToSpace(object)); | 1520 ASSERT(Heap::InToSpace(object)); |
| 1513 Address addr = reinterpret_cast<Address>(current); | 1521 Address addr = reinterpret_cast<Address>(current); |
| 1514 ASSERT(Page::FromAddress(addr)->IsRegionDirty(addr)); | 1522 ASSERT(Page::FromAddress(addr)->IsRegionDirty(addr)); |
| 1515 } | 1523 } |
| 1516 } | 1524 } |
| 1517 } | 1525 } |
| 1518 } | 1526 } |
| 1519 }; | 1527 }; |
| 1520 #endif | 1528 #endif |
| 1529 #endif |
| 1521 | 1530 |
| 1522 | 1531 |
| 1523 // Space iterator for iterating over all spaces of the heap. | 1532 // Space iterator for iterating over all spaces of the heap. |
| 1524 // Returns each space in turn, and null when it is done. | 1533 // Returns each space in turn, and null when it is done. |
| 1525 class AllSpaces BASE_EMBEDDED { | 1534 class AllSpaces BASE_EMBEDDED { |
| 1526 public: | 1535 public: |
| 1527 Space* next(); | 1536 Space* next(); |
| 1528 AllSpaces() { counter_ = FIRST_SPACE; } | 1537 AllSpaces() { counter_ = FIRST_SPACE; } |
| 1529 private: | 1538 private: |
| 1530 int counter_; | 1539 int counter_; |
| (...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2105 // Return whether this object should be retained. If NULL is returned the | 2114 // Return whether this object should be retained. If NULL is returned the |
| 2106 // object has no references. Otherwise the address of the retained object | 2115 // object has no references. Otherwise the address of the retained object |
| 2107 // should be returned as in some GC situations the object has been moved. | 2116 // should be returned as in some GC situations the object has been moved. |
| 2108 virtual Object* RetainAs(Object* object) = 0; | 2117 virtual Object* RetainAs(Object* object) = 0; |
| 2109 }; | 2118 }; |
| 2110 | 2119 |
| 2111 | 2120 |
| 2112 } } // namespace v8::internal | 2121 } } // namespace v8::internal |
| 2113 | 2122 |
| 2114 #endif // V8_HEAP_H_ | 2123 #endif // V8_HEAP_H_ |
| OLD | NEW |