| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 // Forward declarations. | 42 // Forward declarations. |
| 43 class CodeFlusher; | 43 class CodeFlusher; |
| 44 class GCTracer; | 44 class GCTracer; |
| 45 class MarkingVisitor; | 45 class MarkingVisitor; |
| 46 class RootMarkingVisitor; | 46 class RootMarkingVisitor; |
| 47 | 47 |
| 48 | 48 |
| 49 class Marking { | 49 class Marking { |
| 50 public: | 50 public: |
| 51 explicit Marking(Heap* heap) | 51 explicit Marking(Heap* heap) |
| 52 : heap_(heap), | 52 : heap_(heap) { |
| 53 new_space_bitmap_(NULL) { | |
| 54 } | 53 } |
| 55 | 54 |
| 56 inline MarkBit MarkBitFromNewSpace(HeapObject* obj); | 55 static inline MarkBit MarkBitFrom(Address addr); |
| 57 | 56 |
| 58 static inline MarkBit MarkBitFromOldSpace(HeapObject* obj); | 57 static inline MarkBit MarkBitFrom(HeapObject* obj) { |
| 59 | |
| 60 inline MarkBit MarkBitFrom(Address addr); | |
| 61 | |
| 62 // For embedding in generated code. | |
| 63 inline Address new_space_bitmap() { | |
| 64 return reinterpret_cast<Address>(new_space_bitmap_); | |
| 65 } | |
| 66 | |
| 67 inline MarkBit MarkBitFrom(HeapObject* obj) { | |
| 68 return MarkBitFrom(reinterpret_cast<Address>(obj)); | 58 return MarkBitFrom(reinterpret_cast<Address>(obj)); |
| 69 } | 59 } |
| 70 | 60 |
| 71 inline void ClearRange(Address addr, int size); | |
| 72 | |
| 73 void TransferMark(Address old_start, Address new_start); | 61 void TransferMark(Address old_start, Address new_start); |
| 74 | 62 |
| 75 bool Setup(); | 63 bool Setup(); |
| 76 | 64 |
| 77 void TearDown(); | 65 void TearDown(); |
| 78 | 66 |
| 79 private: | 67 private: |
| 80 class BitmapStorageDescriptor { | |
| 81 public: | |
| 82 INLINE(static int CellsCount(Address addr)) { | |
| 83 return HeaderOf(addr)->cells_count_; | |
| 84 } | |
| 85 | |
| 86 static Bitmap<BitmapStorageDescriptor>* Allocate(int cells_count) { | |
| 87 VirtualMemory* memory = new VirtualMemory(SizeFor(cells_count)); | |
| 88 | |
| 89 if (!memory->Commit(memory->address(), memory->size(), false)) { | |
| 90 delete memory; | |
| 91 return NULL; | |
| 92 } | |
| 93 | |
| 94 Address bitmap_address = | |
| 95 reinterpret_cast<Address>(memory->address()) + sizeof(Header); | |
| 96 HeaderOf(bitmap_address)->cells_count_ = cells_count; | |
| 97 HeaderOf(bitmap_address)->storage_ = memory; | |
| 98 return Bitmap<BitmapStorageDescriptor>::FromAddress(bitmap_address); | |
| 99 } | |
| 100 | |
| 101 static void Free(Bitmap<BitmapStorageDescriptor>* bitmap) { | |
| 102 delete HeaderOf(bitmap->address())->storage_; | |
| 103 } | |
| 104 | |
| 105 private: | |
| 106 struct Header { | |
| 107 VirtualMemory* storage_; | |
| 108 int cells_count_; | |
| 109 }; | |
| 110 | |
| 111 static int SizeFor(int cell_count) { | |
| 112 return sizeof(Header) + | |
| 113 Bitmap<BitmapStorageDescriptor>::SizeFor(cell_count); | |
| 114 } | |
| 115 | |
| 116 static Header* HeaderOf(Address addr) { | |
| 117 return reinterpret_cast<Header*>(addr - sizeof(Header)); | |
| 118 } | |
| 119 }; | |
| 120 | |
| 121 typedef Bitmap<BitmapStorageDescriptor> NewSpaceMarkbitsBitmap; | |
| 122 | |
| 123 Heap* heap_; | 68 Heap* heap_; |
| 124 NewSpaceMarkbitsBitmap* new_space_bitmap_; | |
| 125 }; | 69 }; |
| 126 | 70 |
| 127 // ---------------------------------------------------------------------------- | 71 // ---------------------------------------------------------------------------- |
| 128 // Marking deque for tracing live objects. | 72 // Marking deque for tracing live objects. |
| 129 | 73 |
| 130 class MarkingDeque { | 74 class MarkingDeque { |
| 131 public: | 75 public: |
| 132 MarkingDeque() | 76 MarkingDeque() |
| 133 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) { } | 77 : array_(NULL), top_(0), bottom_(0), mask_(0), overflowed_(false) { } |
| 134 | 78 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 CodeFlusher* code_flusher_; | 457 CodeFlusher* code_flusher_; |
| 514 | 458 |
| 515 friend class Heap; | 459 friend class Heap; |
| 516 friend class OverflowedObjectsScanner; | 460 friend class OverflowedObjectsScanner; |
| 517 }; | 461 }; |
| 518 | 462 |
| 519 | 463 |
| 520 } } // namespace v8::internal | 464 } } // namespace v8::internal |
| 521 | 465 |
| 522 #endif // V8_MARK_COMPACT_H_ | 466 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |