| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Serializer(); | 128 Serializer(); |
| 129 | 129 |
| 130 virtual ~Serializer(); | 130 virtual ~Serializer(); |
| 131 | 131 |
| 132 // Serialize the current state of the heap. This operation destroys the | 132 // Serialize the current state of the heap. This operation destroys the |
| 133 // heap contents and the contents of the roots into the heap. | 133 // heap contents and the contents of the roots into the heap. |
| 134 void Serialize(); | 134 void Serialize(); |
| 135 | 135 |
| 136 // Returns the serialized buffer. Ownership is transferred to the | 136 // Returns the serialized buffer. Ownership is transferred to the |
| 137 // caller. Only the destructor and getters may be called after this call. | 137 // caller. Only the destructor and getters may be called after this call. |
| 138 void Finalize(char** str, int* len); | 138 void Finalize(byte** str, int* len); |
| 139 | 139 |
| 140 int roots() { return roots_; } | 140 int roots() { return roots_; } |
| 141 int objects() { return objects_; } | 141 int objects() { return objects_; } |
| 142 | 142 |
| 143 #ifdef DEBUG | 143 #ifdef DEBUG |
| 144 // insert "tag" into the serialized stream | 144 // insert "tag" into the serialized stream |
| 145 virtual void Synchronize(const char* tag); | 145 virtual void Synchronize(const char* tag); |
| 146 #endif | 146 #endif |
| 147 | 147 |
| 148 static bool enabled() { return serialization_enabled_; } | 148 static bool enabled() { return serialization_enabled_; } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 204 |
| 205 HashMap saved_addresses_; | 205 HashMap saved_addresses_; |
| 206 | 206 |
| 207 DISALLOW_COPY_AND_ASSIGN(Serializer); | 207 DISALLOW_COPY_AND_ASSIGN(Serializer); |
| 208 }; | 208 }; |
| 209 | 209 |
| 210 // Helper class to read the bytes of the serialized heap. | 210 // Helper class to read the bytes of the serialized heap. |
| 211 | 211 |
| 212 class SnapshotReader { | 212 class SnapshotReader { |
| 213 public: | 213 public: |
| 214 SnapshotReader(const char* str, int len): str_(str), end_(str + len) {} | 214 SnapshotReader(const byte* str, int len): str_(str), end_(str + len) {} |
| 215 | 215 |
| 216 void ExpectC(char expected) { | 216 void ExpectC(char expected) { |
| 217 int c = GetC(); | 217 int c = GetC(); |
| 218 USE(c); | 218 USE(c); |
| 219 ASSERT(c == expected); | 219 ASSERT(c == expected); |
| 220 } | 220 } |
| 221 | 221 |
| 222 int GetC() { | 222 int GetC() { |
| 223 if (str_ >= end_) return EOF; | 223 if (str_ >= end_) return EOF; |
| 224 return *str_++; | 224 return *str_++; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 240 ExpectC('['); | 240 ExpectC('['); |
| 241 int size = GetInt(); | 241 int size = GetInt(); |
| 242 ExpectC(']'); | 242 ExpectC(']'); |
| 243 char* s = NewArray<char>(size + 1); | 243 char* s = NewArray<char>(size + 1); |
| 244 GetBytes(reinterpret_cast<Address>(s), size); | 244 GetBytes(reinterpret_cast<Address>(s), size); |
| 245 s[size] = 0; | 245 s[size] = 0; |
| 246 return s; | 246 return s; |
| 247 } | 247 } |
| 248 | 248 |
| 249 private: | 249 private: |
| 250 const char* str_; | 250 const byte* str_; |
| 251 const char* end_; | 251 const byte* end_; |
| 252 }; | 252 }; |
| 253 | 253 |
| 254 | 254 |
| 255 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. | 255 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. |
| 256 | 256 |
| 257 class Deserializer: public ObjectVisitor { | 257 class Deserializer: public ObjectVisitor { |
| 258 public: | 258 public: |
| 259 // Create a deserializer. The snapshot is held in str and has size len. | 259 // Create a deserializer. The snapshot is held in str and has size len. |
| 260 Deserializer(const char* str, int len); | 260 Deserializer(const byte* str, int len); |
| 261 | 261 |
| 262 virtual ~Deserializer(); | 262 virtual ~Deserializer(); |
| 263 | 263 |
| 264 // Read the flags from the header of the file, and set those that | 264 // Read the flags from the header of the file, and set those that |
| 265 // should be inherited from the snapshot. | 265 // should be inherited from the snapshot. |
| 266 void GetFlags(); | 266 void GetFlags(); |
| 267 | 267 |
| 268 // Read saved profiling information from the file and log it if required. | 268 // Read saved profiling information from the file and log it if required. |
| 269 void GetLog(); | 269 void GetLog(); |
| 270 | 270 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 #ifdef DEBUG | 325 #ifdef DEBUG |
| 326 bool expect_debug_information_; | 326 bool expect_debug_information_; |
| 327 #endif | 327 #endif |
| 328 | 328 |
| 329 DISALLOW_COPY_AND_ASSIGN(Deserializer); | 329 DISALLOW_COPY_AND_ASSIGN(Deserializer); |
| 330 }; | 330 }; |
| 331 | 331 |
| 332 } } // namespace v8::internal | 332 } } // namespace v8::internal |
| 333 | 333 |
| 334 #endif // V8_SERIALIZE_H_ | 334 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |