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

Unified Diff: runtime/vm/flow_graph_compiler.cc

Issue 253013006: Add flag —source-lines which emits appropriate source lines as code comments. Added token_pos to … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 8 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
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_compiler.cc
===================================================================
--- runtime/vm/flow_graph_compiler.cc (revision 35591)
+++ runtime/vm/flow_graph_compiler.cc (working copy)
@@ -40,6 +40,7 @@
DEFINE_FLAG(bool, enable_simd_inline, true,
"Enable inlining of SIMD related method calls.");
+DEFINE_FLAG(bool, source_lines, false, "Emit source line as assembly comment.");
// Assign locations to incoming arguments, i.e., values pushed above spill slots
// with PushArgument. Recursively allocates from outermost to innermost
@@ -273,6 +274,23 @@
}
+
+void FlowGraphCompiler::EmitSourceLine(Instruction* instr) {
+ if ((instr->token_pos() == Scanner::kNoSourcePos) || (instr->env() == NULL)) {
+ return;
+ }
+ const Function& function =
+ Function::Handle(instr->env()->code().function());
+ const Script& s = Script::Handle(function.script());
+ intptr_t line_nr;
+ intptr_t column_nr;
+ s.GetTokenLocation(instr->token_pos(), &line_nr, &column_nr);
+ const String& line = String::Handle(s.GetLine(line_nr));
+ assembler()->Comment("Line %" Pd " in '%s':\n %s",
+ line_nr, function.ToFullyQualifiedCString(), line.ToCString());
+}
+
+
void FlowGraphCompiler::VisitBlocks() {
CompactBlocks();
@@ -292,6 +310,9 @@
Instruction* instr = it.Current();
if (FLAG_code_comments &&
(FLAG_disassemble || FLAG_disassemble_optimized)) {
+ if (FLAG_source_lines) {
+ EmitSourceLine(instr);
+ }
EmitComment(instr);
}
if (instr->IsParallelMove()) {
« no previous file with comments | « runtime/vm/flow_graph_compiler.h ('k') | runtime/vm/flow_graph_inliner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698