Implement << operator for DexRegisterLocation::Kind.
This makes it comparable in DCHECK_EQ and similar methods.
Change-Id: I6b5b237be89325850ae6860d011fd6741189ab01
diff --git a/compiler/debug/elf_debug_loc_writer.h b/compiler/debug/elf_debug_loc_writer.h
index 8fd20aa..32f624a 100644
--- a/compiler/debug/elf_debug_loc_writer.h
+++ b/compiler/debug/elf_debug_loc_writer.h
@@ -232,8 +232,7 @@
// kInStackLargeOffset and kConstantLargeValue are hidden by GetKind().
// kInRegisterHigh and kInFpuRegisterHigh should be handled by
// the special cases above and they should not occur alone.
- LOG(ERROR) << "Unexpected register location kind: "
- << DexRegisterLocation::PrettyDescriptor(kind);
+ LOG(ERROR) << "Unexpected register location kind: " << kind;
break;
}
if (is64bitValue) {
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index 4784de1..b44f508 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -63,8 +63,7 @@
void StackMapStream::AddDexRegisterEntry(DexRegisterLocation::Kind kind, int32_t value) {
if (kind != DexRegisterLocation::Kind::kNone) {
// Ensure we only use non-compressed location kind at this stage.
- DCHECK(DexRegisterLocation::IsShortLocationKind(kind))
- << DexRegisterLocation::PrettyDescriptor(kind);
+ DCHECK(DexRegisterLocation::IsShortLocationKind(kind)) << kind;
DexRegisterLocation location(kind, value);
// Look for Dex register `location` in the location catalog (using the
diff --git a/runtime/check_reference_map_visitor.h b/runtime/check_reference_map_visitor.h
index b9ea475..fcf3326 100644
--- a/runtime/check_reference_map_visitor.h
+++ b/runtime/check_reference_map_visitor.h
@@ -100,8 +100,7 @@
CHECK_EQ(location.GetValue(), 0);
break;
default:
- LOG(FATAL) << "Unexpected location kind"
- << DexRegisterLocation::PrettyDescriptor(location.GetInternalKind());
+ LOG(FATAL) << "Unexpected location kind " << location.GetInternalKind();
}
}
}
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 8d3da37..c6ec5b0 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -378,8 +378,7 @@
continue;
}
- DCHECK(location == DexRegisterLocation::Kind::kInStack)
- << DexRegisterLocation::PrettyDescriptor(location);
+ DCHECK_EQ(location, DexRegisterLocation::Kind::kInStack);
int32_t vreg_value = shadow_frame->GetVReg(vreg);
int32_t slot_offset = vreg_map.GetStackOffsetInBytes(vreg,
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc
index dd384c7..fe6a529 100644
--- a/runtime/quick_exception_handler.cc
+++ b/runtime/quick_exception_handler.cc
@@ -204,8 +204,7 @@
return VRegKind::kDoubleHiVReg;
default:
- LOG(FATAL) << "Unexpected vreg location "
- << DexRegisterLocation::PrettyDescriptor(kind);
+ LOG(FATAL) << "Unexpected vreg location " << kind;
UNREACHABLE();
}
}
@@ -450,12 +449,11 @@
}
default: {
LOG(FATAL)
- << "Unexpected location kind"
- << DexRegisterLocation::PrettyDescriptor(
- vreg_map.GetLocationInternalKind(vreg,
- number_of_vregs,
- code_info,
- encoding));
+ << "Unexpected location kind "
+ << vreg_map.GetLocationInternalKind(vreg,
+ number_of_vregs,
+ code_info,
+ encoding);
UNREACHABLE();
}
}
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 5faff93..b1f1ed6 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -352,12 +352,11 @@
return false;
default:
LOG(FATAL)
- << "Unexpected location kind"
- << DexRegisterLocation::PrettyDescriptor(
- dex_register_map.GetLocationInternalKind(vreg,
- number_of_dex_registers,
- code_info,
- encoding));
+ << "Unexpected location kind "
+ << dex_register_map.GetLocationInternalKind(vreg,
+ number_of_dex_registers,
+ code_info,
+ encoding);
UNREACHABLE();
}
}
diff --git a/runtime/stack_map.cc b/runtime/stack_map.cc
index 5544507..3093436 100644
--- a/runtime/stack_map.cc
+++ b/runtime/stack_map.cc
@@ -27,6 +27,31 @@
constexpr uint32_t StackMap::kNoDexRegisterMap;
constexpr uint32_t StackMap::kNoInlineInfo;
+std::ostream& operator<<(std::ostream& stream, const DexRegisterLocation::Kind& kind) {
+ using Kind = DexRegisterLocation::Kind;
+ switch (kind) {
+ case Kind::kNone:
+ return stream << "none";
+ case Kind::kInStack:
+ return stream << "in stack";
+ case Kind::kInRegister:
+ return stream << "in register";
+ case Kind::kInRegisterHigh:
+ return stream << "in register high";
+ case Kind::kInFpuRegister:
+ return stream << "in fpu register";
+ case Kind::kInFpuRegisterHigh:
+ return stream << "in fpu register high";
+ case Kind::kConstant:
+ return stream << "as constant";
+ case Kind::kInStackLargeOffset:
+ return stream << "in stack (large offset)";
+ case Kind::kConstantLargeValue:
+ return stream << "as constant (large value)";
+ }
+ return stream << "Kind<" << static_cast<uint32_t>(kind) << ">";
+}
+
DexRegisterLocation::Kind DexRegisterMap::GetLocationInternalKind(
uint16_t dex_register_number,
uint16_t number_of_dex_registers,
@@ -97,7 +122,7 @@
const std::string& prefix = "v",
const std::string& suffix = "") {
os << prefix << dex_register_num << ": "
- << DexRegisterLocation::PrettyDescriptor(location.GetInternalKind())
+ << location.GetInternalKind()
<< " (" << location.GetValue() << ")" << suffix << '\n';
}
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 97eb805..dbf23aa 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -110,30 +110,6 @@
sizeof(Kind) == 1u,
"art::DexRegisterLocation::Kind has a size different from one byte.");
- static const char* PrettyDescriptor(Kind kind) {
- switch (kind) {
- case Kind::kNone:
- return "none";
- case Kind::kInStack:
- return "in stack";
- case Kind::kInRegister:
- return "in register";
- case Kind::kInRegisterHigh:
- return "in register high";
- case Kind::kInFpuRegister:
- return "in fpu register";
- case Kind::kInFpuRegisterHigh:
- return "in fpu register high";
- case Kind::kConstant:
- return "as constant";
- case Kind::kInStackLargeOffset:
- return "in stack (large offset)";
- case Kind::kConstantLargeValue:
- return "as constant (large value)";
- }
- UNREACHABLE();
- }
-
static bool IsShortLocationKind(Kind kind) {
switch (kind) {
case Kind::kInStack:
@@ -149,7 +125,7 @@
return false;
case Kind::kNone:
- LOG(FATAL) << "Unexpected location kind " << PrettyDescriptor(kind);
+ LOG(FATAL) << "Unexpected location kind";
}
UNREACHABLE();
}
@@ -215,6 +191,8 @@
friend class DexRegisterLocationHashFn;
};
+std::ostream& operator<<(std::ostream& stream, const DexRegisterLocation::Kind& kind);
+
/**
* Store information on unique Dex register locations used in a method.
* The information is of the form:
@@ -349,7 +327,7 @@
case DexRegisterLocation::Kind::kConstantLargeValue:
case DexRegisterLocation::Kind::kInStackLargeOffset:
case DexRegisterLocation::Kind::kNone:
- LOG(FATAL) << "Unexpected location kind " << DexRegisterLocation::PrettyDescriptor(kind);
+ LOG(FATAL) << "Unexpected location kind " << kind;
}
UNREACHABLE();
}
@@ -373,7 +351,7 @@
case DexRegisterLocation::Kind::kConstantLargeValue:
case DexRegisterLocation::Kind::kInStackLargeOffset:
case DexRegisterLocation::Kind::kNone:
- LOG(FATAL) << "Unexpected location kind " << DexRegisterLocation::PrettyDescriptor(kind);
+ LOG(FATAL) << "Unexpected location kind " << kind;
}
UNREACHABLE();
}
@@ -515,8 +493,7 @@
const StackMapEncoding& enc) const {
DexRegisterLocation location =
GetDexRegisterLocation(dex_register_number, number_of_dex_registers, code_info, enc);
- DCHECK(location.GetKind() == DexRegisterLocation::Kind::kConstant)
- << DexRegisterLocation::PrettyDescriptor(location.GetKind());
+ DCHECK_EQ(location.GetKind(), DexRegisterLocation::Kind::kConstant);
return location.GetValue();
}
@@ -530,7 +507,7 @@
location.GetInternalKind() == DexRegisterLocation::Kind::kInRegisterHigh ||
location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegister ||
location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegisterHigh)
- << DexRegisterLocation::PrettyDescriptor(location.GetInternalKind());
+ << location.GetInternalKind();
return location.GetValue();
}