diff options
-rw-r--r-- | disassembler/Android.mk | 4 | ||||
-rw-r--r-- | disassembler/disassembler.cc | 14 | ||||
-rw-r--r-- | disassembler/disassembler.h | 8 | ||||
-rw-r--r-- | disassembler/disassembler_arm.cc | 7 | ||||
-rw-r--r-- | disassembler/disassembler_arm64.cc | 6 | ||||
-rw-r--r-- | disassembler/disassembler_mips.cc | 6 | ||||
-rw-r--r-- | disassembler/disassembler_x86.cc | 6 | ||||
-rw-r--r-- | runtime/arch/instruction_set.cc | 22 | ||||
-rw-r--r-- | runtime/arch/instruction_set.h | 32 | ||||
-rw-r--r-- | runtime/arch/instruction_set_features_test.cc | 1 | ||||
-rw-r--r-- | runtime/arch/mips/instruction_set_features_mips.h | 2 | ||||
-rw-r--r-- | runtime/base/bit_utils.h | 5 | ||||
-rw-r--r-- | runtime/base/enums.h | 13 | ||||
-rw-r--r-- | runtime/base/stl_util.h | 4 | ||||
-rw-r--r-- | runtime/code_simulator_container.h | 1 | ||||
-rw-r--r-- | runtime/image.cc | 5 | ||||
-rw-r--r-- | runtime/image.h | 4 | ||||
-rw-r--r-- | runtime/simulator/code_simulator_arm64.cc | 2 | ||||
-rw-r--r-- | runtime/utils.h | 10 | ||||
-rw-r--r-- | runtime/utils/dex_cache_arrays_layout-inl.h | 3 |
20 files changed, 97 insertions, 58 deletions
diff --git a/disassembler/Android.mk b/disassembler/Android.mk index 630f3e4656..6304c57e3e 100644 --- a/disassembler/Android.mk +++ b/disassembler/Android.mk @@ -90,14 +90,14 @@ define build-libart-disassembler endif ifeq ($$(art_static_or_shared),static) - LOCAL_STATIC_LIBRARIES += liblog + LOCAL_STATIC_LIBRARIES += liblog libbase ifeq ($$(art_ndebug_or_debug),debug) LOCAL_STATIC_LIBRARIES += libartd else LOCAL_STATIC_LIBRARIES += libart endif else # shared - LOCAL_SHARED_LIBRARIES += liblog + LOCAL_SHARED_LIBRARIES += liblog libbase ifeq ($$(art_ndebug_or_debug),debug) LOCAL_SHARED_LIBRARIES += libartd else diff --git a/disassembler/disassembler.cc b/disassembler/disassembler.cc index bcd0d1630a..8eecc62cd5 100644 --- a/disassembler/disassembler.cc +++ b/disassembler/disassembler.cc @@ -18,15 +18,23 @@ #include <ostream> -#include "base/logging.h" -#include "base/stringprintf.h" +#include "android-base/logging.h" +#include "android-base/stringprintf.h" + #include "disassembler_arm.h" #include "disassembler_arm64.h" #include "disassembler_mips.h" #include "disassembler_x86.h" +using android::base::StringPrintf; + namespace art { +Disassembler::Disassembler(DisassemblerOptions* disassembler_options) + : disassembler_options_(disassembler_options) { + CHECK(disassembler_options_ != nullptr); +} + Disassembler* Disassembler::Create(InstructionSet instruction_set, DisassemblerOptions* options) { if (instruction_set == kArm || instruction_set == kThumb2) { return new arm::DisassemblerArm(options); @@ -39,7 +47,7 @@ Disassembler* Disassembler::Create(InstructionSet instruction_set, DisassemblerO } else if (instruction_set == kX86_64) { return new x86::DisassemblerX86(options, true); } else { - UNIMPLEMENTED(FATAL) << "no disassembler for " << instruction_set; + UNIMPLEMENTED(FATAL) << static_cast<uint32_t>(instruction_set); return nullptr; } } diff --git a/disassembler/disassembler.h b/disassembler/disassembler.h index 86793ccb19..1ef456cefd 100644 --- a/disassembler/disassembler.h +++ b/disassembler/disassembler.h @@ -21,8 +21,9 @@ #include <iosfwd> +#include "android-base/macros.h" + #include "arch/instruction_set.h" -#include "base/macros.h" namespace art { @@ -81,10 +82,7 @@ class Disassembler { } protected: - explicit Disassembler(DisassemblerOptions* disassembler_options) - : disassembler_options_(disassembler_options) { - CHECK(disassembler_options_ != nullptr); - } + explicit Disassembler(DisassemblerOptions* disassembler_options); std::string FormatInstructionPointer(const uint8_t* begin); diff --git a/disassembler/disassembler_arm.cc b/disassembler/disassembler_arm.cc index a47b6adcc9..c3e288deae 100644 --- a/disassembler/disassembler_arm.cc +++ b/disassembler/disassembler_arm.cc @@ -21,10 +21,13 @@ #include <ostream> #include <sstream> +#include "android-base/logging.h" +#include "android-base/stringprintf.h" + #include "arch/arm/registers_arm.h" #include "base/bit_utils.h" -#include "base/logging.h" -#include "base/stringprintf.h" + +using android::base::StringPrintf; namespace art { namespace arm { diff --git a/disassembler/disassembler_arm64.cc b/disassembler/disassembler_arm64.cc index 80bacb2be3..49b9623f4f 100644 --- a/disassembler/disassembler_arm64.cc +++ b/disassembler/disassembler_arm64.cc @@ -20,8 +20,10 @@ #include <sstream> -#include "base/logging.h" -#include "base/stringprintf.h" +#include "android-base/logging.h" +#include "android-base/stringprintf.h" + +using android::base::StringPrintf; using namespace vixl::aarch64; // NOLINT(build/namespaces) diff --git a/disassembler/disassembler_mips.cc b/disassembler/disassembler_mips.cc index 02c6d71510..9a73f29556 100644 --- a/disassembler/disassembler_mips.cc +++ b/disassembler/disassembler_mips.cc @@ -19,8 +19,10 @@ #include <ostream> #include <sstream> -#include "base/logging.h" -#include "base/stringprintf.h" +#include "android-base/logging.h" +#include "android-base/stringprintf.h" + +using android::base::StringPrintf; namespace art { namespace mips { diff --git a/disassembler/disassembler_x86.cc b/disassembler/disassembler_x86.cc index 2ca84e5e5b..9f49ec6f60 100644 --- a/disassembler/disassembler_x86.cc +++ b/disassembler/disassembler_x86.cc @@ -21,8 +21,10 @@ #include <ostream> #include <sstream> -#include "base/logging.h" -#include "base/stringprintf.h" +#include "android-base/logging.h" +#include "android-base/stringprintf.h" + +using android::base::StringPrintf; namespace art { namespace x86 { diff --git a/runtime/arch/instruction_set.cc b/runtime/arch/instruction_set.cc index b35e0889e4..8f64dcd306 100644 --- a/runtime/arch/instruction_set.cc +++ b/runtime/arch/instruction_set.cc @@ -19,11 +19,31 @@ // Explicitly include our own elf.h to avoid Linux and other dependencies. #include "../elf.h" #include "base/bit_utils.h" +#include "base/logging.h" #include "globals.h" namespace art { -const char* GetInstructionSetString(const InstructionSet isa) { +void InstructionSetAbort(InstructionSet isa) { + switch (isa) { + case kArm: + case kThumb2: + case kArm64: + case kX86: + case kX86_64: + case kMips: + case kMips64: + case kNone: + LOG(FATAL) << "Unsupported instruction set " << isa; + UNREACHABLE(); + + default: + LOG(FATAL) << "Unknown ISA " << isa; + UNREACHABLE(); + } +} + +const char* GetInstructionSetString(InstructionSet isa) { switch (isa) { case kArm: case kThumb2: diff --git a/runtime/arch/instruction_set.h b/runtime/arch/instruction_set.h index 917acc9eec..4a8bea45e5 100644 --- a/runtime/arch/instruction_set.h +++ b/runtime/arch/instruction_set.h @@ -21,7 +21,7 @@ #include <string> #include "base/enums.h" -#include "base/logging.h" // Logging is required for FATAL in the helper functions. +#include "base/macros.h" namespace art { @@ -75,7 +75,6 @@ static constexpr size_t kMipsAlignment = 8; // X86 instruction alignment. This is the recommended alignment for maximum performance. static constexpr size_t kX86Alignment = 16; - const char* GetInstructionSetString(InstructionSet isa); // Note: Returns kNone when the string cannot be parsed to a known value. @@ -83,6 +82,9 @@ InstructionSet GetInstructionSetFromString(const char* instruction_set); InstructionSet GetInstructionSetFromELF(uint16_t e_machine, uint32_t e_flags); +// Fatal logging out of line to keep the header clean of logging.h. +NO_RETURN void InstructionSetAbort(InstructionSet isa); + static inline PointerSize GetInstructionSetPointerSize(InstructionSet isa) { switch (isa) { case kArm: @@ -99,12 +101,8 @@ static inline PointerSize GetInstructionSetPointerSize(InstructionSet isa) { return kMipsPointerSize; case kMips64: return kMips64PointerSize; - case kNone: - LOG(FATAL) << "ISA kNone does not have pointer size."; - UNREACHABLE(); default: - LOG(FATAL) << "Unknown ISA " << isa; - UNREACHABLE(); + InstructionSetAbort(isa); } } @@ -139,12 +137,8 @@ static inline bool Is64BitInstructionSet(InstructionSet isa) { case kMips64: return true; - case kNone: - LOG(FATAL) << "ISA kNone does not have bit width."; - UNREACHABLE(); default: - LOG(FATAL) << "Unknown ISA " << isa; - UNREACHABLE(); + InstructionSetAbort(isa); } } @@ -168,12 +162,9 @@ static inline size_t GetBytesPerGprSpillLocation(InstructionSet isa) { return 4; case kMips64: return 8; - case kNone: - LOG(FATAL) << "ISA kNone does not have spills."; - UNREACHABLE(); + default: - LOG(FATAL) << "Unknown ISA " << isa; - UNREACHABLE(); + InstructionSetAbort(isa); } } @@ -193,12 +184,9 @@ static inline size_t GetBytesPerFprSpillLocation(InstructionSet isa) { return 4; case kMips64: return 8; - case kNone: - LOG(FATAL) << "ISA kNone does not have spills."; - UNREACHABLE(); + default: - LOG(FATAL) << "Unknown ISA " << isa; - UNREACHABLE(); + InstructionSetAbort(isa); } } diff --git a/runtime/arch/instruction_set_features_test.cc b/runtime/arch/instruction_set_features_test.cc index fb38b47ea7..7bbc709f69 100644 --- a/runtime/arch/instruction_set_features_test.cc +++ b/runtime/arch/instruction_set_features_test.cc @@ -22,6 +22,7 @@ #include "cutils/properties.h" #endif +#include "base/logging.h" #include "base/stringprintf.h" namespace art { diff --git a/runtime/arch/mips/instruction_set_features_mips.h b/runtime/arch/mips/instruction_set_features_mips.h index 120dc1c0a5..2d54988683 100644 --- a/runtime/arch/mips/instruction_set_features_mips.h +++ b/runtime/arch/mips/instruction_set_features_mips.h @@ -18,6 +18,8 @@ #define ART_RUNTIME_ARCH_MIPS_INSTRUCTION_SET_FEATURES_MIPS_H_ #include "arch/instruction_set_features.h" +#include "base/logging.h" +#include "base/macros.h" namespace art { diff --git a/runtime/base/bit_utils.h b/runtime/base/bit_utils.h index 378371da84..d2f0fdbd9c 100644 --- a/runtime/base/bit_utils.h +++ b/runtime/base/bit_utils.h @@ -21,7 +21,12 @@ #include <limits> #include <type_traits> +// This header is used in the disassembler with libbase's logging. Only include ART logging +// when no other logging macros are available. b/15436106, b/31338270 +#ifndef CHECK #include "base/logging.h" +#endif + #include "base/iteration_range.h" #include "base/stl_util.h" diff --git a/runtime/base/enums.h b/runtime/base/enums.h index 51b86eae2b..52cab2a9c0 100644 --- a/runtime/base/enums.h +++ b/runtime/base/enums.h @@ -20,9 +20,6 @@ #include <cstddef> #include <ostream> -#include "base/logging.h" -#include "base/macros.h" - namespace art { enum class PointerSize : size_t { @@ -35,16 +32,6 @@ static constexpr PointerSize kRuntimePointerSize = sizeof(void*) == 8U ? PointerSize::k64 : PointerSize::k32; -template <typename T> -static constexpr PointerSize ConvertToPointerSize(T any) { - if (any == 4 || any == 8) { - return static_cast<PointerSize>(any); - } else { - LOG(FATAL); - UNREACHABLE(); - } -} - } // namespace art #endif // ART_RUNTIME_BASE_ENUMS_H_ diff --git a/runtime/base/stl_util.h b/runtime/base/stl_util.h index a53dcea2d7..a4cf249861 100644 --- a/runtime/base/stl_util.h +++ b/runtime/base/stl_util.h @@ -20,7 +20,11 @@ #include <algorithm> #include <sstream> +// This header is used in the disassembler with libbase's logging. Only include ART logging +// when no other logging macros are available. b/15436106, b/31338270 +#ifndef CHECK #include "base/logging.h" +#endif namespace art { diff --git a/runtime/code_simulator_container.h b/runtime/code_simulator_container.h index 655a2472f4..10178bac67 100644 --- a/runtime/code_simulator_container.h +++ b/runtime/code_simulator_container.h @@ -18,6 +18,7 @@ #define ART_RUNTIME_CODE_SIMULATOR_CONTAINER_H_ #include "arch/instruction_set.h" +#include "base/logging.h" #include "simulator/code_simulator.h" namespace art { diff --git a/runtime/image.cc b/runtime/image.cc index 68881831ae..7e6790a551 100644 --- a/runtime/image.cc +++ b/runtime/image.cc @@ -20,6 +20,7 @@ #include "mirror/object_array.h" #include "mirror/object_array-inl.h" #include "mirror/object-inl.h" +#include "utils.h" namespace art { @@ -179,4 +180,8 @@ void ImageHeader::VisitPackedArtMethods(ArtMethodVisitor* visitor, } } +PointerSize ImageHeader::GetPointerSize() const { + return ConvertToPointerSize(pointer_size_); +} + } // namespace art diff --git a/runtime/image.h b/runtime/image.h index 8cd94bb30e..3a4fa79bc4 100644 --- a/runtime/image.h +++ b/runtime/image.h @@ -157,9 +157,7 @@ class PACKED(4) ImageHeader { return reinterpret_cast<uint8_t*>(oat_file_end_); } - PointerSize GetPointerSize() const { - return ConvertToPointerSize(pointer_size_); - } + PointerSize GetPointerSize() const; uint32_t GetPointerSizeUnchecked() const { return pointer_size_; diff --git a/runtime/simulator/code_simulator_arm64.cc b/runtime/simulator/code_simulator_arm64.cc index 897d4f515d..c7ad1fd8aa 100644 --- a/runtime/simulator/code_simulator_arm64.cc +++ b/runtime/simulator/code_simulator_arm64.cc @@ -16,6 +16,8 @@ #include "simulator/code_simulator_arm64.h" +#include "base/logging.h" + using namespace vixl::aarch64; // NOLINT(build/namespaces) namespace art { diff --git a/runtime/utils.h b/runtime/utils.h index 2389ce77fc..958f0a35e1 100644 --- a/runtime/utils.h +++ b/runtime/utils.h @@ -386,6 +386,16 @@ inline void FlushInstructionCache(char* begin, char* end) { __builtin___clear_cache(begin, end); } +template <typename T> +constexpr PointerSize ConvertToPointerSize(T any) { + if (any == 4 || any == 8) { + return static_cast<PointerSize>(any); + } else { + LOG(FATAL); + UNREACHABLE(); + } +} + } // namespace art #endif // ART_RUNTIME_UTILS_H_ diff --git a/runtime/utils/dex_cache_arrays_layout-inl.h b/runtime/utils/dex_cache_arrays_layout-inl.h index 4c63156939..a85d0332c3 100644 --- a/runtime/utils/dex_cache_arrays_layout-inl.h +++ b/runtime/utils/dex_cache_arrays_layout-inl.h @@ -55,7 +55,8 @@ inline constexpr size_t DexCacheArraysLayout::Alignment() { template <typename T> static constexpr PointerSize GcRootAsPointerSize() { - return ConvertToPointerSize(sizeof(GcRoot<T>)); + static_assert(sizeof(GcRoot<T>) == 4U, "Unexpected GcRoot size"); + return PointerSize::k32; } inline size_t DexCacheArraysLayout::TypeOffset(uint32_t type_idx) const { |