Index: src/compiler/code-assembler.cc |
diff --git a/src/compiler/code-assembler.cc b/src/compiler/code-assembler.cc |
index 9bc40258c8150fed693870f43e62a3ca89d79767..f2d45e27b7128c9a03c10bb76729f344b275699f 100644 |
--- a/src/compiler/code-assembler.cc |
+++ b/src/compiler/code-assembler.cc |
@@ -19,6 +19,7 @@ |
#include "src/interpreter/bytecodes.h" |
#include "src/machine-type.h" |
#include "src/macro-assembler.h" |
+#include "src/utils.h" |
#include "src/zone.h" |
namespace v8 { |
@@ -162,6 +163,25 @@ void CodeAssembler::Return(Node* value) { |
void CodeAssembler::DebugBreak() { raw_assembler_->DebugBreak(); } |
+void CodeAssembler::Comment(const char* format, ...) { |
+ if (!FLAG_code_comments) return; |
+ char buffer[4 * KB]; |
+ StringBuilder builder(buffer, arraysize(buffer)); |
+ va_list arguments; |
+ va_start(arguments, format); |
+ builder.AddFormattedList(format, arguments); |
+ va_end(arguments); |
+ |
+ // Copy the string before recording it in the assembler to avoid |
+ // issues when the stack allocated buffer goes out of scope. |
+ size_t length = builder.position() + 3; |
+ char* copy = reinterpret_cast<char*>(malloc(static_cast<int>(length))); |
+ MemCopy(copy + 2, builder.Finalize(), length); |
+ copy[0] = ';'; |
+ copy[1] = ' '; |
+ raw_assembler_->Comment(copy); |
+} |
+ |
void CodeAssembler::Bind(CodeAssembler::Label* label) { return label->Bind(); } |
Node* CodeAssembler::LoadFramePointer() { |