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

Unified Diff: src/snapshot-source-sink.h

Issue 669133003: De-virtualize snapshot sink. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 2 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/serialize.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot-source-sink.h
diff --git a/src/snapshot-source-sink.h b/src/snapshot-source-sink.h
index c1a31b5645fec748a9d562538b611601dddf41ce..68901a13190135a9cd457e968ec88f96285058e8 100644
--- a/src/snapshot-source-sink.h
+++ b/src/snapshot-source-sink.h
@@ -70,53 +70,27 @@ class SnapshotByteSource FINAL {
*/
class SnapshotByteSink {
public:
- virtual ~SnapshotByteSink() { }
- virtual void Put(byte b, const char* description) = 0;
- virtual void PutSection(int b, const char* description) {
+ SnapshotByteSink() {}
+ explicit SnapshotByteSink(int initial_size) : data_(initial_size) {}
+
+ ~SnapshotByteSink() {}
+
+ void Put(byte b, const char* description) { data_.Add(b); }
+
+ void PutSection(int b, const char* description) {
DCHECK_LE(b, kMaxUInt8);
Put(static_cast<byte>(b), description);
}
+
void PutInt(uintptr_t integer, const char* description);
void PutRaw(byte* data, int number_of_bytes, const char* description);
void PutBlob(byte* data, int number_of_bytes, const char* description);
- virtual int Position() = 0;
-};
-
+ int Position() { return data_.length(); }
-class DummySnapshotSink : public SnapshotByteSink {
- public:
- DummySnapshotSink() : length_(0) {}
- virtual ~DummySnapshotSink() {}
- virtual void Put(byte b, const char* description) { length_++; }
- virtual int Position() { return length_; }
-
- private:
- int length_;
-};
-
-
-// Wrap a SnapshotByteSink into a DebugSnapshotSink to get debugging output.
-class DebugSnapshotSink : public SnapshotByteSink {
- public:
- explicit DebugSnapshotSink(SnapshotByteSink* chained) : sink_(chained) {}
- virtual void Put(byte b, const char* description) OVERRIDE;
- virtual int Position() OVERRIDE { return sink_->Position(); }
-
- private:
- SnapshotByteSink* sink_;
-};
-
-
-class ListSnapshotSink : public i::SnapshotByteSink {
- public:
- explicit ListSnapshotSink(i::List<byte>* data) : data_(data) {}
- virtual void Put(byte b, const char* description) OVERRIDE {
- data_->Add(b);
- }
- virtual int Position() OVERRIDE { return data_->length(); }
+ const List<byte>& data() const { return data_; }
private:
- i::List<byte>* data_;
+ List<byte> data_;
};
} // namespace v8::internal
« no previous file with comments | « src/serialize.cc ('k') | src/snapshot-source-sink.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698