OLD | NEW |
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/bigint_operations.h" | 5 #include "vm/bigint_operations.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/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 return cls.raw(); | 74 return cls.raw(); |
75 } | 75 } |
76 | 76 |
77 | 77 |
78 void RawClass::WriteTo(SnapshotWriter* writer, | 78 void RawClass::WriteTo(SnapshotWriter* writer, |
79 intptr_t object_id, | 79 intptr_t object_id, |
80 Snapshot::Kind kind) { | 80 Snapshot::Kind kind) { |
81 ASSERT(writer != NULL); | 81 ASSERT(writer != NULL); |
82 | 82 |
83 // Write out the serialization header value for this object. | 83 // Write out the serialization header value for this object. |
84 writer->WriteSerializationMarker(kInlined, object_id); | 84 writer->WriteInlinedObjectHeader(object_id); |
85 | 85 |
86 if ((kind == Snapshot::kFull) || | 86 if ((kind == Snapshot::kFull) || |
87 (kind == Snapshot::kScript && | 87 (kind == Snapshot::kScript && |
88 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { | 88 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)))) { |
89 // Write out the class and tags information. | 89 // Write out the class and tags information. |
90 writer->WriteObjectHeader(Object::kClassClass, writer->GetObjectTags(this)); | 90 writer->WriteVMIsolateObject(Object::kClassClass); |
| 91 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
91 | 92 |
92 // Write out all the non object pointer fields. | 93 // Write out all the non object pointer fields. |
93 // NOTE: cpp_vtable_ is not written. | 94 // NOTE: cpp_vtable_ is not written. |
94 writer->Write<ObjectKind>(ptr()->instance_kind_); | 95 writer->Write<ObjectKind>(ptr()->instance_kind_); |
95 writer->WriteIntptrValue(ptr()->instance_size_); | 96 writer->WriteIntptrValue(ptr()->instance_size_); |
96 writer->WriteIntptrValue(ptr()->type_arguments_instance_field_offset_); | 97 writer->WriteIntptrValue(ptr()->type_arguments_instance_field_offset_); |
97 writer->WriteIntptrValue(ptr()->next_field_offset_); | 98 writer->WriteIntptrValue(ptr()->next_field_offset_); |
98 writer->WriteIntptrValue(ptr()->num_native_fields_); | 99 writer->WriteIntptrValue(ptr()->num_native_fields_); |
99 writer->WriteIntptrValue(ptr()->token_pos_); | 100 writer->WriteIntptrValue(ptr()->token_pos_); |
100 writer->Write<int8_t>(ptr()->class_state_); | 101 writer->Write<int8_t>(ptr()->class_state_); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 return unresolved_class.raw(); | 139 return unresolved_class.raw(); |
139 } | 140 } |
140 | 141 |
141 | 142 |
142 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, | 143 void RawUnresolvedClass::WriteTo(SnapshotWriter* writer, |
143 intptr_t object_id, | 144 intptr_t object_id, |
144 Snapshot::Kind kind) { | 145 Snapshot::Kind kind) { |
145 ASSERT(writer != NULL); | 146 ASSERT(writer != NULL); |
146 | 147 |
147 // Write out the serialization header value for this object. | 148 // Write out the serialization header value for this object. |
148 writer->WriteSerializationMarker(kInlined, object_id); | 149 writer->WriteInlinedObjectHeader(object_id); |
149 | 150 |
150 // Write out the class and tags information. | 151 // Write out the class and tags information. |
151 writer->WriteObjectHeader(Object::kUnresolvedClassClass, | 152 writer->WriteVMIsolateObject(Object::kUnresolvedClassClass); |
152 writer->GetObjectTags(this)); | 153 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
153 | 154 |
154 // Write out all the non object pointer fields. | 155 // Write out all the non object pointer fields. |
155 writer->WriteIntptrValue(ptr()->token_pos_); | 156 writer->WriteIntptrValue(ptr()->token_pos_); |
156 | 157 |
157 // Write out all the object pointer fields. | 158 // Write out all the object pointer fields. |
158 SnapshotWriterVisitor visitor(writer); | 159 SnapshotWriterVisitor visitor(writer); |
159 visitor.VisitPointers(from(), to()); | 160 visitor.VisitPointers(from(), to()); |
160 } | 161 } |
161 | 162 |
162 | 163 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 return parameterized_type.raw(); | 211 return parameterized_type.raw(); |
211 } | 212 } |
212 | 213 |
213 | 214 |
214 void RawType::WriteTo(SnapshotWriter* writer, | 215 void RawType::WriteTo(SnapshotWriter* writer, |
215 intptr_t object_id, | 216 intptr_t object_id, |
216 Snapshot::Kind kind) { | 217 Snapshot::Kind kind) { |
217 ASSERT(writer != NULL); | 218 ASSERT(writer != NULL); |
218 | 219 |
219 // Write out the serialization header value for this object. | 220 // Write out the serialization header value for this object. |
220 writer->WriteSerializationMarker(kInlined, object_id); | 221 writer->WriteInlinedObjectHeader(object_id); |
221 | 222 |
222 // Write out the class and tags information. | 223 // Write out the class and tags information. |
223 writer->WriteObjectHeader(Object::kTypeClass, writer->GetObjectTags(this)); | 224 writer->WriteVMIsolateObject(Object::kTypeClass); |
| 225 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
224 | 226 |
225 // Write out all the non object pointer fields. | 227 // Write out all the non object pointer fields. |
226 writer->WriteIntptrValue(ptr()->token_pos_); | 228 writer->WriteIntptrValue(ptr()->token_pos_); |
227 writer->Write<int8_t>(ptr()->type_state_); | 229 writer->Write<int8_t>(ptr()->type_state_); |
228 | 230 |
229 // Write out all the object pointer fields. | 231 // Write out all the object pointer fields. |
230 SnapshotWriterVisitor visitor(writer, false); | 232 SnapshotWriterVisitor visitor(writer, false); |
231 visitor.VisitPointers(from(), to()); | 233 visitor.VisitPointers(from(), to()); |
232 } | 234 } |
233 | 235 |
(...skipping 29 matching lines...) Expand all Loading... |
263 return type_parameter.raw(); | 265 return type_parameter.raw(); |
264 } | 266 } |
265 | 267 |
266 | 268 |
267 void RawTypeParameter::WriteTo(SnapshotWriter* writer, | 269 void RawTypeParameter::WriteTo(SnapshotWriter* writer, |
268 intptr_t object_id, | 270 intptr_t object_id, |
269 Snapshot::Kind kind) { | 271 Snapshot::Kind kind) { |
270 ASSERT(writer != NULL); | 272 ASSERT(writer != NULL); |
271 | 273 |
272 // Write out the serialization header value for this object. | 274 // Write out the serialization header value for this object. |
273 writer->WriteSerializationMarker(kInlined, object_id); | 275 writer->WriteInlinedObjectHeader(object_id); |
274 | 276 |
275 // Write out the class and tags information. | 277 // Write out the class and tags information. |
276 writer->WriteObjectHeader(Object::kTypeParameterClass, | 278 writer->WriteVMIsolateObject(Object::kTypeParameterClass); |
277 writer->GetObjectTags(this)); | 279 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
278 | 280 |
279 // Write out all the non object pointer fields. | 281 // Write out all the non object pointer fields. |
280 writer->WriteIntptrValue(ptr()->index_); | 282 writer->WriteIntptrValue(ptr()->index_); |
281 writer->WriteIntptrValue(ptr()->token_pos_); | 283 writer->WriteIntptrValue(ptr()->token_pos_); |
282 writer->Write<int8_t>(ptr()->type_state_); | 284 writer->Write<int8_t>(ptr()->type_state_); |
283 | 285 |
284 // Write out all the object pointer fields. | 286 // Write out all the object pointer fields. |
285 SnapshotWriterVisitor visitor(writer, false); | 287 SnapshotWriterVisitor visitor(writer, false); |
286 visitor.VisitPointers(from(), to()); | 288 visitor.VisitPointers(from(), to()); |
287 } | 289 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 return type_arguments.raw(); | 337 return type_arguments.raw(); |
336 } | 338 } |
337 | 339 |
338 | 340 |
339 void RawTypeArguments::WriteTo(SnapshotWriter* writer, | 341 void RawTypeArguments::WriteTo(SnapshotWriter* writer, |
340 intptr_t object_id, | 342 intptr_t object_id, |
341 Snapshot::Kind kind) { | 343 Snapshot::Kind kind) { |
342 ASSERT(writer != NULL); | 344 ASSERT(writer != NULL); |
343 | 345 |
344 // Write out the serialization header value for this object. | 346 // Write out the serialization header value for this object. |
345 writer->WriteSerializationMarker(kInlined, object_id); | 347 writer->WriteInlinedObjectHeader(object_id); |
346 | 348 |
347 // Write out the class and tags information. | 349 // Write out the class and tags information. |
348 writer->WriteObjectHeader(Object::kTypeArgumentsClass, | 350 writer->WriteVMIsolateObject(Object::kTypeArgumentsClass); |
349 writer->GetObjectTags(this)); | 351 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
350 | 352 |
351 // Write out the length field. | 353 // Write out the length field. |
352 writer->Write<RawObject*>(ptr()->length_); | 354 writer->Write<RawObject*>(ptr()->length_); |
353 | 355 |
354 // Write out the individual types. | 356 // Write out the individual types. |
355 intptr_t len = Smi::Value(ptr()->length_); | 357 intptr_t len = Smi::Value(ptr()->length_); |
356 for (intptr_t i = 0; i < len; i++) { | 358 for (intptr_t i = 0; i < len; i++) { |
357 writer->WriteObjectImpl(ptr()->types_[i]); | 359 writer->WriteObjectImpl(ptr()->types_[i]); |
358 } | 360 } |
359 } | 361 } |
(...skipping 28 matching lines...) Expand all Loading... |
388 } | 390 } |
389 | 391 |
390 | 392 |
391 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, | 393 void RawInstantiatedTypeArguments::WriteTo(SnapshotWriter* writer, |
392 intptr_t object_id, | 394 intptr_t object_id, |
393 Snapshot::Kind kind) { | 395 Snapshot::Kind kind) { |
394 ASSERT(writer != NULL); | 396 ASSERT(writer != NULL); |
395 ASSERT(kind == Snapshot::kMessage); | 397 ASSERT(kind == Snapshot::kMessage); |
396 | 398 |
397 // Write out the serialization header value for this object. | 399 // Write out the serialization header value for this object. |
398 writer->WriteSerializationMarker(kInlined, object_id); | 400 writer->WriteInlinedObjectHeader(object_id); |
399 | 401 |
400 // Write out the class and tags information. | 402 // Write out the class and tags information. |
401 writer->WriteObjectHeader(Object::kInstantiatedTypeArgumentsClass, | 403 writer->WriteVMIsolateObject(Object::kInstantiatedTypeArgumentsClass); |
402 writer->GetObjectTags(this)); | 404 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
403 | 405 |
404 // Write out all the object pointer fields. | 406 // Write out all the object pointer fields. |
405 SnapshotWriterVisitor visitor(writer, false); | 407 SnapshotWriterVisitor visitor(writer, false); |
406 visitor.VisitPointers(from(), to()); | 408 visitor.VisitPointers(from(), to()); |
407 } | 409 } |
408 | 410 |
409 | 411 |
410 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 412 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
411 intptr_t object_id, | 413 intptr_t object_id, |
412 intptr_t tags, | 414 intptr_t tags, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 | 450 |
449 | 451 |
450 void RawFunction::WriteTo(SnapshotWriter* writer, | 452 void RawFunction::WriteTo(SnapshotWriter* writer, |
451 intptr_t object_id, | 453 intptr_t object_id, |
452 Snapshot::Kind kind) { | 454 Snapshot::Kind kind) { |
453 ASSERT(writer != NULL); | 455 ASSERT(writer != NULL); |
454 ASSERT(kind != Snapshot::kMessage && | 456 ASSERT(kind != Snapshot::kMessage && |
455 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 457 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
456 | 458 |
457 // Write out the serialization header value for this object. | 459 // Write out the serialization header value for this object. |
458 writer->WriteSerializationMarker(kInlined, object_id); | 460 writer->WriteInlinedObjectHeader(object_id); |
459 | 461 |
460 // Write out the class and tags information. | 462 // Write out the class and tags information. |
461 writer->WriteObjectHeader(Object::kFunctionClass, | 463 writer->WriteVMIsolateObject(Object::kFunctionClass); |
462 writer->GetObjectTags(this)); | 464 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
463 | 465 |
464 // Write out all the non object fields. | 466 // Write out all the non object fields. |
465 writer->WriteIntptrValue(ptr()->token_pos_); | 467 writer->WriteIntptrValue(ptr()->token_pos_); |
466 writer->WriteIntptrValue(ptr()->end_token_pos_); | 468 writer->WriteIntptrValue(ptr()->end_token_pos_); |
467 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); | 469 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); |
468 writer->WriteIntptrValue(ptr()->num_optional_parameters_); | 470 writer->WriteIntptrValue(ptr()->num_optional_parameters_); |
469 writer->WriteIntptrValue(ptr()->usage_counter_); | 471 writer->WriteIntptrValue(ptr()->usage_counter_); |
470 writer->WriteIntptrValue(ptr()->deoptimization_counter_); | 472 writer->WriteIntptrValue(ptr()->deoptimization_counter_); |
471 writer->WriteIntptrValue(ptr()->kind_); | 473 writer->WriteIntptrValue(ptr()->kind_); |
472 writer->Write<bool>(ptr()->is_static_); | 474 writer->Write<bool>(ptr()->is_static_); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 | 516 |
515 | 517 |
516 void RawField::WriteTo(SnapshotWriter* writer, | 518 void RawField::WriteTo(SnapshotWriter* writer, |
517 intptr_t object_id, | 519 intptr_t object_id, |
518 Snapshot::Kind kind) { | 520 Snapshot::Kind kind) { |
519 ASSERT(writer != NULL); | 521 ASSERT(writer != NULL); |
520 ASSERT(kind != Snapshot::kMessage && | 522 ASSERT(kind != Snapshot::kMessage && |
521 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 523 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
522 | 524 |
523 // Write out the serialization header value for this object. | 525 // Write out the serialization header value for this object. |
524 writer->WriteSerializationMarker(kInlined, object_id); | 526 writer->WriteInlinedObjectHeader(object_id); |
525 | 527 |
526 // Write out the class and tags information. | 528 // Write out the class and tags information. |
527 writer->WriteObjectHeader(Object::kFieldClass, writer->GetObjectTags(this)); | 529 writer->WriteVMIsolateObject(Object::kFieldClass); |
| 530 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
528 | 531 |
529 // Write out all the non object fields. | 532 // Write out all the non object fields. |
530 writer->WriteIntptrValue(ptr()->token_pos_); | 533 writer->WriteIntptrValue(ptr()->token_pos_); |
531 writer->Write<bool>(ptr()->is_static_); | 534 writer->Write<bool>(ptr()->is_static_); |
532 writer->Write<bool>(ptr()->is_final_); | 535 writer->Write<bool>(ptr()->is_final_); |
533 writer->Write<bool>(ptr()->is_const_); | 536 writer->Write<bool>(ptr()->is_const_); |
534 writer->Write<bool>(ptr()->has_initializer_); | 537 writer->Write<bool>(ptr()->has_initializer_); |
535 | 538 |
536 // Write out all the object pointer fields. | 539 // Write out all the object pointer fields. |
537 SnapshotWriterVisitor visitor(writer); | 540 SnapshotWriterVisitor visitor(writer); |
(...skipping 28 matching lines...) Expand all Loading... |
566 } | 569 } |
567 | 570 |
568 | 571 |
569 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 572 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
570 intptr_t object_id, | 573 intptr_t object_id, |
571 Snapshot::Kind kind) { | 574 Snapshot::Kind kind) { |
572 ASSERT(writer != NULL); | 575 ASSERT(writer != NULL); |
573 ASSERT(kind != Snapshot::kMessage); | 576 ASSERT(kind != Snapshot::kMessage); |
574 | 577 |
575 // Write out the serialization header value for this object. | 578 // Write out the serialization header value for this object. |
576 writer->WriteSerializationMarker(kInlined, object_id); | 579 writer->WriteInlinedObjectHeader(object_id); |
577 | 580 |
578 // Write out the class and tags information. | 581 // Write out the class and tags information. |
579 writer->WriteObjectHeader(Object::kLiteralTokenClass, | 582 writer->WriteVMIsolateObject(Object::kLiteralTokenClass); |
580 writer->GetObjectTags(this)); | 583 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
581 | 584 |
582 // Write out the kind field. | 585 // Write out the kind field. |
583 writer->Write<intptr_t>(ptr()->kind_); | 586 writer->Write<intptr_t>(ptr()->kind_); |
584 | 587 |
585 // Write out literal and value fields. | 588 // Write out literal and value fields. |
586 writer->WriteObjectImpl(ptr()->literal_); | 589 writer->WriteObjectImpl(ptr()->literal_); |
587 writer->WriteObjectImpl(ptr()->value_); | 590 writer->WriteObjectImpl(ptr()->value_); |
588 } | 591 } |
589 | 592 |
590 | 593 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 | 625 |
623 | 626 |
624 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 627 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
625 intptr_t object_id, | 628 intptr_t object_id, |
626 Snapshot::Kind kind) { | 629 Snapshot::Kind kind) { |
627 ASSERT(writer != NULL); | 630 ASSERT(writer != NULL); |
628 ASSERT(kind != Snapshot::kMessage && | 631 ASSERT(kind != Snapshot::kMessage && |
629 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 632 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
630 | 633 |
631 // Write out the serialization header value for this object. | 634 // Write out the serialization header value for this object. |
632 writer->WriteSerializationMarker(kInlined, object_id); | 635 writer->WriteInlinedObjectHeader(object_id); |
633 | 636 |
634 // Write out the class and tags information. | 637 // Write out the class and tags information. |
635 writer->WriteObjectHeader(Object::kTokenStreamClass, | 638 writer->WriteVMIsolateObject(Object::kTokenStreamClass); |
636 writer->GetObjectTags(this)); | 639 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
637 | 640 |
638 // Write out the length field and the token stream. | 641 // Write out the length field and the token stream. |
639 intptr_t len = Smi::Value(ptr()->length_); | 642 intptr_t len = Smi::Value(ptr()->length_); |
640 writer->Write<RawObject*>(ptr()->length_); | 643 writer->Write<RawObject*>(ptr()->length_); |
641 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); | 644 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); |
642 | 645 |
643 // Write out the literal/identifier token array. | 646 // Write out the literal/identifier token array. |
644 writer->WriteObjectImpl(ptr()->token_objects_); | 647 writer->WriteObjectImpl(ptr()->token_objects_); |
645 } | 648 } |
646 | 649 |
(...skipping 29 matching lines...) Expand all Loading... |
676 | 679 |
677 void RawScript::WriteTo(SnapshotWriter* writer, | 680 void RawScript::WriteTo(SnapshotWriter* writer, |
678 intptr_t object_id, | 681 intptr_t object_id, |
679 Snapshot::Kind kind) { | 682 Snapshot::Kind kind) { |
680 ASSERT(writer != NULL); | 683 ASSERT(writer != NULL); |
681 ASSERT(tokens_ != TokenStream::null()); | 684 ASSERT(tokens_ != TokenStream::null()); |
682 ASSERT(kind != Snapshot::kMessage && | 685 ASSERT(kind != Snapshot::kMessage && |
683 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 686 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
684 | 687 |
685 // Write out the serialization header value for this object. | 688 // Write out the serialization header value for this object. |
686 writer->WriteSerializationMarker(kInlined, object_id); | 689 writer->WriteInlinedObjectHeader(object_id); |
687 | 690 |
688 // Write out the class and tags information. | 691 // Write out the class and tags information. |
689 writer->WriteObjectHeader(Object::kScriptClass, writer->GetObjectTags(this)); | 692 writer->WriteVMIsolateObject(Object::kScriptClass); |
| 693 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
690 | 694 |
691 // Write out all the object pointer fields. | 695 // Write out all the object pointer fields. |
692 writer->WriteObjectImpl(ptr()->url_); | 696 writer->WriteObjectImpl(ptr()->url_); |
693 writer->WriteObjectImpl(ptr()->tokens_); | 697 writer->WriteObjectImpl(ptr()->tokens_); |
694 } | 698 } |
695 | 699 |
696 | 700 |
697 RawLibrary* Library::ReadFrom(SnapshotReader* reader, | 701 RawLibrary* Library::ReadFrom(SnapshotReader* reader, |
698 intptr_t object_id, | 702 intptr_t object_id, |
699 intptr_t tags, | 703 intptr_t tags, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 } | 751 } |
748 | 752 |
749 | 753 |
750 void RawLibrary::WriteTo(SnapshotWriter* writer, | 754 void RawLibrary::WriteTo(SnapshotWriter* writer, |
751 intptr_t object_id, | 755 intptr_t object_id, |
752 Snapshot::Kind kind) { | 756 Snapshot::Kind kind) { |
753 ASSERT(writer != NULL); | 757 ASSERT(writer != NULL); |
754 ASSERT(kind != Snapshot::kMessage); | 758 ASSERT(kind != Snapshot::kMessage); |
755 | 759 |
756 // Write out the serialization header value for this object. | 760 // Write out the serialization header value for this object. |
757 writer->WriteSerializationMarker(kInlined, object_id); | 761 writer->WriteInlinedObjectHeader(object_id); |
758 | 762 |
759 // Write out the class and tags information. | 763 // Write out the class and tags information. |
760 writer->WriteObjectHeader(Object::kLibraryClass, writer->GetObjectTags(this)); | 764 writer->WriteVMIsolateObject(Object::kLibraryClass); |
| 765 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
761 | 766 |
762 if (RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { | 767 if (RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { |
763 ASSERT(kind != Snapshot::kFull); | 768 ASSERT(kind != Snapshot::kFull); |
764 // Write out library URL so that it can be looked up when reading. | 769 // Write out library URL so that it can be looked up when reading. |
765 writer->WriteObjectImpl(ptr()->url_); | 770 writer->WriteObjectImpl(ptr()->url_); |
766 } else { | 771 } else { |
767 // Write out all non object fields. | 772 // Write out all non object fields. |
768 writer->WriteIntptrValue(ptr()->index_); | 773 writer->WriteIntptrValue(ptr()->index_); |
769 writer->WriteIntptrValue(ptr()->num_imports_); | 774 writer->WriteIntptrValue(ptr()->num_imports_); |
770 writer->WriteIntptrValue(ptr()->num_imported_into_); | 775 writer->WriteIntptrValue(ptr()->num_imported_into_); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 | 822 |
818 | 823 |
819 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 824 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
820 intptr_t object_id, | 825 intptr_t object_id, |
821 Snapshot::Kind kind) { | 826 Snapshot::Kind kind) { |
822 ASSERT(writer != NULL); | 827 ASSERT(writer != NULL); |
823 ASSERT(kind != Snapshot::kMessage && | 828 ASSERT(kind != Snapshot::kMessage && |
824 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 829 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
825 | 830 |
826 // Write out the serialization header value for this object. | 831 // Write out the serialization header value for this object. |
827 writer->WriteSerializationMarker(kInlined, object_id); | 832 writer->WriteInlinedObjectHeader(object_id); |
828 | 833 |
829 // Write out the class and tags information. | 834 // Write out the class and tags information. |
830 writer->WriteObjectHeader(Object::kLibraryPrefixClass, | 835 writer->WriteVMIsolateObject(Object::kLibraryPrefixClass); |
831 writer->GetObjectTags(this)); | 836 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
832 | 837 |
833 // Write out all non object fields. | 838 // Write out all non object fields. |
834 writer->WriteIntptrValue(ptr()->num_libs_); | 839 writer->WriteIntptrValue(ptr()->num_libs_); |
835 | 840 |
836 // Write out all the object pointer fields. | 841 // Write out all the object pointer fields. |
837 SnapshotWriterVisitor visitor(writer); | 842 SnapshotWriterVisitor visitor(writer); |
838 visitor.VisitPointers(from(), to()); | 843 visitor.VisitPointers(from(), to()); |
839 } | 844 } |
840 | 845 |
841 | 846 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
970 return context.raw(); | 975 return context.raw(); |
971 } | 976 } |
972 | 977 |
973 | 978 |
974 void RawContext::WriteTo(SnapshotWriter* writer, | 979 void RawContext::WriteTo(SnapshotWriter* writer, |
975 intptr_t object_id, | 980 intptr_t object_id, |
976 Snapshot::Kind kind) { | 981 Snapshot::Kind kind) { |
977 ASSERT(writer != NULL); | 982 ASSERT(writer != NULL); |
978 | 983 |
979 // Write out the serialization header value for this object. | 984 // Write out the serialization header value for this object. |
980 writer->WriteSerializationMarker(kInlined, object_id); | 985 writer->WriteInlinedObjectHeader(object_id); |
981 | 986 |
982 // Write out the class and tags information. | 987 // Write out the class and tags information. |
983 writer->WriteObjectHeader(Object::kContextClass, writer->GetObjectTags(this)); | 988 writer->WriteVMIsolateObject(Object::kContextClass); |
| 989 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
984 | 990 |
985 // Write out num of variables in the context. | 991 // Write out num of variables in the context. |
986 writer->WriteIntptrValue(ptr()->num_variables_); | 992 writer->WriteIntptrValue(ptr()->num_variables_); |
987 | 993 |
988 // Can't serialize the isolate pointer, we set it implicitly on read. | 994 // Can't serialize the isolate pointer, we set it implicitly on read. |
989 | 995 |
990 // Write out all the object pointer fields. | 996 // Write out all the object pointer fields. |
991 SnapshotWriterVisitor visitor(writer); | 997 SnapshotWriterVisitor visitor(writer); |
992 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 998 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
993 } | 999 } |
(...skipping 27 matching lines...) Expand all Loading... |
1021 } | 1027 } |
1022 | 1028 |
1023 | 1029 |
1024 void RawContextScope::WriteTo(SnapshotWriter* writer, | 1030 void RawContextScope::WriteTo(SnapshotWriter* writer, |
1025 intptr_t object_id, | 1031 intptr_t object_id, |
1026 Snapshot::Kind kind) { | 1032 Snapshot::Kind kind) { |
1027 ASSERT(writer != NULL); | 1033 ASSERT(writer != NULL); |
1028 ASSERT(kind == Snapshot::kMessage); | 1034 ASSERT(kind == Snapshot::kMessage); |
1029 | 1035 |
1030 // Write out the serialization header value for this object. | 1036 // Write out the serialization header value for this object. |
1031 writer->WriteSerializationMarker(kInlined, object_id); | 1037 writer->WriteInlinedObjectHeader(object_id); |
1032 | 1038 |
1033 // Write out the class and tags information. | 1039 // Write out the class and tags information. |
1034 writer->WriteObjectHeader(Object::kContextScopeClass, | 1040 writer->WriteVMIsolateObject(Object::kContextScopeClass); |
1035 writer->GetObjectTags(this)); | 1041 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1036 | 1042 |
1037 // Serialize number of variables. | 1043 // Serialize number of variables. |
1038 writer->WriteIntptrValue(ptr()->num_variables_); | 1044 writer->WriteIntptrValue(ptr()->num_variables_); |
1039 | 1045 |
1040 // Write out all the object pointer fields. | 1046 // Write out all the object pointer fields. |
1041 SnapshotWriterVisitor visitor(writer); | 1047 SnapshotWriterVisitor visitor(writer); |
1042 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 1048 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
1043 } | 1049 } |
1044 | 1050 |
1045 | 1051 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 return mint.raw(); | 1205 return mint.raw(); |
1200 } | 1206 } |
1201 | 1207 |
1202 | 1208 |
1203 void RawMint::WriteTo(SnapshotWriter* writer, | 1209 void RawMint::WriteTo(SnapshotWriter* writer, |
1204 intptr_t object_id, | 1210 intptr_t object_id, |
1205 Snapshot::Kind kind) { | 1211 Snapshot::Kind kind) { |
1206 ASSERT(writer != NULL); | 1212 ASSERT(writer != NULL); |
1207 | 1213 |
1208 // Write out the serialization header value for this object. | 1214 // Write out the serialization header value for this object. |
1209 writer->WriteSerializationMarker(kInlined, object_id); | 1215 writer->WriteInlinedObjectHeader(object_id); |
1210 | 1216 |
1211 // Write out the class and tags information. | 1217 // Write out the class and tags information. |
1212 writer->WriteObjectHeader(ObjectStore::kMintClass, | 1218 writer->WriteIndexedObject(ObjectStore::kMintClass); |
1213 writer->GetObjectTags(this)); | 1219 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1214 | 1220 |
1215 // Write out the 64 bit value. | 1221 // Write out the 64 bit value. |
1216 writer->Write<int64_t>(ptr()->value_); | 1222 writer->Write<int64_t>(ptr()->value_); |
1217 } | 1223 } |
1218 | 1224 |
1219 | 1225 |
1220 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, | 1226 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, |
1221 intptr_t object_id, | 1227 intptr_t object_id, |
1222 intptr_t tags, | 1228 intptr_t tags, |
1223 Snapshot::Kind kind) { | 1229 Snapshot::Kind kind) { |
(...skipping 23 matching lines...) Expand all Loading... |
1247 return obj.raw(); | 1253 return obj.raw(); |
1248 } | 1254 } |
1249 | 1255 |
1250 | 1256 |
1251 void RawBigint::WriteTo(SnapshotWriter* writer, | 1257 void RawBigint::WriteTo(SnapshotWriter* writer, |
1252 intptr_t object_id, | 1258 intptr_t object_id, |
1253 Snapshot::Kind kind) { | 1259 Snapshot::Kind kind) { |
1254 ASSERT(writer != NULL); | 1260 ASSERT(writer != NULL); |
1255 | 1261 |
1256 // Write out the serialization header value for this object. | 1262 // Write out the serialization header value for this object. |
1257 writer->WriteSerializationMarker(kInlined, object_id); | 1263 writer->WriteInlinedObjectHeader(object_id); |
1258 | 1264 |
1259 // Write out the class and tags information. | 1265 // Write out the class and tags information. |
1260 writer->WriteObjectHeader(ObjectStore::kBigintClass, | 1266 writer->WriteIndexedObject(ObjectStore::kBigintClass); |
1261 writer->GetObjectTags(this)); | 1267 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1262 | 1268 |
1263 // Write out the bigint value as a HEXCstring. | 1269 // Write out the bigint value as a HEXCstring. |
1264 intptr_t length = ptr()->signed_length_; | 1270 intptr_t length = ptr()->signed_length_; |
1265 bool is_negative = false; | 1271 bool is_negative = false; |
1266 if (length <= 0) { | 1272 if (length <= 0) { |
1267 length = -length; | 1273 length = -length; |
1268 is_negative = true; | 1274 is_negative = true; |
1269 } | 1275 } |
1270 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint); | 1276 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint); |
1271 const char* str = BigintOperations::ToHexCString( | 1277 const char* str = BigintOperations::ToHexCString( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 return dbl.raw(); | 1323 return dbl.raw(); |
1318 } | 1324 } |
1319 | 1325 |
1320 | 1326 |
1321 void RawDouble::WriteTo(SnapshotWriter* writer, | 1327 void RawDouble::WriteTo(SnapshotWriter* writer, |
1322 intptr_t object_id, | 1328 intptr_t object_id, |
1323 Snapshot::Kind kind) { | 1329 Snapshot::Kind kind) { |
1324 ASSERT(writer != NULL); | 1330 ASSERT(writer != NULL); |
1325 | 1331 |
1326 // Write out the serialization header value for this object. | 1332 // Write out the serialization header value for this object. |
1327 writer->WriteSerializationMarker(kInlined, object_id); | 1333 writer->WriteInlinedObjectHeader(object_id); |
1328 | 1334 |
1329 // Write out the class and tags information. | 1335 // Write out the class and tags information. |
1330 writer->WriteObjectHeader(ObjectStore::kDoubleClass, | 1336 writer->WriteIndexedObject(ObjectStore::kDoubleClass); |
1331 writer->GetObjectTags(this)); | 1337 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1332 | 1338 |
1333 // Write out the double value. | 1339 // Write out the double value. |
1334 writer->Write<double>(ptr()->value_); | 1340 writer->Write<double>(ptr()->value_); |
1335 } | 1341 } |
1336 | 1342 |
1337 | 1343 |
1338 RawString* String::ReadFrom(SnapshotReader* reader, | 1344 RawString* String::ReadFrom(SnapshotReader* reader, |
1339 intptr_t object_id, | 1345 intptr_t object_id, |
1340 intptr_t tags, | 1346 intptr_t tags, |
1341 Snapshot::Kind kind) { | 1347 Snapshot::Kind kind) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 Snapshot::Kind kind, | 1481 Snapshot::Kind kind, |
1476 intptr_t class_id, | 1482 intptr_t class_id, |
1477 intptr_t tags, | 1483 intptr_t tags, |
1478 RawSmi* length, | 1484 RawSmi* length, |
1479 RawSmi* hash, | 1485 RawSmi* hash, |
1480 T* data) { | 1486 T* data) { |
1481 ASSERT(writer != NULL); | 1487 ASSERT(writer != NULL); |
1482 intptr_t len = Smi::Value(length); | 1488 intptr_t len = Smi::Value(length); |
1483 | 1489 |
1484 // Write out the serialization header value for this object. | 1490 // Write out the serialization header value for this object. |
1485 writer->WriteSerializationMarker(kInlined, object_id); | 1491 writer->WriteInlinedObjectHeader(object_id); |
1486 | 1492 |
1487 // Write out the class and tags information. | 1493 // Write out the class and tags information. |
1488 writer->WriteObjectHeader(class_id, tags); | 1494 writer->WriteIndexedObject(class_id); |
| 1495 writer->WriteIntptrValue(tags); |
1489 | 1496 |
1490 // Write out the length field. | 1497 // Write out the length field. |
1491 writer->Write<RawObject*>(length); | 1498 writer->Write<RawObject*>(length); |
1492 | 1499 |
1493 // Write out the hash field. | 1500 // Write out the hash field. |
1494 writer->Write<RawObject*>(hash); | 1501 writer->Write<RawObject*>(hash); |
1495 | 1502 |
1496 // Write out the string. | 1503 // Write out the string. |
1497 if (len > 0) { | 1504 if (len > 0) { |
1498 if (class_id == ObjectStore::kOneByteStringClass) { | 1505 if (class_id == ObjectStore::kOneByteStringClass) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 return array.raw(); | 1736 return array.raw(); |
1730 } | 1737 } |
1731 | 1738 |
1732 | 1739 |
1733 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, | 1740 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, |
1734 intptr_t object_id, | 1741 intptr_t object_id, |
1735 Snapshot::Kind kind) { | 1742 Snapshot::Kind kind) { |
1736 ASSERT(writer != NULL); | 1743 ASSERT(writer != NULL); |
1737 | 1744 |
1738 // Write out the serialization header value for this object. | 1745 // Write out the serialization header value for this object. |
1739 writer->WriteSerializationMarker(kInlined, object_id); | 1746 writer->WriteInlinedObjectHeader(object_id); |
1740 | 1747 |
1741 // Write out the class and tags information. | 1748 // Write out the class and tags information. |
1742 writer->WriteObjectHeader(ObjectStore::kGrowableObjectArrayClass, | 1749 writer->WriteIndexedObject(ObjectStore::kGrowableObjectArrayClass); |
1743 writer->GetObjectTags(this)); | 1750 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1744 | 1751 |
1745 // Write out the used length field. | 1752 // Write out the used length field. |
1746 writer->Write<RawObject*>(ptr()->length_); | 1753 writer->Write<RawObject*>(ptr()->length_); |
1747 | 1754 |
1748 // Write out the Array object. | 1755 // Write out the Array object. |
1749 writer->WriteObjectImpl(ptr()->data_); | 1756 writer->WriteObjectImpl(ptr()->data_); |
1750 } | 1757 } |
1751 | 1758 |
1752 | 1759 |
1753 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader, | 1760 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 intptr_t object_id, | 1846 intptr_t object_id, |
1840 Snapshot::Kind kind, | 1847 Snapshot::Kind kind, |
1841 intptr_t byte_array_kind, | 1848 intptr_t byte_array_kind, |
1842 intptr_t tags, | 1849 intptr_t tags, |
1843 RawSmi* length, | 1850 RawSmi* length, |
1844 uint8_t* data) { | 1851 uint8_t* data) { |
1845 ASSERT(writer != NULL); | 1852 ASSERT(writer != NULL); |
1846 intptr_t len = Smi::Value(length); | 1853 intptr_t len = Smi::Value(length); |
1847 | 1854 |
1848 // Write out the serialization header value for this object. | 1855 // Write out the serialization header value for this object. |
1849 writer->WriteSerializationMarker(kInlined, object_id); | 1856 writer->WriteInlinedObjectHeader(object_id); |
1850 | 1857 |
1851 // Write out the class and tags information. | 1858 // Write out the class and tags information. |
1852 writer->WriteObjectHeader(byte_array_kind, tags); | 1859 writer->WriteIndexedObject(byte_array_kind); |
| 1860 writer->WriteIntptrValue(tags); |
1853 | 1861 |
1854 // Write out the length field. | 1862 // Write out the length field. |
1855 writer->Write<RawObject*>(length); | 1863 writer->Write<RawObject*>(length); |
1856 | 1864 |
1857 // Write out the array elements. | 1865 // Write out the array elements. |
1858 for (intptr_t i = 0; i < len; i++) { | 1866 for (intptr_t i = 0; i < len; i++) { |
1859 writer->Write(data[i]); | 1867 writer->Write(data[i]); |
1860 } | 1868 } |
1861 } | 1869 } |
1862 | 1870 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 } | 1977 } |
1970 | 1978 |
1971 | 1979 |
1972 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 1980 void RawJSRegExp::WriteTo(SnapshotWriter* writer, |
1973 intptr_t object_id, | 1981 intptr_t object_id, |
1974 Snapshot::Kind kind) { | 1982 Snapshot::Kind kind) { |
1975 ASSERT(writer != NULL); | 1983 ASSERT(writer != NULL); |
1976 ASSERT(kind == Snapshot::kMessage); | 1984 ASSERT(kind == Snapshot::kMessage); |
1977 | 1985 |
1978 // Write out the serialization header value for this object. | 1986 // Write out the serialization header value for this object. |
1979 writer->WriteSerializationMarker(kInlined, object_id); | 1987 writer->WriteInlinedObjectHeader(object_id); |
1980 | 1988 |
1981 // Write out the class and tags information. | 1989 // Write out the class and tags information. |
1982 writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, | 1990 writer->WriteIndexedObject(ObjectStore::kJSRegExpClass); |
1983 writer->GetObjectTags(this)); | 1991 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1984 | 1992 |
1985 // Write out the data length field. | 1993 // Write out the data length field. |
1986 writer->Write<RawObject*>(ptr()->data_length_); | 1994 writer->Write<RawObject*>(ptr()->data_length_); |
1987 | 1995 |
1988 // Write out all the other fields. | 1996 // Write out all the other fields. |
1989 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1997 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
1990 writer->WriteObjectImpl(ptr()->pattern_); | 1998 writer->WriteObjectImpl(ptr()->pattern_); |
1991 writer->WriteIntptrValue(ptr()->type_); | 1999 writer->WriteIntptrValue(ptr()->type_); |
1992 writer->WriteIntptrValue(ptr()->flags_); | 2000 writer->WriteIntptrValue(ptr()->flags_); |
1993 | 2001 |
1994 // Do not write out the data part which is native. | 2002 // Do not write out the data part which is native. |
1995 } | 2003 } |
1996 | 2004 |
1997 | 2005 |
1998 } // namespace dart | 2006 } // namespace dart |
OLD | NEW |