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

Side by Side Diff: src/serialize.h

Issue 536077: Implement enough of the partial snapshots that we can deserialize... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/serialize.cc » ('j') | test/cctest/test-serialize.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // A Deserializer reads a snapshot and reconstructs the Object graph it defines. 232 // A Deserializer reads a snapshot and reconstructs the Object graph it defines.
233 class Deserializer: public SerDes { 233 class Deserializer: public SerDes {
234 public: 234 public:
235 // Create a deserializer from a snapshot byte source. 235 // Create a deserializer from a snapshot byte source.
236 explicit Deserializer(SnapshotByteSource* source); 236 explicit Deserializer(SnapshotByteSource* source);
237 237
238 virtual ~Deserializer() { } 238 virtual ~Deserializer() { }
239 239
240 // Deserialize the snapshot into an empty heap. 240 // Deserialize the snapshot into an empty heap.
241 void Deserialize(); 241 void Deserialize();
242
243 // Deserialize a single object and the objects reachable from it.
244 void DeserializePartial(Object** root);
245
242 #ifdef DEBUG 246 #ifdef DEBUG
243 virtual void Synchronize(const char* tag); 247 virtual void Synchronize(const char* tag);
244 #endif 248 #endif
245 249
250 static void TearDown();
251
246 private: 252 private:
247 virtual void VisitPointers(Object** start, Object** end); 253 virtual void VisitPointers(Object** start, Object** end);
248 254
249 virtual void VisitExternalReferences(Address* start, Address* end) { 255 virtual void VisitExternalReferences(Address* start, Address* end) {
250 UNREACHABLE(); 256 UNREACHABLE();
251 } 257 }
252 258
253 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { 259 virtual void VisitRuntimeEntry(RelocInfo* rinfo) {
254 UNREACHABLE(); 260 UNREACHABLE();
255 } 261 }
256 262
257 void ReadChunk(Object** start, Object** end, int space, Address address); 263 void ReadChunk(Object** start, Object** end, int space, Address address);
258 HeapObject* GetAddressFromStart(int space); 264 HeapObject* GetAddressFromStart(int space);
259 inline HeapObject* GetAddressFromEnd(int space); 265 inline HeapObject* GetAddressFromEnd(int space);
260 Address Allocate(int space_number, Space* space, int size); 266 Address Allocate(int space_number, Space* space, int size);
261 void ReadObject(int space_number, Space* space, Object** write_back); 267 void ReadObject(int space_number, Space* space, Object** write_back);
262 268
263 // Keep track of the pages in the paged spaces. 269 // Keep track of the pages in the paged spaces.
264 // (In large object space we are keeping track of individual objects 270 // (In large object space we are keeping track of individual objects
265 // rather than pages.) In new space we just need the address of the 271 // rather than pages.) In new space we just need the address of the
266 // first object and the others will flow from that. 272 // first object and the others will flow from that.
267 List<Address> pages_[SerDes::kNumberOfSpaces]; 273 List<Address> pages_[SerDes::kNumberOfSpaces];
268 274
269 SnapshotByteSource* source_; 275 SnapshotByteSource* source_;
270 ExternalReferenceDecoder* external_reference_decoder_; 276 static ExternalReferenceDecoder* external_reference_decoder_;
271 // This is the address of the next object that will be allocated in each 277 // This is the address of the next object that will be allocated in each
272 // space. It is used to calculate the addresses of back-references. 278 // space. It is used to calculate the addresses of back-references.
273 Address high_water_[LAST_SPACE + 1]; 279 Address high_water_[LAST_SPACE + 1];
274 // This is the address of the most recent object that was allocated. It 280 // This is the address of the most recent object that was allocated. It
275 // is used to set the location of the new page when we encounter a 281 // is used to set the location of the new page when we encounter a
276 // START_NEW_PAGE_SERIALIZATION tag. 282 // START_NEW_PAGE_SERIALIZATION tag.
277 Address last_object_address_; 283 Address last_object_address_;
278 284
279 DISALLOW_COPY_AND_ASSIGN(Deserializer); 285 DISALLOW_COPY_AND_ASSIGN(Deserializer);
280 }; 286 };
(...skipping 14 matching lines...) Expand all
295 public: 301 public:
296 explicit Serializer(SnapshotByteSink* sink); 302 explicit Serializer(SnapshotByteSink* sink);
297 // Serialize the current state of the heap. 303 // Serialize the current state of the heap.
298 void Serialize(); 304 void Serialize();
299 // Serialize a single object and the objects reachable from it. 305 // Serialize a single object and the objects reachable from it.
300 void SerializePartial(Object** obj); 306 void SerializePartial(Object** obj);
301 void VisitPointers(Object** start, Object** end); 307 void VisitPointers(Object** start, Object** end);
302 // You can call this after serialization to find out how much space was used 308 // You can call this after serialization to find out how much space was used
303 // in each space. 309 // in each space.
304 int CurrentAllocationAddress(int space) { 310 int CurrentAllocationAddress(int space) {
305 if (SpaceIsLarge(space)) space = LO_SPACE; 311 if (SpaceIsLarge(space)) return large_object_total_;
306 return fullness_[space]; 312 return fullness_[space];
307 } 313 }
308 314
309 static void Enable() { 315 static void Enable() {
310 if (!serialization_enabled_) { 316 if (!serialization_enabled_) {
311 ASSERT(!too_late_to_enable_now_); 317 ASSERT(!too_late_to_enable_now_);
312 } 318 }
313 serialization_enabled_ = true; 319 serialization_enabled_ = true;
314 } 320 }
315 321
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 // just numbered sequentially since relative addresses make no 391 // just numbered sequentially since relative addresses make no
386 // sense in large object space. 392 // sense in large object space.
387 int fullness_[LAST_SPACE + 1]; 393 int fullness_[LAST_SPACE + 1];
388 SnapshotByteSink* sink_; 394 SnapshotByteSink* sink_;
389 int current_root_index_; 395 int current_root_index_;
390 ExternalReferenceEncoder* external_reference_encoder_; 396 ExternalReferenceEncoder* external_reference_encoder_;
391 bool partial_; 397 bool partial_;
392 static bool serialization_enabled_; 398 static bool serialization_enabled_;
393 // Did we already make use of the fact that serialization was not enabled? 399 // Did we already make use of the fact that serialization was not enabled?
394 static bool too_late_to_enable_now_; 400 static bool too_late_to_enable_now_;
401 int large_object_total_;
395 402
396 friend class ObjectSerializer; 403 friend class ObjectSerializer;
397 friend class Deserializer; 404 friend class Deserializer;
398 405
399 DISALLOW_COPY_AND_ASSIGN(Serializer); 406 DISALLOW_COPY_AND_ASSIGN(Serializer);
400 }; 407 };
401 408
402 } } // namespace v8::internal 409 } } // namespace v8::internal
403 410
404 #endif // V8_SERIALIZE_H_ 411 #endif // V8_SERIALIZE_H_
OLDNEW
« no previous file with comments | « no previous file | src/serialize.cc » ('j') | test/cctest/test-serialize.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698