OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/snapshot/serializer.h" | 5 #include "src/snapshot/serializer.h" |
6 | 6 |
7 #include "src/macro-assembler.h" | 7 #include "src/macro-assembler.h" |
8 #include "src/snapshot/natives.h" | 8 #include "src/snapshot/natives.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 ExtraNatives::GetSourceCache(serializer_->isolate()->heap()), | 700 ExtraNatives::GetSourceCache(serializer_->isolate()->heap()), |
701 kExtraNativesStringResource)) { | 701 kExtraNativesStringResource)) { |
702 return; | 702 return; |
703 } | 703 } |
704 // One of the strings in the natives cache should match the resource. We | 704 // One of the strings in the natives cache should match the resource. We |
705 // don't expect any other kinds of external strings here. | 705 // don't expect any other kinds of external strings here. |
706 UNREACHABLE(); | 706 UNREACHABLE(); |
707 } | 707 } |
708 | 708 |
709 Address Serializer::ObjectSerializer::PrepareCode() { | 709 Address Serializer::ObjectSerializer::PrepareCode() { |
710 // To make snapshots reproducible, we make a copy of the code object | 710 Code* code = Code::cast(object_); |
711 // and wipe all pointers in the copy, which we then serialize. | 711 if (FLAG_predictable) { |
712 Code* original = Code::cast(object_); | 712 // To make snapshots reproducible, we make a copy of the code object |
713 Code* code = serializer_->CopyCode(original); | 713 // and wipe all pointers in the copy, which we then serialize. |
| 714 code = serializer_->CopyCode(code); |
| 715 int mode_mask = RelocInfo::kCodeTargetMask | |
| 716 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | |
| 717 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | |
| 718 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | |
| 719 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | |
| 720 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); |
| 721 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { |
| 722 RelocInfo* rinfo = it.rinfo(); |
| 723 rinfo->WipeOut(); |
| 724 } |
| 725 // We need to wipe out the header fields *after* wiping out the |
| 726 // relocations, because some of these fields are needed for the latter. |
| 727 code->WipeOutHeader(); |
| 728 } |
714 // Code age headers are not serializable. | 729 // Code age headers are not serializable. |
715 code->MakeYoung(serializer_->isolate()); | 730 code->MakeYoung(serializer_->isolate()); |
716 int mode_mask = RelocInfo::kCodeTargetMask | | |
717 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) | | |
718 RelocInfo::ModeMask(RelocInfo::EXTERNAL_REFERENCE) | | |
719 RelocInfo::ModeMask(RelocInfo::RUNTIME_ENTRY) | | |
720 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE) | | |
721 RelocInfo::ModeMask(RelocInfo::INTERNAL_REFERENCE_ENCODED); | |
722 for (RelocIterator it(code, mode_mask); !it.done(); it.next()) { | |
723 RelocInfo* rinfo = it.rinfo(); | |
724 rinfo->WipeOut(); | |
725 } | |
726 // We need to wipe out the header fields *after* wiping out the | |
727 // relocations, because some of these fields are needed for the latter. | |
728 code->WipeOutHeader(); | |
729 return code->address(); | 731 return code->address(); |
730 } | 732 } |
731 | 733 |
732 int Serializer::ObjectSerializer::OutputRawData( | 734 int Serializer::ObjectSerializer::OutputRawData( |
733 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { | 735 Address up_to, Serializer::ObjectSerializer::ReturnSkip return_skip) { |
734 Address object_start = object_->address(); | 736 Address object_start = object_->address(); |
735 int base = bytes_processed_so_far_; | 737 int base = bytes_processed_so_far_; |
736 int up_to_offset = static_cast<int>(up_to - object_start); | 738 int up_to_offset = static_cast<int>(up_to - object_start); |
737 int to_skip = up_to_offset - bytes_processed_so_far_; | 739 int to_skip = up_to_offset - bytes_processed_so_far_; |
738 int bytes_to_output = to_skip; | 740 int bytes_to_output = to_skip; |
(...skipping 30 matching lines...) Expand all Loading... |
769 if (to_skip != 0 && return_skip == kIgnoringReturn) { | 771 if (to_skip != 0 && return_skip == kIgnoringReturn) { |
770 sink_->Put(kSkip, "Skip"); | 772 sink_->Put(kSkip, "Skip"); |
771 sink_->PutInt(to_skip, "SkipDistance"); | 773 sink_->PutInt(to_skip, "SkipDistance"); |
772 to_skip = 0; | 774 to_skip = 0; |
773 } | 775 } |
774 return to_skip; | 776 return to_skip; |
775 } | 777 } |
776 | 778 |
777 } // namespace internal | 779 } // namespace internal |
778 } // namespace v8 | 780 } // namespace v8 |
OLD | NEW |