From 356412e2b7ba3fde164bc08a44fee0ddc19c54e1 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Mon, 21 Sep 2015 09:07:37 -0700 Subject: Add one LinearAlloc per ClassLoader Also added freeing linear alloc and class table when the corresponding class loader is no longer reachable. Bug: 22720414 Change-Id: Icb32c3a4c865f240e147bc87ed080a6b1d8a5795 --- runtime/mirror/class_loader.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'runtime/mirror/class_loader.h') diff --git a/runtime/mirror/class_loader.h b/runtime/mirror/class_loader.h index f27b6155ce..c2a65d62e2 100644 --- a/runtime/mirror/class_loader.h +++ b/runtime/mirror/class_loader.h @@ -35,18 +35,31 @@ class MANAGED ClassLoader : public Object { static constexpr uint32_t InstanceSize() { return sizeof(ClassLoader); } + ClassLoader* GetParent() SHARED_REQUIRES(Locks::mutator_lock_) { return GetFieldObject(OFFSET_OF_OBJECT_MEMBER(ClassLoader, parent_)); } + ClassTable* GetClassTable() SHARED_REQUIRES(Locks::mutator_lock_) { return reinterpret_cast( GetField64(OFFSET_OF_OBJECT_MEMBER(ClassLoader, class_table_))); } + void SetClassTable(ClassTable* class_table) SHARED_REQUIRES(Locks::mutator_lock_) { SetField64(OFFSET_OF_OBJECT_MEMBER(ClassLoader, class_table_), reinterpret_cast(class_table)); } + LinearAlloc* GetAllocator() SHARED_REQUIRES(Locks::mutator_lock_) { + return reinterpret_cast( + GetField64(OFFSET_OF_OBJECT_MEMBER(ClassLoader, allocator_))); + } + + void SetAllocator(LinearAlloc* allocator) SHARED_REQUIRES(Locks::mutator_lock_) { + SetField64(OFFSET_OF_OBJECT_MEMBER(ClassLoader, allocator_), + reinterpret_cast(allocator)); + } + private: // Visit instance fields of the class loader as well as its associated classes. // Null class loader is handled by ClassLinker::VisitClassRoots. @@ -61,6 +74,7 @@ class MANAGED ClassLoader : public Object { HeapReference proxyCache_; // Native pointer to class table, need to zero this out when image writing. uint32_t padding_ ATTRIBUTE_UNUSED; + uint64_t allocator_; uint64_t class_table_; friend struct art::ClassLoaderOffsets; // for verifying offset information -- cgit v1.2.3-59-g8ed1b