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

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

Issue 10871005: Make ClassFinalizer indifferent on whether we are generating a snapshot or not. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/snapshot.h » ('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/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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 225
226 // Write out the class and tags information. 226 // Write out the class and tags information.
227 writer->WriteVMIsolateObject(kTypeCid); 227 writer->WriteVMIsolateObject(kTypeCid);
228 writer->WriteIntptrValue(writer->GetObjectTags(this)); 228 writer->WriteIntptrValue(writer->GetObjectTags(this));
229 229
230 // Write out all the non object pointer fields. 230 // Write out all the non object pointer fields.
231 writer->WriteIntptrValue(ptr()->token_pos_); 231 writer->WriteIntptrValue(ptr()->token_pos_);
232 writer->Write<int8_t>(ptr()->type_state_); 232 writer->Write<int8_t>(ptr()->type_state_);
233 233
234 // Write out all the object pointer fields. 234 // Write out all the object pointer fields.
235 SnapshotWriterVisitor visitor(writer, false); 235 SnapshotWriterVisitor visitor(writer);
siva 2012/08/22 23:55:05 We should probably leave it as , false here becaus
regis 2012/08/23 00:24:25 I fixed it the other way around, by reading refs.
236 visitor.VisitPointers(from(), to()); 236 visitor.VisitPointers(from(), to());
237 } 237 }
238 238
239 239
240 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader, 240 RawTypeParameter* TypeParameter::ReadFrom(SnapshotReader* reader,
241 intptr_t object_id, 241 intptr_t object_id,
242 intptr_t tags, 242 intptr_t tags,
243 Snapshot::Kind kind) { 243 Snapshot::Kind kind) {
244 ASSERT(reader != NULL); 244 ASSERT(reader != NULL);
245 245
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 // Write out the class and tags information. 280 // Write out the class and tags information.
281 writer->WriteVMIsolateObject(kTypeParameterCid); 281 writer->WriteVMIsolateObject(kTypeParameterCid);
282 writer->WriteIntptrValue(writer->GetObjectTags(this)); 282 writer->WriteIntptrValue(writer->GetObjectTags(this));
283 283
284 // Write out all the non object pointer fields. 284 // Write out all the non object pointer fields.
285 writer->WriteIntptrValue(ptr()->index_); 285 writer->WriteIntptrValue(ptr()->index_);
286 writer->WriteIntptrValue(ptr()->token_pos_); 286 writer->WriteIntptrValue(ptr()->token_pos_);
287 writer->Write<int8_t>(ptr()->type_state_); 287 writer->Write<int8_t>(ptr()->type_state_);
288 288
289 // Write out all the object pointer fields. 289 // Write out all the object pointer fields.
290 SnapshotWriterVisitor visitor(writer, false); 290 SnapshotWriterVisitor visitor(writer);
siva 2012/08/22 23:55:05 Ditto.
regis 2012/08/23 00:24:25 Ditto
291 visitor.VisitPointers(from(), to()); 291 visitor.VisitPointers(from(), to());
292 } 292 }
293 293
294 294
295 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom( 295 RawAbstractTypeArguments* AbstractTypeArguments::ReadFrom(
296 SnapshotReader* reader, 296 SnapshotReader* reader,
297 intptr_t object_id, 297 intptr_t object_id,
298 intptr_t tags, 298 intptr_t tags,
299 Snapshot::Kind kind) { 299 Snapshot::Kind kind) {
300 UNREACHABLE(); // AbstractTypeArguments is an abstract class. 300 UNREACHABLE(); // AbstractTypeArguments is an abstract class.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 ASSERT(kind == Snapshot::kMessage); 400 ASSERT(kind == Snapshot::kMessage);
401 401
402 // Write out the serialization header value for this object. 402 // Write out the serialization header value for this object.
403 writer->WriteInlinedObjectHeader(object_id); 403 writer->WriteInlinedObjectHeader(object_id);
404 404
405 // Write out the class and tags information. 405 // Write out the class and tags information.
406 writer->WriteVMIsolateObject(kInstantiatedTypeArgumentsCid); 406 writer->WriteVMIsolateObject(kInstantiatedTypeArgumentsCid);
407 writer->WriteIntptrValue(writer->GetObjectTags(this)); 407 writer->WriteIntptrValue(writer->GetObjectTags(this));
408 408
409 // Write out all the object pointer fields. 409 // Write out all the object pointer fields.
410 SnapshotWriterVisitor visitor(writer, false); 410 SnapshotWriterVisitor visitor(writer);
siva 2012/08/22 23:55:05 Ditto.
regis 2012/08/23 00:24:25 Ditto
411 visitor.VisitPointers(from(), to()); 411 visitor.VisitPointers(from(), to());
412 } 412 }
413 413
414 414
415 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, 415 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader,
416 intptr_t object_id, 416 intptr_t object_id,
417 intptr_t tags, 417 intptr_t tags,
418 Snapshot::Kind kind) { 418 Snapshot::Kind kind) {
419 ASSERT(reader != NULL); 419 ASSERT(reader != NULL);
420 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 420 ASSERT((kind != Snapshot::kMessage) &&
turnidge 2012/08/22 23:49:17 Why the extra parens?
regis 2012/08/23 00:24:25 Not that I like them that much, but our style guid
421 !RawObject::IsCreatedFromSnapshot(tags));
421 422
422 // Allocate function object. 423 // Allocate function object.
423 PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(), 424 PatchClass& cls = PatchClass::ZoneHandle(reader->isolate(),
424 NEW_OBJECT(PatchClass)); 425 NEW_OBJECT(PatchClass));
425 reader->AddBackRef(object_id, &cls, kIsDeserialized); 426 reader->AddBackRef(object_id, &cls, kIsDeserialized);
426 427
427 // Set the object tags. 428 // Set the object tags.
428 cls.set_tags(tags); 429 cls.set_tags(tags);
429 430
430 // Set all the object fields. 431 // Set all the object fields.
431 // TODO(5411462): Need to assert No GC can happen here, even though 432 // TODO(5411462): Need to assert No GC can happen here, even though
432 // allocations may happen. 433 // allocations may happen.
433 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); 434 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from());
434 for (intptr_t i = 0; i <= num_flds; i++) { 435 for (intptr_t i = 0; i <= num_flds; i++) {
435 *(cls.raw()->from() + i) = reader->ReadObjectRef(); 436 *(cls.raw()->from() + i) = reader->ReadObjectRef();
436 } 437 }
437 438
438 return cls.raw(); 439 return cls.raw();
439 } 440 }
440 441
441 442
442 void RawPatchClass::WriteTo(SnapshotWriter* writer, 443 void RawPatchClass::WriteTo(SnapshotWriter* writer,
443 intptr_t object_id, 444 intptr_t object_id,
444 Snapshot::Kind kind) { 445 Snapshot::Kind kind) {
445 ASSERT(writer != NULL); 446 ASSERT(writer != NULL);
446 ASSERT(kind != Snapshot::kMessage && 447 ASSERT((kind != Snapshot::kMessage) &&
447 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 448 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
448 449
449 // Write out the serialization header value for this object. 450 // Write out the serialization header value for this object.
450 writer->WriteInlinedObjectHeader(object_id); 451 writer->WriteInlinedObjectHeader(object_id);
451 452
452 // Write out the class and tags information. 453 // Write out the class and tags information.
453 writer->WriteVMIsolateObject(kPatchClassCid); 454 writer->WriteVMIsolateObject(kPatchClassCid);
454 writer->WriteIntptrValue(writer->GetObjectTags(this)); 455 writer->WriteIntptrValue(writer->GetObjectTags(this));
455 // Write out all the object pointer fields. 456 // Write out all the object pointer fields.
456 SnapshotWriterVisitor visitor(writer); 457 SnapshotWriterVisitor visitor(writer);
457 visitor.VisitPointers(from(), to()); 458 visitor.VisitPointers(from(), to());
458 } 459 }
459 460
460 461
461 RawFunction* Function::ReadFrom(SnapshotReader* reader, 462 RawFunction* Function::ReadFrom(SnapshotReader* reader,
462 intptr_t object_id, 463 intptr_t object_id,
463 intptr_t tags, 464 intptr_t tags,
464 Snapshot::Kind kind) { 465 Snapshot::Kind kind) {
465 ASSERT(reader != NULL); 466 ASSERT(reader != NULL);
466 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 467 ASSERT((kind != Snapshot::kMessage) &&
468 !RawObject::IsCreatedFromSnapshot(tags));
467 469
468 // Allocate function object. 470 // Allocate function object.
469 Function& func = Function::ZoneHandle( 471 Function& func = Function::ZoneHandle(
470 reader->isolate(), NEW_OBJECT(Function)); 472 reader->isolate(), NEW_OBJECT(Function));
471 reader->AddBackRef(object_id, &func, kIsDeserialized); 473 reader->AddBackRef(object_id, &func, kIsDeserialized);
472 474
473 // Set the object tags. 475 // Set the object tags.
474 func.set_tags(tags); 476 func.set_tags(tags);
475 477
476 // Set all the non object fields. 478 // Set all the non object fields.
(...skipping 14 matching lines...) Expand all
491 } 493 }
492 494
493 return func.raw(); 495 return func.raw();
494 } 496 }
495 497
496 498
497 void RawFunction::WriteTo(SnapshotWriter* writer, 499 void RawFunction::WriteTo(SnapshotWriter* writer,
498 intptr_t object_id, 500 intptr_t object_id,
499 Snapshot::Kind kind) { 501 Snapshot::Kind kind) {
500 ASSERT(writer != NULL); 502 ASSERT(writer != NULL);
501 ASSERT(kind != Snapshot::kMessage && 503 ASSERT((kind != Snapshot::kMessage) &&
502 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 504 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
503 505
504 // Write out the serialization header value for this object. 506 // Write out the serialization header value for this object.
505 writer->WriteInlinedObjectHeader(object_id); 507 writer->WriteInlinedObjectHeader(object_id);
506 508
507 // Write out the class and tags information. 509 // Write out the class and tags information.
508 writer->WriteVMIsolateObject(kFunctionCid); 510 writer->WriteVMIsolateObject(kFunctionCid);
509 writer->WriteIntptrValue(writer->GetObjectTags(this)); 511 writer->WriteIntptrValue(writer->GetObjectTags(this));
510 512
511 // Write out all the non object fields. 513 // Write out all the non object fields.
512 writer->WriteIntptrValue(ptr()->token_pos_); 514 writer->WriteIntptrValue(ptr()->token_pos_);
513 writer->WriteIntptrValue(ptr()->end_token_pos_); 515 writer->WriteIntptrValue(ptr()->end_token_pos_);
514 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); 516 writer->WriteIntptrValue(ptr()->num_fixed_parameters_);
515 writer->WriteIntptrValue(ptr()->num_optional_parameters_); 517 writer->WriteIntptrValue(ptr()->num_optional_parameters_);
516 writer->WriteIntptrValue(ptr()->usage_counter_); 518 writer->WriteIntptrValue(ptr()->usage_counter_);
517 writer->WriteIntptrValue(ptr()->deoptimization_counter_); 519 writer->WriteIntptrValue(ptr()->deoptimization_counter_);
518 writer->WriteIntptrValue(ptr()->kind_tag_); 520 writer->WriteIntptrValue(ptr()->kind_tag_);
519 521
520 // Write out all the object pointer fields. 522 // Write out all the object pointer fields.
521 SnapshotWriterVisitor visitor(writer); 523 SnapshotWriterVisitor visitor(writer);
522 visitor.VisitPointers(from(), to()); 524 visitor.VisitPointers(from(), to());
523 } 525 }
524 526
525 527
526 RawField* Field::ReadFrom(SnapshotReader* reader, 528 RawField* Field::ReadFrom(SnapshotReader* reader,
527 intptr_t object_id, 529 intptr_t object_id,
528 intptr_t tags, 530 intptr_t tags,
529 Snapshot::Kind kind) { 531 Snapshot::Kind kind) {
530 ASSERT(reader != NULL); 532 ASSERT(reader != NULL);
531 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 533 ASSERT((kind != Snapshot::kMessage) &&
534 !RawObject::IsCreatedFromSnapshot(tags));
532 535
533 // Allocate field object. 536 // Allocate field object.
534 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field)); 537 Field& field = Field::ZoneHandle(reader->isolate(), NEW_OBJECT(Field));
535 reader->AddBackRef(object_id, &field, kIsDeserialized); 538 reader->AddBackRef(object_id, &field, kIsDeserialized);
536 539
537 // Set the object tags. 540 // Set the object tags.
538 field.set_tags(tags); 541 field.set_tags(tags);
539 542
540 // Set all non object fields. 543 // Set all non object fields.
541 field.set_token_pos(reader->ReadIntptrValue()); 544 field.set_token_pos(reader->ReadIntptrValue());
542 field.set_kind_bits(reader->Read<uint8_t>()); 545 field.set_kind_bits(reader->Read<uint8_t>());
543 546
544 // Set all the object fields. 547 // Set all the object fields.
545 // TODO(5411462): Need to assert No GC can happen here, even though 548 // TODO(5411462): Need to assert No GC can happen here, even though
546 // allocations may happen. 549 // allocations may happen.
547 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); 550 intptr_t num_flds = (field.raw()->to() - field.raw()->from());
548 for (intptr_t i = 0; i <= num_flds; i++) { 551 for (intptr_t i = 0; i <= num_flds; i++) {
549 *(field.raw()->from() + i) = reader->ReadObjectRef(); 552 *(field.raw()->from() + i) = reader->ReadObjectRef();
550 } 553 }
551 554
552 return field.raw(); 555 return field.raw();
553 } 556 }
554 557
555 558
556 void RawField::WriteTo(SnapshotWriter* writer, 559 void RawField::WriteTo(SnapshotWriter* writer,
557 intptr_t object_id, 560 intptr_t object_id,
558 Snapshot::Kind kind) { 561 Snapshot::Kind kind) {
559 ASSERT(writer != NULL); 562 ASSERT(writer != NULL);
560 ASSERT(kind != Snapshot::kMessage && 563 ASSERT((kind != Snapshot::kMessage) &&
561 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 564 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
562 565
563 // Write out the serialization header value for this object. 566 // Write out the serialization header value for this object.
564 writer->WriteInlinedObjectHeader(object_id); 567 writer->WriteInlinedObjectHeader(object_id);
565 568
566 // Write out the class and tags information. 569 // Write out the class and tags information.
567 writer->WriteVMIsolateObject(kFieldCid); 570 writer->WriteVMIsolateObject(kFieldCid);
568 writer->WriteIntptrValue(writer->GetObjectTags(this)); 571 writer->WriteIntptrValue(writer->GetObjectTags(this));
569 572
570 // Write out all the non object fields. 573 // Write out all the non object fields.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 writer->WriteObjectImpl(ptr()->literal_); 627 writer->WriteObjectImpl(ptr()->literal_);
625 writer->WriteObjectImpl(ptr()->value_); 628 writer->WriteObjectImpl(ptr()->value_);
626 } 629 }
627 630
628 631
629 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, 632 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader,
630 intptr_t object_id, 633 intptr_t object_id,
631 intptr_t tags, 634 intptr_t tags,
632 Snapshot::Kind kind) { 635 Snapshot::Kind kind) {
633 ASSERT(reader != NULL); 636 ASSERT(reader != NULL);
634 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 637 ASSERT((kind != Snapshot::kMessage)
638 && !RawObject::IsCreatedFromSnapshot(tags));
635 639
636 // Read the length so that we can determine number of tokens to read. 640 // Read the length so that we can determine number of tokens to read.
637 intptr_t len = reader->ReadSmiValue(); 641 intptr_t len = reader->ReadSmiValue();
638 642
639 // Create the token stream object. 643 // Create the token stream object.
640 TokenStream& token_stream = TokenStream::ZoneHandle( 644 TokenStream& token_stream = TokenStream::ZoneHandle(
641 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); 645 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len));
642 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); 646 reader->AddBackRef(object_id, &token_stream, kIsDeserialized);
643 647
644 // Set the object tags. 648 // Set the object tags.
(...skipping 14 matching lines...) Expand all
659 token_stream.SetPrivateKey(*(reader->StringHandle())); 663 token_stream.SetPrivateKey(*(reader->StringHandle()));
660 664
661 return token_stream.raw(); 665 return token_stream.raw();
662 } 666 }
663 667
664 668
665 void RawTokenStream::WriteTo(SnapshotWriter* writer, 669 void RawTokenStream::WriteTo(SnapshotWriter* writer,
666 intptr_t object_id, 670 intptr_t object_id,
667 Snapshot::Kind kind) { 671 Snapshot::Kind kind) {
668 ASSERT(writer != NULL); 672 ASSERT(writer != NULL);
669 ASSERT(kind != Snapshot::kMessage && 673 ASSERT((kind != Snapshot::kMessage) &&
670 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 674 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
671 675
672 // Write out the serialization header value for this object. 676 // Write out the serialization header value for this object.
673 writer->WriteInlinedObjectHeader(object_id); 677 writer->WriteInlinedObjectHeader(object_id);
674 678
675 // Write out the class and tags information. 679 // Write out the class and tags information.
676 writer->WriteVMIsolateObject(kTokenStreamCid); 680 writer->WriteVMIsolateObject(kTokenStreamCid);
677 writer->WriteIntptrValue(writer->GetObjectTags(this)); 681 writer->WriteIntptrValue(writer->GetObjectTags(this));
678 682
679 // Write out the length field and the token stream. 683 // Write out the length field and the token stream.
680 intptr_t len = Smi::Value(ptr()->length_); 684 intptr_t len = Smi::Value(ptr()->length_);
681 writer->Write<RawObject*>(ptr()->length_); 685 writer->Write<RawObject*>(ptr()->length_);
682 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); 686 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len);
683 687
684 // Write out the literal/identifier token array. 688 // Write out the literal/identifier token array.
685 writer->WriteObjectImpl(ptr()->token_objects_); 689 writer->WriteObjectImpl(ptr()->token_objects_);
686 // Write out the private key in use by the token stream. 690 // Write out the private key in use by the token stream.
687 writer->WriteObjectImpl(ptr()->private_key_); 691 writer->WriteObjectImpl(ptr()->private_key_);
688 } 692 }
689 693
690 694
691 RawScript* Script::ReadFrom(SnapshotReader* reader, 695 RawScript* Script::ReadFrom(SnapshotReader* reader,
692 intptr_t object_id, 696 intptr_t object_id,
693 intptr_t tags, 697 intptr_t tags,
694 Snapshot::Kind kind) { 698 Snapshot::Kind kind) {
695 ASSERT(reader != NULL); 699 ASSERT(reader != NULL);
696 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 700 ASSERT((kind != Snapshot::kMessage) &&
701 !RawObject::IsCreatedFromSnapshot(tags));
697 702
698 // Allocate script object. 703 // Allocate script object.
699 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); 704 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script));
700 reader->AddBackRef(object_id, &script, kIsDeserialized); 705 reader->AddBackRef(object_id, &script, kIsDeserialized);
701 706
702 // Set the object tags. 707 // Set the object tags.
703 script.set_tags(tags); 708 script.set_tags(tags);
704 709
705 // Set all the object fields. 710 // Set all the object fields.
706 // TODO(5411462): Need to assert No GC can happen here, even though 711 // TODO(5411462): Need to assert No GC can happen here, even though
707 // allocations may happen. 712 // allocations may happen.
708 *reader->StringHandle() ^= reader->ReadObjectImpl(); 713 *reader->StringHandle() ^= reader->ReadObjectImpl();
709 script.set_url(*reader->StringHandle()); 714 script.set_url(*reader->StringHandle());
710 *reader->StringHandle() ^= String::null(); 715 *reader->StringHandle() ^= String::null();
711 script.set_source(*reader->StringHandle()); 716 script.set_source(*reader->StringHandle());
712 TokenStream& stream = TokenStream::Handle(); 717 TokenStream& stream = TokenStream::Handle();
713 stream ^= reader->ReadObjectImpl(); 718 stream ^= reader->ReadObjectImpl();
714 script.set_tokens(stream); 719 script.set_tokens(stream);
715 720
716 return script.raw(); 721 return script.raw();
717 } 722 }
718 723
719 724
720 void RawScript::WriteTo(SnapshotWriter* writer, 725 void RawScript::WriteTo(SnapshotWriter* writer,
721 intptr_t object_id, 726 intptr_t object_id,
722 Snapshot::Kind kind) { 727 Snapshot::Kind kind) {
723 ASSERT(writer != NULL); 728 ASSERT(writer != NULL);
724 ASSERT(tokens_ != TokenStream::null()); 729 ASSERT(tokens_ != TokenStream::null());
725 ASSERT(kind != Snapshot::kMessage && 730 ASSERT((kind != Snapshot::kMessage) &&
726 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 731 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
727 732
728 // Write out the serialization header value for this object. 733 // Write out the serialization header value for this object.
729 writer->WriteInlinedObjectHeader(object_id); 734 writer->WriteInlinedObjectHeader(object_id);
730 735
731 // Write out the class and tags information. 736 // Write out the class and tags information.
732 writer->WriteVMIsolateObject(kScriptCid); 737 writer->WriteVMIsolateObject(kScriptCid);
733 writer->WriteIntptrValue(writer->GetObjectTags(this)); 738 writer->WriteIntptrValue(writer->GetObjectTags(this));
734 739
735 // Write out all the object pointer fields. 740 // Write out all the object pointer fields.
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 visitor.VisitPointers(from(), to()); 832 visitor.VisitPointers(from(), to());
828 } 833 }
829 } 834 }
830 835
831 836
832 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, 837 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader,
833 intptr_t object_id, 838 intptr_t object_id,
834 intptr_t tags, 839 intptr_t tags,
835 Snapshot::Kind kind) { 840 Snapshot::Kind kind) {
836 ASSERT(reader != NULL); 841 ASSERT(reader != NULL);
837 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); 842 ASSERT((kind != Snapshot::kMessage) &&
843 !RawObject::IsCreatedFromSnapshot(tags));
838 844
839 // Allocate library prefix object. 845 // Allocate library prefix object.
840 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( 846 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(
841 reader->isolate(), NEW_OBJECT(LibraryPrefix)); 847 reader->isolate(), NEW_OBJECT(LibraryPrefix));
842 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 848 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
843 849
844 // Set the object tags. 850 // Set the object tags.
845 prefix.set_tags(tags); 851 prefix.set_tags(tags);
846 852
847 // Set all non object fields. 853 // Set all non object fields.
848 prefix.raw_ptr()->num_libs_ = reader->ReadIntptrValue(); 854 prefix.raw_ptr()->num_libs_ = reader->ReadIntptrValue();
849 855
850 // Set all the object fields. 856 // Set all the object fields.
851 // TODO(5411462): Need to assert No GC can happen here, even though 857 // TODO(5411462): Need to assert No GC can happen here, even though
852 // allocations may happen. 858 // allocations may happen.
853 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); 859 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from());
854 for (intptr_t i = 0; i <= num_flds; i++) { 860 for (intptr_t i = 0; i <= num_flds; i++) {
855 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); 861 *(prefix.raw()->from() + i) = reader->ReadObjectRef();
856 } 862 }
857 863
858 return prefix.raw(); 864 return prefix.raw();
859 } 865 }
860 866
861 867
862 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 868 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
863 intptr_t object_id, 869 intptr_t object_id,
864 Snapshot::Kind kind) { 870 Snapshot::Kind kind) {
865 ASSERT(writer != NULL); 871 ASSERT(writer != NULL);
866 ASSERT(kind != Snapshot::kMessage && 872 ASSERT((kind != Snapshot::kMessage) &&
867 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); 873 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this)));
868 874
869 // Write out the serialization header value for this object. 875 // Write out the serialization header value for this object.
870 writer->WriteInlinedObjectHeader(object_id); 876 writer->WriteInlinedObjectHeader(object_id);
871 877
872 // Write out the class and tags information. 878 // Write out the class and tags information.
873 writer->WriteVMIsolateObject(kLibraryPrefixCid); 879 writer->WriteVMIsolateObject(kLibraryPrefixCid);
874 writer->WriteIntptrValue(writer->GetObjectTags(this)); 880 writer->WriteIntptrValue(writer->GetObjectTags(this));
875 881
876 // Write out all non object fields. 882 // Write out all non object fields.
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1133 Snapshot::Kind kind) { 1139 Snapshot::Kind kind) {
1134 UNREACHABLE(); 1140 UNREACHABLE();
1135 } 1141 }
1136 1142
1137 1143
1138 RawError* Error::ReadFrom(SnapshotReader* reader, 1144 RawError* Error::ReadFrom(SnapshotReader* reader,
1139 intptr_t object_id, 1145 intptr_t object_id,
1140 intptr_t tags, 1146 intptr_t tags,
1141 Snapshot::Kind kind) { 1147 Snapshot::Kind kind) {
1142 UNREACHABLE(); 1148 UNREACHABLE();
1143 return Error::null(); 1149 return Error::null(); // Error is an abstract class.
1144 } 1150 }
1145 1151
1146 1152
1147 void RawError::WriteTo(SnapshotWriter* writer, 1153 void RawError::WriteTo(SnapshotWriter* writer,
1148 intptr_t object_id, 1154 intptr_t object_id,
1149 Snapshot::Kind kind) { 1155 Snapshot::Kind kind) {
1150 UNREACHABLE(); 1156 UNREACHABLE(); // Error is an abstract class.
1151 } 1157 }
1152 1158
1153 1159
1154 RawApiError* ApiError::ReadFrom(SnapshotReader* reader, 1160 RawApiError* ApiError::ReadFrom(SnapshotReader* reader,
1155 intptr_t object_id, 1161 intptr_t object_id,
1156 intptr_t tags, 1162 intptr_t tags,
1157 Snapshot::Kind kind) { 1163 Snapshot::Kind kind) {
1158 UNREACHABLE(); 1164 ASSERT(reader != NULL);
1159 return ApiError::null(); 1165
1166 // Allocate ApiError object.
1167 ApiError& api_error =
1168 ApiError::ZoneHandle(reader->isolate(), NEW_OBJECT(ApiError));
1169 reader->AddBackRef(object_id, &api_error, kIsDeserialized);
1170
1171 // Set the object tags.
1172 api_error.set_tags(tags);
1173
1174 // Set all the object fields.
1175 // TODO(5411462): Need to assert No GC can happen here, even though
1176 // allocations may happen.
1177 intptr_t num_flds = (api_error.raw()->to() - api_error.raw()->from());
1178 for (intptr_t i = 0; i <= num_flds; i++) {
1179 *(api_error.raw()->from() + i) = reader->ReadObjectRef();
1180 }
1181
1182 return api_error.raw();
1160 } 1183 }
1161 1184
1162 1185
1163 void RawApiError::WriteTo(SnapshotWriter* writer, 1186 void RawApiError::WriteTo(SnapshotWriter* writer,
1164 intptr_t object_id, 1187 intptr_t object_id,
1165 Snapshot::Kind kind) { 1188 Snapshot::Kind kind) {
1166 UNREACHABLE(); 1189 ASSERT(writer != NULL);
1190
1191 // Write out the serialization header value for this object.
1192 writer->WriteInlinedObjectHeader(object_id);
1193
1194 // Write out the class and tags information.
1195 writer->WriteVMIsolateObject(kApiErrorCid);
1196 writer->WriteIntptrValue(writer->GetObjectTags(this));
1197
1198 // Write out all the object pointer fields.
1199 SnapshotWriterVisitor visitor(writer);
1200 visitor.VisitPointers(from(), to());
1167 } 1201 }
1168 1202
1169 1203
1170 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader, 1204 RawLanguageError* LanguageError::ReadFrom(SnapshotReader* reader,
1171 intptr_t object_id, 1205 intptr_t object_id,
1172 intptr_t tags, 1206 intptr_t tags,
1173 Snapshot::Kind kind) { 1207 Snapshot::Kind kind) {
1174 UNREACHABLE(); 1208 ASSERT(reader != NULL);
1175 return LanguageError::null(); 1209
1210 // Allocate LanguageError object.
1211 LanguageError& language_error =
1212 LanguageError::ZoneHandle(reader->isolate(), NEW_OBJECT(LanguageError));
1213 reader->AddBackRef(object_id, &language_error, kIsDeserialized);
1214
1215 // Set the object tags.
1216 language_error.set_tags(tags);
1217
1218 // Set all the object fields.
1219 // TODO(5411462): Need to assert No GC can happen here, even though
1220 // allocations may happen.
1221 intptr_t num_flds =
1222 (language_error.raw()->to() - language_error.raw()->from());
1223 for (intptr_t i = 0; i <= num_flds; i++) {
1224 *(language_error.raw()->from() + i) = reader->ReadObjectRef();
1225 }
1226
1227 return language_error.raw();
1176 } 1228 }
1177 1229
1178 1230
1179 void RawLanguageError::WriteTo(SnapshotWriter* writer, 1231 void RawLanguageError::WriteTo(SnapshotWriter* writer,
1180 intptr_t object_id, 1232 intptr_t object_id,
1181 Snapshot::Kind kind) { 1233 Snapshot::Kind kind) {
1182 UNREACHABLE(); 1234 ASSERT(writer != NULL);
1235
1236 // Write out the serialization header value for this object.
1237 writer->WriteInlinedObjectHeader(object_id);
1238
1239 // Write out the class and tags information.
1240 writer->WriteVMIsolateObject(kLanguageErrorCid);
1241 writer->WriteIntptrValue(writer->GetObjectTags(this));
1242
1243 // Write out all the object pointer fields.
1244 SnapshotWriterVisitor visitor(writer);
1245 visitor.VisitPointers(from(), to());
1183 } 1246 }
1184 1247
1185 1248
1186 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader, 1249 RawUnhandledException* UnhandledException::ReadFrom(SnapshotReader* reader,
1187 intptr_t object_id, 1250 intptr_t object_id,
1188 intptr_t tags, 1251 intptr_t tags,
1189 Snapshot::Kind kind) { 1252 Snapshot::Kind kind) {
1190 UNREACHABLE(); 1253 UNREACHABLE();
1191 return UnhandledException::null(); 1254 return UnhandledException::null();
1192 } 1255 }
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
2092 // Write out the class and tags information. 2155 // Write out the class and tags information.
2093 writer->WriteIndexedObject(kWeakPropertyCid); 2156 writer->WriteIndexedObject(kWeakPropertyCid);
2094 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2157 writer->WriteIntptrValue(writer->GetObjectTags(this));
2095 2158
2096 // Write out all the other fields. 2159 // Write out all the other fields.
2097 writer->Write<RawObject*>(ptr()->key_); 2160 writer->Write<RawObject*>(ptr()->key_);
2098 writer->Write<RawObject*>(ptr()->value_); 2161 writer->Write<RawObject*>(ptr()->value_);
2099 } 2162 }
2100 2163
2101 } // namespace dart 2164 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/parser.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698