Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1412)

Unified Diff: vm/il_printer.cc

Issue 10539108: First step to SSA construction: Phi insertion. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: vm/il_printer.cc
===================================================================
--- vm/il_printer.cc (revision 8546)
+++ vm/il_printer.cc (working copy)
@@ -330,9 +330,26 @@
void JoinEntryInstr::PrintTo(BufferFormatter* f) const {
f->Print("%2d: [join]", block_id());
+ if (phis_ != NULL) {
+ for (intptr_t i = 0; i < phis_->length(); ++i) {
+ if ((*phis_)[i] == NULL) continue;
+ f->Print("\n");
+ (*phis_)[i]->PrintTo(f);
+ }
+ }
}
+void PhiInstr::PrintTo(BufferFormatter* f) const {
+ f->Print(" phi(");
+ for (intptr_t i = 0; i < inputs_.length(); ++i) {
+ if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
+ if (i < inputs_.length() - 1) f->Print(",");
+ }
+ f->Print(")");
+}
+
+
void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
f->Print("%2d: [target", block_id());
if (HasTryIndex()) {
@@ -466,9 +483,21 @@
BEGIN("states"); // Required section.
{
BEGIN("locals"); // Required section.
- // TODO(fschneider): Insert phi-instructions here.
- intptr_t num_phis = 0;
+ JoinEntryInstr* join = entry->AsJoinEntry();
+ intptr_t num_phis = (join != NULL && join->phi_count())
+ ? join->phis()->length()
+ : 0;
Print("%s %d\n", "size", num_phis);
+ for (intptr_t j = 0; j < num_phis; ++j) {
+ PhiInstr* phi = (*join->phis())[j];
+ if (phi != NULL) {
+ Print("%d ", j); // Print variable index.
+ char buffer[120];
+ BufferFormatter formatter(buffer, sizeof(buffer));
+ phi->PrintToVisualizer(&formatter);
+ Print("%s\n", buffer);
+ }
+ }
END("locals");
}
END("states");
@@ -516,6 +545,16 @@
}
+void PhiInstr::PrintToVisualizer(BufferFormatter* f) const {
+ // TODO(fschneider): Print operands when SSA renaming is implemented.
+ f->Print("v [");
+ for (intptr_t i = 0; i < InputCount(); ++i) {
+ f->Print(" v ");
+ }
+ f->Print("]");
+}
+
+
void TargetEntryInstr::PrintToVisualizer(BufferFormatter* f) const {
f->Print("_ [target");
if (HasTryIndex()) {

Powered by Google App Engine
This is Rietveld 408576698