Fix sort order to make register promotion stable
Also some minor oatdump fixes
Change-Id: I5679835bf684b98d130b77ecf00bda5f6547d383
diff --git a/compiler/dex/quick/ralloc_util.cc b/compiler/dex/quick/ralloc_util.cc
index d59c986..a0b98dd 100644
--- a/compiler/dex/quick/ralloc_util.cc
+++ b/compiler/dex/quick/ralloc_util.cc
@@ -931,7 +931,12 @@
static int SortCounts(const void *val1, const void *val2) {
const Mir2Lir::RefCounts* op1 = reinterpret_cast<const Mir2Lir::RefCounts*>(val1);
const Mir2Lir::RefCounts* op2 = reinterpret_cast<const Mir2Lir::RefCounts*>(val2);
- return (op1->count == op2->count) ? 0 : (op1->count < op2->count ? 1 : -1);
+ // Note that we fall back to sorting on reg so we get stable output
+ // on differing qsort implementations (such as on host and target or
+ // between local host and build servers).
+ return (op1->count == op2->count)
+ ? (op1->s_reg - op2->s_reg)
+ : (op1->count < op2->count ? 1 : -1);
}
void Mir2Lir::DumpCounts(const RefCounts* arr, int size, const char* msg) {
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 8bc7877..0227381 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -506,7 +506,7 @@
typedef MappingTable::PcToDexIterator It;
for (It cur = table.PcToDexBegin(), end = table.PcToDexEnd(); cur != end; ++cur) {
if (offset == cur.NativePcOffset()) {
- os << "suspend point dex PC: 0x" << cur.DexPc() << "\n";
+ os << StringPrintf("suspend point dex PC: 0x%04x\n", cur.DexPc());
return cur.DexPc();
}
}
@@ -514,7 +514,7 @@
typedef MappingTable::DexToPcIterator It;
for (It cur = table.DexToPcBegin(), end = table.DexToPcEnd(); cur != end; ++cur) {
if (offset == cur.NativePcOffset()) {
- os << "catch entry dex PC: 0x" << cur.DexPc() << "\n";
+ os << StringPrintf("catch entry dex PC: 0x%04x\n", cur.DexPc());
return cur.DexPc();
}
}
@@ -917,10 +917,10 @@
os << StringPrintf("%p: java.lang.Class \"%s\" (", obj, PrettyDescriptor(klass).c_str())
<< klass->GetStatus() << ")\n";
} else if (obj->IsArtField()) {
- os << StringPrintf("%p: java.lang.reflect.Field %s\n", obj,
+ os << StringPrintf("%p: java.lang.reflect.ArtField %s\n", obj,
PrettyField(obj->AsArtField()).c_str());
} else if (obj->IsArtMethod()) {
- os << StringPrintf("%p: java.lang.reflect.Method %s\n", obj,
+ os << StringPrintf("%p: java.lang.reflect.ArtMethod %s\n", obj,
PrettyMethod(obj->AsArtMethod()).c_str());
} else if (obj_class->IsStringClass()) {
os << StringPrintf("%p: java.lang.String %s\n", obj,