diff options
25 files changed, 71 insertions, 37 deletions
diff --git a/dex2oat/linker/image_writer.h b/dex2oat/linker/image_writer.h index 7bdaebef2a..c35dbaa418 100644 --- a/dex2oat/linker/image_writer.h +++ b/dex2oat/linker/image_writer.h @@ -26,6 +26,7 @@ #include <set> #include <stack> #include <string> +#include <unordered_map> #include "art_method.h" #include "base/bit_utils.h" diff --git a/runtime/class_linker-inl.h b/runtime/class_linker-inl.h index 0dc62d346d..7e011371b7 100644 --- a/runtime/class_linker-inl.h +++ b/runtime/class_linker-inl.h @@ -22,7 +22,6 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "class_linker.h" -#include "gc/heap-inl.h" #include "gc_root-inl.h" #include "handle_scope-inl.h" #include "mirror/class_loader.h" @@ -439,6 +438,14 @@ inline void ClassLinker::VisitClassTables(const Visitor& visitor) { } } +template <ReadBarrierOption kReadBarrierOption> +inline ObjPtr<mirror::ObjectArray<mirror::Class>> ClassLinker::GetClassRoots() { + ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots = + class_roots_.Read<kReadBarrierOption>(); + DCHECK(class_roots != nullptr); + return class_roots; +} + } // namespace art #endif // ART_RUNTIME_CLASS_LINKER_INL_H_ diff --git a/runtime/class_linker.h b/runtime/class_linker.h index cc17d57228..0ae7a9bbe6 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -556,12 +556,7 @@ class ClassLinker { REQUIRES_SHARED(Locks::mutator_lock_); template <ReadBarrierOption kReadBarrierOption = kWithReadBarrier> - ObjPtr<mirror::ObjectArray<mirror::Class>> GetClassRoots() REQUIRES_SHARED(Locks::mutator_lock_) { - ObjPtr<mirror::ObjectArray<mirror::Class>> class_roots = - class_roots_.Read<kReadBarrierOption>(); - DCHECK(class_roots != nullptr); - return class_roots; - } + ObjPtr<mirror::ObjectArray<mirror::Class>> GetClassRoots() REQUIRES_SHARED(Locks::mutator_lock_); // Move the class table to the pre-zygote table to reduce memory usage. This works by ensuring // that no more classes are ever added to the pre zygote table which makes it that the pages diff --git a/runtime/class_root.h b/runtime/class_root.h index 19a78b1ffb..1cd135f2aa 100644 --- a/runtime/class_root.h +++ b/runtime/class_root.h @@ -17,7 +17,8 @@ #ifndef ART_RUNTIME_CLASS_ROOT_H_ #define ART_RUNTIME_CLASS_ROOT_H_ -#include "class_linker.h" +#include "class_linker-inl.h" +#include "gc_root-inl.h" #include "mirror/class.h" #include "mirror/object_array-inl.h" #include "obj_ptr-inl.h" diff --git a/runtime/class_table-inl.h b/runtime/class_table-inl.h index 6b6fe341e0..a2cdb2c28c 100644 --- a/runtime/class_table-inl.h +++ b/runtime/class_table-inl.h @@ -19,6 +19,7 @@ #include "class_table.h" +#include "base/mutex-inl.h" #include "gc_root-inl.h" #include "mirror/class.h" #include "oat_file.h" diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index 8cc0c4ebf8..4e2cf2bf8c 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "rosalloc.h" +#include "rosalloc-inl.h" #include <list> #include <map> diff --git a/runtime/gc/collector/concurrent_copying-inl.h b/runtime/gc/collector/concurrent_copying-inl.h index 8fd235f338..6b394c7061 100644 --- a/runtime/gc/collector/concurrent_copying-inl.h +++ b/runtime/gc/collector/concurrent_copying-inl.h @@ -22,7 +22,7 @@ #include "gc/accounting/atomic_stack.h" #include "gc/accounting/space_bitmap-inl.h" #include "gc/heap.h" -#include "gc/space/region_space.h" +#include "gc/space/region_space-inl.h" #include "gc/verification.h" #include "lock_word.h" #include "mirror/class.h" diff --git a/runtime/gc/space/malloc_space.cc b/runtime/gc/space/malloc_space.cc index be75efec6d..189aeb5297 100644 --- a/runtime/gc/space/malloc_space.cc +++ b/runtime/gc/space/malloc_space.cc @@ -19,6 +19,7 @@ #include "android-base/stringprintf.h" #include "base/logging.h" // For VLOG +#include "base/mutex-inl.h" #include "base/utils.h" #include "gc/accounting/card_table-inl.h" #include "gc/accounting/space_bitmap-inl.h" diff --git a/runtime/gc/space/region_space-inl.h b/runtime/gc/space/region_space-inl.h index 8cb079d53a..5ff1270b56 100644 --- a/runtime/gc/space/region_space-inl.h +++ b/runtime/gc/space/region_space-inl.h @@ -18,6 +18,10 @@ #define ART_RUNTIME_GC_SPACE_REGION_SPACE_INL_H_ #include "region_space.h" + +#include "base/mutex-inl.h" +#include "mirror/object-inl.h" +#include "region_space.h" #include "thread-current-inl.h" namespace art { @@ -236,6 +240,15 @@ inline void RegionSpace::WalkInternal(Visitor&& visitor) { } } +template <typename Visitor> +inline void RegionSpace::Walk(Visitor&& visitor) { + WalkInternal</* kToSpaceOnly= */ false>(visitor); +} +template <typename Visitor> +inline void RegionSpace::WalkToSpace(Visitor&& visitor) { + WalkInternal</* kToSpaceOnly= */ true>(visitor); +} + inline mirror::Object* RegionSpace::GetNextObject(mirror::Object* obj) { const uintptr_t position = reinterpret_cast<uintptr_t>(obj) + obj->SizeOf(); return reinterpret_cast<mirror::Object*>(RoundUp(position, kAlignment)); diff --git a/runtime/gc/space/region_space.h b/runtime/gc/space/region_space.h index cc371b8d01..8810f8ce58 100644 --- a/runtime/gc/space/region_space.h +++ b/runtime/gc/space/region_space.h @@ -205,14 +205,9 @@ class RegionSpace final : public ContinuousMemMapAllocSpace { // Go through all of the blocks and visit the continuous objects. template <typename Visitor> - ALWAYS_INLINE void Walk(Visitor&& visitor) REQUIRES(Locks::mutator_lock_) { - WalkInternal</* kToSpaceOnly= */ false>(visitor); - } + ALWAYS_INLINE void Walk(Visitor&& visitor) REQUIRES(Locks::mutator_lock_); template <typename Visitor> - ALWAYS_INLINE void WalkToSpace(Visitor&& visitor) - REQUIRES(Locks::mutator_lock_) { - WalkInternal</* kToSpaceOnly= */ true>(visitor); - } + ALWAYS_INLINE void WalkToSpace(Visitor&& visitor) REQUIRES(Locks::mutator_lock_); accounting::ContinuousSpaceBitmap::SweepCallback* GetSweepCallback() override { return nullptr; diff --git a/runtime/gc/space/rosalloc_space_random_test.cc b/runtime/gc/space/rosalloc_space_random_test.cc index ca3aff47f0..b50859b8e6 100644 --- a/runtime/gc/space/rosalloc_space_random_test.cc +++ b/runtime/gc/space/rosalloc_space_random_test.cc @@ -16,6 +16,8 @@ #include "space_test.h" +#include "rosalloc_space.h" + namespace art { namespace gc { namespace space { diff --git a/runtime/gc/space/rosalloc_space_static_test.cc b/runtime/gc/space/rosalloc_space_static_test.cc index a78623e593..5e7ced6e23 100644 --- a/runtime/gc/space/rosalloc_space_static_test.cc +++ b/runtime/gc/space/rosalloc_space_static_test.cc @@ -16,6 +16,8 @@ #include "space_test.h" +#include "rosalloc_space.h" + namespace art { namespace gc { namespace space { diff --git a/runtime/gc/space/space_test.h b/runtime/gc/space/space_test.h index c94b666695..5aac21721f 100644 --- a/runtime/gc/space/space_test.h +++ b/runtime/gc/space/space_test.h @@ -22,6 +22,7 @@ #include "base/globals.h" #include "common_runtime_test.h" +#include "handle_scope-inl.h" #include "mirror/array-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 8600b41c71..8239602b50 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -39,6 +39,7 @@ #include "dex/method_reference.h" #include "entrypoints/runtime_asm_entrypoints.h" #include "gc/accounting/bitmap-inl.h" +#include "gc/allocator/dlmalloc.h" #include "gc/scoped_gc_critical_section.h" #include "handle.h" #include "instrumentation.h" diff --git a/runtime/method_handles.cc b/runtime/method_handles.cc index 86ad32ef9b..7d889c0694 100644 --- a/runtime/method_handles.cc +++ b/runtime/method_handles.cc @@ -22,6 +22,7 @@ #include "common_dex_operations.h" #include "interpreter/shadow_frame-inl.h" #include "jvalue-inl.h" +#include "mirror/class-inl.h" #include "mirror/emulated_stack_frame.h" #include "mirror/method_handle_impl-inl.h" #include "mirror/method_type.h" diff --git a/runtime/mirror/array-inl.h b/runtime/mirror/array-inl.h index 704fb118e3..d806e40005 100644 --- a/runtime/mirror/array-inl.h +++ b/runtime/mirror/array-inl.h @@ -27,6 +27,7 @@ #include "class.h" #include "gc/heap-inl.h" #include "obj_ptr-inl.h" +#include "runtime.h" #include "thread-current-inl.h" namespace art { diff --git a/runtime/mirror/dex_cache-inl.h b/runtime/mirror/dex_cache-inl.h index 6efb7474e0..13eaf3da45 100644 --- a/runtime/mirror/dex_cache-inl.h +++ b/runtime/mirror/dex_cache-inl.h @@ -27,12 +27,12 @@ #include "base/enums.h" #include "class_linker.h" #include "dex/dex_file.h" -#include "gc/heap-inl.h" #include "gc_root-inl.h" #include "mirror/call_site.h" #include "mirror/class.h" #include "mirror/method_type.h" #include "obj_ptr.h" +#include "object-inl.h" #include "runtime.h" #include "write_barrier-inl.h" @@ -42,6 +42,27 @@ namespace art { namespace mirror { template <typename T> +inline DexCachePair<T>::DexCachePair(ObjPtr<T> object, uint32_t index) + : object(object), index(index) {} + +template <typename T> +inline void DexCachePair<T>::Initialize(std::atomic<DexCachePair<T>>* dex_cache) { + DexCachePair<T> first_elem; + first_elem.object = GcRoot<T>(nullptr); + first_elem.index = InvalidIndexForSlot(0); + dex_cache[0].store(first_elem, std::memory_order_relaxed); +} + +template <typename T> +inline T* DexCachePair<T>::GetObjectForIndex(uint32_t idx) { + if (idx != index) { + return nullptr; + } + DCHECK(!object.IsNull()); + return object.Read(); +} + +template <typename T> inline void NativeDexCachePair<T>::Initialize(std::atomic<NativeDexCachePair<T>>* dex_cache, PointerSize pointer_size) { NativeDexCachePair<T> first_elem; diff --git a/runtime/mirror/dex_cache.h b/runtime/mirror/dex_cache.h index da1cd3fc2b..6149f9c0be 100644 --- a/runtime/mirror/dex_cache.h +++ b/runtime/mirror/dex_cache.h @@ -21,7 +21,7 @@ #include "base/bit_utils.h" #include "base/mutex.h" #include "dex/dex_file_types.h" -#include "gc_root-inl.h" +#include "gc_root.h" // Note: must not use -inl here to avoid circular dependency. #include "object.h" #include "object_array.h" @@ -67,19 +67,12 @@ template <typename T> struct PACKED(8) DexCachePair { // it's always non-null if the id branch succeeds (except for the 0th id). // Set the initial state for the 0th entry to be {0,1} which is guaranteed to fail // the lookup id == stored id branch. - DexCachePair(ObjPtr<T> object, uint32_t index) - : object(object), - index(index) {} + DexCachePair(ObjPtr<T> object, uint32_t index); DexCachePair() : index(0) {} DexCachePair(const DexCachePair<T>&) = default; DexCachePair& operator=(const DexCachePair<T>&) = default; - static void Initialize(std::atomic<DexCachePair<T>>* dex_cache) { - DexCachePair<T> first_elem; - first_elem.object = GcRoot<T>(nullptr); - first_elem.index = InvalidIndexForSlot(0); - dex_cache[0].store(first_elem, std::memory_order_relaxed); - } + static void Initialize(std::atomic<DexCachePair<T>>* dex_cache); static uint32_t InvalidIndexForSlot(uint32_t slot) { // Since the cache size is a power of two, 0 will always map to slot 0. @@ -87,13 +80,7 @@ template <typename T> struct PACKED(8) DexCachePair { return (slot == 0) ? 1u : 0u; } - T* GetObjectForIndex(uint32_t idx) REQUIRES_SHARED(Locks::mutator_lock_) { - if (idx != index) { - return nullptr; - } - DCHECK(!object.IsNull()); - return object.Read(); - } + T* GetObjectForIndex(uint32_t idx) REQUIRES_SHARED(Locks::mutator_lock_); }; template <typename T> struct PACKED(2 * __SIZEOF_POINTER__) NativeDexCachePair { diff --git a/runtime/mirror/object.cc b/runtime/mirror/object.cc index 025c10bc2a..9b38576fc5 100644 --- a/runtime/mirror/object.cc +++ b/runtime/mirror/object.cc @@ -27,7 +27,7 @@ #include "dex/descriptors_names.h" #include "dex/dex_file-inl.h" #include "gc/accounting/card_table-inl.h" -#include "gc/heap.h" +#include "gc/heap-inl.h" #include "handle_scope-inl.h" #include "iftable-inl.h" #include "monitor.h" diff --git a/runtime/native/dalvik_system_DexFile.cc b/runtime/native/dalvik_system_DexFile.cc index 69f7648dcb..f9f87d83f6 100644 --- a/runtime/native/dalvik_system_DexFile.cc +++ b/runtime/native/dalvik_system_DexFile.cc @@ -35,6 +35,7 @@ #include "dex/descriptors_names.h" #include "dex/dex_file-inl.h" #include "dex/dex_file_loader.h" +#include "handle_scope-inl.h" #include "jit/debugger_interface.h" #include "jni/jni_internal.h" #include "mirror/class_loader.h" diff --git a/runtime/native/java_lang_VMClassLoader.cc b/runtime/native/java_lang_VMClassLoader.cc index 1ad233a6b2..46162c1989 100644 --- a/runtime/native/java_lang_VMClassLoader.cc +++ b/runtime/native/java_lang_VMClassLoader.cc @@ -21,6 +21,7 @@ #include "dex/descriptors_names.h" #include "dex/dex_file_loader.h" #include "dex/utf.h" +#include "handle_scope-inl.h" #include "jni/jni_internal.h" #include "mirror/class_loader.h" #include "mirror/object-inl.h" diff --git a/runtime/non_debuggable_classes.cc b/runtime/non_debuggable_classes.cc index f42a2d6755..8b6c2edc66 100644 --- a/runtime/non_debuggable_classes.cc +++ b/runtime/non_debuggable_classes.cc @@ -16,6 +16,7 @@ #include "non_debuggable_classes.h" +#include "jni/jni_env_ext.h" #include "jni/jni_internal.h" #include "mirror/class-inl.h" #include "nativehelper/scoped_local_ref.h" diff --git a/runtime/oat.h b/runtime/oat.h index 5c5a02dff5..2a6d738178 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -23,7 +23,6 @@ #include "base/macros.h" #include "base/safe_map.h" #include "compiler_filter.h" -#include "dex/dex_file.h" namespace art { diff --git a/runtime/transaction.cc b/runtime/transaction.cc index 1e5b2bbd4c..e4bf447a6f 100644 --- a/runtime/transaction.cc +++ b/runtime/transaction.cc @@ -18,6 +18,7 @@ #include <android-base/logging.h> +#include "base/mutex-inl.h" #include "base/stl_util.h" #include "gc/accounting/card_table-inl.h" #include "gc_root-inl.h" diff --git a/test/626-const-class-linking/clear_dex_cache_types.cc b/test/626-const-class-linking/clear_dex_cache_types.cc index 96ef2665cb..52367c7731 100644 --- a/test/626-const-class-linking/clear_dex_cache_types.cc +++ b/test/626-const-class-linking/clear_dex_cache_types.cc @@ -15,6 +15,7 @@ */ #include "jni.h" +#include "handle_scope-inl.h" #include "mirror/class-inl.h" #include "mirror/class_loader.h" #include "mirror/dex_cache-inl.h" |