OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 static void* Value(int v) { | 452 static void* Value(int v) { |
453 return reinterpret_cast<void*>(v); | 453 return reinterpret_cast<void*>(v); |
454 } | 454 } |
455 | 455 |
456 DisallowHeapAllocation no_allocation_; | 456 DisallowHeapAllocation no_allocation_; |
457 HashMap* serialization_map_; | 457 HashMap* serialization_map_; |
458 DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper); | 458 DISALLOW_COPY_AND_ASSIGN(SerializationAddressMapper); |
459 }; | 459 }; |
460 | 460 |
461 | 461 |
462 class CodeAddressMap; | |
463 | |
464 // There can be only one serializer per V8 process. | 462 // There can be only one serializer per V8 process. |
465 class Serializer : public SerializerDeserializer { | 463 class Serializer : public SerializerDeserializer { |
466 public: | 464 public: |
467 explicit Serializer(SnapshotByteSink* sink); | 465 explicit Serializer(SnapshotByteSink* sink); |
468 ~Serializer(); | 466 ~Serializer(); |
469 void VisitPointers(Object** start, Object** end); | 467 void VisitPointers(Object** start, Object** end); |
470 // You can call this after serialization to find out how much space was used | 468 // You can call this after serialization to find out how much space was used |
471 // in each space. | 469 // in each space. |
472 int CurrentAllocationAddress(int space) { | 470 int CurrentAllocationAddress(int space) { |
473 ASSERT(space < kNumberOfSpaces); | 471 ASSERT(space < kNumberOfSpaces); |
474 return fullness_[space]; | 472 return fullness_[space]; |
475 } | 473 } |
476 | 474 |
477 static void Enable(); | 475 static void Enable() { |
478 static void Disable(); | 476 if (!serialization_enabled_) { |
| 477 ASSERT(!too_late_to_enable_now_); |
| 478 } |
| 479 serialization_enabled_ = true; |
| 480 } |
479 | 481 |
| 482 static void Disable() { serialization_enabled_ = false; } |
480 // Call this when you have made use of the fact that there is no serialization | 483 // Call this when you have made use of the fact that there is no serialization |
481 // going on. | 484 // going on. |
482 static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } | 485 static void TooLateToEnableNow() { too_late_to_enable_now_ = true; } |
483 static bool enabled() { return serialization_enabled_; } | 486 static bool enabled() { return serialization_enabled_; } |
484 SerializationAddressMapper* address_mapper() { return &address_mapper_; } | 487 SerializationAddressMapper* address_mapper() { return &address_mapper_; } |
485 void PutRoot(int index, | 488 void PutRoot(int index, |
486 HeapObject* object, | 489 HeapObject* object, |
487 HowToCode how, | 490 HowToCode how, |
488 WhereToPoint where, | 491 WhereToPoint where, |
489 int skip); | 492 int skip); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 // Did we already make use of the fact that serialization was not enabled? | 582 // Did we already make use of the fact that serialization was not enabled? |
580 static bool too_late_to_enable_now_; | 583 static bool too_late_to_enable_now_; |
581 SerializationAddressMapper address_mapper_; | 584 SerializationAddressMapper address_mapper_; |
582 intptr_t root_index_wave_front_; | 585 intptr_t root_index_wave_front_; |
583 void Pad(); | 586 void Pad(); |
584 | 587 |
585 friend class ObjectSerializer; | 588 friend class ObjectSerializer; |
586 friend class Deserializer; | 589 friend class Deserializer; |
587 | 590 |
588 private: | 591 private: |
589 static CodeAddressMap* code_address_map_; | |
590 DISALLOW_COPY_AND_ASSIGN(Serializer); | 592 DISALLOW_COPY_AND_ASSIGN(Serializer); |
591 }; | 593 }; |
592 | 594 |
593 | 595 |
594 class PartialSerializer : public Serializer { | 596 class PartialSerializer : public Serializer { |
595 public: | 597 public: |
596 PartialSerializer(Serializer* startup_snapshot_serializer, | 598 PartialSerializer(Serializer* startup_snapshot_serializer, |
597 SnapshotByteSink* sink) | 599 SnapshotByteSink* sink) |
598 : Serializer(sink), | 600 : Serializer(sink), |
599 startup_serializer_(startup_snapshot_serializer) { | 601 startup_serializer_(startup_snapshot_serializer) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 private: | 657 private: |
656 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 658 virtual bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
657 return false; | 659 return false; |
658 } | 660 } |
659 }; | 661 }; |
660 | 662 |
661 | 663 |
662 } } // namespace v8::internal | 664 } } // namespace v8::internal |
663 | 665 |
664 #endif // V8_SERIALIZE_H_ | 666 #endif // V8_SERIALIZE_H_ |
OLD | NEW |