Skip to content

Commit bda1d60

Browse files
committed
ART: Detach libart-disassembler from libart
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
1 parent d14d515 commit bda1d60

20 files changed

+97
-58
lines changed

disassembler/Android.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ define build-libart-disassembler
9090
endif
9191

9292
ifeq ($$(art_static_or_shared),static)
93-
LOCAL_STATIC_LIBRARIES += liblog
93+
LOCAL_STATIC_LIBRARIES += liblog libbase
9494
ifeq ($$(art_ndebug_or_debug),debug)
9595
LOCAL_STATIC_LIBRARIES += libartd
9696
else
9797
LOCAL_STATIC_LIBRARIES += libart
9898
endif
9999
else # shared
100-
LOCAL_SHARED_LIBRARIES += liblog
100+
LOCAL_SHARED_LIBRARIES += liblog libbase
101101
ifeq ($$(art_ndebug_or_debug),debug)
102102
LOCAL_SHARED_LIBRARIES += libartd
103103
else

disassembler/disassembler.cc

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,23 @@
1818

1919
#include <ostream>
2020

21-
#include "base/logging.h"
22-
#include "base/stringprintf.h"
21+
#include "android-base/logging.h"
22+
#include "android-base/stringprintf.h"
23+
2324
#include "disassembler_arm.h"
2425
#include "disassembler_arm64.h"
2526
#include "disassembler_mips.h"
2627
#include "disassembler_x86.h"
2728

