mirror of
https://github.com/dart-lang/sdk
synced 2024-09-20 08:26:53 +00:00
Repair flow graph printing after graph refactoring.
Recent refactoring broke flow graph printing (including code comments). Clean it up. BUG= Review URL: https://chromiumcodereview.appspot.com//10915141 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@12014 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
4e8426a5b4
commit
1d4790280a
|
@ -494,7 +494,9 @@ void FlowGraph::Rename(GrowableArray<PhiInstr*>* live_phis) {
|
|||
}
|
||||
|
||||
// Name global constants.
|
||||
graph_entry_->constant_null()->set_ssa_temp_index(alloc_ssa_temp_index());
|
||||
ConstantInstr* constant_null = new ConstantInstr(Object::ZoneHandle());
|
||||
constant_null->set_ssa_temp_index(alloc_ssa_temp_index());
|
||||
graph_entry_->set_constant_null(constant_null);
|
||||
|
||||
// Initialize start environment.
|
||||
GrowableArray<Definition*> start_env(variable_count());
|
||||
|
|
|
@ -77,6 +77,7 @@ void FlowGraphPrinter::PrintOneInstruction(Instruction* instr,
|
|||
if (instr->lifetime_position() != -1) {
|
||||
OS::Print("%3"Pd": ", instr->lifetime_position());
|
||||
}
|
||||
if (!instr->IsBlockEntry()) OS::Print(" ");
|
||||
OS::Print("%s", str);
|
||||
}
|
||||
|
||||
|
@ -128,15 +129,40 @@ static void PrintICData(BufferFormatter* f, const ICData& ic_data) {
|
|||
}
|
||||
|
||||
|
||||
void Definition::PrintTo(BufferFormatter* f) const {
|
||||
// Do not access 'deopt_id()' as it asserts that the computation can
|
||||
// deoptimize.
|
||||
if (HasSSATemp()) {
|
||||
f->Print("v%"Pd" <- ", ssa_temp_index());
|
||||
static void PrintPropagatedType(BufferFormatter* f, const Definition& def) {
|
||||
if (def.HasPropagatedType()) {
|
||||
String& name = String::Handle();
|
||||
name = AbstractType::Handle(def.PropagatedType()).Name();
|
||||
f->Print(" {PT: %s}", name.ToCString());
|
||||
}
|
||||
f->Print("%s:%"Pd"(", DebugName(), deopt_id_);
|
||||
if (def.has_propagated_cid()) {
|
||||
const Class& cls = Class::Handle(
|
||||
Isolate::Current()->class_table()->At(def.propagated_cid()));
|
||||
f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PrintUse(BufferFormatter* f, const Definition& definition) {
|
||||
if (definition.is_used()) {
|
||||
if (definition.HasSSATemp()) {
|
||||
f->Print("v%"Pd, definition.ssa_temp_index());
|
||||
} else if (definition.temp_index() != -1) {
|
||||
f->Print("t%"Pd, definition.temp_index());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Definition::PrintTo(BufferFormatter* f) const {
|
||||
PrintUse(f, *this);
|
||||
if (is_used()) {
|
||||
if (HasSSATemp() || (temp_index() != -1)) f->Print(" <- ");
|
||||
}
|
||||
f->Print("%s:%"Pd"(", DebugName(), GetDeoptId());
|
||||
PrintOperandsTo(f);
|
||||
f->Print(")");
|
||||
PrintPropagatedType(f, *this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -154,11 +180,7 @@ void Definition::PrintToVisualizer(BufferFormatter* f) const {
|
|||
|
||||
|
||||
void Value::PrintTo(BufferFormatter* f) const {
|
||||
if (definition()->HasSSATemp()) {
|
||||
f->Print("v%"Pd"", definition()->ssa_temp_index());
|
||||
} else {
|
||||
f->Print("t%"Pd"", definition()->temp_index());
|
||||
}
|
||||
PrintUse(f, *definition());
|
||||
}
|
||||
|
||||
|
||||
|
@ -216,10 +238,8 @@ void InstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
|
|||
}
|
||||
|
||||
|
||||
void PolymorphicInstanceCallInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print("%s(", DebugName());
|
||||
void PolymorphicInstanceCallInstr::PrintOperandsTo(BufferFormatter* f) const {
|
||||
instance_call()->PrintOperandsTo(f);
|
||||
f->Print(") ");
|
||||
PrintICData(f, ic_data());
|
||||
}
|
||||
|
||||
|
@ -433,54 +453,47 @@ void CheckClassInstr::PrintOperandsTo(BufferFormatter* f) const {
|
|||
|
||||
|
||||
void GraphEntryInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print("%2"Pd": [graph]", block_id());
|
||||
if (start_env_ != NULL) {
|
||||
f->Print("\n{\n");
|
||||
const GrowableArray<Value*>& values = start_env_->values();
|
||||
for (intptr_t i = 0; i < values.length(); i++) {
|
||||
Definition* def = values[i]->definition();
|
||||
f->Print(" ");
|
||||
def->PrintTo(f);
|
||||
f->Print("\n");
|
||||
f->Print("B%"Pd"[graph]", block_id());
|
||||
if ((constant_null() != NULL) || (start_env() != NULL)) {
|
||||
f->Print(" {");
|
||||
if (constant_null() != NULL) {
|
||||
f->Print("\n ");
|
||||
constant_null()->PrintTo(f);
|
||||
}
|
||||
f->Print("} ");
|
||||
start_env_->PrintTo(f);
|
||||
if (start_env() != NULL) {
|
||||
for (intptr_t i = 0; i < start_env()->values().length(); ++i) {
|
||||
Definition* def = start_env()->values()[i]->definition();
|
||||
if (def->IsParameter()) {
|
||||
f->Print("\n ");
|
||||
def->PrintTo(f);
|
||||
}
|
||||
}
|
||||
}
|
||||
f->Print("\n}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void JoinEntryInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print("%2"Pd": [join]", block_id());
|
||||
f->Print("B%"Pd"[join]", block_id());
|
||||
if (phis_ != NULL) {
|
||||
f->Print(" {");
|
||||
for (intptr_t i = 0; i < phis_->length(); ++i) {
|
||||
if ((*phis_)[i] == NULL) continue;
|
||||
f->Print("\n");
|
||||
f->Print("\n ");
|
||||
(*phis_)[i]->PrintTo(f);
|
||||
}
|
||||
f->Print("\n}");
|
||||
}
|
||||
if (HasParallelMove()) {
|
||||
f->Print("\n");
|
||||
f->Print(" ");
|
||||
parallel_move()->PrintTo(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void PrintPropagatedType(BufferFormatter* f, const Definition& def) {
|
||||
if (def.HasPropagatedType()) {
|
||||
String& name = String::Handle();
|
||||
name = AbstractType::Handle(def.PropagatedType()).Name();
|
||||
f->Print(" {PT: %s}", name.ToCString());
|
||||
}
|
||||
if (def.has_propagated_cid()) {
|
||||
const Class& cls = Class::Handle(
|
||||
Isolate::Current()->class_table()->At(def.propagated_cid()));
|
||||
f->Print(" {PCid: %s}", String::Handle(cls.Name()).ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PhiInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" v%"Pd" <- phi(", ssa_temp_index());
|
||||
f->Print("v%"Pd" <- phi(", ssa_temp_index());
|
||||
for (intptr_t i = 0; i < inputs_.length(); ++i) {
|
||||
if (inputs_[i] != NULL) inputs_[i]->PrintTo(f);
|
||||
if (i < inputs_.length() - 1) f->Print(", ");
|
||||
|
@ -490,62 +503,57 @@ void PhiInstr::PrintTo(BufferFormatter* f) const {
|
|||
}
|
||||
|
||||
|
||||
void ParameterInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" v%"Pd" <- parameter(%"Pd")",
|
||||
HasSSATemp() ? ssa_temp_index() : temp_index(),
|
||||
index());
|
||||
PrintPropagatedType(f, *this);
|
||||
void ParameterInstr::PrintOperandsTo(BufferFormatter* f) const {
|
||||
f->Print("%"Pd, index());
|
||||
}
|
||||
|
||||
|
||||
void TargetEntryInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print("%2"Pd": [target", block_id());
|
||||
f->Print("B%"Pd"[target", block_id());
|
||||
if (IsCatchEntry()) {
|
||||
f->Print(" catch %"Pd"]", catch_try_index());
|
||||
} else {
|
||||
f->Print("]");
|
||||
}
|
||||
if (HasParallelMove()) {
|
||||
f->Print("\n");
|
||||
f->Print(" ");
|
||||
parallel_move()->PrintTo(f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PushArgumentInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s ", DebugName());
|
||||
void PushArgumentInstr::PrintOperandsTo(BufferFormatter* f) const {
|
||||
value()->PrintTo(f);
|
||||
}
|
||||
|
||||
|
||||
void ReturnInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s ", DebugName());
|
||||
f->Print("%s ", DebugName());
|
||||
value()->PrintTo(f);
|
||||
}
|
||||
|
||||
|
||||
void ThrowInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s" , DebugName());
|
||||
f->Print("%s" , DebugName());
|
||||
}
|
||||
|
||||
|
||||
void ReThrowInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s ", DebugName());
|
||||
f->Print("%s ", DebugName());
|
||||
}
|
||||
|
||||
|
||||
void GotoInstr::PrintTo(BufferFormatter* f) const {
|
||||
if (HasParallelMove()) {
|
||||
parallel_move()->PrintTo(f);
|
||||
} else {
|
||||
f->Print(" ");
|
||||
f->Print(" ");
|
||||
}
|
||||
f->Print(" goto:%"Pd" %"Pd"", GetDeoptId(), successor()->block_id());
|
||||
f->Print("goto:%"Pd" %"Pd"", GetDeoptId(), successor()->block_id());
|
||||
}
|
||||
|
||||
|
||||
void BranchInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s ", DebugName());
|
||||
f->Print("%s ", DebugName());
|
||||
f->Print("if ");
|
||||
comparison()->PrintTo(f);
|
||||
|
||||
|
@ -556,7 +564,7 @@ void BranchInstr::PrintTo(BufferFormatter* f) const {
|
|||
|
||||
|
||||
void ParallelMoveInstr::PrintTo(BufferFormatter* f) const {
|
||||
f->Print(" %s ", DebugName());
|
||||
f->Print("%s ", DebugName());
|
||||
for (intptr_t i = 0; i < moves_.length(); i++) {
|
||||
if (i != 0) f->Print(", ");
|
||||
moves_[i]->dest().PrintTo(f);
|
||||
|
|
|
@ -105,7 +105,7 @@ GraphEntryInstr::GraphEntryInstr(TargetEntryInstr* normal_entry)
|
|||
normal_entry_(normal_entry),
|
||||
catch_entries_(),
|
||||
start_env_(NULL),
|
||||
constant_null_(new ConstantInstr(Object::ZoneHandle())),
|
||||
constant_null_(NULL),
|
||||
spill_slot_count_(0) {
|
||||
}
|
||||
|
||||
|
|
|
@ -777,6 +777,7 @@ class GraphEntryInstr : public BlockEntryInstr {
|
|||
void set_start_env(Environment* env) { start_env_ = env; }
|
||||
|
||||
ConstantInstr* constant_null() const { return constant_null_; }
|
||||
void set_constant_null(ConstantInstr* instr) { constant_null_ = instr; }
|
||||
|
||||
intptr_t spill_slot_count() const { return spill_slot_count_; }
|
||||
void set_spill_slot_count(intptr_t count) {
|
||||
|
@ -1154,7 +1155,7 @@ class ParameterInstr : public Definition {
|
|||
return kIllegalCid;
|
||||
}
|
||||
|
||||
virtual void PrintTo(BufferFormatter* f) const;
|
||||
virtual void PrintOperandsTo(BufferFormatter* f) const;
|
||||
virtual void PrintToVisualizer(BufferFormatter* f) const;
|
||||
|
||||
private:
|
||||
|
@ -1209,7 +1210,7 @@ class PushArgumentInstr : public Definition {
|
|||
|
||||
virtual bool CanDeoptimize() const { return false; }
|
||||
|
||||
virtual void PrintTo(BufferFormatter* f) const;
|
||||
virtual void PrintOperandsTo(BufferFormatter* f) const;
|
||||
virtual void PrintToVisualizer(BufferFormatter* f) const;
|
||||
|
||||
private:
|
||||
|
@ -1745,7 +1746,7 @@ class PolymorphicInstanceCallInstr : public TemplateDefinition<0> {
|
|||
virtual bool CanDeoptimize() const { return true; }
|
||||
virtual intptr_t ResultCid() const { return kDynamicCid; }
|
||||
|
||||
virtual void PrintTo(BufferFormatter* f) const;
|
||||
virtual void PrintOperandsTo(BufferFormatter* f) const;
|
||||
|
||||
private:
|
||||
InstanceCallInstr* instance_call_;
|
||||
|
|
Loading…
Reference in a new issue