diff options
Diffstat (limited to 'src/heap.cc')
| -rw-r--r-- | src/heap.cc | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/heap.cc b/src/heap.cc index 6fd4ade7a1..40bc67362d 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -54,17 +54,6 @@ Mutex* Heap::lock_ = NULL; bool Heap::verify_objects_ = false; -class ScopedHeapLock { - public: - ScopedHeapLock() { - Heap::Lock(); - } - - ~ScopedHeapLock() { - Heap::Unlock(); - } -}; - void Heap::Init(bool is_verbose_heap, bool is_verbose_gc, size_t initial_size, size_t maximum_size, size_t growth_size, const std::vector<std::string>& image_file_names) { @@ -183,13 +172,18 @@ Object* Heap::AllocObject(Class* klass, size_t byte_count) { bool Heap::IsHeapAddress(const Object* obj) { // Note: we deliberately don't take the lock here, and mustn't test anything that would // require taking the lock. - if (!IsAligned<kObjectAlignment>(obj)) { + if (obj == NULL || !IsAligned<kObjectAlignment>(obj)) { return false; } // TODO return true; } +bool Heap::IsLiveObjectLocked(const Object* obj) { + lock_->AssertHeld(); + return IsHeapAddress(obj) && live_bitmap_->Test(obj); +} + #if VERIFY_OBJECT_ENABLED void Heap::VerifyObject(const Object* obj) { if (!verify_objects_) { @@ -543,6 +537,13 @@ void Heap::WaitForConcurrentGcToComplete() { lock_->AssertHeld(); } +void Heap::WalkHeap(void(*callback)(const void*, size_t, const void*, size_t, void*), void* arg) { + typedef std::vector<Space*>::iterator It; // C++0x auto. + for (It it = spaces_.begin(); it != spaces_.end(); ++it) { + (*it)->Walk(callback, arg); + } +} + /* Terminology: * 1. Footprint: Capacity we allocate from system. * 2. Active space: a.k.a. alloc_space_. |