Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: src/heap.h

Issue 5736008: Provide baseline for experimental GC implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« src/globals.h ('K') | « src/globals.h ('k') | src/heap.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 static int GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object);
1256 1255
1257 // Update the GC state. Called from the mark-compact collector. 1256 // Update the GC state. Called from the mark-compact collector.
1258 static void MarkMapPointersAsEncoded(bool encoded) { 1257 static void MarkMapPointersAsEncoded(bool encoded) {
1259 gc_safe_size_of_old_object_ = encoded 1258 ASSERT(!encoded);
1260 ? &GcSafeSizeOfOldObjectWithEncodedMap 1259 gc_safe_size_of_old_object_ = &GcSafeSizeOfOldObject;
1261 : &GcSafeSizeOfOldObject;
1262 } 1260 }
1263 1261
1264 // Checks whether a global GC is necessary 1262 // Checks whether a global GC is necessary
1265 static GarbageCollector SelectGarbageCollector(AllocationSpace space); 1263 static GarbageCollector SelectGarbageCollector(AllocationSpace space);
1266 1264
1267 // Performs garbage collection 1265 // Performs garbage collection
1268 // Returns whether there is a chance another major GC could 1266 // Returns whether there is a chance another major GC could
1269 // collect more garbage. 1267 // collect more garbage.
1270 static bool PerformGarbageCollection(GarbageCollector collector, 1268 static bool PerformGarbageCollection(GarbageCollector collector,
1271 GCTracer* tracer); 1269 GCTracer* tracer);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 if ((*current)->IsHeapObject()) { 1487 if ((*current)->IsHeapObject()) {
1490 HeapObject* object = HeapObject::cast(*current); 1488 HeapObject* object = HeapObject::cast(*current);
1491 ASSERT(Heap::Contains(object)); 1489 ASSERT(Heap::Contains(object));
1492 ASSERT(object->map()->IsMap()); 1490 ASSERT(object->map()->IsMap());
1493 } 1491 }
1494 } 1492 }
1495 } 1493 }
1496 }; 1494 };
1497 1495
1498 1496
1497 #ifdef ENABLE_CARDMARKING_WRITE_BARRIER
1499 // Visitor class to verify interior pointers in spaces that use region marks 1498 // Visitor class to verify interior pointers in spaces that use region marks
1500 // to keep track of intergenerational references. 1499 // to keep track of intergenerational references.
1501 // As VerifyPointersVisitor but also checks that dirty marks are set 1500 // As VerifyPointersVisitor but also checks that dirty marks are set
1502 // for regions covering intergenerational references. 1501 // for regions covering intergenerational references.
1503 class VerifyPointersAndDirtyRegionsVisitor: public ObjectVisitor { 1502 class VerifyPointersAndDirtyRegionsVisitor: public ObjectVisitor {
1504 public: 1503 public:
1505 void VisitPointers(Object** start, Object** end) { 1504 void VisitPointers(Object** start, Object** end) {
1506 for (Object** current = start; current < end; current++) { 1505 for (Object** current = start; current < end; current++) {
1507 if ((*current)->IsHeapObject()) { 1506 if ((*current)->IsHeapObject()) {
1508 HeapObject* object = HeapObject::cast(*current); 1507 HeapObject* object = HeapObject::cast(*current);
1509 ASSERT(Heap::Contains(object)); 1508 ASSERT(Heap::Contains(object));
1510 ASSERT(object->map()->IsMap()); 1509 ASSERT(object->map()->IsMap());
1511 if (Heap::InNewSpace(object)) { 1510 if (Heap::InNewSpace(object)) {
1512 ASSERT(Heap::InToSpace(object)); 1511 ASSERT(Heap::InToSpace(object));
1513 Address addr = reinterpret_cast<Address>(current); 1512 Address addr = reinterpret_cast<Address>(current);
1514 ASSERT(Page::FromAddress(addr)->IsRegionDirty(addr)); 1513 ASSERT(Page::FromAddress(addr)->IsRegionDirty(addr));
1515 } 1514 }
1516 } 1515 }
1517 } 1516 }
1518 } 1517 }
1519 }; 1518 };
1520 #endif 1519 #endif
1520 #endif
1521 1521
1522 1522
1523 // Space iterator for iterating over all spaces of the heap. 1523 // Space iterator for iterating over all spaces of the heap.
1524 // Returns each space in turn, and null when it is done. 1524 // Returns each space in turn, and null when it is done.
1525 class AllSpaces BASE_EMBEDDED { 1525 class AllSpaces BASE_EMBEDDED {
1526 public: 1526 public:
1527 Space* next(); 1527 Space* next();
1528 AllSpaces() { counter_ = FIRST_SPACE; } 1528 AllSpaces() { counter_ = FIRST_SPACE; }
1529 private: 1529 private:
1530 int counter_; 1530 int counter_;
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 // Return whether this object should be retained. If NULL is returned the 2105 // Return whether this object should be retained. If NULL is returned the
2106 // object has no references. Otherwise the address of the retained object 2106 // 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. 2107 // should be returned as in some GC situations the object has been moved.
2108 virtual Object* RetainAs(Object* object) = 0; 2108 virtual Object* RetainAs(Object* object) = 0;
2109 }; 2109 };
2110 2110
2111 2111
2112 } } // namespace v8::internal 2112 } } // namespace v8::internal
2113 2113
2114 #endif // V8_HEAP_H_ 2114 #endif // V8_HEAP_H_
OLDNEW
« src/globals.h ('K') | « src/globals.h ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698