| 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 17 matching lines...) Expand all Loading... |
| 28 #ifndef V8_MARK_COMPACT_INL_H_ | 28 #ifndef V8_MARK_COMPACT_INL_H_ |
| 29 #define V8_MARK_COMPACT_INL_H_ | 29 #define V8_MARK_COMPACT_INL_H_ |
| 30 | 30 |
| 31 #include "isolate.h" | 31 #include "isolate.h" |
| 32 #include "memory.h" | 32 #include "memory.h" |
| 33 #include "mark-compact.h" | 33 #include "mark-compact.h" |
| 34 | 34 |
| 35 namespace v8 { | 35 namespace v8 { |
| 36 namespace internal { | 36 namespace internal { |
| 37 | 37 |
| 38 MarkBit Marking::MarkBitFromNewSpace(HeapObject* obj) { | |
| 39 ASSERT(heap_->InNewSpace(obj)); | |
| 40 uint32_t index = heap_->new_space()->AddressToMarkbitIndex( | |
| 41 reinterpret_cast<Address>(obj)); | |
| 42 bool data_object = obj->map()->instance_type() == HEAP_NUMBER_TYPE; | |
| 43 return new_space_bitmap_->MarkBitFromIndex(index, data_object); | |
| 44 } | |
| 45 | 38 |
| 46 | 39 MarkBit Marking::MarkBitFrom(Address addr) { |
| 47 MarkBit Marking::MarkBitFromOldSpace(HeapObject* obj) { | |
| 48 ASSERT(!HEAP->InNewSpace(obj)); | |
| 49 ASSERT(obj->IsHeapObject()); | |
| 50 Address addr = reinterpret_cast<Address>(obj); | |
| 51 Page *p = Page::FromAddress(addr); | 40 Page *p = Page::FromAddress(addr); |
| 52 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), | 41 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), |
| 53 p->ContainsOnlyData()); | 42 p->ContainsOnlyData()); |
| 54 } | 43 } |
| 55 | 44 |
| 56 | 45 |
| 57 MarkBit Marking::MarkBitFrom(Address addr) { | |
| 58 if (heap_->InNewSpace(addr)) { | |
| 59 uint32_t index = heap_->new_space()->AddressToMarkbitIndex(addr); | |
| 60 return new_space_bitmap_->MarkBitFromIndex(index); | |
| 61 } else { | |
| 62 Page *p = Page::FromAddress(addr); | |
| 63 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), | |
| 64 p->ContainsOnlyData()); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 | |
| 69 void Marking::ClearRange(Address addr, int size) { | |
| 70 if (heap_->InNewSpace(addr)) { | |
| 71 uint32_t index = heap_->new_space()->AddressToMarkbitIndex(addr); | |
| 72 new_space_bitmap_->ClearRange(index, size >> kPointerSizeLog2); | |
| 73 } else { | |
| 74 Page *p = Page::FromAddress(addr); | |
| 75 p->markbits()->ClearRange(p->FastAddressToMarkbitIndex(addr), | |
| 76 size >> kPointerSizeLog2); | |
| 77 } | |
| 78 } | |
| 79 | |
| 80 | |
| 81 void MarkCompactCollector::SetFlags(int flags) { | 46 void MarkCompactCollector::SetFlags(int flags) { |
| 82 force_compaction_ = ((flags & Heap::kForceCompactionMask) != 0); | 47 force_compaction_ = ((flags & Heap::kForceCompactionMask) != 0); |
| 83 sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0); | 48 sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0); |
| 84 } | 49 } |
| 85 | 50 |
| 86 | 51 |
| 87 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 52 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
| 88 ASSERT(heap()->marking()->MarkBitFrom(obj) == mark_bit); | 53 ASSERT(heap()->marking()->MarkBitFrom(obj) == mark_bit); |
| 89 if (!mark_bit.Get()) { | 54 if (!mark_bit.Get()) { |
| 90 mark_bit.Set(); | 55 mark_bit.Set(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 109 bool MarkCompactCollector::IsMarked(Object* obj) { | 74 bool MarkCompactCollector::IsMarked(Object* obj) { |
| 110 ASSERT(obj->IsHeapObject()); | 75 ASSERT(obj->IsHeapObject()); |
| 111 HeapObject* heap_object = HeapObject::cast(obj); | 76 HeapObject* heap_object = HeapObject::cast(obj); |
| 112 return heap_->marking()->MarkBitFrom(heap_object).Get(); | 77 return heap_->marking()->MarkBitFrom(heap_object).Get(); |
| 113 } | 78 } |
| 114 | 79 |
| 115 | 80 |
| 116 } } // namespace v8::internal | 81 } } // namespace v8::internal |
| 117 | 82 |
| 118 #endif // V8_MARK_COMPACT_INL_H_ | 83 #endif // V8_MARK_COMPACT_INL_H_ |
| OLD | NEW |