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_SNAPSHOT_SERIALIZE_H_ | 5 #ifndef V8_SNAPSHOT_SERIALIZE_H_ |
6 #define V8_SNAPSHOT_SERIALIZE_H_ | 6 #define V8_SNAPSHOT_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" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 static const int kSynchronize = 0x17; | 389 static const int kSynchronize = 0x17; |
390 // Used for the source code of the natives, which is in the executable, but | 390 // Used for the source code of the natives, which is in the executable, but |
391 // is referred to from external strings in the snapshot. | 391 // is referred to from external strings in the snapshot. |
392 static const int kNativesStringResource = 0x37; | 392 static const int kNativesStringResource = 0x37; |
393 // Raw data of variable length. | 393 // Raw data of variable length. |
394 static const int kVariableRawData = 0x57; | 394 static const int kVariableRawData = 0x57; |
395 // Repeats of variable length. | 395 // Repeats of variable length. |
396 static const int kVariableRepeat = 0x77; | 396 static const int kVariableRepeat = 0x77; |
397 // Alignment prefixes 0x7d..0x7f | 397 // Alignment prefixes 0x7d..0x7f |
398 static const int kAlignmentPrefix = 0x7d; | 398 static const int kAlignmentPrefix = 0x7d; |
| 399 // Used for the source code for compiled stubs, which is in the executable, |
| 400 // but is referred to from external strings in the snapshot. |
| 401 static const int kCodeStubNativesStringResource = 0x5d; |
399 | 402 |
400 // 0x5d..0x5f unused | 403 // 0x5e..0x5f unused |
401 | 404 |
402 // ---------- byte code range 0x80..0xff ---------- | 405 // ---------- byte code range 0x80..0xff ---------- |
403 // First 32 root array items. | 406 // First 32 root array items. |
404 static const int kNumberOfRootArrayConstants = 0x20; | 407 static const int kNumberOfRootArrayConstants = 0x20; |
405 // 0x80..0x9f | 408 // 0x80..0x9f |
406 static const int kRootArrayConstants = 0x80; | 409 static const int kRootArrayConstants = 0x80; |
407 // 0xa0..0xbf | 410 // 0xa0..0xbf |
408 static const int kRootArrayConstantsWithSkip = 0xa0; | 411 static const int kRootArrayConstantsWithSkip = 0xa0; |
409 static const int kRootArrayConstantsMask = 0x1f; | 412 static const int kRootArrayConstantsMask = 0x1f; |
410 | 413 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 void ReadObject(int space_number, Object** write_back); | 583 void ReadObject(int space_number, Object** write_back); |
581 Address Allocate(int space_index, int size); | 584 Address Allocate(int space_index, int size); |
582 | 585 |
583 // Special handling for serialized code like hooking up internalized strings. | 586 // Special handling for serialized code like hooking up internalized strings. |
584 HeapObject* PostProcessNewObject(HeapObject* obj, int space); | 587 HeapObject* PostProcessNewObject(HeapObject* obj, int space); |
585 | 588 |
586 // This returns the address of an object that has been described in the | 589 // This returns the address of an object that has been described in the |
587 // snapshot by chunk index and offset. | 590 // snapshot by chunk index and offset. |
588 HeapObject* GetBackReferencedObject(int space); | 591 HeapObject* GetBackReferencedObject(int space); |
589 | 592 |
| 593 Object** CopyInNativesSource(Vector<const char> source_vector, |
| 594 Object** current); |
| 595 |
590 // Cached current isolate. | 596 // Cached current isolate. |
591 Isolate* isolate_; | 597 Isolate* isolate_; |
592 | 598 |
593 // Objects from the attached object descriptions in the serialized user code. | 599 // Objects from the attached object descriptions in the serialized user code. |
594 Vector<Handle<Object> > attached_objects_; | 600 Vector<Handle<Object> > attached_objects_; |
595 | 601 |
596 SnapshotByteSource source_; | 602 SnapshotByteSource source_; |
597 uint32_t magic_number_; | 603 uint32_t magic_number_; |
598 | 604 |
599 // The address of the next object that will be allocated in each space. | 605 // The address of the next object that will be allocated in each space. |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 v8::String::ExternalOneByteStringResource** resource); | 674 v8::String::ExternalOneByteStringResource** resource); |
669 // We can't serialize a heap with external two byte strings. | 675 // We can't serialize a heap with external two byte strings. |
670 void VisitExternalTwoByteString( | 676 void VisitExternalTwoByteString( |
671 v8::String::ExternalStringResource** resource) { | 677 v8::String::ExternalStringResource** resource) { |
672 UNREACHABLE(); | 678 UNREACHABLE(); |
673 } | 679 } |
674 | 680 |
675 private: | 681 private: |
676 void SerializePrologue(AllocationSpace space, int size, Map* map); | 682 void SerializePrologue(AllocationSpace space, int size, Map* map); |
677 | 683 |
| 684 bool SerializeExternalNativeSourceString( |
| 685 int builtin_count, |
| 686 v8::String::ExternalOneByteStringResource** resource_pointer, |
| 687 FixedArray* source_cache, int resource_index, const char* begin_string, |
| 688 const char* end_string); |
| 689 |
678 enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn }; | 690 enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn }; |
679 // This function outputs or skips the raw data between the last pointer and | 691 // This function outputs or skips the raw data between the last pointer and |
680 // up to the current position. It optionally can just return the number of | 692 // up to the current position. It optionally can just return the number of |
681 // bytes to skip instead of performing a skip instruction, in case the skip | 693 // bytes to skip instead of performing a skip instruction, in case the skip |
682 // can be merged into the next instruction. | 694 // can be merged into the next instruction. |
683 int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn); | 695 int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn); |
684 // External strings are serialized in a way to resemble sequential strings. | 696 // External strings are serialized in a way to resemble sequential strings. |
685 void SerializeExternalString(); | 697 void SerializeExternalString(); |
686 | 698 |
687 Address PrepareCode(); | 699 Address PrepareCode(); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; | 1048 static const int kNumReservationsOffset = kFlagHashOffset + kInt32Size; |
1037 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 1049 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
1038 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 1050 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
1039 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 1051 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
1040 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 1052 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
1041 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1053 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
1042 }; | 1054 }; |
1043 } } // namespace v8::internal | 1055 } } // namespace v8::internal |
1044 | 1056 |
1045 #endif // V8_SNAPSHOT_SERIALIZE_H_ | 1057 #endif // V8_SNAPSHOT_SERIALIZE_H_ |
OLD | NEW |