| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 | 451 |
| 450 | 452 |
| 451 void RawFunction::WriteTo(SnapshotWriter* writer, | 453 void RawFunction::WriteTo(SnapshotWriter* writer, |
| 452 intptr_t object_id, | 454 intptr_t object_id, |
| 453 Snapshot::Kind kind) { | 455 Snapshot::Kind kind) { |
| 454 ASSERT(writer != NULL); | 456 ASSERT(writer != NULL); |
| 455 ASSERT(kind != Snapshot::kMessage && | 457 ASSERT(kind != Snapshot::kMessage && |
| 456 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 458 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 457 | 459 |
| 458 // Write out the serialization header value for this object. | 460 // Write out the serialization header value for this object. |
| 459 writer->WriteSerializationMarker(kInlined, object_id); | 461 writer->WriteInlinedObjectHeader(object_id); |
| 460 | 462 |
| 461 // Write out the class and tags information. | 463 // Write out the class and tags information. |
| 462 writer->WriteObjectHeader(Object::kFunctionClass, | 464 writer->WriteVMIsolateObject(Object::kFunctionClass); |
| 463 writer->GetObjectTags(this)); | 465 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 464 | 466 |
| 465 // Write out all the non object fields. | 467 // Write out all the non object fields. |
| 466 writer->WriteIntptrValue(ptr()->token_pos_); | 468 writer->WriteIntptrValue(ptr()->token_pos_); |
| 467 writer->WriteIntptrValue(ptr()->end_token_pos_); | 469 writer->WriteIntptrValue(ptr()->end_token_pos_); |
| 468 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); | 470 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); |
| 469 writer->WriteIntptrValue(ptr()->num_optional_parameters_); | 471 writer->WriteIntptrValue(ptr()->num_optional_parameters_); |
| 470 writer->WriteIntptrValue(ptr()->usage_counter_); | 472 writer->WriteIntptrValue(ptr()->usage_counter_); |
| 471 writer->WriteIntptrValue(ptr()->deoptimization_counter_); | 473 writer->WriteIntptrValue(ptr()->deoptimization_counter_); |
| 472 writer->WriteIntptrValue(GetKind()); | 474 writer->WriteIntptrValue(GetKind()); |
| 473 writer->Write<bool>(IsStatic()); | 475 writer->Write<bool>(IsStatic()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 | 518 |
| 517 | 519 |
| 518 void RawField::WriteTo(SnapshotWriter* writer, | 520 void RawField::WriteTo(SnapshotWriter* writer, |
| 519 intptr_t object_id, | 521 intptr_t object_id, |
| 520 Snapshot::Kind kind) { | 522 Snapshot::Kind kind) { |
| 521 ASSERT(writer != NULL); | 523 ASSERT(writer != NULL); |
| 522 ASSERT(kind != Snapshot::kMessage && | 524 ASSERT(kind != Snapshot::kMessage && |
| 523 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 525 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 524 | 526 |
| 525 // Write out the serialization header value for this object. | 527 // Write out the serialization header value for this object. |
| 526 writer->WriteSerializationMarker(kInlined, object_id); | 528 writer->WriteInlinedObjectHeader(object_id); |
| 527 | 529 |
| 528 // Write out the class and tags information. | 530 // Write out the class and tags information. |
| 529 writer->WriteObjectHeader(Object::kFieldClass, writer->GetObjectTags(this)); | 531 writer->WriteVMIsolateObject(Object::kFieldClass); |
| 532 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 530 | 533 |
| 531 // Write out all the non object fields. | 534 // Write out all the non object fields. |
| 532 writer->WriteIntptrValue(ptr()->token_pos_); | 535 writer->WriteIntptrValue(ptr()->token_pos_); |
| 533 writer->Write<bool>(ptr()->is_static_); | 536 writer->Write<bool>(ptr()->is_static_); |
| 534 writer->Write<bool>(ptr()->is_final_); | 537 writer->Write<bool>(ptr()->is_final_); |
| 535 writer->Write<bool>(ptr()->is_const_); | 538 writer->Write<bool>(ptr()->is_const_); |
| 536 writer->Write<bool>(ptr()->has_initializer_); | 539 writer->Write<bool>(ptr()->has_initializer_); |
| 537 | 540 |
| 538 // Write out all the object pointer fields. | 541 // Write out all the object pointer fields. |
| 539 SnapshotWriterVisitor visitor(writer); | 542 SnapshotWriterVisitor visitor(writer); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 568 } | 571 } |
| 569 | 572 |
| 570 | 573 |
| 571 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 574 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
| 572 intptr_t object_id, | 575 intptr_t object_id, |
| 573 Snapshot::Kind kind) { | 576 Snapshot::Kind kind) { |
| 574 ASSERT(writer != NULL); | 577 ASSERT(writer != NULL); |
| 575 ASSERT(kind != Snapshot::kMessage); | 578 ASSERT(kind != Snapshot::kMessage); |
| 576 | 579 |
| 577 // Write out the serialization header value for this object. | 580 // Write out the serialization header value for this object. |
| 578 writer->WriteSerializationMarker(kInlined, object_id); | 581 writer->WriteInlinedObjectHeader(object_id); |
| 579 | 582 |
| 580 // Write out the class and tags information. | 583 // Write out the class and tags information. |
| 581 writer->WriteObjectHeader(Object::kLiteralTokenClass, | 584 writer->WriteVMIsolateObject(Object::kLiteralTokenClass); |
| 582 writer->GetObjectTags(this)); | 585 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 583 | 586 |
| 584 // Write out the kind field. | 587 // Write out the kind field. |
| 585 writer->Write<intptr_t>(ptr()->kind_); | 588 writer->Write<intptr_t>(ptr()->kind_); |
| 586 | 589 |
| 587 // Write out literal and value fields. | 590 // Write out literal and value fields. |
| 588 writer->WriteObjectImpl(ptr()->literal_); | 591 writer->WriteObjectImpl(ptr()->literal_); |
| 589 writer->WriteObjectImpl(ptr()->value_); | 592 writer->WriteObjectImpl(ptr()->value_); |
| 590 } | 593 } |
| 591 | 594 |
| 592 | 595 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 | 627 |
| 625 | 628 |
| 626 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 629 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
| 627 intptr_t object_id, | 630 intptr_t object_id, |
| 628 Snapshot::Kind kind) { | 631 Snapshot::Kind kind) { |
| 629 ASSERT(writer != NULL); | 632 ASSERT(writer != NULL); |
| 630 ASSERT(kind != Snapshot::kMessage && | 633 ASSERT(kind != Snapshot::kMessage && |
| 631 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 634 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 632 | 635 |
| 633 // Write out the serialization header value for this object. | 636 // Write out the serialization header value for this object. |
| 634 writer->WriteSerializationMarker(kInlined, object_id); | 637 writer->WriteInlinedObjectHeader(object_id); |
| 635 | 638 |
| 636 // Write out the class and tags information. | 639 // Write out the class and tags information. |
| 637 writer->WriteObjectHeader(Object::kTokenStreamClass, | 640 writer->WriteVMIsolateObject(Object::kTokenStreamClass); |
| 638 writer->GetObjectTags(this)); | 641 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 639 | 642 |
| 640 // Write out the length field and the token stream. | 643 // Write out the length field and the token stream. |
| 641 intptr_t len = Smi::Value(ptr()->length_); | 644 intptr_t len = Smi::Value(ptr()->length_); |
| 642 writer->Write<RawObject*>(ptr()->length_); | 645 writer->Write<RawObject*>(ptr()->length_); |
| 643 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); | 646 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); |
| 644 | 647 |
| 645 // Write out the literal/identifier token array. | 648 // Write out the literal/identifier token array. |
| 646 writer->WriteObjectImpl(ptr()->token_objects_); | 649 writer->WriteObjectImpl(ptr()->token_objects_); |
| 647 } | 650 } |
| 648 | 651 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 678 | 681 |
| 679 void RawScript::WriteTo(SnapshotWriter* writer, | 682 void RawScript::WriteTo(SnapshotWriter* writer, |
| 680 intptr_t object_id, | 683 intptr_t object_id, |
| 681 Snapshot::Kind kind) { | 684 Snapshot::Kind kind) { |
| 682 ASSERT(writer != NULL); | 685 ASSERT(writer != NULL); |
| 683 ASSERT(tokens_ != TokenStream::null()); | 686 ASSERT(tokens_ != TokenStream::null()); |
| 684 ASSERT(kind != Snapshot::kMessage && | 687 ASSERT(kind != Snapshot::kMessage && |
| 685 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 688 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 686 | 689 |
| 687 // Write out the serialization header value for this object. | 690 // Write out the serialization header value for this object. |
| 688 writer->WriteSerializationMarker(kInlined, object_id); | 691 writer->WriteInlinedObjectHeader(object_id); |
| 689 | 692 |
| 690 // Write out the class and tags information. | 693 // Write out the class and tags information. |
| 691 writer->WriteObjectHeader(Object::kScriptClass, writer->GetObjectTags(this)); | 694 writer->WriteVMIsolateObject(Object::kScriptClass); |
| 695 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 692 | 696 |
| 693 // Write out all the object pointer fields. | 697 // Write out all the object pointer fields. |
| 694 writer->WriteObjectImpl(ptr()->url_); | 698 writer->WriteObjectImpl(ptr()->url_); |
| 695 writer->WriteObjectImpl(ptr()->tokens_); | 699 writer->WriteObjectImpl(ptr()->tokens_); |
| 696 } | 700 } |
| 697 | 701 |
| 698 | 702 |
| 699 RawLibrary* Library::ReadFrom(SnapshotReader* reader, | 703 RawLibrary* Library::ReadFrom(SnapshotReader* reader, |
| 700 intptr_t object_id, | 704 intptr_t object_id, |
| 701 intptr_t tags, | 705 intptr_t tags, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 } | 753 } |
| 750 | 754 |
| 751 | 755 |
| 752 void RawLibrary::WriteTo(SnapshotWriter* writer, | 756 void RawLibrary::WriteTo(SnapshotWriter* writer, |
| 753 intptr_t object_id, | 757 intptr_t object_id, |
| 754 Snapshot::Kind kind) { | 758 Snapshot::Kind kind) { |
| 755 ASSERT(writer != NULL); | 759 ASSERT(writer != NULL); |
| 756 ASSERT(kind != Snapshot::kMessage); | 760 ASSERT(kind != Snapshot::kMessage); |
| 757 | 761 |
| 758 // Write out the serialization header value for this object. | 762 // Write out the serialization header value for this object. |
| 759 writer->WriteSerializationMarker(kInlined, object_id); | 763 writer->WriteInlinedObjectHeader(object_id); |
| 760 | 764 |
| 761 // Write out the class and tags information. | 765 // Write out the class and tags information. |
| 762 writer->WriteObjectHeader(Object::kLibraryClass, writer->GetObjectTags(this)); | 766 writer->WriteVMIsolateObject(Object::kLibraryClass); |
| 767 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 763 | 768 |
| 764 if (RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { | 769 if (RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) { |
| 765 ASSERT(kind != Snapshot::kFull); | 770 ASSERT(kind != Snapshot::kFull); |
| 766 // Write out library URL so that it can be looked up when reading. | 771 // Write out library URL so that it can be looked up when reading. |
| 767 writer->WriteObjectImpl(ptr()->url_); | 772 writer->WriteObjectImpl(ptr()->url_); |
| 768 } else { | 773 } else { |
| 769 // Write out all non object fields. | 774 // Write out all non object fields. |
| 770 writer->WriteIntptrValue(ptr()->index_); | 775 writer->WriteIntptrValue(ptr()->index_); |
| 771 writer->WriteIntptrValue(ptr()->num_imports_); | 776 writer->WriteIntptrValue(ptr()->num_imports_); |
| 772 writer->WriteIntptrValue(ptr()->num_imported_into_); | 777 writer->WriteIntptrValue(ptr()->num_imported_into_); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 824 |
| 820 | 825 |
| 821 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 826 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
| 822 intptr_t object_id, | 827 intptr_t object_id, |
| 823 Snapshot::Kind kind) { | 828 Snapshot::Kind kind) { |
| 824 ASSERT(writer != NULL); | 829 ASSERT(writer != NULL); |
| 825 ASSERT(kind != Snapshot::kMessage && | 830 ASSERT(kind != Snapshot::kMessage && |
| 826 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 831 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 827 | 832 |
| 828 // Write out the serialization header value for this object. | 833 // Write out the serialization header value for this object. |
| 829 writer->WriteSerializationMarker(kInlined, object_id); | 834 writer->WriteInlinedObjectHeader(object_id); |
| 830 | 835 |
| 831 // Write out the class and tags information. | 836 // Write out the class and tags information. |
| 832 writer->WriteObjectHeader(Object::kLibraryPrefixClass, | 837 writer->WriteVMIsolateObject(Object::kLibraryPrefixClass); |
| 833 writer->GetObjectTags(this)); | 838 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 834 | 839 |
| 835 // Write out all non object fields. | 840 // Write out all non object fields. |
| 836 writer->WriteIntptrValue(ptr()->num_libs_); | 841 writer->WriteIntptrValue(ptr()->num_libs_); |
| 837 | 842 |
| 838 // Write out all the object pointer fields. | 843 // Write out all the object pointer fields. |
| 839 SnapshotWriterVisitor visitor(writer); | 844 SnapshotWriterVisitor visitor(writer); |
| 840 visitor.VisitPointers(from(), to()); | 845 visitor.VisitPointers(from(), to()); |
| 841 } | 846 } |
| 842 | 847 |
| 843 | 848 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 return context.raw(); | 993 return context.raw(); |
| 989 } | 994 } |
| 990 | 995 |
| 991 | 996 |
| 992 void RawContext::WriteTo(SnapshotWriter* writer, | 997 void RawContext::WriteTo(SnapshotWriter* writer, |
| 993 intptr_t object_id, | 998 intptr_t object_id, |
| 994 Snapshot::Kind kind) { | 999 Snapshot::Kind kind) { |
| 995 ASSERT(writer != NULL); | 1000 ASSERT(writer != NULL); |
| 996 | 1001 |
| 997 // Write out the serialization header value for this object. | 1002 // Write out the serialization header value for this object. |
| 998 writer->WriteSerializationMarker(kInlined, object_id); | 1003 writer->WriteInlinedObjectHeader(object_id); |
| 999 | 1004 |
| 1000 // Write out the class and tags information. | 1005 // Write out the class and tags information. |
| 1001 writer->WriteObjectHeader(Object::kContextClass, writer->GetObjectTags(this)); | 1006 writer->WriteVMIsolateObject(Object::kContextClass); |
| 1007 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1002 | 1008 |
| 1003 // Write out num of variables in the context. | 1009 // Write out num of variables in the context. |
| 1004 writer->WriteIntptrValue(ptr()->num_variables_); | 1010 writer->WriteIntptrValue(ptr()->num_variables_); |
| 1005 | 1011 |
| 1006 // Can't serialize the isolate pointer, we set it implicitly on read. | 1012 // Can't serialize the isolate pointer, we set it implicitly on read. |
| 1007 | 1013 |
| 1008 // Write out all the object pointer fields. | 1014 // Write out all the object pointer fields. |
| 1009 SnapshotWriterVisitor visitor(writer); | 1015 SnapshotWriterVisitor visitor(writer); |
| 1010 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 1016 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
| 1011 } | 1017 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1039 } | 1045 } |
| 1040 | 1046 |
| 1041 | 1047 |
| 1042 void RawContextScope::WriteTo(SnapshotWriter* writer, | 1048 void RawContextScope::WriteTo(SnapshotWriter* writer, |
| 1043 intptr_t object_id, | 1049 intptr_t object_id, |
| 1044 Snapshot::Kind kind) { | 1050 Snapshot::Kind kind) { |
| 1045 ASSERT(writer != NULL); | 1051 ASSERT(writer != NULL); |
| 1046 ASSERT(kind == Snapshot::kMessage); | 1052 ASSERT(kind == Snapshot::kMessage); |
| 1047 | 1053 |
| 1048 // Write out the serialization header value for this object. | 1054 // Write out the serialization header value for this object. |
| 1049 writer->WriteSerializationMarker(kInlined, object_id); | 1055 writer->WriteInlinedObjectHeader(object_id); |
| 1050 | 1056 |
| 1051 // Write out the class and tags information. | 1057 // Write out the class and tags information. |
| 1052 writer->WriteObjectHeader(Object::kContextScopeClass, | 1058 writer->WriteVMIsolateObject(Object::kContextScopeClass); |
| 1053 writer->GetObjectTags(this)); | 1059 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1054 | 1060 |
| 1055 // Serialize number of variables. | 1061 // Serialize number of variables. |
| 1056 writer->WriteIntptrValue(ptr()->num_variables_); | 1062 writer->WriteIntptrValue(ptr()->num_variables_); |
| 1057 | 1063 |
| 1058 // Write out all the object pointer fields. | 1064 // Write out all the object pointer fields. |
| 1059 SnapshotWriterVisitor visitor(writer); | 1065 SnapshotWriterVisitor visitor(writer); |
| 1060 visitor.VisitPointers(from(), to(ptr()->num_variables_)); | 1066 visitor.VisitPointers(from(), to(ptr()->num_variables_)); |
| 1061 } | 1067 } |
| 1062 | 1068 |
| 1063 | 1069 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1217 return mint.raw(); | 1223 return mint.raw(); |
| 1218 } | 1224 } |
| 1219 | 1225 |
| 1220 | 1226 |
| 1221 void RawMint::WriteTo(SnapshotWriter* writer, | 1227 void RawMint::WriteTo(SnapshotWriter* writer, |
| 1222 intptr_t object_id, | 1228 intptr_t object_id, |
| 1223 Snapshot::Kind kind) { | 1229 Snapshot::Kind kind) { |
| 1224 ASSERT(writer != NULL); | 1230 ASSERT(writer != NULL); |
| 1225 | 1231 |
| 1226 // Write out the serialization header value for this object. | 1232 // Write out the serialization header value for this object. |
| 1227 writer->WriteSerializationMarker(kInlined, object_id); | 1233 writer->WriteInlinedObjectHeader(object_id); |
| 1228 | 1234 |
| 1229 // Write out the class and tags information. | 1235 // Write out the class and tags information. |
| 1230 writer->WriteObjectHeader(ObjectStore::kMintClass, | 1236 writer->WriteIndexedObject(ObjectStore::kMintClass); |
| 1231 writer->GetObjectTags(this)); | 1237 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1232 | 1238 |
| 1233 // Write out the 64 bit value. | 1239 // Write out the 64 bit value. |
| 1234 writer->Write<int64_t>(ptr()->value_); | 1240 writer->Write<int64_t>(ptr()->value_); |
| 1235 } | 1241 } |
| 1236 | 1242 |
| 1237 | 1243 |
| 1238 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, | 1244 RawBigint* Bigint::ReadFrom(SnapshotReader* reader, |
| 1239 intptr_t object_id, | 1245 intptr_t object_id, |
| 1240 intptr_t tags, | 1246 intptr_t tags, |
| 1241 Snapshot::Kind kind) { | 1247 Snapshot::Kind kind) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1265 return obj.raw(); | 1271 return obj.raw(); |
| 1266 } | 1272 } |
| 1267 | 1273 |
| 1268 | 1274 |
| 1269 void RawBigint::WriteTo(SnapshotWriter* writer, | 1275 void RawBigint::WriteTo(SnapshotWriter* writer, |
| 1270 intptr_t object_id, | 1276 intptr_t object_id, |
| 1271 Snapshot::Kind kind) { | 1277 Snapshot::Kind kind) { |
| 1272 ASSERT(writer != NULL); | 1278 ASSERT(writer != NULL); |
| 1273 | 1279 |
| 1274 // Write out the serialization header value for this object. | 1280 // Write out the serialization header value for this object. |
| 1275 writer->WriteSerializationMarker(kInlined, object_id); | 1281 writer->WriteInlinedObjectHeader(object_id); |
| 1276 | 1282 |
| 1277 // Write out the class and tags information. | 1283 // Write out the class and tags information. |
| 1278 writer->WriteObjectHeader(ObjectStore::kBigintClass, | 1284 writer->WriteIndexedObject(ObjectStore::kBigintClass); |
| 1279 writer->GetObjectTags(this)); | 1285 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1280 | 1286 |
| 1281 // Write out the bigint value as a HEXCstring. | 1287 // Write out the bigint value as a HEXCstring. |
| 1282 intptr_t length = ptr()->signed_length_; | 1288 intptr_t length = ptr()->signed_length_; |
| 1283 bool is_negative = false; | 1289 bool is_negative = false; |
| 1284 if (length <= 0) { | 1290 if (length <= 0) { |
| 1285 length = -length; | 1291 length = -length; |
| 1286 is_negative = true; | 1292 is_negative = true; |
| 1287 } | 1293 } |
| 1288 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint); | 1294 uword data_start = reinterpret_cast<uword>(ptr()) + sizeof(RawBigint); |
| 1289 const char* str = BigintOperations::ToHexCString( | 1295 const char* str = BigintOperations::ToHexCString( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 return dbl.raw(); | 1341 return dbl.raw(); |
| 1336 } | 1342 } |
| 1337 | 1343 |
| 1338 | 1344 |
| 1339 void RawDouble::WriteTo(SnapshotWriter* writer, | 1345 void RawDouble::WriteTo(SnapshotWriter* writer, |
| 1340 intptr_t object_id, | 1346 intptr_t object_id, |
| 1341 Snapshot::Kind kind) { | 1347 Snapshot::Kind kind) { |
| 1342 ASSERT(writer != NULL); | 1348 ASSERT(writer != NULL); |
| 1343 | 1349 |
| 1344 // Write out the serialization header value for this object. | 1350 // Write out the serialization header value for this object. |
| 1345 writer->WriteSerializationMarker(kInlined, object_id); | 1351 writer->WriteInlinedObjectHeader(object_id); |
| 1346 | 1352 |
| 1347 // Write out the class and tags information. | 1353 // Write out the class and tags information. |
| 1348 writer->WriteObjectHeader(ObjectStore::kDoubleClass, | 1354 writer->WriteIndexedObject(ObjectStore::kDoubleClass); |
| 1349 writer->GetObjectTags(this)); | 1355 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1350 | 1356 |
| 1351 // Write out the double value. | 1357 // Write out the double value. |
| 1352 writer->Write<double>(ptr()->value_); | 1358 writer->Write<double>(ptr()->value_); |
| 1353 } | 1359 } |
| 1354 | 1360 |
| 1355 | 1361 |
| 1356 RawString* String::ReadFrom(SnapshotReader* reader, | 1362 RawString* String::ReadFrom(SnapshotReader* reader, |
| 1357 intptr_t object_id, | 1363 intptr_t object_id, |
| 1358 intptr_t tags, | 1364 intptr_t tags, |
| 1359 Snapshot::Kind kind) { | 1365 Snapshot::Kind kind) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 Snapshot::Kind kind, | 1500 Snapshot::Kind kind, |
| 1495 intptr_t class_id, | 1501 intptr_t class_id, |
| 1496 intptr_t tags, | 1502 intptr_t tags, |
| 1497 RawSmi* length, | 1503 RawSmi* length, |
| 1498 RawSmi* hash, | 1504 RawSmi* hash, |
| 1499 T* data) { | 1505 T* data) { |
| 1500 ASSERT(writer != NULL); | 1506 ASSERT(writer != NULL); |
| 1501 intptr_t len = Smi::Value(length); | 1507 intptr_t len = Smi::Value(length); |
| 1502 | 1508 |
| 1503 // Write out the serialization header value for this object. | 1509 // Write out the serialization header value for this object. |
| 1504 writer->WriteSerializationMarker(kInlined, object_id); | 1510 writer->WriteInlinedObjectHeader(object_id); |
| 1505 | 1511 |
| 1506 // Write out the class and tags information. | 1512 // Write out the class and tags information. |
| 1507 writer->WriteObjectHeader(class_id, tags); | 1513 writer->WriteIndexedObject(class_id); |
| 1514 writer->WriteIntptrValue(tags); |
| 1508 | 1515 |
| 1509 // Write out the length field. | 1516 // Write out the length field. |
| 1510 writer->Write<RawObject*>(length); | 1517 writer->Write<RawObject*>(length); |
| 1511 | 1518 |
| 1512 // Write out the hash field. | 1519 // Write out the hash field. |
| 1513 writer->Write<RawObject*>(hash); | 1520 writer->Write<RawObject*>(hash); |
| 1514 | 1521 |
| 1515 // Write out the string. | 1522 // Write out the string. |
| 1516 if (len > 0) { | 1523 if (len > 0) { |
| 1517 if (class_id == ObjectStore::kOneByteStringClass) { | 1524 if (class_id == ObjectStore::kOneByteStringClass) { |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1748 return array.raw(); | 1755 return array.raw(); |
| 1749 } | 1756 } |
| 1750 | 1757 |
| 1751 | 1758 |
| 1752 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, | 1759 void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer, |
| 1753 intptr_t object_id, | 1760 intptr_t object_id, |
| 1754 Snapshot::Kind kind) { | 1761 Snapshot::Kind kind) { |
| 1755 ASSERT(writer != NULL); | 1762 ASSERT(writer != NULL); |
| 1756 | 1763 |
| 1757 // Write out the serialization header value for this object. | 1764 // Write out the serialization header value for this object. |
| 1758 writer->WriteSerializationMarker(kInlined, object_id); | 1765 writer->WriteInlinedObjectHeader(object_id); |
| 1759 | 1766 |
| 1760 // Write out the class and tags information. | 1767 // Write out the class and tags information. |
| 1761 writer->WriteObjectHeader(ObjectStore::kGrowableObjectArrayClass, | 1768 writer->WriteIndexedObject(ObjectStore::kGrowableObjectArrayClass); |
| 1762 writer->GetObjectTags(this)); | 1769 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1763 | 1770 |
| 1764 // Write out the used length field. | 1771 // Write out the used length field. |
| 1765 writer->Write<RawObject*>(ptr()->length_); | 1772 writer->Write<RawObject*>(ptr()->length_); |
| 1766 | 1773 |
| 1767 // Write out the Array object. | 1774 // Write out the Array object. |
| 1768 writer->WriteObjectImpl(ptr()->data_); | 1775 writer->WriteObjectImpl(ptr()->data_); |
| 1769 } | 1776 } |
| 1770 | 1777 |
| 1771 | 1778 |
| 1772 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader, | 1779 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 intptr_t object_id, | 1865 intptr_t object_id, |
| 1859 Snapshot::Kind kind, | 1866 Snapshot::Kind kind, |
| 1860 intptr_t byte_array_kind, | 1867 intptr_t byte_array_kind, |
| 1861 intptr_t tags, | 1868 intptr_t tags, |
| 1862 RawSmi* length, | 1869 RawSmi* length, |
| 1863 uint8_t* data) { | 1870 uint8_t* data) { |
| 1864 ASSERT(writer != NULL); | 1871 ASSERT(writer != NULL); |
| 1865 intptr_t len = Smi::Value(length); | 1872 intptr_t len = Smi::Value(length); |
| 1866 | 1873 |
| 1867 // Write out the serialization header value for this object. | 1874 // Write out the serialization header value for this object. |
| 1868 writer->WriteSerializationMarker(kInlined, object_id); | 1875 writer->WriteInlinedObjectHeader(object_id); |
| 1869 | 1876 |
| 1870 // Write out the class and tags information. | 1877 // Write out the class and tags information. |
| 1871 writer->WriteObjectHeader(byte_array_kind, tags); | 1878 writer->WriteIndexedObject(byte_array_kind); |
| 1879 writer->WriteIntptrValue(tags); |
| 1872 | 1880 |
| 1873 // Write out the length field. | 1881 // Write out the length field. |
| 1874 writer->Write<RawObject*>(length); | 1882 writer->Write<RawObject*>(length); |
| 1875 | 1883 |
| 1876 // Write out the array elements. | 1884 // Write out the array elements. |
| 1877 for (intptr_t i = 0; i < len; i++) { | 1885 for (intptr_t i = 0; i < len; i++) { |
| 1878 writer->Write(data[i]); | 1886 writer->Write(data[i]); |
| 1879 } | 1887 } |
| 1880 } | 1888 } |
| 1881 | 1889 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1988 } | 1996 } |
| 1989 | 1997 |
| 1990 | 1998 |
| 1991 void RawJSRegExp::WriteTo(SnapshotWriter* writer, | 1999 void RawJSRegExp::WriteTo(SnapshotWriter* writer, |
| 1992 intptr_t object_id, | 2000 intptr_t object_id, |
| 1993 Snapshot::Kind kind) { | 2001 Snapshot::Kind kind) { |
| 1994 ASSERT(writer != NULL); | 2002 ASSERT(writer != NULL); |
| 1995 ASSERT(kind == Snapshot::kMessage); | 2003 ASSERT(kind == Snapshot::kMessage); |
| 1996 | 2004 |
| 1997 // Write out the serialization header value for this object. | 2005 // Write out the serialization header value for this object. |
| 1998 writer->WriteSerializationMarker(kInlined, object_id); | 2006 writer->WriteInlinedObjectHeader(object_id); |
| 1999 | 2007 |
| 2000 // Write out the class and tags information. | 2008 // Write out the class and tags information. |
| 2001 writer->WriteObjectHeader(ObjectStore::kJSRegExpClass, | 2009 writer->WriteIndexedObject(ObjectStore::kJSRegExpClass); |
| 2002 writer->GetObjectTags(this)); | 2010 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2003 | 2011 |
| 2004 // Write out the data length field. | 2012 // Write out the data length field. |
| 2005 writer->Write<RawObject*>(ptr()->data_length_); | 2013 writer->Write<RawObject*>(ptr()->data_length_); |
| 2006 | 2014 |
| 2007 // Write out all the other fields. | 2015 // Write out all the other fields. |
| 2008 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 2016 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 2009 writer->WriteObjectImpl(ptr()->pattern_); | 2017 writer->WriteObjectImpl(ptr()->pattern_); |
| 2010 writer->WriteIntptrValue(ptr()->type_); | 2018 writer->WriteIntptrValue(ptr()->type_); |
| 2011 writer->WriteIntptrValue(ptr()->flags_); | 2019 writer->WriteIntptrValue(ptr()->flags_); |
| 2012 | 2020 |
| 2013 // Do not write out the data part which is native. | 2021 // Do not write out the data part which is native. |
| 2014 } | 2022 } |
| 2015 | 2023 |
| 2016 | 2024 |
| 2017 } // namespace dart | 2025 } // namespace dart |
| OLD | NEW |