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

Unified Diff: runtime/vm/datastream.h

Issue 1309563006: Emit assembly instead of a blob for the instructions snapshot, and provide labels for the entry poi… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/bin/main.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/datastream.h
diff --git a/runtime/vm/datastream.h b/runtime/vm/datastream.h
index bb46e4f49943fa81f37260320bfea45154460b9c..f47e822bd8ed4657e9af80f79bb73f862f0ff1a2 100644
--- a/runtime/vm/datastream.h
+++ b/runtime/vm/datastream.h
@@ -10,6 +10,7 @@
#include "vm/allocation.h"
#include "vm/exceptions.h"
#include "vm/globals.h"
+#include "vm/os.h"
namespace dart {
@@ -386,6 +387,12 @@ class WriteStream : public ValueObject {
current_ += len;
}
+ void Print(const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ VPrint(format, args);
+ }
+
private:
template<typename T>
void Write(T value) {
@@ -426,6 +433,28 @@ class WriteStream : public ValueObject {
ASSERT(end_ > *buffer_);
}
+ void VPrint(const char* format, va_list args) {
+ // Measure.
+ va_list measure_args;
+ va_copy(measure_args, args);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, measure_args);
+ va_end(measure_args);
+
+ // Alloc.
+ if ((end_ - current_) < (len + 1)) {
+ Resize(len + 1);
+ }
+ ASSERT((end_ - current_) >= (len + 1));
+
+ // Print.
+ va_list print_args;
+ va_copy(print_args, args);
+ OS::VSNPrint(reinterpret_cast<char*>(current_),
+ len + 1, format, print_args);
+ va_end(print_args);
+ current_ += len; // Not len + 1 to swallow the terminating NUL.
+ }
+
private:
uint8_t** const buffer_;
uint8_t* end_;
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698