Skip to content

Commit

Permalink
ART: Detach libart-disassembler from libart
Browse files Browse the repository at this point in the history
Some more intrusive changes than I would have liked, as long as
ART logging is different from libbase logging.

Fix up some includes.

Bug: 15436106
Bug: 31338270
Test: m test-art-host
Change-Id: I9fbe4b85b2d74e079a4981f3aec9af63b163a461
  • Loading branch information
agampe committed Sep 8, 2016
1 parent d14d515 commit bda1d60
Show file tree
Hide file tree
Showing 20 changed files with 97 additions and 58 deletions.
4 changes: 2 additions & 2 deletions disassembler/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 11 additions & 3 deletions disassembler/disassembler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}
}
Expand Down
8 changes: 3 additions & 5 deletions disassembler/disassembler.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@

#include <iosfwd>

#include "android-base/macros.h"

#include "arch/instruction_set.h"
#include "base/macros.h"

namespace art {

Expand Down Expand Up @@ -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);

Expand Down
7 changes: 5 additions & 2 deletions disassembler/disassembler_arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions disassembler/disassembler_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 4 additions & 2 deletions disassembler/disassembler_mips.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions disassembler/disassembler_x86.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 21 additions & 1 deletion runtime/arch/instruction_set.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
32 changes: 10 additions & 22 deletions runtime/arch/instruction_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -75,14 +75,16 @@ 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.
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:
Expand All @@ -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);
}
}

Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
1 change: 1 addition & 0 deletions runtime/arch/instruction_set_features_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "cutils/properties.h"
#endif

#include "base/logging.h"
#include "base/stringprintf.h"

namespace art {
Expand Down
2 changes: 2 additions & 0 deletions runtime/arch/mips/instruction_set_features_mips.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
5 changes: 5 additions & 0 deletions runtime/base/bit_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
13 changes: 0 additions & 13 deletions runtime/base/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
#include <cstddef>
#include <ostream>

#include "base/logging.h"
#include "base/macros.h"

namespace art {

enum class PointerSize : size_t {
Expand All @@ -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_
4 changes: 4 additions & 0 deletions runtime/base/stl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
1 change: 1 addition & 0 deletions runtime/code_simulator_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions runtime/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -179,4 +180,8 @@ void ImageHeader::VisitPackedArtMethods(ArtMethodVisitor* visitor,
}
}

PointerSize ImageHeader::GetPointerSize() const {
return ConvertToPointerSize(pointer_size_);
}

} // namespace art
4 changes: 1 addition & 3 deletions runtime/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down
2 changes: 2 additions & 0 deletions runtime/simulator/code_simulator_arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include "simulator/code_simulator_arm64.h"

#include "base/logging.h"

using namespace vixl::aarch64; // NOLINT(build/namespaces)

namespace art {
Expand Down
10 changes: 10 additions & 0 deletions runtime/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
3 changes: 2 additions & 1 deletion runtime/utils/dex_cache_arrays_layout-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bda1d60

Please sign in to comment.