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

Unified Diff: src/compiler/code-assembler.cc

Issue 2056503003: [turbofan] Add comments to CodeAssembler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove extraneous change Created 4 years, 6 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 | « src/compiler/code-assembler.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « src/compiler/code-assembler.h ('k') | src/compiler/ia32/code-generator-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698