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

Unified Diff: runtime/vm/assembler_x64.cc

Issue 10407019: Extend assembler with ability to produce comments for the generated code. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: address Srdjan comments Created 8 years, 7 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: runtime/vm/assembler_x64.cc
diff --git a/runtime/vm/assembler_x64.cc b/runtime/vm/assembler_x64.cc
index b2c6614bccc291bc2134a57a246f992f0878f091..55639129621e6542fb78cf03a64858326962772b 100644
--- a/runtime/vm/assembler_x64.cc
+++ b/runtime/vm/assembler_x64.cc
@@ -14,6 +14,8 @@
namespace dart {
DEFINE_FLAG(bool, print_stop_message, true, "Print stop message.");
+DEFINE_FLAG(bool, code_comments, false,
+ "Include comments into code and disassembly");
void Assembler::InitializeMemoryWithBreakpoints(uword data, int length) {
@@ -1516,6 +1518,34 @@ void Assembler::EmitGenericShift(bool wide,
EmitOperand(rm, Operand(operand));
}
+
+void Assembler::Comment(const char* format, ...) {
+ if (FLAG_code_comments) {
+ char buffer[1024];
+
+ va_list args;
+ va_start(args, format);
+ OS::VSNPrint(buffer, sizeof(buffer), format, args);
+ va_end(args);
+
+ comments_.Add(new CodeComment(buffer_.GetPosition(),
+ String::Handle(String::New(buffer))));
+ }
+}
+
+
+const Code::Comments& Assembler::GetCodeComments() const {
+ Code::Comments& comments = Code::Comments::New(comments_.length());
+
+ for (intptr_t i = 0; i < comments_.length(); i++) {
+ comments.SetPCOffsetAt(i, comments_[i]->pc_offset());
+ comments.SetCommentAt(i, comments_[i]->comment());
+ }
+
+ return comments;
+}
+
+
} // namespace dart
#endif // defined TARGET_ARCH_X64

Powered by Google App Engine
This is Rietveld 408576698