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

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

Issue 1644793002: Replace intptr_t with TokenDescriptor (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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') | runtime/vm/regexp.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) 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/native_entry.h" 5 #include "vm/native_entry.h"
6 #include "vm/object.h" 6 #include "vm/object.h"
7 #include "vm/object_store.h" 7 #include "vm/object_store.h"
8 #include "vm/snapshot.h" 8 #include "vm/snapshot.h"
9 #include "vm/stub_code.h" 9 #include "vm/stub_code.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 // Set all non object fields. 70 // Set all non object fields.
71 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 71 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
72 // Instance size of a VM defined class is already set up. 72 // Instance size of a VM defined class is already set up.
73 cls.set_instance_size_in_words(reader->Read<int32_t>()); 73 cls.set_instance_size_in_words(reader->Read<int32_t>());
74 cls.set_next_field_offset_in_words(reader->Read<int32_t>()); 74 cls.set_next_field_offset_in_words(reader->Read<int32_t>());
75 } 75 }
76 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>()); 76 cls.set_type_arguments_field_offset_in_words(reader->Read<int32_t>());
77 cls.set_num_type_arguments(reader->Read<int16_t>()); 77 cls.set_num_type_arguments(reader->Read<int16_t>());
78 cls.set_num_own_type_arguments(reader->Read<int16_t>()); 78 cls.set_num_own_type_arguments(reader->Read<int16_t>());
79 cls.set_num_native_fields(reader->Read<uint16_t>()); 79 cls.set_num_native_fields(reader->Read<uint16_t>());
80 cls.set_token_pos(reader->Read<int32_t>()); 80 cls.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
81 cls.set_state_bits(reader->Read<uint16_t>()); 81 cls.set_state_bits(reader->Read<uint16_t>());
82 82
83 // Set all the object fields. 83 // Set all the object fields.
84 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference); 84 READ_OBJECT_FIELDS(cls, cls.raw()->from(), cls.raw()->to(), kAsReference);
85 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull)); 85 ASSERT(!cls.IsInFullSnapshot() || (kind == Snapshot::kFull));
86 } else { 86 } else {
87 cls ^= reader->ReadClassId(object_id); 87 cls ^= reader->ReadClassId(object_id);
88 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot()); 88 ASSERT((kind == Snapshot::kMessage) || cls.IsInFullSnapshot());
89 } 89 }
90 return cls.raw(); 90 return cls.raw();
(...skipping 29 matching lines...) Expand all
120 // We don't write the instance size of VM defined classes as they 120 // We don't write the instance size of VM defined classes as they
121 // are already setup during initialization as part of pre populating 121 // are already setup during initialization as part of pre populating
122 // the class table. 122 // the class table.
123 writer->Write<int32_t>(ptr()->instance_size_in_words_); 123 writer->Write<int32_t>(ptr()->instance_size_in_words_);
124 writer->Write<int32_t>(ptr()->next_field_offset_in_words_); 124 writer->Write<int32_t>(ptr()->next_field_offset_in_words_);
125 } 125 }
126 writer->Write<int32_t>(ptr()->type_arguments_field_offset_in_words_); 126 writer->Write<int32_t>(ptr()->type_arguments_field_offset_in_words_);
127 writer->Write<uint16_t>(ptr()->num_type_arguments_); 127 writer->Write<uint16_t>(ptr()->num_type_arguments_);
128 writer->Write<uint16_t>(ptr()->num_own_type_arguments_); 128 writer->Write<uint16_t>(ptr()->num_own_type_arguments_);
129 writer->Write<uint16_t>(ptr()->num_native_fields_); 129 writer->Write<uint16_t>(ptr()->num_native_fields_);
130 writer->Write<int32_t>(ptr()->token_pos_); 130 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
131 writer->Write<uint16_t>(ptr()->state_bits_); 131 writer->Write<uint16_t>(ptr()->state_bits_);
132 132
133 // Write out all the object pointer fields. 133 // Write out all the object pointer fields.
134 SnapshotWriterVisitor visitor(writer, kAsReference); 134 SnapshotWriterVisitor visitor(writer, kAsReference);
135 visitor.VisitPointers(from(), to()); 135 visitor.VisitPointers(from(), to());
136 } else { 136 } else {
137 if (writer->can_send_any_object() || 137 if (writer->can_send_any_object() ||
138 writer->AllowObjectsInDartLibrary(ptr()->library_)) { 138 writer->AllowObjectsInDartLibrary(ptr()->library_)) {
139 writer->WriteClassId(this); 139 writer->WriteClassId(this);
140 } else { 140 } else {
(...skipping 12 matching lines...) Expand all
153 Snapshot::Kind kind, 153 Snapshot::Kind kind,
154 bool as_reference) { 154 bool as_reference) {
155 ASSERT(reader != NULL); 155 ASSERT(reader != NULL);
156 156
157 // Allocate unresolved class object. 157 // Allocate unresolved class object.
158 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle( 158 UnresolvedClass& unresolved_class = UnresolvedClass::ZoneHandle(
159 reader->zone(), NEW_OBJECT(UnresolvedClass)); 159 reader->zone(), NEW_OBJECT(UnresolvedClass));
160 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized); 160 reader->AddBackRef(object_id, &unresolved_class, kIsDeserialized);
161 161
162 // Set all non object fields. 162 // Set all non object fields.
163 unresolved_class.set_token_pos(reader->Read<int32_t>()); 163 unresolved_class.set_token_pos(
164 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
164 165
165 // Set all the object fields. 166 // Set all the object fields.
166 READ_OBJECT_FIELDS(unresolved_class, 167 READ_OBJECT_FIELDS(unresolved_class,
167 unresolved_class.raw()->from(), 168 unresolved_class.raw()->from(),
168 unresolved_class.raw()->to(), 169 unresolved_class.raw()->to(),
169 kAsReference); 170 kAsReference);
170 171
171 return unresolved_class.raw(); 172 return unresolved_class.raw();
172 } 173 }
173 174
174 175
175 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, 176 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer,
176 intptr_t object_id, 177 intptr_t object_id,
177 Snapshot::Kind kind, 178 Snapshot::Kind kind,
178 bool as_reference) { 179 bool as_reference) {
179 ASSERT(writer != NULL); 180 ASSERT(writer != NULL);
180 181
181 // Write out the serialization header value for this object. 182 // Write out the serialization header value for this object.
182 writer->WriteInlinedObjectHeader(object_id); 183 writer->WriteInlinedObjectHeader(object_id);
183 184
184 // Write out the class and tags information. 185 // Write out the class and tags information.
185 writer->WriteVMIsolateObject(kUnresolvedClassCid); 186 writer->WriteVMIsolateObject(kUnresolvedClassCid);
186 writer->WriteTags(writer->GetObjectTags(this)); 187 writer->WriteTags(writer->GetObjectTags(this));
187 188
188 // Write out all the non object pointer fields. 189 // Write out all the non object pointer fields.
189 writer->Write<int32_t>(ptr()->token_pos_); 190 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
190 191
191 // Write out all the object pointer fields. 192 // Write out all the object pointer fields.
192 SnapshotWriterVisitor visitor(writer, kAsReference); 193 SnapshotWriterVisitor visitor(writer, kAsReference);
193 visitor.VisitPointers(from(), to()); 194 visitor.VisitPointers(from(), to());
194 } 195 }
195 196
196 197
197 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader, 198 RawAbstractType* AbstractType::ReadFrom(SnapshotReader* reader,
198 intptr_t object_id, 199 intptr_t object_id,
199 intptr_t tags, 200 intptr_t tags,
(...skipping 23 matching lines...) Expand all
223 bool typeclass_is_in_fullsnapshot = reader->Read<bool>(); 224 bool typeclass_is_in_fullsnapshot = reader->Read<bool>();
224 225
225 // Allocate type object. 226 // Allocate type object.
226 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type)); 227 Type& type = Type::ZoneHandle(reader->zone(), NEW_OBJECT(Type));
227 bool is_canonical = RawObject::IsCanonical(tags); 228 bool is_canonical = RawObject::IsCanonical(tags);
228 bool defer_canonicalization = is_canonical && 229 bool defer_canonicalization = is_canonical &&
229 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot); 230 (kind != Snapshot::kFull && typeclass_is_in_fullsnapshot);
230 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization); 231 reader->AddBackRef(object_id, &type, kIsDeserialized, defer_canonicalization);
231 232
232 // Set all non object fields. 233 // Set all non object fields.
233 type.set_token_pos(reader->Read<int32_t>()); 234 type.set_token_pos(TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
234 type.set_type_state(reader->Read<int8_t>()); 235 type.set_type_state(reader->Read<int8_t>());
235 236
236 // Set all the object fields. 237 // Set all the object fields.
237 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference); 238 READ_OBJECT_FIELDS(type, type.raw()->from(), type.raw()->to(), kAsReference);
238 239
239 // Set the canonical bit. 240 // Set the canonical bit.
240 if (!defer_canonicalization && is_canonical) { 241 if (!defer_canonicalization && is_canonical) {
241 type.SetCanonical(); 242 type.SetCanonical();
242 } 243 }
243 244
(...skipping 21 matching lines...) Expand all
265 266
266 // Write out typeclass_is_in_fullsnapshot first as this will 267 // Write out typeclass_is_in_fullsnapshot first as this will
267 // help the reader decide on how to canonicalize the type object. 268 // help the reader decide on how to canonicalize the type object.
268 intptr_t tags = writer->GetObjectTags(ptr()->type_class_); 269 intptr_t tags = writer->GetObjectTags(ptr()->type_class_);
269 bool typeclass_is_in_fullsnapshot = 270 bool typeclass_is_in_fullsnapshot =
270 (ClassIdTag::decode(tags) == kClassCid) && 271 (ClassIdTag::decode(tags) == kClassCid) &&
271 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->type_class_)); 272 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->type_class_));
272 writer->Write<bool>(typeclass_is_in_fullsnapshot); 273 writer->Write<bool>(typeclass_is_in_fullsnapshot);
273 274
274 // Write out all the non object pointer fields. 275 // Write out all the non object pointer fields.
275 writer->Write<int32_t>(ptr()->token_pos_); 276 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
276 writer->Write<int8_t>(ptr()->type_state_); 277 writer->Write<int8_t>(ptr()->type_state_);
277 278
278 // Write out all the object pointer fields. 279 // Write out all the object pointer fields.
279 ASSERT(ptr()->type_class_ != Object::null()); 280 ASSERT(ptr()->type_class_ != Object::null());
280 SnapshotWriterVisitor visitor(writer, kAsReference); 281 SnapshotWriterVisitor visitor(writer, kAsReference);
281 visitor.VisitPointers(from(), to()); 282 visitor.VisitPointers(from(), to());
282 } 283 }
283 284
284 285
285 RawFunctionType* FunctionType::ReadFrom(SnapshotReader* reader, 286 RawFunctionType* FunctionType::ReadFrom(SnapshotReader* reader,
(...skipping 11 matching lines...) Expand all
297 FunctionType::ZoneHandle(reader->zone(), NEW_OBJECT(FunctionType)); 298 FunctionType::ZoneHandle(reader->zone(), NEW_OBJECT(FunctionType));
298 bool is_canonical = RawObject::IsCanonical(tags); 299 bool is_canonical = RawObject::IsCanonical(tags);
299 bool defer_canonicalization = is_canonical && 300 bool defer_canonicalization = is_canonical &&
300 (kind != Snapshot::kFull && scopeclass_is_in_fullsnapshot); 301 (kind != Snapshot::kFull && scopeclass_is_in_fullsnapshot);
301 reader->AddBackRef(object_id, 302 reader->AddBackRef(object_id,
302 &function_type, 303 &function_type,
303 kIsDeserialized, 304 kIsDeserialized,
304 defer_canonicalization); 305 defer_canonicalization);
305 306
306 // Set all non object fields. 307 // Set all non object fields.
307 function_type.set_token_pos(reader->Read<int32_t>()); 308 function_type.set_token_pos(
309 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
308 function_type.set_type_state(reader->Read<int8_t>()); 310 function_type.set_type_state(reader->Read<int8_t>());
309 311
310 // Set all the object fields. 312 // Set all the object fields.
311 READ_OBJECT_FIELDS(function_type, 313 READ_OBJECT_FIELDS(function_type,
312 function_type.raw()->from(), function_type.raw()->to(), 314 function_type.raw()->from(), function_type.raw()->to(),
313 kAsReference); 315 kAsReference);
314 316
315 // Set the canonical bit. 317 // Set the canonical bit.
316 if (!defer_canonicalization && is_canonical) { 318 if (!defer_canonicalization && is_canonical) {
317 function_type.SetCanonical(); 319 function_type.SetCanonical();
(...skipping 23 matching lines...) Expand all
341 343
342 // Write out scopeclass_is_in_fullsnapshot first as this will 344 // Write out scopeclass_is_in_fullsnapshot first as this will
343 // help the reader decide on how to canonicalize the type object. 345 // help the reader decide on how to canonicalize the type object.
344 intptr_t tags = writer->GetObjectTags(ptr()->scope_class_); 346 intptr_t tags = writer->GetObjectTags(ptr()->scope_class_);
345 bool scopeclass_is_in_fullsnapshot = 347 bool scopeclass_is_in_fullsnapshot =
346 (ClassIdTag::decode(tags) == kClassCid) && 348 (ClassIdTag::decode(tags) == kClassCid) &&
347 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->scope_class_)); 349 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->scope_class_));
348 writer->Write<bool>(scopeclass_is_in_fullsnapshot); 350 writer->Write<bool>(scopeclass_is_in_fullsnapshot);
349 351
350 // Write out all the non object pointer fields. 352 // Write out all the non object pointer fields.
351 writer->Write<int32_t>(ptr()->token_pos_); 353 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
352 writer->Write<int8_t>(ptr()->type_state_); 354 writer->Write<int8_t>(ptr()->type_state_);
353 355
354 // Write out all the object pointer fields. 356 // Write out all the object pointer fields.
355 ASSERT(ptr()->scope_class_ != Object::null()); 357 ASSERT(ptr()->scope_class_ != Object::null());
356 SnapshotWriterVisitor visitor(writer, kAsReference); 358 SnapshotWriterVisitor visitor(writer, kAsReference);
357 visitor.VisitPointers(from(), to()); 359 visitor.VisitPointers(from(), to());
358 } 360 }
359 361
360 362
361 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader, 363 RawTypeRef* TypeRef::ReadFrom(SnapshotReader* reader,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 Snapshot::Kind kind, 406 Snapshot::Kind kind,
405 bool as_reference) { 407 bool as_reference) {
406 ASSERT(reader != NULL); 408 ASSERT(reader != NULL);
407 409
408 // Allocate type parameter object. 410 // Allocate type parameter object.
409 TypeParameter& type_parameter = TypeParameter::ZoneHandle( 411 TypeParameter& type_parameter = TypeParameter::ZoneHandle(
410 reader->zone(), NEW_OBJECT(TypeParameter)); 412 reader->zone(), NEW_OBJECT(TypeParameter));
411 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized); 413 reader->AddBackRef(object_id, &type_parameter, kIsDeserialized);
412 414
413 // Set all non object fields. 415 // Set all non object fields.
414 type_parameter.set_token_pos(reader->Read<int32_t>()); 416 type_parameter.set_token_pos(
417 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
415 type_parameter.set_index(reader->Read<int16_t>()); 418 type_parameter.set_index(reader->Read<int16_t>());
416 type_parameter.set_type_state(reader->Read<int8_t>()); 419 type_parameter.set_type_state(reader->Read<int8_t>());
417 420
418 // Set all the object fields. 421 // Set all the object fields.
419 READ_OBJECT_FIELDS(type_parameter, 422 READ_OBJECT_FIELDS(type_parameter,
420 type_parameter.raw()->from(), type_parameter.raw()->to(), 423 type_parameter.raw()->from(), type_parameter.raw()->to(),
421 kAsReference); 424 kAsReference);
422 425
423 return type_parameter.raw(); 426 return type_parameter.raw();
424 } 427 }
425 428
426 429
427 void RawTypeParameter::WriteTo(SnapshotWriter* writer, 430 void RawTypeParameter::WriteTo(SnapshotWriter* writer,
428 intptr_t object_id, 431 intptr_t object_id,
429 Snapshot::Kind kind, 432 Snapshot::Kind kind,
430 bool as_reference) { 433 bool as_reference) {
431 ASSERT(writer != NULL); 434 ASSERT(writer != NULL);
432 435
433 // Only finalized type parameters should be written to a snapshot. 436 // Only finalized type parameters should be written to a snapshot.
434 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated); 437 ASSERT(ptr()->type_state_ == RawTypeParameter::kFinalizedUninstantiated);
435 438
436 // Write out the serialization header value for this object. 439 // Write out the serialization header value for this object.
437 writer->WriteInlinedObjectHeader(object_id); 440 writer->WriteInlinedObjectHeader(object_id);
438 441
439 // Write out the class and tags information. 442 // Write out the class and tags information.
440 writer->WriteIndexedObject(kTypeParameterCid); 443 writer->WriteIndexedObject(kTypeParameterCid);
441 writer->WriteTags(writer->GetObjectTags(this)); 444 writer->WriteTags(writer->GetObjectTags(this));
442 445
443 // Write out all the non object pointer fields. 446 // Write out all the non object pointer fields.
444 writer->Write<int32_t>(ptr()->token_pos_); 447 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
445 writer->Write<int16_t>(ptr()->index_); 448 writer->Write<int16_t>(ptr()->index_);
446 writer->Write<int8_t>(ptr()->type_state_); 449 writer->Write<int8_t>(ptr()->type_state_);
447 450
448 // Write out all the object pointer fields. 451 // Write out all the object pointer fields.
449 SnapshotWriterVisitor visitor(writer, kAsReference); 452 SnapshotWriterVisitor visitor(writer, kAsReference);
450 visitor.VisitPointers(from(), to()); 453 visitor.VisitPointers(from(), to());
451 } 454 }
452 455
453 456
454 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader, 457 RawBoundedType* BoundedType::ReadFrom(SnapshotReader* reader,
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 reader->zone(), NEW_OBJECT(Function)); 793 reader->zone(), NEW_OBJECT(Function));
791 reader->AddBackRef(object_id, &func, kIsDeserialized); 794 reader->AddBackRef(object_id, &func, kIsDeserialized);
792 795
793 // Set all the non object fields. Read the token positions now but 796 // Set all the non object fields. Read the token positions now but
794 // don't set them until after setting the kind. 797 // don't set them until after setting the kind.
795 const int32_t token_pos = reader->Read<int32_t>(); 798 const int32_t token_pos = reader->Read<int32_t>();
796 const int32_t end_token_pos = reader->Read<uint32_t>(); 799 const int32_t end_token_pos = reader->Read<uint32_t>();
797 func.set_num_fixed_parameters(reader->Read<int16_t>()); 800 func.set_num_fixed_parameters(reader->Read<int16_t>());
798 func.set_num_optional_parameters(reader->Read<int16_t>()); 801 func.set_num_optional_parameters(reader->Read<int16_t>());
799 func.set_kind_tag(reader->Read<uint32_t>()); 802 func.set_kind_tag(reader->Read<uint32_t>());
800 func.set_token_pos(token_pos); 803 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos));
801 func.set_end_token_pos(end_token_pos); 804 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos));
802 if (reader->snapshot_code()) { 805 if (reader->snapshot_code()) {
803 func.set_usage_counter(0); 806 func.set_usage_counter(0);
804 func.set_deoptimization_counter(0); 807 func.set_deoptimization_counter(0);
805 func.set_optimized_instruction_count(0); 808 func.set_optimized_instruction_count(0);
806 func.set_optimized_call_site_count(0); 809 func.set_optimized_call_site_count(0);
807 } else { 810 } else {
808 func.set_usage_counter(reader->Read<int32_t>()); 811 func.set_usage_counter(reader->Read<int32_t>());
809 func.set_deoptimization_counter(reader->Read<int16_t>()); 812 func.set_deoptimization_counter(reader->Read<int16_t>());
810 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 813 func.set_optimized_instruction_count(reader->Read<uint16_t>());
811 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 814 func.set_optimized_call_site_count(reader->Read<uint16_t>());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 870
868 // Write out the boolean is_in_fullsnapshot first as this will 871 // Write out the boolean is_in_fullsnapshot first as this will
869 // help the reader decide how the rest of the information needs 872 // help the reader decide how the rest of the information needs
870 // to be interpreted. 873 // to be interpreted.
871 writer->Write<bool>(is_in_fullsnapshot); 874 writer->Write<bool>(is_in_fullsnapshot);
872 875
873 if (kind == Snapshot::kFull || !is_in_fullsnapshot) { 876 if (kind == Snapshot::kFull || !is_in_fullsnapshot) {
874 bool is_optimized = Code::IsOptimized(ptr()->code_); 877 bool is_optimized = Code::IsOptimized(ptr()->code_);
875 878
876 // Write out all the non object fields. 879 // Write out all the non object fields.
877 writer->Write<int32_t>(ptr()->token_pos_); 880 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
878 writer->Write<int32_t>(ptr()->end_token_pos_); 881 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode());
879 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 882 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
880 writer->Write<int16_t>(ptr()->num_optional_parameters_); 883 writer->Write<int16_t>(ptr()->num_optional_parameters_);
881 writer->Write<uint32_t>(ptr()->kind_tag_); 884 writer->Write<uint32_t>(ptr()->kind_tag_);
882 if (writer->snapshot_code()) { 885 if (writer->snapshot_code()) {
883 // Omit fields used to support de/reoptimization. 886 // Omit fields used to support de/reoptimization.
884 } else { 887 } else {
885 if (is_optimized) { 888 if (is_optimized) {
886 writer->Write<int32_t>(FLAG_optimization_counter_threshold); 889 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
887 } else { 890 } else {
888 writer->Write<int32_t>(0); 891 writer->Write<int32_t>(0);
(...skipping 30 matching lines...) Expand all
919 bool as_reference) { 922 bool as_reference) {
920 ASSERT(reader != NULL); 923 ASSERT(reader != NULL);
921 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 924 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
922 925
923 // Allocate field object. 926 // Allocate field object.
924 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field)); 927 Field& field = Field::ZoneHandle(reader->zone(), NEW_OBJECT(Field));
925 reader->AddBackRef(object_id, &field, kIsDeserialized); 928 reader->AddBackRef(object_id, &field, kIsDeserialized);
926 929
927 // Set all non object fields. 930 // Set all non object fields.
928 if (reader->snapshot_code()) { 931 if (reader->snapshot_code()) {
929 field.set_token_pos(0); 932 field.set_token_pos(TokenPosition::kNoSource);
930 ASSERT(!FLAG_use_field_guards); 933 ASSERT(!FLAG_use_field_guards);
931 field.set_guarded_cid(kDynamicCid); 934 field.set_guarded_cid(kDynamicCid);
932 field.set_is_nullable(true); 935 field.set_is_nullable(true);
933 } else { 936 } else {
934 field.set_token_pos(reader->Read<int32_t>()); 937 field.set_token_pos(
938 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
935 field.set_guarded_cid(reader->Read<int32_t>()); 939 field.set_guarded_cid(reader->Read<int32_t>());
936 field.set_is_nullable(reader->Read<int32_t>()); 940 field.set_is_nullable(reader->Read<int32_t>());
937 } 941 }
938 field.set_kind_bits(reader->Read<uint8_t>()); 942 field.set_kind_bits(reader->Read<uint8_t>());
939 943
940 // Set all the object fields. 944 // Set all the object fields.
941 RawObject** toobj = reader->snapshot_code() 945 RawObject** toobj = reader->snapshot_code()
942 ? field.raw()->to_precompiled_snapshot() 946 ? field.raw()->to_precompiled_snapshot()
943 : field.raw()->to(); 947 : field.raw()->to();
944 READ_OBJECT_FIELDS(field, 948 READ_OBJECT_FIELDS(field,
(...skipping 21 matching lines...) Expand all
966 970
967 // Write out the serialization header value for this object. 971 // Write out the serialization header value for this object.
968 writer->WriteInlinedObjectHeader(object_id); 972 writer->WriteInlinedObjectHeader(object_id);
969 973
970 // Write out the class and tags information. 974 // Write out the class and tags information.
971 writer->WriteVMIsolateObject(kFieldCid); 975 writer->WriteVMIsolateObject(kFieldCid);
972 writer->WriteTags(writer->GetObjectTags(this)); 976 writer->WriteTags(writer->GetObjectTags(this));
973 977
974 // Write out all the non object fields. 978 // Write out all the non object fields.
975 if (!writer->snapshot_code()) { 979 if (!writer->snapshot_code()) {
976 writer->Write<int32_t>(ptr()->token_pos_); 980 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
977 writer->Write<int32_t>(ptr()->guarded_cid_); 981 writer->Write<int32_t>(ptr()->guarded_cid_);
978 writer->Write<int32_t>(ptr()->is_nullable_); 982 writer->Write<int32_t>(ptr()->is_nullable_);
979 } 983 }
980 writer->Write<uint8_t>(ptr()->kind_bits_); 984 writer->Write<uint8_t>(ptr()->kind_bits_);
981 985
982 // Write out the name. 986 // Write out the name.
983 writer->WriteObjectImpl(ptr()->name_, kAsReference); 987 writer->WriteObjectImpl(ptr()->name_, kAsReference);
984 // Write out the owner. 988 // Write out the owner.
985 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 989 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
986 // Write out the type. 990 // Write out the type.
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 context_scope = reader->NewContextScope(1); 1957 context_scope = reader->NewContextScope(1);
1954 context_scope.set_is_implicit(true); 1958 context_scope.set_is_implicit(true);
1955 } else { 1959 } else {
1956 context_scope = ContextScope::New(1, true); 1960 context_scope = ContextScope::New(1, true);
1957 } 1961 }
1958 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); 1962 reader->AddBackRef(object_id, &context_scope, kIsDeserialized);
1959 1963
1960 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); 1964 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject);
1961 1965
1962 // Create a descriptor for 'this' variable. 1966 // Create a descriptor for 'this' variable.
1963 context_scope.SetTokenIndexAt(0, 0); 1967 context_scope.SetTokenIndexAt(0, TokenPosition::kMinSource);
1964 context_scope.SetNameAt(0, Symbols::This()); 1968 context_scope.SetNameAt(0, Symbols::This());
1965 context_scope.SetIsFinalAt(0, true); 1969 context_scope.SetIsFinalAt(0, true);
1966 context_scope.SetIsConstAt(0, false); 1970 context_scope.SetIsConstAt(0, false);
1967 context_scope.SetTypeAt(0, *reader->TypeHandle()); 1971 context_scope.SetTypeAt(0, *reader->TypeHandle());
1968 context_scope.SetContextIndexAt(0, 0); 1972 context_scope.SetContextIndexAt(0, 0);
1969 context_scope.SetContextLevelAt(0, 0); 1973 context_scope.SetContextLevelAt(0, 0);
1970 return context_scope.raw(); 1974 return context_scope.raw();
1971 } 1975 }
1972 UNREACHABLE(); 1976 UNREACHABLE();
1973 return NULL; 1977 return NULL;
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 Snapshot::Kind kind, 2206 Snapshot::Kind kind,
2203 bool as_reference) { 2207 bool as_reference) {
2204 ASSERT(reader != NULL); 2208 ASSERT(reader != NULL);
2205 2209
2206 // Allocate LanguageError object. 2210 // Allocate LanguageError object.
2207 LanguageError& language_error = 2211 LanguageError& language_error =
2208 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError)); 2212 LanguageError::ZoneHandle(reader->zone(), NEW_OBJECT(LanguageError));
2209 reader->AddBackRef(object_id, &language_error, kIsDeserialized); 2213 reader->AddBackRef(object_id, &language_error, kIsDeserialized);
2210 2214
2211 // Set all non object fields. 2215 // Set all non object fields.
2212 language_error.set_token_pos(reader->Read<int32_t>()); 2216 language_error.set_token_pos(
2217 TokenPosition::SnapshotDecode(reader->Read<int32_t>()));
2213 language_error.set_report_after_token(reader->Read<bool>()); 2218 language_error.set_report_after_token(reader->Read<bool>());
2214 language_error.set_kind(reader->Read<uint8_t>()); 2219 language_error.set_kind(reader->Read<uint8_t>());
2215 2220
2216 // Set all the object fields. 2221 // Set all the object fields.
2217 READ_OBJECT_FIELDS(language_error, 2222 READ_OBJECT_FIELDS(language_error,
2218 language_error.raw()->from(), language_error.raw()->to(), 2223 language_error.raw()->from(), language_error.raw()->to(),
2219 kAsReference); 2224 kAsReference);
2220 2225
2221 return language_error.raw(); 2226 return language_error.raw();
2222 } 2227 }
2223 2228
2224 2229
2225 void RawLanguageError::WriteTo(SnapshotWriter* writer, 2230 void RawLanguageError::WriteTo(SnapshotWriter* writer,
2226 intptr_t object_id, 2231 intptr_t object_id,
2227 Snapshot::Kind kind, 2232 Snapshot::Kind kind,
2228 bool as_reference) { 2233 bool as_reference) {
2229 ASSERT(writer != NULL); 2234 ASSERT(writer != NULL);
2230 2235
2231 // Write out the serialization header value for this object. 2236 // Write out the serialization header value for this object.
2232 writer->WriteInlinedObjectHeader(object_id); 2237 writer->WriteInlinedObjectHeader(object_id);
2233 2238
2234 // Write out the class and tags information. 2239 // Write out the class and tags information.
2235 writer->WriteVMIsolateObject(kLanguageErrorCid); 2240 writer->WriteVMIsolateObject(kLanguageErrorCid);
2236 writer->WriteTags(writer->GetObjectTags(this)); 2241 writer->WriteTags(writer->GetObjectTags(this));
2237 2242
2238 // Write out all the non object fields. 2243 // Write out all the non object fields.
2239 writer->Write<int32_t>(ptr()->token_pos_); 2244 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
2240 writer->Write<bool>(ptr()->report_after_token_); 2245 writer->Write<bool>(ptr()->report_after_token_);
2241 writer->Write<uint8_t>(ptr()->kind_); 2246 writer->Write<uint8_t>(ptr()->kind_);
2242 2247
2243 // Write out all the object pointer fields. 2248 // Write out all the object pointer fields.
2244 SnapshotWriterVisitor visitor(writer, kAsReference); 2249 SnapshotWriterVisitor visitor(writer, kAsReference);
2245 visitor.VisitPointers(from(), to()); 2250 visitor.VisitPointers(from(), to());
2246 } 2251 }
2247 2252
2248 2253
2249 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, 2254 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
3687 // We do not allow objects with native fields in an isolate message. 3692 // We do not allow objects with native fields in an isolate message.
3688 writer->SetWriteException(Exceptions::kArgument, 3693 writer->SetWriteException(Exceptions::kArgument,
3689 "Illegal argument in isolate message" 3694 "Illegal argument in isolate message"
3690 " : (object is a UserTag)"); 3695 " : (object is a UserTag)");
3691 } else { 3696 } else {
3692 UNREACHABLE(); 3697 UNREACHABLE();
3693 } 3698 }
3694 } 3699 }
3695 3700
3696 } // namespace dart 3701 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698