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

Side by Side Diff: src/serialize.h

Issue 545026: Add some interfaces to the GC that allow us to reserve space. This is needed... (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
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 // And 15 common raw lengths. 192 // And 15 common raw lengths.
193 OBJECT_SERIALIZATION = 16, 193 OBJECT_SERIALIZATION = 16,
194 // One variant per space. 194 // One variant per space.
195 CODE_OBJECT_SERIALIZATION = 25, 195 CODE_OBJECT_SERIALIZATION = 25,
196 // One per space (only code spaces in use). 196 // One per space (only code spaces in use).
197 EXTERNAL_REFERENCE_SERIALIZATION = 34, 197 EXTERNAL_REFERENCE_SERIALIZATION = 34,
198 EXTERNAL_BRANCH_TARGET_SERIALIZATION = 35, 198 EXTERNAL_BRANCH_TARGET_SERIALIZATION = 35,
199 SYNCHRONIZE = 36, 199 SYNCHRONIZE = 36,
200 START_NEW_PAGE_SERIALIZATION = 37, 200 START_NEW_PAGE_SERIALIZATION = 37,
201 NATIVES_STRING_RESOURCE = 38, 201 NATIVES_STRING_RESOURCE = 38,
202 // Free: 39-47. 202 ROOT_SERIALIZATION = 39,
203 // Free: 40-47.
203 BACKREF_SERIALIZATION = 48, 204 BACKREF_SERIALIZATION = 48,
204 // One per space, must be kSpaceMask aligned. 205 // One per space, must be kSpaceMask aligned.
205 // Free: 57-63. 206 // Free: 57-63.
206 REFERENCE_SERIALIZATION = 64, 207 REFERENCE_SERIALIZATION = 64,
207 // One per space and common references. Must be kSpaceMask aligned. 208 // One per space and common references. Must be kSpaceMask aligned.
208 CODE_BACKREF_SERIALIZATION = 80, 209 CODE_BACKREF_SERIALIZATION = 80,
209 // One per space, must be kSpaceMask aligned. 210 // One per space, must be kSpaceMask aligned.
210 // Free: 89-95. 211 // Free: 89-95.
211 CODE_REFERENCE_SERIALIZATION = 96 212 CODE_REFERENCE_SERIALIZATION = 96
212 // One per space, must be kSpaceMask aligned. 213 // One per space, must be kSpaceMask aligned.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 virtual void PutSection(int byte, const char* description) { 287 virtual void PutSection(int byte, const char* description) {
287 Put(byte, description); 288 Put(byte, description);
288 } 289 }
289 void PutInt(uintptr_t integer, const char* description); 290 void PutInt(uintptr_t integer, const char* description);
290 }; 291 };
291 292
292 293
293 class Serializer : public SerDes { 294 class Serializer : public SerDes {
294 public: 295 public:
295 explicit Serializer(SnapshotByteSink* sink); 296 explicit Serializer(SnapshotByteSink* sink);
296 // Serialize the current state of the heap. This operation destroys the 297 // Serialize the current state of the heap.
297 // heap contents.
298 void Serialize(); 298 void Serialize();
299 // Serialize a single object and the objects reachable from it.
300 void SerializePartial(Object** obj);
299 void VisitPointers(Object** start, Object** end); 301 void VisitPointers(Object** start, Object** end);
302 // You can call this after serialization to find out how much space was used
303 // in each space.
304 int CurrentAllocationAddress(int space) {
305 if (SpaceIsLarge(space)) space = LO_SPACE;
306 return fullness_[space];
307 }
300 308
301 static void Enable() { 309 static void Enable() {
302 if (!serialization_enabled_) { 310 if (!serialization_enabled_) {
303 ASSERT(!too_late_to_enable_now_); 311 ASSERT(!too_late_to_enable_now_);
304 } 312 }
305 serialization_enabled_ = true; 313 serialization_enabled_ = true;
306 } 314 }
307 315
308 static void Disable() { serialization_enabled_ = false; } 316 static void Disable() { serialization_enabled_ = false; }
309 // Call this when you have made use of the fact that there is no serialization 317 // Call this when you have made use of the fact that there is no serialization
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // This will return the space for an object. If the object is in large 367 // This will return the space for an object. If the object is in large
360 // object space it may return kLargeCode or kLargeFixedArray in order 368 // object space it may return kLargeCode or kLargeFixedArray in order
361 // to indicate to the deserializer what kind of large object allocation 369 // to indicate to the deserializer what kind of large object allocation
362 // to make. 370 // to make.
363 static int SpaceOfObject(HeapObject* object); 371 static int SpaceOfObject(HeapObject* object);
364 // This just returns the space of the object. It will return LO_SPACE 372 // This just returns the space of the object. It will return LO_SPACE
365 // for all large objects since you can't check the type of the object 373 // for all large objects since you can't check the type of the object
366 // once the map has been used for the serialization address. 374 // once the map has been used for the serialization address.
367 static int SpaceOfAlreadySerializedObject(HeapObject* object); 375 static int SpaceOfAlreadySerializedObject(HeapObject* object);
368 int Allocate(int space, int size, bool* new_page_started); 376 int Allocate(int space, int size, bool* new_page_started);
369 int CurrentAllocationAddress(int space) {
370 if (SpaceIsLarge(space)) space = LO_SPACE;
371 return fullness_[space];
372 }
373 int EncodeExternalReference(Address addr) { 377 int EncodeExternalReference(Address addr) {
374 return external_reference_encoder_->Encode(addr); 378 return external_reference_encoder_->Encode(addr);
375 } 379 }
380 int RootIndex(HeapObject* heap_object);
381 static const int kInvalidRootIndex = -1;
376 382
377 // Keep track of the fullness of each space in order to generate 383 // Keep track of the fullness of each space in order to generate
378 // relative addresses for back references. Large objects are 384 // relative addresses for back references. Large objects are
379 // just numbered sequentially since relative addresses make no 385 // just numbered sequentially since relative addresses make no
380 // sense in large object space. 386 // sense in large object space.
381 int fullness_[LAST_SPACE + 1]; 387 int fullness_[LAST_SPACE + 1];
382 SnapshotByteSink* sink_; 388 SnapshotByteSink* sink_;
383 int current_root_index_; 389 int current_root_index_;
384 ExternalReferenceEncoder* external_reference_encoder_; 390 ExternalReferenceEncoder* external_reference_encoder_;
391 bool partial_;
385 static bool serialization_enabled_; 392 static bool serialization_enabled_;
386 // Did we already make use of the fact that serialization was not enabled? 393 // Did we already make use of the fact that serialization was not enabled?
387 static bool too_late_to_enable_now_; 394 static bool too_late_to_enable_now_;
388 395
389 friend class ObjectSerializer; 396 friend class ObjectSerializer;
390 friend class Deserializer; 397 friend class Deserializer;
391 398
392 DISALLOW_COPY_AND_ASSIGN(Serializer); 399 DISALLOW_COPY_AND_ASSIGN(Serializer);
393 }; 400 };
394 401
395 } } // namespace v8::internal 402 } } // namespace v8::internal
396 403
397 #endif // V8_SERIALIZE_H_ 404 #endif // V8_SERIALIZE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698