29+
using android::base::StringPrintf;
30+
2831
namespace art {
2932

33+
Disassembler::Disassembler(DisassemblerOptions* disassembler_options)
34+
: disassembler_options_(disassembler_options) {
35+
CHECK(disassembler_options_ != nullptr);
36+
}
37+
3038
Disassembler* Disassembler::Create(InstructionSet instruction_set, DisassemblerOptions* options) {
3139
if (instruction_set == kArm || instruction_set == kThumb2) {
3240
return new arm::DisassemblerArm(options);
@@ -39,7 +47,7 @@ Disassembler* Disassembler::Create(InstructionSet instruction_set, DisassemblerO
3947
} else if (instruction_set == kX86_64) {
4048
return new x86::DisassemblerX86(options, true);
4149
} else {
42-
UNIMPLEMENTED(FATAL) << "no disassembler for " << instruction_set;
50+
UNIMPLEMENTED(FATAL) << static_cast<uint32_t>(instruction_set);
4351
return nullptr;
4452
}
4553
}

disassembler/disassembler.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121

2222
#include <iosfwd>
2323

24+
#include "android-base/macros.h"
25+
2426
#include "arch/instruction_set.h"
25-
#include "base/macros.h"
2627

2728
namespace art {
2829

@@ -81,10 +82,7 @@ class Disassembler {
8182
}
8283

8384
protected:
84-
explicit Disassembler(DisassemblerOptions* disassembler_options)
85-
: disassembler_options_(disassembler_options) {
86-
CHECK(disassembler_options_ != nullptr);
87-
}
85+
explicit Disassembler(DisassemblerOptions* disassembler_options);
8886

8987
std::string FormatInstructionPointer(const uint8_t* begin);
9088

disassembler/disassembler_arm.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,13 @@
2121
#include <ostream>
2222
#include <sstream>
2323

24+
#include "android-base/logging.h"
25+
#include "android-base/stringprintf.h"
26+
2427
#include "arch/arm/registers_arm.h"
2528
#include "base/bit_utils.h"
26-
#include "base/logging.h"
27-
#include "base/stringprintf.h"
29+
30+
using android::base::StringPrintf;
2831

2932
namespace art {
3033
namespace arm {

disassembler/disassembler_arm64.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020

2121
#include <sstream>
2222

23-
#include "base/logging.h"
24-
#include "base/stringprintf.h"
23+
#include "android-base/logging.h"
24+
#include "android-base/stringprintf.h"
25+
26+
using android::base::StringPrintf;
2527

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

disassembler/disassembler_mips.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
#include <ostream>
2020
#include <sstream>
2121

22-
#include "base/logging.h"
23-
#include "base/stringprintf.h"
22+
#include "android-base/logging.h"
23+
#include "android-base/stringprintf.h"
24+
25+
using android::base::StringPrintf;
2426

2527
namespace art {
2628
namespace mips {

disassembler/disassembler_x86.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@
2121
#include <ostream>
2222
#include <sstream>
2323

24-
#include "base/logging.h"
25-
#include "base/stringprintf.h"
24+
#include "android-base/logging.h"
25+
#include "android-base/stringprintf.h"
26+
27+
using android::base::StringPrintf;
2628

2729
namespace art {
2830
namespace x86 {

runtime/arch/instruction_set.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,31 @@
1919
// Explicitly include our own elf.h to avoid Linux and other dependencies.
2020
#include "../elf.h"
2121
#include "base/bit_utils.h"
22+
#include "base/logging.h"
2223
#include "globals.h"
2324

2425
namespace art {
2526

26-
const char* GetInstructionSetString(const InstructionSet isa) {
27+
void InstructionSetAbort(InstructionSet isa) {
28+
switch (isa) {
29+
case kArm:
30+
case kThumb2:
31+
case kArm64:
32+
case kX86:
33+
case kX86_64:
34+
case kMips:
35+
case kMips64:
36+
case kNone:
37+
LOG(FATAL) << "Unsupported instruction set " << isa;
38+
UNREACHABLE();
39+
40+
default:
41+
LOG(FATAL) << "Unknown ISA " << isa;
42+
UNREACHABLE();
43+
}
44+
}
45+
46+
const char* GetInstructionSetString(InstructionSet isa) {
2747
switch (isa) {
2848
case kArm:
2949
case kThumb2:

runtime/arch/instruction_set.h

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <string>
2222

2323
#include "base/enums.h"
24-
#include "base/logging.h" // Logging is required for FATAL in the helper functions.
24+
#include "base/macros.h"
2525

2626
namespace art {
2727

@@ -75,14 +75,16 @@ static constexpr size_t kMipsAlignment = 8;
7575
// X86 instruction alignment. This is the recommended alignment for maximum performance.
7676
static constexpr size_t kX86Alignment = 16;
7777

78-
7978
const char* GetInstructionSetString(InstructionSet isa);
8079

8180
// Note: Returns kNone when the string cannot be parsed to a known value.
8281
InstructionSet GetInstructionSetFromString(const char* instruction_set);
8382

8483
InstructionSet GetInstructionSetFromELF(uint16_t e_machine, uint32_t e_flags);
8584

85+
// Fatal logging out of line to keep the header clean of logging.h.
86+
NO_RETURN void InstructionSetAbort(InstructionSet isa);
87+
8688
static inline PointerSize GetInstructionSetPointerSize(InstructionSet isa) {
8789
switch (isa) {
8890
case kArm:
@@ -99,12 +101,8 @@ static inline PointerSize GetInstructionSetPointerSize(InstructionSet isa) {
99101
return kMipsPointerSize;
100102
case kMips64:
101103
return kMips64PointerSize;
102-
case kNone:
103-
LOG(FATAL) << "ISA kNone does not have pointer size.";
104-
UNREACHABLE();
105104
default:
106-
LOG(FATAL) << "Unknown ISA " << isa;
107-
UNREACHABLE();
105+
InstructionSetAbort(isa);
108106
}
109107
}
110108

@@ -139,12 +137,8 @@ static inline bool Is64BitInstructionSet(InstructionSet isa) {
139137
case kMips64:
140138
return true;
141139

142-
case kNone:
143-
LOG(FATAL) << "ISA kNone does not have bit width.";
144-
UNREACHABLE();
145140
default:
146-
LOG(FATAL) << "Unknown ISA " << isa;
147-
UNREACHABLE();
141+
InstructionSetAbort(isa);
148142
}
149143
}
150144

@@ -168,12 +162,9 @@ static inline size_t GetBytesPerGprSpillLocation(InstructionSet isa) {
168162
return 4;
169163
case kMips64:
170164
return 8;
171-
case kNone:
172-
LOG(FATAL) << "ISA kNone does not have spills.";
173-
UNREACHABLE();
165+
174166
default:
175-
LOG(FATAL) << "Unknown ISA " << isa;
176-
UNREACHABLE();
167+
InstructionSetAbort(isa);
177168
}
178169
}
179170

@@ -193,12 +184,9 @@ static inline size_t GetBytesPerFprSpillLocation(InstructionSet isa) {
193184
return 4;
194185
case kMips64:
195186
return 8;
196-
case kNone:
197-
LOG(FATAL) << "ISA kNone does not have spills.";
198-
UNREACHABLE();
187+
199188
default:
200-
LOG(FATAL) << "Unknown ISA " << isa;
201-
UNREACHABLE();
189+
InstructionSetAbort(isa);
202190
}
203191
}
204192

runtime/arch/instruction_set_features_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "cutils/properties.h"
2323
#endif
2424

25+
#include "base/logging.h"
2526
#include "base/stringprintf.h"
2627

2728
namespace art {

0 commit comments

Comments
 (0)