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

Side by Side Diff: runtime/vm/clustered_snapshot.cc

Issue 2822843002: Use to_snapshot when cluster serializing LibraryPrefixes. (Closed)
Patch Set: ports -> imports/exports 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 | « no previous file | runtime/vm/object_service.cc » ('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 (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/clustered_snapshot.h" 5 #include "vm/clustered_snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 2842 matching lines...) Expand 10 before | Expand all | Expand 10 after
2853 class LibraryPrefixSerializationCluster : public SerializationCluster { 2853 class LibraryPrefixSerializationCluster : public SerializationCluster {
2854 public: 2854 public:
2855 LibraryPrefixSerializationCluster() {} 2855 LibraryPrefixSerializationCluster() {}
2856 virtual ~LibraryPrefixSerializationCluster() {} 2856 virtual ~LibraryPrefixSerializationCluster() {}
2857 2857
2858 void Trace(Serializer* s, RawObject* object) { 2858 void Trace(Serializer* s, RawObject* object) {
2859 RawLibraryPrefix* prefix = LibraryPrefix::RawCast(object); 2859 RawLibraryPrefix* prefix = LibraryPrefix::RawCast(object);
2860 objects_.Add(prefix); 2860 objects_.Add(prefix);
2861 2861
2862 RawObject** from = prefix->from(); 2862 RawObject** from = prefix->from();
2863 RawObject** to = prefix->to(); 2863 RawObject** to = prefix->to_snapshot(s->kind());
2864 for (RawObject** p = from; p <= to; p++) { 2864 for (RawObject** p = from; p <= to; p++) {
2865 s->Push(*p); 2865 s->Push(*p);
2866 } 2866 }
2867 } 2867 }
2868 2868
2869 void WriteAlloc(Serializer* s) { 2869 void WriteAlloc(Serializer* s) {
2870 s->WriteCid(kLibraryPrefixCid); 2870 s->WriteCid(kLibraryPrefixCid);
2871 intptr_t count = objects_.length(); 2871 intptr_t count = objects_.length();
2872 s->Write<int32_t>(count); 2872 s->Write<int32_t>(count);
2873 for (intptr_t i = 0; i < count; i++) { 2873 for (intptr_t i = 0; i < count; i++) {
2874 RawLibraryPrefix* prefix = objects_[i]; 2874 RawLibraryPrefix* prefix = objects_[i];
2875 s->AssignRef(prefix); 2875 s->AssignRef(prefix);
2876 } 2876 }
2877 } 2877 }
2878 2878
2879 void WriteFill(Serializer* s) { 2879 void WriteFill(Serializer* s) {
2880 Snapshot::Kind kind = s->kind();
2880 intptr_t count = objects_.length(); 2881 intptr_t count = objects_.length();
2881 for (intptr_t i = 0; i < count; i++) { 2882 for (intptr_t i = 0; i < count; i++) {
2882 RawLibraryPrefix* prefix = objects_[i]; 2883 RawLibraryPrefix* prefix = objects_[i];
2883 RawObject** from = prefix->from(); 2884 RawObject** from = prefix->from();
2884 RawObject** to = prefix->to(); 2885 RawObject** to = prefix->to_snapshot(kind);
2885 for (RawObject** p = from; p <= to; p++) { 2886 for (RawObject** p = from; p <= to; p++) {
2886 s->WriteRef(*p); 2887 s->WriteRef(*p);
2887 } 2888 }
2888 s->Write<uint16_t>(prefix->ptr()->num_imports_); 2889 s->Write<uint16_t>(prefix->ptr()->num_imports_);
2889 s->Write<bool>(prefix->ptr()->is_deferred_load_); 2890 s->Write<bool>(prefix->ptr()->is_deferred_load_);
2890 } 2891 }
2891 } 2892 }
2892 2893
2893 private: 2894 private:
2894 GrowableArray<RawLibraryPrefix*> objects_; 2895 GrowableArray<RawLibraryPrefix*> objects_;
(...skipping 11 matching lines...) Expand all
2906 PageSpace* old_space = d->heap()->old_space(); 2907 PageSpace* old_space = d->heap()->old_space();
2907 intptr_t count = d->Read<int32_t>(); 2908 intptr_t count = d->Read<int32_t>();
2908 for (intptr_t i = 0; i < count; i++) { 2909 for (intptr_t i = 0; i < count; i++) {
2909 d->AssignRef( 2910 d->AssignRef(
2910 AllocateUninitialized(old_space, LibraryPrefix::InstanceSize())); 2911 AllocateUninitialized(old_space, LibraryPrefix::InstanceSize()));
2911 } 2912 }
2912 stop_index_ = d->next_index(); 2913 stop_index_ = d->next_index();
2913 } 2914 }
2914 2915
2915 void ReadFill(Deserializer* d) { 2916 void ReadFill(Deserializer* d) {
2917 Snapshot::Kind kind = d->kind();
2916 bool is_vm_object = d->isolate() == Dart::vm_isolate(); 2918 bool is_vm_object = d->isolate() == Dart::vm_isolate();
2917 2919
2918 for (intptr_t id = start_index_; id < stop_index_; id++) { 2920 for (intptr_t id = start_index_; id < stop_index_; id++) {
2919 RawLibraryPrefix* prefix = 2921 RawLibraryPrefix* prefix =
2920 reinterpret_cast<RawLibraryPrefix*>(d->Ref(id)); 2922 reinterpret_cast<RawLibraryPrefix*>(d->Ref(id));
2921 Deserializer::InitializeHeader(prefix, kLibraryPrefixCid, 2923 Deserializer::InitializeHeader(prefix, kLibraryPrefixCid,
2922 LibraryPrefix::InstanceSize(), 2924 LibraryPrefix::InstanceSize(),
2923 is_vm_object); 2925 is_vm_object);
2924 RawObject** from = prefix->from(); 2926 RawObject** from = prefix->from();
2927 RawObject** to_snapshot = prefix->to_snapshot(kind);
2925 RawObject** to = prefix->to(); 2928 RawObject** to = prefix->to();
2926 for (RawObject** p = from; p <= to; p++) { 2929 for (RawObject** p = from; p <= to_snapshot; p++) {
2927 *p = d->ReadRef(); 2930 *p = d->ReadRef();
2928 } 2931 }
2932 for (RawObject** p = to_snapshot + 1; p <= to; p++) {
2933 *p = Object::null();
2934 }
2935
2929 prefix->ptr()->num_imports_ = d->Read<uint16_t>(); 2936 prefix->ptr()->num_imports_ = d->Read<uint16_t>();
2930 prefix->ptr()->is_deferred_load_ = d->Read<bool>(); 2937 prefix->ptr()->is_deferred_load_ = d->Read<bool>();
2931 prefix->ptr()->is_loaded_ = !prefix->ptr()->is_deferred_load_; 2938 prefix->ptr()->is_loaded_ = !prefix->ptr()->is_deferred_load_;
2932 } 2939 }
2933 } 2940 }
2934 }; 2941 };
2935 2942
2936 2943
2937 #if !defined(DART_PRECOMPILED_RUNTIME) 2944 #if !defined(DART_PRECOMPILED_RUNTIME)
2938 class TypeSerializationCluster : public SerializationCluster { 2945 class TypeSerializationCluster : public SerializationCluster {
(...skipping 2627 matching lines...) Expand 10 before | Expand all | Expand 10 after
5566 thread_->isolate()->SetupImagePage(data_buffer_, 5573 thread_->isolate()->SetupImagePage(data_buffer_,
5567 /* is_executable */ false); 5574 /* is_executable */ false);
5568 } 5575 }
5569 5576
5570 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store()); 5577 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store());
5571 5578
5572 return ApiError::null(); 5579 return ApiError::null();
5573 } 5580 }
5574 5581
5575 } // namespace dart 5582 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698