OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 14 matching lines...) Expand all Loading... |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // The common functionality when building with or without snapshots. | 28 // The common functionality when building with or without snapshots. |
29 | 29 |
30 #include "v8.h" | 30 #include "v8.h" |
31 | 31 |
32 #include "api.h" | 32 #include "api.h" |
33 #include "serialize.h" | 33 #include "serialize.h" |
34 #include "snapshot.h" | 34 #include "snapshot.h" |
| 35 #include "platform.h" |
35 | 36 |
36 namespace v8 { | 37 namespace v8 { |
37 namespace internal { | 38 namespace internal { |
38 | 39 |
39 bool Snapshot::Deserialize(const byte* content, int len) { | 40 bool Snapshot::Deserialize(const byte* content, int len) { |
40 Deserializer des(content, len); | 41 Deserializer des(content, len); |
41 des.GetFlags(); | 42 des.GetFlags(); |
42 return V8::Initialize(&des); | 43 return V8::Initialize(&des); |
43 } | 44 } |
44 | 45 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 int written = WriteBytes(snapshot_file, str, len); | 90 int written = WriteBytes(snapshot_file, str, len); |
90 | 91 |
91 DeleteArray(str); | 92 DeleteArray(str); |
92 return written == len; | 93 return written == len; |
93 } | 94 } |
94 | 95 |
95 | 96 |
96 class FileByteSink : public SnapshotByteSink { | 97 class FileByteSink : public SnapshotByteSink { |
97 public: | 98 public: |
98 explicit FileByteSink(const char* snapshot_file) { | 99 explicit FileByteSink(const char* snapshot_file) { |
99 fp_ = fopen(snapshot_file, "wb"); | 100 fp_ = OS::FOpen(snapshot_file, "wb"); |
100 if (fp_ == NULL) { | 101 if (fp_ == NULL) { |
101 PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file); | 102 PrintF("Unable to write to snapshot file \"%s\"\n", snapshot_file); |
102 exit(1); | 103 exit(1); |
103 } | 104 } |
104 } | 105 } |
105 virtual ~FileByteSink() { | 106 virtual ~FileByteSink() { |
106 if (fp_ != NULL) { | 107 if (fp_ != NULL) { |
107 fclose(fp_); | 108 fclose(fp_); |
108 } | 109 } |
109 } | 110 } |
(...skipping 11 matching lines...) Expand all Loading... |
121 bool Snapshot::WriteToFile2(const char* snapshot_file) { | 122 bool Snapshot::WriteToFile2(const char* snapshot_file) { |
122 FileByteSink file(snapshot_file); | 123 FileByteSink file(snapshot_file); |
123 Serializer2 ser(&file); | 124 Serializer2 ser(&file); |
124 ser.Serialize(); | 125 ser.Serialize(); |
125 return true; | 126 return true; |
126 } | 127 } |
127 | 128 |
128 | 129 |
129 | 130 |
130 } } // namespace v8::internal | 131 } } // namespace v8::internal |
OLD | NEW |