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 17 matching lines...) Expand all Loading... |
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 | 35 |
36 namespace v8 { namespace internal { | 36 namespace v8 { namespace internal { |
37 | 37 |
38 bool Snapshot::Deserialize(const char* content, int len) { | 38 bool Snapshot::Deserialize(const byte* content, int len) { |
39 Deserializer des(content, len); | 39 Deserializer des(content, len); |
40 des.GetFlags(); | 40 des.GetFlags(); |
41 return V8::Initialize(&des); | 41 return V8::Initialize(&des); |
42 } | 42 } |
43 | 43 |
44 | 44 |
45 bool Snapshot::Initialize(const char* snapshot_file) { | 45 bool Snapshot::Initialize(const char* snapshot_file) { |
46 if (snapshot_file) { | 46 if (snapshot_file) { |
47 int len; | 47 int len; |
48 char* str = ReadChars(snapshot_file, &len); | 48 byte* str = ReadBytes(snapshot_file, &len); |
49 if (!str) return false; | 49 if (!str) return false; |
50 bool result = Deserialize(str, len); | 50 bool result = Deserialize(str, len); |
51 DeleteArray(str); | 51 DeleteArray(str); |
52 return result; | 52 return result; |
53 } else if (size_ > 0) { | 53 } else if (size_ > 0) { |
54 return Deserialize(data_, size_); | 54 return Deserialize(data_, size_); |
55 } | 55 } |
56 return false; | 56 return false; |
57 } | 57 } |
58 | 58 |
59 | 59 |
60 bool Snapshot::WriteToFile(const char* snapshot_file) { | 60 bool Snapshot::WriteToFile(const char* snapshot_file) { |
61 Serializer ser; | 61 Serializer ser; |
62 ser.Serialize(); | 62 ser.Serialize(); |
63 char* str; | 63 byte* str; |
64 int len; | 64 int len; |
65 ser.Finalize(&str, &len); | 65 ser.Finalize(&str, &len); |
66 | 66 |
67 int written = WriteChars(snapshot_file, str, len); | 67 int written = WriteBytes(snapshot_file, str, len); |
68 | 68 |
69 DeleteArray(str); | 69 DeleteArray(str); |
70 return written == len; | 70 return written == len; |
71 } | 71 } |
72 | 72 |
73 | 73 |
74 } } // namespace v8::internal | 74 } } // namespace v8::internal |
OLD | NEW |