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

Unified Diff: src/snapshot-common.cc

Issue 335009: New snapshot framework. Doesn't work on ARM yet (code targets... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 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
Index: src/snapshot-common.cc
===================================================================
--- src/snapshot-common.cc (revision 3115)
+++ src/snapshot-common.cc (working copy)
@@ -43,6 +43,13 @@
}
+bool Snapshot::Deserialize2(const byte* content, int len) {
+ SnapshotByteSource source(content, len);
+ Deserializer2 deserializer(&source);
+ return V8::Initialize(&deserializer);
+}
+
+
bool Snapshot::Initialize(const char* snapshot_file) {
if (snapshot_file) {
int len;
@@ -58,6 +65,20 @@
}
+bool Snapshot::Initialize2(const char* snapshot_file) {
+ if (snapshot_file) {
+ int len;
+ byte* str = ReadBytes(snapshot_file, &len);
+ if (!str) return false;
+ Deserialize2(str, len);
+ DeleteArray(str);
+ } else if (size_ > 0) {
+ Deserialize2(data_, size_);
+ }
+ return true;
+}
+
+
bool Snapshot::WriteToFile(const char* snapshot_file) {
Serializer ser;
ser.Serialize();
@@ -72,4 +93,38 @@
}
+class FileByteSink : public SnapshotByteSink {
+ public:
+ explicit FileByteSink(const char* snapshot_file) {
+ fp_ = fopen(snapshot_file, "wb");
+ if (fp_ == NULL) {
+ PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file);
+ exit(1);
+ }
+ }
+ virtual ~FileByteSink() {
+ if (fp_ != NULL) {
+ fclose(fp_);
+ }
+ }
+ virtual void Put(int byte, const char* description) {
+ if (fp_ != NULL) {
+ fputc(byte, fp_);
+ }
+ }
+
+ private:
+ FILE* fp_;
+};
+
+
+bool Snapshot::WriteToFile2(const char* snapshot_file) {
+ FileByteSink file(snapshot_file);
+ Serializer2 ser(&file);
+ ser.Serialize();
+ return true;
+}
+
+
+
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698