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