diff options
author | 2017-06-06 20:02:03 -0700 | |
---|---|---|
committer | 2017-06-08 13:13:20 -0700 | |
commit | 3b7dc35f4e5c4d86c73b6784b7ee0df701c68ec2 (patch) | |
tree | 1e3a56846ec63148142ac6fb1fef214129f4a05e | |
parent | 8228cdf4ad6322ec8133564aaa51f966d36c0f17 (diff) |
ART: Clean up allocator.h
Move the single-use typedefs to their users. Remove now-unused
includes. Fix up transitive includes.
Test: m
Change-Id: I953d774b28f1e4f3191f96943e3a69ce66aa398a
-rw-r--r-- | compiler/utils/swap_space.cc | 1 | ||||
-rw-r--r-- | runtime/base/allocator.h | 28 | ||||
-rw-r--r-- | runtime/dex_file_verifier.h | 11 | ||||
-rw-r--r-- | runtime/gc/allocator/rosalloc.h | 3 | ||||
-rw-r--r-- | runtime/mem_map.cc | 6 | ||||
-rw-r--r-- | runtime/mirror/class.h | 1 | ||||
-rw-r--r-- | runtime/obj_ptr-inl.h | 1 | ||||
-rw-r--r-- | runtime/zip_archive.cc | 1 |
8 files changed, 24 insertions, 28 deletions
diff --git a/compiler/utils/swap_space.cc b/compiler/utils/swap_space.cc index 4f6c915142..621a652f0a 100644 --- a/compiler/utils/swap_space.cc +++ b/compiler/utils/swap_space.cc @@ -20,6 +20,7 @@ #include <numeric> #include <sys/mman.h> +#include "base/bit_utils.h" #include "base/logging.h" #include "base/macros.h" #include "base/mutex.h" diff --git a/runtime/base/allocator.h b/runtime/base/allocator.h index 8d1c982f3d..fba9308e8e 100644 --- a/runtime/base/allocator.h +++ b/runtime/base/allocator.h @@ -17,12 +17,7 @@ #ifndef ART_RUNTIME_BASE_ALLOCATOR_H_ #define ART_RUNTIME_BASE_ALLOCATOR_H_ -#include <map> -#include <set> -#include <unordered_map> - #include "atomic.h" -#include "base/hash_map.h" #include "base/macros.h" #include "base/mutex.h" #include "base/type_static_if.h" @@ -156,29 +151,6 @@ using TrackingAllocator = typename TypeStaticIf<kEnableTrackingAllocator, TrackingAllocatorImpl<T, kTag>, std::allocator<T>>::type; -template<class Key, class T, AllocatorTag kTag, class Compare = std::less<Key>> -using AllocationTrackingMultiMap = std::multimap< - Key, T, Compare, TrackingAllocator<std::pair<const Key, T>, kTag>>; - -template<class Key, AllocatorTag kTag, class Compare = std::less<Key>> -using AllocationTrackingSet = std::set<Key, Compare, TrackingAllocator<Key, kTag>>; - -template<class Key, - class T, - AllocatorTag kTag, - class Hash = std::hash<Key>, - class Pred = std::equal_to<Key>> -using AllocationTrackingUnorderedMap = std::unordered_map< - Key, T, Hash, Pred, TrackingAllocator<std::pair<const Key, T>, kTag>>; - -template<class Key, - class T, - class EmptyFn, - AllocatorTag kTag, - class Hash = std::hash<Key>, - class Pred = std::equal_to<Key>> -using AllocationTrackingHashMap = HashMap< - Key, T, EmptyFn, Hash, Pred, TrackingAllocator<std::pair<Key, T>, kTag>>; } // namespace art #endif // ART_RUNTIME_BASE_ALLOCATOR_H_ diff --git a/runtime/dex_file_verifier.h b/runtime/dex_file_verifier.h index d1043c6841..74f82254b3 100644 --- a/runtime/dex_file_verifier.h +++ b/runtime/dex_file_verifier.h @@ -19,6 +19,8 @@ #include <unordered_set> +#include "base/allocator.h" +#include "base/hash_map.h" #include "dex_file.h" #include "dex_file_types.h" #include "safe_map.h" @@ -226,6 +228,15 @@ class DexFileVerifier { } }; // Map from offset to dex file type, HashMap for performance reasons. + template<class Key, + class T, + class EmptyFn, + AllocatorTag kTag, + class Hash = std::hash<Key>, + class Pred = std::equal_to<Key>> + using AllocationTrackingHashMap = HashMap< + Key, T, EmptyFn, Hash, Pred, TrackingAllocator<std::pair<Key, T>, kTag>>; + AllocationTrackingHashMap<uint32_t, uint16_t, OffsetTypeMapEmptyFn, diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h index 562fc750ed..b85d7dff5c 100644 --- a/runtime/gc/allocator/rosalloc.h +++ b/runtime/gc/allocator/rosalloc.h @@ -707,6 +707,9 @@ class RosAlloc { // the end of the memory region that's ever managed by this allocator. size_t max_capacity_; + template<class Key, AllocatorTag kTag, class Compare = std::less<Key>> + using AllocationTrackingSet = std::set<Key, Compare, TrackingAllocator<Key, kTag>>; + // The run sets that hold the runs whose slots are not all // full. non_full_runs_[i] is guarded by size_bracket_locks_[i]. AllocationTrackingSet<Run*, kAllocatorTagRosAlloc> non_full_runs_[kNumOfSizeBrackets]; diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc index 12793e433e..8b94404dfa 100644 --- a/runtime/mem_map.cc +++ b/runtime/mem_map.cc @@ -23,6 +23,7 @@ #include <sys/resource.h> #endif +#include <map> #include <memory> #include <sstream> @@ -32,6 +33,7 @@ #include "cutils/ashmem.h" #include "base/allocator.h" +#include "base/bit_utils.h" #include "base/memory_tool.h" #include "globals.h" #include "utils.h" @@ -46,6 +48,10 @@ namespace art { using android::base::StringPrintf; using android::base::unique_fd; +template<class Key, class T, AllocatorTag kTag, class Compare = std::less<Key>> +using AllocationTrackingMultiMap = + std::multimap<Key, T, Compare, TrackingAllocator<std::pair<const Key, T>, kTag>>; + using Maps = AllocationTrackingMultiMap<void*, MemMap*, kAllocatorTagMaps>; // All the non-empty MemMaps. Use a multimap as we do a reserve-and-divide (eg ElfMap::Load()). diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index dfdd16240b..913ab796a1 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -17,6 +17,7 @@ #ifndef ART_RUNTIME_MIRROR_CLASS_H_ #define ART_RUNTIME_MIRROR_CLASS_H_ +#include "base/bit_utils.h" #include "base/enums.h" #include "base/iteration_range.h" #include "dex_file.h" diff --git a/runtime/obj_ptr-inl.h b/runtime/obj_ptr-inl.h index 3d9b3c6cf7..f1e3b5053b 100644 --- a/runtime/obj_ptr-inl.h +++ b/runtime/obj_ptr-inl.h @@ -17,6 +17,7 @@ #ifndef ART_RUNTIME_OBJ_PTR_INL_H_ #define ART_RUNTIME_OBJ_PTR_INL_H_ +#include "base/bit_utils.h" #include "obj_ptr.h" #include "thread-current-inl.h" diff --git a/runtime/zip_archive.cc b/runtime/zip_archive.cc index 0d0d5c73ae..df1012ea3c 100644 --- a/runtime/zip_archive.cc +++ b/runtime/zip_archive.cc @@ -25,6 +25,7 @@ #include <vector> #include "android-base/stringprintf.h" +#include "base/bit_utils.h" #include "base/unix_file/fd_file.h" namespace art { |