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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 intptr_t len = reader->ReadSmiValue(); | 647 intptr_t len = reader->ReadSmiValue(); |
648 | 648 |
649 // Create the token stream object. | 649 // Create the token stream object. |
650 TokenStream& token_stream = TokenStream::ZoneHandle( | 650 TokenStream& token_stream = TokenStream::ZoneHandle( |
651 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); | 651 reader->isolate(), NEW_OBJECT_WITH_LEN(TokenStream, len)); |
652 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 652 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
653 | 653 |
654 // Set the object tags. | 654 // Set the object tags. |
655 token_stream.set_tags(tags); | 655 token_stream.set_tags(tags); |
656 | 656 |
657 // Read the stream of tokens into the TokenStream object. | 657 // Read the stream of tokens into the TokenStream object for script |
658 { | 658 // snapshots as we made a copy of token stream. |
| 659 if (kind == Snapshot::kScript) { |
659 NoGCScope no_gc; | 660 NoGCScope no_gc; |
660 reader->ReadBytes(reinterpret_cast<uint8_t*>(token_stream.EntryAddr(0)), | 661 RawExternalUint8Array* stream = token_stream.GetStream(); |
661 len); | 662 reader->ReadBytes(stream->ptr()->external_data_->data(), len); |
662 } | 663 } |
663 | 664 |
664 // Read in the literal/identifier token array. | 665 // Read in the literal/identifier token array. |
665 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); | 666 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); |
666 token_stream.SetTokenObjects(*(reader->TokensHandle())); | 667 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
667 // Read in the private key in use by the token stream. | 668 // Read in the private key in use by the token stream. |
668 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); | 669 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); |
669 token_stream.SetPrivateKey(*(reader->StringHandle())); | 670 token_stream.SetPrivateKey(*(reader->StringHandle())); |
670 | 671 |
671 return token_stream.raw(); | 672 return token_stream.raw(); |
672 } | 673 } |
673 | 674 |
674 | 675 |
675 void RawTokenStream::WriteTo(SnapshotWriter* writer, | 676 void RawTokenStream::WriteTo(SnapshotWriter* writer, |
676 intptr_t object_id, | 677 intptr_t object_id, |
677 Snapshot::Kind kind) { | 678 Snapshot::Kind kind) { |
678 ASSERT(writer != NULL); | 679 ASSERT(writer != NULL); |
679 ASSERT((kind != Snapshot::kMessage) && | 680 ASSERT((kind != Snapshot::kMessage) && |
680 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); | 681 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
681 | 682 |
682 // Write out the serialization header value for this object. | 683 // Write out the serialization header value for this object. |
683 writer->WriteInlinedObjectHeader(object_id); | 684 writer->WriteInlinedObjectHeader(object_id); |
684 | 685 |
685 // Write out the class and tags information. | 686 // Write out the class and tags information. |
686 writer->WriteVMIsolateObject(kTokenStreamCid); | 687 writer->WriteVMIsolateObject(kTokenStreamCid); |
687 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 688 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
688 | 689 |
689 // Write out the length field and the token stream. | 690 // Write out the length field and the token stream. |
690 intptr_t len = Smi::Value(ptr()->length_); | 691 RawExternalUint8Array* stream = ptr()->stream_; |
691 writer->Write<RawObject*>(ptr()->length_); | 692 intptr_t len = Smi::Value(stream->ptr()->length_); |
692 writer->WriteBytes(reinterpret_cast<uint8_t*>(ptr()->data_), len); | 693 writer->Write<RawObject*>(stream->ptr()->length_); |
| 694 writer->WriteBytes(stream->ptr()->external_data_->data(), len); |
693 | 695 |
694 // Write out the literal/identifier token array. | 696 // Write out the literal/identifier token array. |
695 writer->WriteObjectImpl(ptr()->token_objects_); | 697 writer->WriteObjectImpl(ptr()->token_objects_); |
696 // Write out the private key in use by the token stream. | 698 // Write out the private key in use by the token stream. |
697 writer->WriteObjectImpl(ptr()->private_key_); | 699 writer->WriteObjectImpl(ptr()->private_key_); |
698 } | 700 } |
699 | 701 |
700 | 702 |
701 RawScript* Script::ReadFrom(SnapshotReader* reader, | 703 RawScript* Script::ReadFrom(SnapshotReader* reader, |
702 intptr_t object_id, | 704 intptr_t object_id, |
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 // Write out the class and tags information. | 2180 // Write out the class and tags information. |
2179 writer->WriteIndexedObject(kWeakPropertyCid); | 2181 writer->WriteIndexedObject(kWeakPropertyCid); |
2180 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2182 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
2181 | 2183 |
2182 // Write out all the other fields. | 2184 // Write out all the other fields. |
2183 writer->Write<RawObject*>(ptr()->key_); | 2185 writer->Write<RawObject*>(ptr()->key_); |
2184 writer->Write<RawObject*>(ptr()->value_); | 2186 writer->Write<RawObject*>(ptr()->value_); |
2185 } | 2187 } |
2186 | 2188 |
2187 } // namespace dart | 2189 } // namespace dart |
OLD | NEW |