summaryrefslogtreecommitdiffstats
path: root/runtime/gc
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2014-03-06 18:11:53 -0800
committerMathieu Chartier <mathieuc@google.com>2014-03-07 12:09:04 -0800
commitc645f1ddb7c40bea6a38eda4b3f83f6b6dec405b (patch)
treede6141864c1c011216c19dd99a2c1e2bc442dd6d /runtime/gc
parenta9d7be62735e3356cef7e8ed797c519134a17061 (diff)
downloadart-c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b.zip
art-c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b.tar.gz
art-c645f1ddb7c40bea6a38eda4b3f83f6b6dec405b.tar.bz2
Add more VerifyObject calls.
Added verify object calls to SirtRef, IndirectReferenceTable, ReferenceTable. Removed un-needed verify object in ScopedObjectAccess / DecodeJObject since object sources are handled. Bug: 12934910 Change-Id: I55a46a8ea61fed2a77526eda27fd2cce97a9b125
Diffstat (limited to 'runtime/gc')
-rw-r--r--runtime/gc/heap-inl.h13
-rw-r--r--runtime/gc/heap.cc7
-rw-r--r--runtime/gc/heap.h2
-rw-r--r--runtime/gc/space/malloc_space.cc1
4 files changed, 13 insertions, 10 deletions
diff --git a/runtime/gc/heap-inl.h b/runtime/gc/heap-inl.h
index 3d2f7ea..b80e72e 100644
--- a/runtime/gc/heap-inl.h
+++ b/runtime/gc/heap-inl.h
@@ -24,8 +24,8 @@
#include "gc/space/dlmalloc_space-inl.h"
#include "gc/space/large_object_space.h"
#include "gc/space/rosalloc_space-inl.h"
-#include "object_utils.h"
#include "runtime.h"
+#include "sirt_ref-inl.h"
#include "thread.h"
#include "thread-inl.h"
#include "verify_object-inl.h"
@@ -37,7 +37,9 @@ template <bool kInstrumented, bool kCheckLargeObject, typename PreFenceVisitor>
inline mirror::Object* Heap::AllocObjectWithAllocator(Thread* self, mirror::Class* klass,
size_t byte_count, AllocatorType allocator,
const PreFenceVisitor& pre_fence_visitor) {
- DebugCheckPreconditionsForAllocObject(klass, byte_count);
+ if (kIsDebugBuild) {
+ CheckPreconditionsForAllocObject(klass, byte_count);
+ }
// Since allocation can cause a GC which will need to SuspendAll, make sure all allocations are
// done in the runnable state where suspension is expected.
DCHECK_EQ(self->GetState(), kRunnable);
@@ -226,13 +228,6 @@ inline mirror::Object* Heap::TryToAllocate(Thread* self, AllocatorType allocator
return ret;
}
-inline void Heap::DebugCheckPreconditionsForAllocObject(mirror::Class* c, size_t byte_count) {
- DCHECK(c == NULL || (c->IsClassClass() && byte_count >= sizeof(mirror::Class)) ||
- (c->IsVariableSize() || c->GetObjectSize() == byte_count) ||
- strlen(ClassHelper(c).GetDescriptor()) == 0);
- DCHECK_GE(byte_count, sizeof(mirror::Object));
-}
-
inline Heap::AllocationTimer::AllocationTimer(Heap* heap, mirror::Object** allocated_obj_ptr)
: heap_(heap), allocated_obj_ptr_(allocated_obj_ptr) {
if (kMeasureAllocationTime) {
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 2497e6a..87b4e60 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2708,5 +2708,12 @@ void Heap::AddModUnionTable(accounting::ModUnionTable* mod_union_table) {
mod_union_tables_.Put(mod_union_table->GetSpace(), mod_union_table);
}
+void Heap::CheckPreconditionsForAllocObject(mirror::Class* c, size_t byte_count) {
+ CHECK(c == NULL || (c->IsClassClass() && byte_count >= sizeof(mirror::Class)) ||
+ (c->IsVariableSize() || c->GetObjectSize() == byte_count) ||
+ strlen(ClassHelper(c).GetDescriptor()) == 0);
+ CHECK_GE(byte_count, sizeof(mirror::Object));
+}
+
} // namespace gc
} // namespace art
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 4c4e943..3a8739a 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -192,7 +192,7 @@ class Heap {
void SwapSemiSpaces() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
- void DebugCheckPreconditionsForAllocObject(mirror::Class* c, size_t byte_count)
+ void CheckPreconditionsForAllocObject(mirror::Class* c, size_t byte_count)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
void ThrowOutOfMemoryError(size_t byte_count, bool large_object_allocation);
diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc
index 61d1071..dac043e 100644
--- a/runtime/gc/space/malloc_space.cc
+++ b/runtime/gc/space/malloc_space.cc
@@ -24,6 +24,7 @@
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
#include "runtime.h"
+#include "sirt_ref-inl.h"
#include "thread.h"
#include "thread_list.h"
#include "utils.h"