diff options
author | Vladimir Marko <vmarko@google.com> | 2015-04-13 12:22:36 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2015-04-13 16:30:13 +0100 |
commit | 3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b (patch) | |
tree | 77551c0a6d060e5a3723ad35d2ab101038f9328a | |
parent | 095d209342420563becfec6676b46a6c6b839107 (diff) | |
download | art-3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b.tar.gz art-3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b.tar.bz2 art-3481ba2c4e4f3aa80d8c6d50a9f85dacb56b508b.zip |
ART: Clean up includes.
Reduce dependencies to improve incremental build times.
Break up circular dependency involving class_linker-inl.h.
Change-Id: I4be742c5c2b5cd9855beea86630fd68aab76b0db
34 files changed, 91 insertions, 31 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 6d7924890e..ef47377bcc 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -30,7 +30,7 @@ #include "art_field-inl.h" #include "base/stl_util.h" #include "base/timing_logger.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "compiled_class.h" #include "compiled_method.h" #include "compiler.h" diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc index 7200cdaa9f..e78ff9078b 100644 --- a/compiler/driver/compiler_driver_test.cc +++ b/compiler/driver/compiler_driver_test.cc @@ -20,7 +20,7 @@ #include <stdio.h> #include <memory> -#include "class_linker.h" +#include "class_linker-inl.h" #include "common_compiler_test.h" #include "dex_file.h" #include "gc/heap.h" diff --git a/compiler/image_test.cc b/compiler/image_test.cc index 627a42e8de..cfd525cc5c 100644 --- a/compiler/image_test.cc +++ b/compiler/image_test.cc @@ -21,7 +21,7 @@ #include <vector> #include "base/unix_file/fd_file.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "common_compiler_test.h" #include "elf_writer.h" #include "gc/space/image_space.h" diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index 6f8884a9ab..2420254046 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -25,7 +25,7 @@ #include "art_field-inl.h" #include "base/logging.h" #include "base/unix_file/fd_file.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "compiled_method.h" #include "dex_file-inl.h" #include "driver/compiler_driver.h" diff --git a/compiler/oat_writer.cc b/compiler/oat_writer.cc index 5b4cc54858..804e4c145a 100644 --- a/compiler/oat_writer.cc +++ b/compiler/oat_writer.cc @@ -36,6 +36,7 @@ #include "mirror/art_method-inl.h" #include "mirror/array.h" #include "mirror/class_loader.h" +#include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" #include "os.h" #include "output_stream.h" diff --git a/compiler/utils/arena_bit_vector.cc b/compiler/utils/arena_bit_vector.cc index ddc0c818c2..fbbfd84fcf 100644 --- a/compiler/utils/arena_bit_vector.cc +++ b/compiler/utils/arena_bit_vector.cc @@ -16,6 +16,7 @@ #include "arena_bit_vector.h" +#include "base/allocator.h" #include "base/arena_allocator.h" namespace art { diff --git a/runtime/arch/stub_test.cc b/runtime/arch/stub_test.cc index d7de119449..9cccf7c761 100644 --- a/runtime/arch/stub_test.cc +++ b/runtime/arch/stub_test.cc @@ -17,6 +17,7 @@ #include <cstdio> #include "art_field-inl.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "entrypoints/quick/quick_entrypoints_enum.h" #include "mirror/art_method-inl.h" diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h index aeb127358c..a2625e2d42 100644 --- a/runtime/art_field-inl.h +++ b/runtime/art_field-inl.h @@ -21,6 +21,7 @@ #include "base/logging.h" #include "class_linker.h" +#include "gc_root-inl.h" #include "gc/accounting/card_table-inl.h" #include "jvalue.h" #include "mirror/dex_cache.h" @@ -289,15 +290,14 @@ inline mirror::Class* ArtField::GetType() { const uint32_t field_index = GetDexFieldIndex(); auto* declaring_class = GetDeclaringClass(); if (UNLIKELY(declaring_class->IsProxyClass())) { - return Runtime::Current()->GetClassLinker()->FindSystemClass(Thread::Current(), - GetTypeDescriptor()); + return ProxyFindSystemClass(GetTypeDescriptor()); } auto* dex_cache = declaring_class->GetDexCache(); const DexFile* const dex_file = dex_cache->GetDexFile(); const DexFile::FieldId& field_id = dex_file->GetFieldId(field_index); mirror::Class* type = dex_cache->GetResolvedType(field_id.type_idx_); if (kResolve && UNLIKELY(type == nullptr)) { - type = Runtime::Current()->GetClassLinker()->ResolveType(field_id.type_idx_, this); + type = ResolveGetType(field_id.type_idx_); CHECK(type != nullptr || Thread::Current()->IsExceptionPending()); } return type; @@ -323,9 +323,7 @@ inline mirror::String* ArtField::GetStringName(Thread* self, bool resolve) { const auto& field_id = dex_file->GetFieldId(dex_field_index); auto* name = dex_cache->GetResolvedString(field_id.name_idx_); if (resolve && name == nullptr) { - StackHandleScope<1> hs(self); - name = Runtime::Current()->GetClassLinker()->ResolveString( - *dex_file, field_id.name_idx_, hs.NewHandle(dex_cache)); + name = ResolveGetStringName(self, *dex_file, field_id.name_idx_, dex_cache); } return name; } diff --git a/runtime/art_field.cc b/runtime/art_field.cc index cdf8967384..2aed440f5e 100644 --- a/runtime/art_field.cc +++ b/runtime/art_field.cc @@ -17,7 +17,9 @@ #include "art_field.h" #include "art_field-inl.h" +#include "class_linker-inl.h" #include "gc/accounting/card_table-inl.h" +#include "handle_scope.h" #include "mirror/object-inl.h" #include "mirror/object_array-inl.h" #include "runtime.h" @@ -61,4 +63,20 @@ ArtField* ArtField::FindInstanceFieldWithOffset(mirror::Class* klass, uint32_t f FindInstanceFieldWithOffset(klass->GetSuperClass(), field_offset) : nullptr; } +mirror::Class* ArtField::ProxyFindSystemClass(const char* descriptor) { + DCHECK(GetDeclaringClass()->IsProxyClass()); + return Runtime::Current()->GetClassLinker()->FindSystemClass(Thread::Current(), descriptor); +} + +mirror::Class* ArtField::ResolveGetType(uint32_t type_idx) { + return Runtime::Current()->GetClassLinker()->ResolveType(type_idx, this); +} + +mirror::String* ArtField::ResolveGetStringName(Thread* self, const DexFile& dex_file, + uint32_t string_idx, mirror::DexCache* dex_cache) { + StackHandleScope<1> hs(self); + return Runtime::Current()->GetClassLinker()->ResolveString( + dex_file, string_idx, hs.NewHandle(dex_cache)); +} + } // namespace art diff --git a/runtime/art_field.h b/runtime/art_field.h index 5bdbe71255..16c46f0b9f 100644 --- a/runtime/art_field.h +++ b/runtime/art_field.h @@ -188,6 +188,13 @@ class ArtField { } private: + mirror::Class* ProxyFindSystemClass(const char* descriptor) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::Class* ResolveGetType(uint32_t type_idx) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + mirror::String* ResolveGetStringName(Thread* self, const DexFile& dex_file, uint32_t string_idx, + mirror::DexCache* dex_cache) + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + GcRoot<mirror::Class> declaring_class_; uint32_t access_flags_; diff --git a/runtime/base/arena_allocator.cc b/runtime/base/arena_allocator.cc index 59d38ad593..b53fa84f5c 100644 --- a/runtime/base/arena_allocator.cc +++ b/runtime/base/arena_allocator.cc @@ -20,6 +20,7 @@ #include "arena_allocator.h" #include "logging.h" +#include "mem_map.h" #include "mutex.h" #include "thread-inl.h" #include <memcheck/memcheck.h> @@ -141,6 +142,10 @@ MemMapArena::MemMapArena(size_t size, bool low_4gb) { size_ = map_->Size(); } +MemMapArena::~MemMapArena() { + // Destroys MemMap via std::unique_ptr<>. +} + void MemMapArena::Release() { if (bytes_allocated_ > 0) { map_->MadviseDontNeedAndZero(); diff --git a/runtime/base/arena_allocator.h b/runtime/base/arena_allocator.h index 3a86b61e1a..ab5968cfb5 100644 --- a/runtime/base/arena_allocator.h +++ b/runtime/base/arena_allocator.h @@ -22,7 +22,6 @@ #include "debug_stack.h" #include "macros.h" -#include "mem_map.h" #include "mutex.h" #include "utils.h" @@ -33,6 +32,7 @@ class ArenaPool; class ArenaAllocator; class ArenaStack; class ScopedArenaAllocator; +class MemMap; class MemStats; template <typename T> @@ -166,7 +166,7 @@ class MallocArena FINAL : public Arena { class MemMapArena FINAL : public Arena { public: explicit MemMapArena(size_t size, bool low_4gb); - virtual ~MemMapArena() { } + virtual ~MemMapArena(); void Release() OVERRIDE; private: diff --git a/runtime/gc/accounting/bitmap.cc b/runtime/gc/accounting/bitmap.cc index 20984fda96..13fcdb305e 100644 --- a/runtime/gc/accounting/bitmap.cc +++ b/runtime/gc/accounting/bitmap.cc @@ -35,6 +35,10 @@ Bitmap::Bitmap(MemMap* mem_map, size_t bitmap_size) CHECK_NE(bitmap_size, 0U); } +Bitmap::~Bitmap() { + // Destroys MemMap via std::unique_ptr<>. +} + MemMap* Bitmap::AllocateMemMap(const std::string& name, size_t num_bits) { const size_t bitmap_size = RoundUp( RoundUp(num_bits, kBitsPerBitmapWord) / kBitsPerBitmapWord * sizeof(uintptr_t), kPageSize); diff --git a/runtime/gc/accounting/bitmap.h b/runtime/gc/accounting/bitmap.h index cf2c2938c4..b294d49324 100644 --- a/runtime/gc/accounting/bitmap.h +++ b/runtime/gc/accounting/bitmap.h @@ -103,6 +103,7 @@ class Bitmap { static constexpr size_t kBitsPerBitmapWord = sizeof(uintptr_t) * kBitsPerByte; Bitmap(MemMap* mem_map, size_t bitmap_size); + ~Bitmap(); // Allocate the mem-map for a bitmap based on how many bits are required. static MemMap* AllocateMemMap(const std::string& name, size_t num_bits); diff --git a/runtime/gc/accounting/card_table-inl.h b/runtime/gc/accounting/card_table-inl.h index 83ad33e145..b936d93b43 100644 --- a/runtime/gc/accounting/card_table-inl.h +++ b/runtime/gc/accounting/card_table-inl.h @@ -20,6 +20,7 @@ #include "atomic.h" #include "base/logging.h" #include "card_table.h" +#include "mem_map.h" #include "space_bitmap.h" #include "utils.h" @@ -223,6 +224,12 @@ inline uint8_t* CardTable::CardFromAddr(const void *addr) const { return card_addr; } +inline bool CardTable::IsValidCard(const uint8_t* card_addr) const { + uint8_t* begin = mem_map_->Begin() + offset_; + uint8_t* end = mem_map_->End(); + return card_addr >= begin && card_addr < end; +} + inline void CardTable::CheckCardValid(uint8_t* card) const { DCHECK(IsValidCard(card)) << " card_addr: " << reinterpret_cast<const void*>(card) diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc index ad1f192dd6..7879632877 100644 --- a/runtime/gc/accounting/card_table.cc +++ b/runtime/gc/accounting/card_table.cc @@ -21,6 +21,7 @@ #include "gc/heap.h" #include "gc/space/space.h" #include "heap_bitmap.h" +#include "mem_map.h" #include "runtime.h" #include "utils.h" @@ -90,6 +91,10 @@ CardTable::CardTable(MemMap* mem_map, uint8_t* biased_begin, size_t offset) : mem_map_(mem_map), biased_begin_(biased_begin), offset_(offset) { } +CardTable::~CardTable() { + // Destroys MemMap via std::unique_ptr<>. +} + void CardTable::ClearSpaceCards(space::ContinuousSpace* space) { // TODO: clear just the range of the table that has been modified uint8_t* card_start = CardFromAddr(space->Begin()); diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h index 3ea765142f..896cce5edc 100644 --- a/runtime/gc/accounting/card_table.h +++ b/runtime/gc/accounting/card_table.h @@ -21,10 +21,11 @@ #include "base/mutex.h" #include "globals.h" -#include "mem_map.h" namespace art { +class MemMap; + namespace mirror { class Object; } // namespace mirror @@ -52,6 +53,7 @@ class CardTable { static constexpr uint8_t kCardDirty = 0x70; static CardTable* Create(const uint8_t* heap_begin, size_t heap_capacity); + ~CardTable(); // Set the card associated with the given address to GC_CARD_DIRTY. ALWAYS_INLINE void MarkCard(const void *addr) { @@ -130,11 +132,7 @@ class CardTable { CardTable(MemMap* begin, uint8_t* biased_begin, size_t offset); // Returns true iff the card table address is within the bounds of the card table. - bool IsValidCard(const uint8_t* card_addr) const { - uint8_t* begin = mem_map_->Begin() + offset_; - uint8_t* end = mem_map_->End(); - return card_addr >= begin && card_addr < end; - } + bool IsValidCard(const uint8_t* card_addr) const ALWAYS_INLINE; void CheckCardValid(uint8_t* card) const ALWAYS_INLINE; diff --git a/runtime/gc/accounting/mod_union_table_test.cc b/runtime/gc/accounting/mod_union_table_test.cc index 94bb3f52cc..043b5580c3 100644 --- a/runtime/gc/accounting/mod_union_table_test.cc +++ b/runtime/gc/accounting/mod_union_table_test.cc @@ -16,6 +16,7 @@ #include "mod_union_table-inl.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "gc/space/space-inl.h" #include "mirror/array-inl.h" diff --git a/runtime/gc/allocator/rosalloc.cc b/runtime/gc/allocator/rosalloc.cc index f64a4ff8df..515f124fcc 100644 --- a/runtime/gc/allocator/rosalloc.cc +++ b/runtime/gc/allocator/rosalloc.cc @@ -18,6 +18,7 @@ #include "base/mutex-inl.h" #include "gc/space/valgrind_settings.h" +#include "mem_map.h" #include "mirror/class-inl.h" #include "mirror/object.h" #include "mirror/object-inl.h" diff --git a/runtime/gc/allocator/rosalloc.h b/runtime/gc/allocator/rosalloc.h index d1e7ad91a0..a54edccff9 100644 --- a/runtime/gc/allocator/rosalloc.h +++ b/runtime/gc/allocator/rosalloc.h @@ -30,11 +30,13 @@ #include "base/mutex.h" #include "base/logging.h" #include "globals.h" -#include "mem_map.h" #include "thread.h" #include "utils.h" namespace art { + +class MemMap; + namespace gc { namespace allocator { diff --git a/runtime/gc/heap_test.cc b/runtime/gc/heap_test.cc index 14d78d8710..a3cefd9b7f 100644 --- a/runtime/gc/heap_test.cc +++ b/runtime/gc/heap_test.cc @@ -14,6 +14,7 @@ * limitations under the License. */ +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "gc/accounting/card_table-inl.h" #include "gc/accounting/space_bitmap-inl.h" diff --git a/runtime/indirect_reference_table_test.cc b/runtime/indirect_reference_table_test.cc index 1156cf5996..fe1b8f00dc 100644 --- a/runtime/indirect_reference_table_test.cc +++ b/runtime/indirect_reference_table_test.cc @@ -16,6 +16,7 @@ #include "indirect_reference_table-inl.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "mirror/object-inl.h" #include "scoped_thread_state_change.h" diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h index 5b72e5a033..f4656ec78b 100644 --- a/runtime/mirror/class-inl.h +++ b/runtime/mirror/class-inl.h @@ -21,7 +21,6 @@ #include "art_field-inl.h" #include "art_method-inl.h" -#include "class_linker-inl.h" #include "class_loader.h" #include "common_throws.h" #include "dex_cache.h" @@ -39,12 +38,8 @@ namespace mirror { template<VerifyObjectFlags kVerifyFlags, ReadBarrierOption kReadBarrierOption> inline uint32_t Class::GetObjectSize() { - if (kIsDebugBuild) { - // Use a local variable as (D)CHECK can't handle the space between - // the two template params. - bool is_variable_size = IsVariableSize<kVerifyFlags, kReadBarrierOption>(); - CHECK(!is_variable_size) << " class=" << PrettyTypeOf(this); - } + // Note: Extra parentheses to avoid the comma being interpreted as macro parameter separator. + DCHECK((!IsVariableSize<kVerifyFlags, kReadBarrierOption>())) << " class=" << PrettyTypeOf(this); return GetField32(ObjectSizeOffset()); } @@ -706,7 +701,7 @@ inline bool Class::DescriptorEquals(const char* match) { } else if (IsPrimitive()) { return strcmp(Primitive::Descriptor(GetPrimitiveType()), match) == 0; } else if (IsProxyClass()) { - return Runtime::Current()->GetClassLinker()->GetDescriptorForProxy(this) == match; + return ProxyDescriptorEquals(match); } else { const DexFile& dex_file = GetDexFile(); const DexFile::TypeId& type_id = dex_file.GetTypeId(GetClassDef()->class_idx_); diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc index 8fb8147a8a..2afb4af0e3 100644 --- a/runtime/mirror/class.cc +++ b/runtime/mirror/class.cc @@ -18,7 +18,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "class_loader.h" #include "class-inl.h" #include "dex_cache.h" @@ -871,5 +871,10 @@ Class* Class::CopyOf(Thread* self, int32_t new_length, return new_class->AsClass(); } +bool Class::ProxyDescriptorEquals(const char* match) { + DCHECK(IsProxyClass()); + return Runtime::Current()->GetClassLinker()->GetDescriptorForProxy(this) == match; +} + } // namespace mirror } // namespace art diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h index 92493bc567..20f23877e6 100644 --- a/runtime/mirror/class.h +++ b/runtime/mirror/class.h @@ -1095,6 +1095,8 @@ class MANAGED Class FINAL : public Object { ArtField* GetSFieldsUnchecked() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); ArtField* GetIFieldsUnchecked() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + bool ProxyDescriptorEquals(const char* match) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + // defining class loader, or NULL for the "bootstrap" system loader HeapReference<ClassLoader> class_loader_; diff --git a/runtime/mirror/field-inl.h b/runtime/mirror/field-inl.h index 7db181112a..9820db77b1 100644 --- a/runtime/mirror/field-inl.h +++ b/runtime/mirror/field-inl.h @@ -20,6 +20,7 @@ #include "field.h" #include "art_field-inl.h" +#include "mirror/dex_cache-inl.h" #include "runtime-inl.h" namespace art { diff --git a/runtime/monitor_test.cc b/runtime/monitor_test.cc index 6d1e721bb6..2351463391 100644 --- a/runtime/monitor_test.cc +++ b/runtime/monitor_test.cc @@ -20,6 +20,7 @@ #include <string> #include "atomic.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "handle_scope-inl.h" #include "mirror/class-inl.h" diff --git a/runtime/native/java_lang_DexCache.cc b/runtime/native/java_lang_DexCache.cc index 89442703b6..1198c2e9ba 100644 --- a/runtime/native/java_lang_DexCache.cc +++ b/runtime/native/java_lang_DexCache.cc @@ -18,7 +18,7 @@ #include "dex_file.h" #include "jni_internal.h" -#include "mirror/dex_cache.h" +#include "mirror/dex_cache-inl.h" #include "mirror/object-inl.h" #include "scoped_fast_native_object_access.h" #include "well_known_classes.h" diff --git a/runtime/oat_file_assistant_test.cc b/runtime/oat_file_assistant_test.cc index 37c635377c..0c942d22ed 100644 --- a/runtime/oat_file_assistant_test.cc +++ b/runtime/oat_file_assistant_test.cc @@ -26,7 +26,7 @@ #include <gtest/gtest.h> #include "art_field-inl.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "compiler_callbacks.h" #include "mem_map.h" diff --git a/runtime/proxy_test.cc b/runtime/proxy_test.cc index a3156b4d09..6061f73c19 100644 --- a/runtime/proxy_test.cc +++ b/runtime/proxy_test.cc @@ -18,6 +18,7 @@ #include <vector> #include "art_field-inl.h" +#include "class_linker-inl.h" #include "common_compiler_test.h" #include "scoped_thread_state_change.h" diff --git a/runtime/quick/inline_method_analyser.cc b/runtime/quick/inline_method_analyser.cc index efaa0ac570..9cf4b16582 100644 --- a/runtime/quick/inline_method_analyser.cc +++ b/runtime/quick/inline_method_analyser.cc @@ -17,6 +17,7 @@ #include "inline_method_analyser.h" #include "art_field-inl.h" +#include "class_linker-inl.h" #include "dex_file-inl.h" #include "dex_instruction.h" #include "dex_instruction-inl.h" diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 66d38ce770..543b9dc6e1 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -54,7 +54,7 @@ #include "base/arena_allocator.h" #include "base/dumpable.h" #include "base/unix_file/fd_file.h" -#include "class_linker.h" +#include "class_linker-inl.h" #include "compiler_callbacks.h" #include "debugger.h" #include "elf_file.h" diff --git a/runtime/transaction_test.cc b/runtime/transaction_test.cc index 9792eca757..aee2c543ac 100644 --- a/runtime/transaction_test.cc +++ b/runtime/transaction_test.cc @@ -17,6 +17,7 @@ #include "transaction.h" #include "art_field-inl.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "mirror/array-inl.h" #include "mirror/art_method-inl.h" diff --git a/runtime/utils_test.cc b/runtime/utils_test.cc index 623a3eccfe..aa7bc64c19 100644 --- a/runtime/utils_test.cc +++ b/runtime/utils_test.cc @@ -16,6 +16,7 @@ #include "utils.h" +#include "class_linker-inl.h" #include "common_runtime_test.h" #include "mirror/array.h" #include "mirror/array-inl.h" |