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
diff --git a/compiler/utils/swap_space.cc b/compiler/utils/swap_space.cc
index 4f6c915..621a652 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 8d1c982..fba9308 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 @@
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 d1043c6..74f8225 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 @@
}
};
// 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 562fc75..b85d7df 100644
--- a/runtime/gc/allocator/rosalloc.h
+++ b/runtime/gc/allocator/rosalloc.h
@@ -707,6 +707,9 @@
// 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 12793e4..8b94404 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 @@
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 dfdd162..913ab79 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 3d9b3c6..f1e3b50 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 0d0d5c7..df1012e 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 {