OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
7 | 7 |
8 #include "src/hashmap.h" | 8 #include "src/hashmap.h" |
9 #include "src/heap-profiler.h" | 9 #include "src/heap-profiler.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| 11 #include "src/parser.h" |
11 #include "src/snapshot-source-sink.h" | 12 #include "src/snapshot-source-sink.h" |
12 | 13 |
13 namespace v8 { | 14 namespace v8 { |
14 namespace internal { | 15 namespace internal { |
15 | 16 |
16 // A TypeCode is used to distinguish different kinds of external reference. | 17 // A TypeCode is used to distinguish different kinds of external reference. |
17 // It is a single bit to make testing for types easy. | 18 // It is a single bit to make testing for types easy. |
18 enum TypeCode { | 19 enum TypeCode { |
19 UNCLASSIFIED, // One-of-a-kind references. | 20 UNCLASSIFIED, // One-of-a-kind references. |
20 BUILTIN, | 21 BUILTIN, |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 Isolate* isolate_; | 463 Isolate* isolate_; |
463 // Keep track of the fullness of each space in order to generate | 464 // Keep track of the fullness of each space in order to generate |
464 // relative addresses for back references. | 465 // relative addresses for back references. |
465 int fullness_[LAST_SPACE + 1]; | 466 int fullness_[LAST_SPACE + 1]; |
466 SnapshotByteSink* sink_; | 467 SnapshotByteSink* sink_; |
467 ExternalReferenceEncoder* external_reference_encoder_; | 468 ExternalReferenceEncoder* external_reference_encoder_; |
468 | 469 |
469 SerializationAddressMapper address_mapper_; | 470 SerializationAddressMapper address_mapper_; |
470 intptr_t root_index_wave_front_; | 471 intptr_t root_index_wave_front_; |
471 void Pad(); | 472 void Pad(); |
| 473 void PadByte(); |
472 | 474 |
473 friend class ObjectSerializer; | 475 friend class ObjectSerializer; |
474 friend class Deserializer; | 476 friend class Deserializer; |
475 | 477 |
476 // We may not need the code address map for logging for every instance | 478 // We may not need the code address map for logging for every instance |
477 // of the serializer. Initialize it on demand. | 479 // of the serializer. Initialize it on demand. |
478 void InitializeCodeAddressMap(); | 480 void InitializeCodeAddressMap(); |
479 | 481 |
480 private: | 482 private: |
481 CodeAddressMap* code_address_map_; | 483 CodeAddressMap* code_address_map_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 int skip); | 546 int skip); |
545 void SerializeWeakReferences(); | 547 void SerializeWeakReferences(); |
546 void Serialize() { | 548 void Serialize() { |
547 SerializeStrongReferences(); | 549 SerializeStrongReferences(); |
548 SerializeWeakReferences(); | 550 SerializeWeakReferences(); |
549 Pad(); | 551 Pad(); |
550 } | 552 } |
551 }; | 553 }; |
552 | 554 |
553 | 555 |
| 556 class CodeSerializer : public Serializer { |
| 557 public: |
| 558 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink) |
| 559 : Serializer(isolate, sink) { |
| 560 set_root_index_wave_front(Heap::kStrongRootListLength); |
| 561 InitializeCodeAddressMap(); |
| 562 } |
| 563 |
| 564 static ScriptData* Serialize(Handle<SharedFunctionInfo> info); |
| 565 virtual void SerializeObject(Object* o, HowToCode how_to_code, |
| 566 WhereToPoint where_to_point, int skip); |
| 567 |
| 568 static Object* Deserialize(Isolate* isolate, ScriptData* data); |
| 569 |
| 570 // The data header consists of int-sized entries: |
| 571 // [0] version hash |
| 572 // [1] length in bytes |
| 573 // [2..8] reservation sizes for spaces from NEW_SPACE to PROPERTY_CELL_SPACE. |
| 574 static const int kHeaderSize = 9; |
| 575 static const int kVersionHashOffset = 0; |
| 576 static const int kPayloadLengthOffset = 1; |
| 577 static const int kReservationsOffset = 2; |
| 578 }; |
554 } } // namespace v8::internal | 579 } } // namespace v8::internal |
555 | 580 |
556 #endif // V8_SERIALIZE_H_ | 581 #endif // V8_SERIALIZE_H_ |
OLD | NEW |