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

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

Issue 1329503002: Changes to prepare for allowing script snapshots to be taken after running the main application (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-comments Created 5 years, 3 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 | « runtime/vm/raw_object.h ('k') | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 #include "vm/object_store.h" 6 #include "vm/object_store.h"
7 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
8 #include "vm/stub_code.h" 8 #include "vm/stub_code.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
11 11
12 namespace dart { 12 namespace dart {
13 13
14 DECLARE_FLAG(int, optimization_counter_threshold);
15
14 #define NEW_OBJECT(type) \ 16 #define NEW_OBJECT(type) \
15 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) 17 ((kind == Snapshot::kFull) ? reader->New##type() : type::New())
16 18
17 #define NEW_OBJECT_WITH_LEN(type, len) \ 19 #define NEW_OBJECT_WITH_LEN(type, len) \
18 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) 20 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len))
19 21
20 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \ 22 #define NEW_OBJECT_WITH_LEN_SPACE(type, len, kind) \
21 ((kind == Snapshot::kFull) ? \ 23 ((kind == Snapshot::kFull) ? \
22 reader->New##type(len) : type::New(len, HEAP_SPACE(kind))) 24 reader->New##type(len) : type::New(len, HEAP_SPACE(kind)))
23 25
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 // Write out the serialization header value for this object. 733 // Write out the serialization header value for this object.
732 writer->WriteInlinedObjectHeader(object_id); 734 writer->WriteInlinedObjectHeader(object_id);
733 735
734 // Write out the class and tags information. 736 // Write out the class and tags information.
735 writer->WriteVMIsolateObject(kFunctionCid); 737 writer->WriteVMIsolateObject(kFunctionCid);
736 writer->WriteTags(writer->GetObjectTags(this)); 738 writer->WriteTags(writer->GetObjectTags(this));
737 739
738 // Write out all the non object fields. 740 // Write out all the non object fields.
739 writer->Write<int32_t>(ptr()->token_pos_); 741 writer->Write<int32_t>(ptr()->token_pos_);
740 writer->Write<int32_t>(ptr()->end_token_pos_); 742 writer->Write<int32_t>(ptr()->end_token_pos_);
741 writer->Write<int32_t>(ptr()->usage_counter_); 743 if (Code::IsOptimized(ptr()->instructions_->ptr()->code_)) {
744 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
745 } else {
746 writer->Write<int32_t>(0);
747 }
742 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 748 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
743 writer->Write<int16_t>(ptr()->num_optional_parameters_); 749 writer->Write<int16_t>(ptr()->num_optional_parameters_);
744 writer->Write<int16_t>(ptr()->deoptimization_counter_); 750 writer->Write<int16_t>(ptr()->deoptimization_counter_);
745 writer->Write<uint32_t>(ptr()->kind_tag_); 751 writer->Write<uint32_t>(ptr()->kind_tag_);
746 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 752 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
747 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 753 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
748 754
749 // Write out all the object pointer fields. 755 // Write out all the object pointer fields.
750 SnapshotWriterVisitor visitor(writer); 756 SnapshotWriterVisitor visitor(writer);
751 visitor.VisitPointers(from(), writer->snapshot_code() ? to() 757 visitor.VisitPointers(from(), writer->snapshot_code() ? to()
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 is_in_fullsnapshot); 1033 is_in_fullsnapshot);
1028 // The native resolver and symbolizer are not serialized. 1034 // The native resolver and symbolizer are not serialized.
1029 library.set_native_entry_resolver(NULL); 1035 library.set_native_entry_resolver(NULL);
1030 library.set_native_entry_symbol_resolver(NULL); 1036 library.set_native_entry_symbol_resolver(NULL);
1031 // The cache of loaded scripts is not serialized. 1037 // The cache of loaded scripts is not serialized.
1032 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); 1038 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null());
1033 1039
1034 // Set all the object fields. 1040 // Set all the object fields.
1035 // TODO(5411462): Need to assert No GC can happen here, even though 1041 // TODO(5411462): Need to assert No GC can happen here, even though
1036 // allocations may happen. 1042 // allocations may happen.
1037 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); 1043 RawObject** toobj = (kind == Snapshot::kFull) ?
1044 library.raw()->to() : library.raw()->to_snapshot();
1045 intptr_t num_flds = (toobj - library.raw()->from());
1038 for (intptr_t i = 0; i <= num_flds; i++) { 1046 for (intptr_t i = 0; i <= num_flds; i++) {
1039 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1047 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1040 library.StorePointer((library.raw()->from() + i), 1048 library.StorePointer((library.raw()->from() + i),
1041 reader->PassiveObjectHandle()->raw()); 1049 reader->PassiveObjectHandle()->raw());
1042 } 1050 }
1043 if (kind != Snapshot::kFull) { 1051 if (kind != Snapshot::kFull) {
1052 // The cache of resolved names in library scope is not serialized.
1053 const intptr_t kInitialNameCacheSize = 64;
1054 library.InitResolvedNamesCache(kInitialNameCacheSize);
1044 library.Register(); 1055 library.Register();
1045 } 1056 }
1046 } 1057 }
1047 return library.raw(); 1058 return library.raw();
1048 } 1059 }
1049 1060
1050 1061
1051 void RawLibrary::WriteTo(SnapshotWriter* writer, 1062 void RawLibrary::WriteTo(SnapshotWriter* writer,
1052 intptr_t object_id, 1063 intptr_t object_id,
1053 Snapshot::Kind kind) { 1064 Snapshot::Kind kind) {
(...skipping 25 matching lines...) Expand all
1079 writer->Write<bool>(ptr()->corelib_imported_); 1090 writer->Write<bool>(ptr()->corelib_imported_);
1080 writer->Write<bool>(ptr()->is_dart_scheme_); 1091 writer->Write<bool>(ptr()->is_dart_scheme_);
1081 writer->Write<bool>(ptr()->debuggable_); 1092 writer->Write<bool>(ptr()->debuggable_);
1082 // We do not serialize the native resolver or symbolizer. These need to be 1093 // We do not serialize the native resolver or symbolizer. These need to be
1083 // explicitly set after deserialization. 1094 // explicitly set after deserialization.
1084 // We do not write the loaded_scripts_ cache to the snapshot. It gets 1095 // We do not write the loaded_scripts_ cache to the snapshot. It gets
1085 // set to NULL when reading the library from the snapshot, and will 1096 // set to NULL when reading the library from the snapshot, and will
1086 // be rebuilt lazily. 1097 // be rebuilt lazily.
1087 1098
1088 // Write out all the object pointer fields. 1099 // Write out all the object pointer fields.
1100 RawObject** toobj = (kind == Snapshot::kFull) ? to() : to_snapshot();
1089 SnapshotWriterVisitor visitor(writer); 1101 SnapshotWriterVisitor visitor(writer);
1090 visitor.VisitPointers(from(), to()); 1102 visitor.VisitPointers(from(), toobj);
1091 } 1103 }
1092 } 1104 }
1093 1105
1094 1106
1095 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 1107 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
1096 intptr_t object_id, 1108 intptr_t object_id,
1097 intptr_t tags, 1109 intptr_t tags,
1098 Snapshot::Kind kind) { 1110 Snapshot::Kind kind) {
1099 ASSERT(reader != NULL); 1111 ASSERT(reader != NULL);
1100 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1112 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 2204 matching lines...) Expand 10 before | Expand all | Expand 10 after
3305 // We do not allow objects with native fields in an isolate message. 3317 // We do not allow objects with native fields in an isolate message.
3306 writer->SetWriteException(Exceptions::kArgument, 3318 writer->SetWriteException(Exceptions::kArgument,
3307 "Illegal argument in isolate message" 3319 "Illegal argument in isolate message"
3308 " : (object is a UserTag)"); 3320 " : (object is a UserTag)");
3309 } else { 3321 } else {
3310 UNREACHABLE(); 3322 UNREACHABLE();
3311 } 3323 }
3312 } 3324 }
3313 3325
3314 } // namespace dart 3326 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698