Index: runtime/vm/flow_graph_compiler_shared.cc |
=================================================================== |
--- runtime/vm/flow_graph_compiler_shared.cc (revision 8338) |
+++ runtime/vm/flow_graph_compiler_shared.cc (working copy) |
@@ -5,6 +5,7 @@ |
#include "vm/flow_graph_compiler_shared.h" |
#include "vm/debugger.h" |
+#include "vm/il_printer.h" |
#include "vm/intermediate_language.h" |
#include "vm/intrinsifier.h" |
#include "vm/longjump.h" |
@@ -13,6 +14,7 @@ |
namespace dart { |
+DECLARE_FLAG(bool, code_comments); |
DECLARE_FLAG(bool, enable_type_checks); |
DECLARE_FLAG(bool, intrinsify); |
DECLARE_FLAG(int, optimization_counter_threshold); |
@@ -325,6 +327,44 @@ |
assembler()->Bind(&unknown); |
} |
+ |
+ |
+void FlowGraphCompilerShared::EmitComment(Instruction* instr) { |
+ char buffer[80]; |
+ BufferFormatter f(buffer, sizeof(buffer)); |
+ instr->PrintTo(&f); |
+ assembler()->Comment("@%d: %s", instr->cid(), buffer); |
+} |
+ |
+ |
+void FlowGraphCompilerShared::VisitBlocks() { |
+ for (intptr_t i = 0; i < block_order().length(); ++i) { |
+ assembler()->Comment("B%d", i); |
+ // Compile the block entry. |
+ set_current_block(block_order()[i]); |
+ current_block()->PrepareEntry(this); |
+ Instruction* instr = current_block()->StraightLineSuccessor(); |
+ // Compile all successors until an exit, branch, or a block entry. |
+ while ((instr != NULL) && !instr->IsBlockEntry()) { |
+ if (FLAG_code_comments) EmitComment(instr); |
+ ASSERT(instr->locs() != NULL); |
+ EmitInstructionPrologue(instr); |
+ instr->EmitNativeCode(this); |
+ instr = instr->StraightLineSuccessor(); |
+ } |
+ BlockEntryInstr* successor = |
+ (instr == NULL) ? NULL : instr->AsBlockEntry(); |
+ if (successor != NULL) { |
+ // Block ended with a "goto". We can fall through if it is the |
+ // next block in the list. Otherwise, we need a jump. |
+ if ((i == block_order().length() - 1) || |
+ (block_order()[i + 1] != successor)) { |
+ assembler()->jmp(GetBlockLabel(successor)); |
+ } |
+ } |
+ } |
+} |
+ |
} // namespace dart |