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/visitor.h" | 9 #include "vm/visitor.h" |
10 | 10 |
(...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 | 586 |
587 | 587 |
588 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 588 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
589 intptr_t object_id, | 589 intptr_t object_id, |
590 intptr_t tags, | 590 intptr_t tags, |
591 Snapshot::Kind kind) { | 591 Snapshot::Kind kind) { |
592 ASSERT(reader != NULL); | 592 ASSERT(reader != NULL); |
593 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 593 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
594 | 594 |
595 // Read the length so that we can determine number of tokens to read. | 595 // Read the length so that we can determine number of tokens to read. |
596 intptr_t len = reader->ReadSmiValue(); | 596 intptr_t len = reader->ReadIntptrValue(); |
597 | 597 |
598 // Create the token stream object. | 598 // Create the token stream object. |
599 TokenStream& token_stream = TokenStream::ZoneHandle( | 599 TokenStream& token_stream = TokenStream::ZoneHandle( |
600 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 600 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
601 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 601 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
602 | 602 |
603 // Set the object tags. | 603 // Set the object tags. |
604 token_stream.set_tags(tags); | 604 token_stream.set_tags(tags); |
605 | 605 |
606 // Read the token stream into the TokenStream. | 606 // Read the stream of tokens into the TokenStream object. |
607 for (intptr_t i = 0; i < len; i++) { | 607 reader->ReadBytes(reinterpret_cast<uint8_t*>(token_stream.EntryAddr(0)), len); |
608 *reader->ObjectHandle() = reader->ReadObjectImpl(); | 608 |
609 token_stream.SetTokenAt(i, *reader->ObjectHandle()); | 609 // Read in the literal/identifier token array. |
610 } | 610 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); |
| 611 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
| 612 |
611 return token_stream.raw(); | 613 return token_stream.raw(); |
612 } | 614 } |
613 | 615 |
614 | 616 |
615 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 617 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
616 intptr_t object_id, | 618 intptr_t object_id, |
617 Snapshot::Kind kind) { | 619 Snapshot::Kind kind) { |
618 ASSERT(writer != NULL); | 620 ASSERT(writer != NULL); |
619 ASSERT(kind != Snapshot::kMessage && | 621 ASSERT(kind != Snapshot::kMessage && |
620 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 622 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
621 | 623 |
622 // Write out the serialization header value for this object. | 624 // Write out the serialization header value for this object. |
623 writer->WriteSerializationMarker(kInlined, object_id); | 625 writer->WriteSerializationMarker(kInlined, object_id); |
624 | 626 |
625 // Write out the class and tags information. | 627 // Write out the class and tags information. |
626 writer->WriteObjectHeader(Object::kTokenStreamClass, | 628 writer->WriteObjectHeader(Object::kTokenStreamClass, |
627 writer->GetObjectTags(this)); | 629 writer->GetObjectTags(this)); |
628 | 630 |
629 // Write out the length field. | 631 // Write out the length field and the token stream. |
630 writer->Write<RawObject*>(ptr()->length_); | 632 intptr_t len = ptr()->length_; |
| 633 writer->Write<intptr_t>(len); |
| 634 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); |
631 | 635 |
632 // Write out the token stream (token kind and literal). | 636 // Write out the literal/identifier token array. |
633 intptr_t len = Smi::Value(ptr()->length_); | 637 writer->WriteObjectImpl(ptr()->token_objects_); |
634 for (intptr_t i = 0; i < TokenStream::StreamLength(len); i++) { | |
635 writer->WriteObjectImpl(ptr()->data_[i]); | |
636 } | |
637 } | 638 } |
638 | 639 |
639 | 640 |
640 RawScript* Script::ReadFrom(SnapshotReader* reader, | 641 RawScript* Script::ReadFrom(SnapshotReader* reader, |
641 intptr_t object_id, | 642 intptr_t object_id, |
642 intptr_t tags, | 643 intptr_t tags, |
643 Snapshot::Kind kind) { | 644 Snapshot::Kind kind) { |
644 ASSERT(reader != NULL); | 645 ASSERT(reader != NULL); |
645 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); | 646 ASSERT(kind != Snapshot::kMessage && !RawObject::IsCreatedFromSnapshot(tags)); |
646 | 647 |
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1982 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
1982 writer->WriteObjectImpl(ptr()->pattern_); | 1983 writer->WriteObjectImpl(ptr()->pattern_); |
1983 writer->WriteIntptrValue(ptr()->type_); | 1984 writer->WriteIntptrValue(ptr()->type_); |
1984 writer->WriteIntptrValue(ptr()->flags_); | 1985 writer->WriteIntptrValue(ptr()->flags_); |
1985 | 1986 |
1986 // Do not write out the data part which is native. | 1987 // Do not write out the data part which is native. |
1987 } | 1988 } |
1988 | 1989 |
1989 | 1990 |
1990 } // namespace dart | 1991 } // namespace dart |
OLD | NEW |