ART: Revert change to LiveRange::Dump
Changes back the LiveRange printing format to "[start,end)" for better
clarity. However, it removes the space after comma due to b/1189305
and prints the "ranges" attribute with curly brackets to improve
readability.
This is a resubmission of CL Ic83025fa78d6f1edb5e0e39d66160182b0198ab8
which fixes a compilation issue on target.
Bug: 21189305
Change-Id: Ic232c02ba19a710ead67793a039f99c0345353c7
diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc
index 7ea1240..640d743 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -42,13 +42,18 @@
class StringList {
public:
+ enum Format {
+ kArrayBrackets,
+ kSetBrackets,
+ };
+
// Create an empty list
- StringList() : is_empty_(true) {}
+ StringList(Format format = kArrayBrackets) : format_(format), is_empty_(true) {}
// Construct StringList from a linked list. List element class T
// must provide methods `GetNext` and `Dump`.
template<class T>
- explicit StringList(T* first_entry) : StringList() {
+ explicit StringList(T* first_entry, Format format = kArrayBrackets) : StringList(format) {
for (T* current = first_entry; current != nullptr; current = current->GetNext()) {
current->Dump(NewEntryStream());
}
@@ -64,6 +69,7 @@
}
private:
+ Format format_;
bool is_empty_;
std::ostringstream sstream_;
@@ -71,7 +77,13 @@
};
std::ostream& operator<<(std::ostream& os, const StringList& list) {
- return os << "[" << list.sstream_.str() << "]";
+ switch (list.format_) {
+ case StringList::kArrayBrackets: return os << "[" << list.sstream_.str() << "]";
+ case StringList::kSetBrackets: return os << "{" << list.sstream_.str() << "}";
+ default:
+ LOG(FATAL) << "Invalid StringList format";
+ UNREACHABLE();
+ }
}
/**
@@ -291,7 +303,8 @@
StartAttributeStream("liveness") << instruction->GetLifetimePosition();
if (instruction->HasLiveInterval()) {
LiveInterval* interval = instruction->GetLiveInterval();
- StartAttributeStream("ranges") << StringList(interval->GetFirstRange());
+ StartAttributeStream("ranges")
+ << StringList(interval->GetFirstRange(), StringList::kSetBrackets);
StartAttributeStream("uses") << StringList(interval->GetFirstUse());
StartAttributeStream("env_uses") << StringList(interval->GetFirstEnvironmentUse());
StartAttributeStream("is_fixed") << interval->IsFixed();
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index ce4bbd4..4b19c5b 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -76,7 +76,7 @@
}
void Dump(std::ostream& stream) const {
- stream << start_ << "-" << end_;
+ stream << "[" << start_ << "," << end_ << ")";
}
LiveRange* Dup(ArenaAllocator* allocator) const {
diff --git a/test/482-checker-loop-back-edge-use/src/Main.java b/test/482-checker-loop-back-edge-use/src/Main.java
index 9e1076a..0ed9267 100644
--- a/test/482-checker-loop-back-edge-use/src/Main.java
+++ b/test/482-checker-loop-back-edge-use/src/Main.java
@@ -18,14 +18,14 @@
public class Main {
// CHECK-START: void Main.loop1(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-22] uses:[17,22]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[17,22]
// CHECK: Goto liveness:20
public static void loop1(boolean incoming) {
while (incoming) {}
}
// CHECK-START: void Main.loop2(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-42] uses:[33,38,42]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,42)} uses:[33,38,42]
// CHECK: Goto liveness:36
// CHECK: Goto liveness:40
public static void loop2(boolean incoming) {
@@ -36,7 +36,7 @@
}
// CHECK-START: void Main.loop3(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-60] uses:[56,60]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,60)} uses:[56,60]
// CHECK: Goto liveness:58
// CHECK-START: void Main.loop3(boolean) liveness (after)
@@ -50,7 +50,7 @@
}
// CHECK-START: void Main.loop4(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-22] uses:[22]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,22)} uses:[22]
// CHECK-START: void Main.loop4(boolean) liveness (after)
// CHECK-NOT: Goto liveness:20
@@ -63,7 +63,7 @@
}
// CHECK-START: void Main.loop5(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-50] uses:[33,42,46,50]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[33,42,46,50]
// CHECK: Goto liveness:44
// CHECK: Goto liveness:48
public static void loop5(boolean incoming) {
@@ -76,7 +76,7 @@
}
// CHECK-START: void Main.loop6(boolean) liveness (after)
- // CHECK ParameterValue liveness:2 ranges:[2-46] uses:[24,46]
+ // CHECK ParameterValue liveness:2 ranges:{[2,46)} uses:[24,46]
// CHECK: Goto liveness:44
// CHECK-START: void Main.loop6(boolean) liveness (after)
@@ -90,7 +90,7 @@
}
// CHECK-START: void Main.loop7(boolean) liveness (after)
- // CHECK: ParameterValue liveness:2 ranges:[2-50] uses:[32,41,46,50]
+ // CHECK: ParameterValue liveness:2 ranges:{[2,50)} uses:[32,41,46,50]
// CHECK: Goto liveness:44
// CHECK: Goto liveness:48
public static void loop7(boolean incoming) {
@@ -102,7 +102,7 @@
}
// CHECK-START: void Main.loop8() liveness (after)
- // CHECK: StaticFieldGet liveness:12 ranges:[12-44] uses:[35,40,44]
+ // CHECK: StaticFieldGet liveness:12 ranges:{[12,44)} uses:[35,40,44]
// CHECK: Goto liveness:38
// CHECK: Goto liveness:42
public static void loop8() {
@@ -114,7 +114,7 @@
}
// CHECK-START: void Main.loop9() liveness (after)
- // CHECK: StaticFieldGet liveness:22 ranges:[22-36] uses:[31,36]
+ // CHECK: StaticFieldGet liveness:22 ranges:{[22,36)} uses:[31,36]
// CHECK: Goto liveness:38
public static void loop9() {
while (Runtime.getRuntime() != null) {