Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: src/snapshot/deserializer.cc

Issue 2807023003: [snapshot] encode resource before serializing. (Closed)
Patch Set: fix Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/deserializer.h ('k') | src/snapshot/natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/deserializer.h" 5 #include "src/snapshot/deserializer.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/assembler-inl.h" 8 #include "src/assembler-inl.h"
9 #include "src/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // We flush all code pages after deserializing the startup snapshot. In that 349 // We flush all code pages after deserializing the startup snapshot. In that
350 // case, we only need to remember code objects in the large object space. 350 // case, we only need to remember code objects in the large object space.
351 // When deserializing user code, remember each individual code object. 351 // When deserializing user code, remember each individual code object.
352 if (deserializing_user_code() || space == LO_SPACE) { 352 if (deserializing_user_code() || space == LO_SPACE) {
353 new_code_objects_.Add(Code::cast(obj)); 353 new_code_objects_.Add(Code::cast(obj));
354 } 354 }
355 } else if (obj->IsAccessorInfo()) { 355 } else if (obj->IsAccessorInfo()) {
356 if (isolate_->external_reference_redirector()) { 356 if (isolate_->external_reference_redirector()) {
357 accessor_infos_.Add(AccessorInfo::cast(obj)); 357 accessor_infos_.Add(AccessorInfo::cast(obj));
358 } 358 }
359 } else if (obj->IsExternalOneByteString()) {
360 DCHECK(obj->map() == isolate_->heap()->native_source_string_map());
361 ExternalOneByteString* string = ExternalOneByteString::cast(obj);
362 DCHECK(string->is_short());
363 string->set_resource(
364 NativesExternalStringResource::DecodeForDeserialization(
365 string->resource()));
366 isolate_->heap()->RegisterExternalString(string);
359 } 367 }
360 // Check alignment. 368 // Check alignment.
361 DCHECK_EQ(0, Heap::GetFillToAlign(obj->address(), obj->RequiredAlignment())); 369 DCHECK_EQ(0, Heap::GetFillToAlign(obj->address(), obj->RequiredAlignment()));
362 return obj; 370 return obj;
363 } 371 }
364 372
365 void Deserializer::CommitPostProcessedObjects(Isolate* isolate) { 373 void Deserializer::CommitPostProcessedObjects(Isolate* isolate) {
366 StringTable::EnsureCapacityForDeserialization( 374 StringTable::EnsureCapacityForDeserialization(
367 isolate, new_internalized_strings_.length()); 375 isolate, new_internalized_strings_.length());
368 for (Handle<String> string : new_internalized_strings_) { 376 for (Handle<String> string : new_internalized_strings_) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Assert that the current reserved chunk is still big enough. 503 // Assert that the current reserved chunk is still big enough.
496 const Heap::Reservation& reservation = reservations_[space_index]; 504 const Heap::Reservation& reservation = reservations_[space_index];
497 int chunk_index = current_chunk_[space_index]; 505 int chunk_index = current_chunk_[space_index];
498 CHECK_LE(high_water_[space_index], reservation[chunk_index].end); 506 CHECK_LE(high_water_[space_index], reservation[chunk_index].end);
499 #endif 507 #endif
500 if (space_index == CODE_SPACE) SkipList::Update(address, size); 508 if (space_index == CODE_SPACE) SkipList::Update(address, size);
501 return address; 509 return address;
502 } 510 }
503 } 511 }
504 512
505 Object** Deserializer::CopyInNativesSource(Vector<const char> source_vector,
506 Object** current) {
507 DCHECK(!isolate_->heap()->deserialization_complete());
508 NativesExternalStringResource* resource = new NativesExternalStringResource(
509 source_vector.start(), source_vector.length());
510 Object* resource_obj = reinterpret_cast<Object*>(resource);
511 UnalignedCopy(current++, &resource_obj);
512 return current;
513 }
514
515 bool Deserializer::ReadData(Object** current, Object** limit, int source_space, 513 bool Deserializer::ReadData(Object** current, Object** limit, int source_space,
516 Address current_object_address) { 514 Address current_object_address) {
517 Isolate* const isolate = isolate_; 515 Isolate* const isolate = isolate_;
518 // Write barrier support costs around 1% in startup time. In fact there 516 // Write barrier support costs around 1% in startup time. In fact there
519 // are no new space objects in current boot snapshots, so it's not needed, 517 // are no new space objects in current boot snapshots, so it's not needed,
520 // but that may change. 518 // but that may change.
521 bool write_barrier_needed = 519 bool write_barrier_needed =
522 (current_object_address != NULL && source_space != NEW_SPACE && 520 (current_object_address != NULL && source_space != NEW_SPACE &&
523 source_space != CODE_SPACE); 521 source_space != CODE_SPACE);
524 while (current < limit) { 522 while (current < limit) {
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 current = limit; 805 current = limit;
808 return false; 806 return false;
809 } 807 }
810 808
811 case kSynchronize: 809 case kSynchronize:
812 // If we get here then that indicates that you have a mismatch between 810 // If we get here then that indicates that you have a mismatch between
813 // the number of GC roots when serializing and deserializing. 811 // the number of GC roots when serializing and deserializing.
814 CHECK(false); 812 CHECK(false);
815 break; 813 break;
816 814
817 case kNativesStringResource:
818 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()),
819 current);
820 break;
821
822 case kExtraNativesStringResource:
823 current = CopyInNativesSource(
824 ExtraNatives::GetScriptSource(source_.Get()), current);
825 break;
826
827 // Deserialize raw data of variable length. 815 // Deserialize raw data of variable length.
828 case kVariableRawData: { 816 case kVariableRawData: {
829 int size_in_bytes = source_.GetInt(); 817 int size_in_bytes = source_.GetInt();
830 byte* raw_data_out = reinterpret_cast<byte*>(current); 818 byte* raw_data_out = reinterpret_cast<byte*>(current);
831 source_.CopyRaw(raw_data_out, size_in_bytes); 819 source_.CopyRaw(raw_data_out, size_in_bytes);
832 break; 820 break;
833 } 821 }
834 822
835 case kVariableRepeat: { 823 case kVariableRepeat: {
836 int repeats = source_.GetInt(); 824 int repeats = source_.GetInt();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 906
919 default: 907 default:
920 CHECK(false); 908 CHECK(false);
921 } 909 }
922 } 910 }
923 CHECK_EQ(limit, current); 911 CHECK_EQ(limit, current);
924 return true; 912 return true;
925 } 913 }
926 } // namespace internal 914 } // namespace internal
927 } // namespace v8 915 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/deserializer.h ('k') | src/snapshot/natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698