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

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: self-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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 // Write out the serialization header value for this object. 723 // Write out the serialization header value for this object.
722 writer->WriteInlinedObjectHeader(object_id); 724 writer->WriteInlinedObjectHeader(object_id);
723 725
724 // Write out the class and tags information. 726 // Write out the class and tags information.
725 writer->WriteVMIsolateObject(kFunctionCid); 727 writer->WriteVMIsolateObject(kFunctionCid);
726 writer->WriteTags(writer->GetObjectTags(this)); 728 writer->WriteTags(writer->GetObjectTags(this));
727 729
728 // Write out all the non object fields. 730 // Write out all the non object fields.
729 writer->Write<int32_t>(ptr()->token_pos_); 731 writer->Write<int32_t>(ptr()->token_pos_);
730 writer->Write<int32_t>(ptr()->end_token_pos_); 732 writer->Write<int32_t>(ptr()->end_token_pos_);
731 writer->Write<int32_t>(ptr()->usage_counter_); 733 if (Code::IsOptimized(ptr()->instructions_->ptr()->code_)) {
srdjan 2015/08/31 22:17:18 Why are you not doing: ptr()->instructions_->ptr(
siva 2015/08/31 23:00:19 This is better, I changed the code.
siva 2015/08/31 23:14:27 Actually I take that back, the reason I did that w
734 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
hausner 2015/08/31 22:36:48 Can the snapshot be written in a VM instance where
siva 2015/08/31 23:00:19 Discussed offline with Srdjan, there should not be
735 } else {
736 writer->Write<int32_t>(0);
737 }
732 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 738 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
733 writer->Write<int16_t>(ptr()->num_optional_parameters_); 739 writer->Write<int16_t>(ptr()->num_optional_parameters_);
734 writer->Write<int16_t>(ptr()->deoptimization_counter_); 740 writer->Write<int16_t>(ptr()->deoptimization_counter_);
735 writer->Write<uint32_t>(ptr()->kind_tag_); 741 writer->Write<uint32_t>(ptr()->kind_tag_);
736 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 742 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
737 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 743 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
738 744
739 // Write out all the object pointer fields. 745 // Write out all the object pointer fields.
740 SnapshotWriterVisitor visitor(writer); 746 SnapshotWriterVisitor visitor(writer);
741 visitor.VisitPointers(from(), writer->snapshot_code() ? to() 747 visitor.VisitPointers(from(), writer->snapshot_code() ? to()
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 is_in_fullsnapshot); 1023 is_in_fullsnapshot);
1018 // The native resolver and symbolizer are not serialized. 1024 // The native resolver and symbolizer are not serialized.
1019 library.set_native_entry_resolver(NULL); 1025 library.set_native_entry_resolver(NULL);
1020 library.set_native_entry_symbol_resolver(NULL); 1026 library.set_native_entry_symbol_resolver(NULL);
1021 // The cache of loaded scripts is not serialized. 1027 // The cache of loaded scripts is not serialized.
1022 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); 1028 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null());
1023 1029
1024 // Set all the object fields. 1030 // Set all the object fields.
1025 // TODO(5411462): Need to assert No GC can happen here, even though 1031 // TODO(5411462): Need to assert No GC can happen here, even though
1026 // allocations may happen. 1032 // allocations may happen.
1027 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); 1033 RawObject** toobj = (kind == Snapshot::kFull) ?
1034 library.raw()->to() : library.raw()->to_snapshot();
1035 intptr_t num_flds = (toobj - library.raw()->from());
1028 for (intptr_t i = 0; i <= num_flds; i++) { 1036 for (intptr_t i = 0; i <= num_flds; i++) {
1029 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); 1037 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference);
1030 library.StorePointer((library.raw()->from() + i), 1038 library.StorePointer((library.raw()->from() + i),
1031 reader->PassiveObjectHandle()->raw()); 1039 reader->PassiveObjectHandle()->raw());
1032 } 1040 }
1033 if (kind != Snapshot::kFull) { 1041 if (kind != Snapshot::kFull) {
1042 // The cache of resolved names in library scope is not serialized.
1043 const intptr_t kInitialNameCacheSize = 64;
1044 library.InitResolvedNamesCache(kInitialNameCacheSize);
1034 library.Register(); 1045 library.Register();
1035 } 1046 }
1036 } 1047 }
1037 return library.raw(); 1048 return library.raw();
1038 } 1049 }
1039 1050
1040 1051
1041 void RawLibrary::WriteTo(SnapshotWriter* writer, 1052 void RawLibrary::WriteTo(SnapshotWriter* writer,
1042 intptr_t object_id, 1053 intptr_t object_id,
1043 Snapshot::Kind kind) { 1054 Snapshot::Kind kind) {
(...skipping 25 matching lines...) Expand all
1069 writer->Write<bool>(ptr()->corelib_imported_); 1080 writer->Write<bool>(ptr()->corelib_imported_);
1070 writer->Write<bool>(ptr()->is_dart_scheme_); 1081 writer->Write<bool>(ptr()->is_dart_scheme_);
1071 writer->Write<bool>(ptr()->debuggable_); 1082 writer->Write<bool>(ptr()->debuggable_);
1072 // We do not serialize the native resolver or symbolizer. These need to be 1083 // We do not serialize the native resolver or symbolizer. These need to be
1073 // explicitly set after deserialization. 1084 // explicitly set after deserialization.
1074 // We do not write the loaded_scripts_ cache to the snapshot. It gets 1085 // We do not write the loaded_scripts_ cache to the snapshot. It gets
1075 // set to NULL when reading the library from the snapshot, and will 1086 // set to NULL when reading the library from the snapshot, and will
1076 // be rebuilt lazily. 1087 // be rebuilt lazily.
1077 1088
1078 // Write out all the object pointer fields. 1089 // Write out all the object pointer fields.
1090 RawObject** toobj = (kind == Snapshot::kFull) ? to() : to_snapshot();
1079 SnapshotWriterVisitor visitor(writer); 1091 SnapshotWriterVisitor visitor(writer);
1080 visitor.VisitPointers(from(), to()); 1092 visitor.VisitPointers(from(), toobj);
1081 } 1093 }
1082 } 1094 }
1083 1095
1084 1096
1085 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 1097 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
1086 intptr_t object_id, 1098 intptr_t object_id,
1087 intptr_t tags, 1099 intptr_t tags,
1088 Snapshot::Kind kind) { 1100 Snapshot::Kind kind) {
1089 ASSERT(reader != NULL); 1101 ASSERT(reader != NULL);
1090 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1102 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 2162 matching lines...) Expand 10 before | Expand all | Expand 10 after
3253 // We do not allow objects with native fields in an isolate message. 3265 // We do not allow objects with native fields in an isolate message.
3254 writer->SetWriteException(Exceptions::kArgument, 3266 writer->SetWriteException(Exceptions::kArgument,
3255 "Illegal argument in isolate message" 3267 "Illegal argument in isolate message"
3256 " : (object is a UserTag)"); 3268 " : (object is a UserTag)");
3257 } else { 3269 } else {
3258 UNREACHABLE(); 3270 UNREACHABLE();
3259 } 3271 }
3260 } 3272 }
3261 3273
3262 } // namespace dart 3274 } // 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