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();