| 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 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); | 760 reader->AddBackRef(object_id, &token_stream, kIsDeserialized); |
| 761 | 761 |
| 762 // Set the object tags. | 762 // Set the object tags. |
| 763 token_stream.set_tags(tags); | 763 token_stream.set_tags(tags); |
| 764 | 764 |
| 765 // Read the stream of tokens into the TokenStream object for script | 765 // Read the stream of tokens into the TokenStream object for script |
| 766 // snapshots as we made a copy of token stream. | 766 // snapshots as we made a copy of token stream. |
| 767 if (kind == Snapshot::kScript) { | 767 if (kind == Snapshot::kScript) { |
| 768 NoGCScope no_gc; | 768 NoGCScope no_gc; |
| 769 RawExternalUint8Array* stream = token_stream.GetStream(); | 769 RawExternalUint8Array* stream = token_stream.GetStream(); |
| 770 reader->ReadBytes(stream->ptr()->external_data_->data(), len); | 770 reader->ReadBytes(stream->ptr()->data_, len); |
| 771 } | 771 } |
| 772 | 772 |
| 773 // Read in the literal/identifier token array. | 773 // Read in the literal/identifier token array. |
| 774 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); | 774 *(reader->TokensHandle()) ^= reader->ReadObjectImpl(); |
| 775 token_stream.SetTokenObjects(*(reader->TokensHandle())); | 775 token_stream.SetTokenObjects(*(reader->TokensHandle())); |
| 776 // Read in the private key in use by the token stream. | 776 // Read in the private key in use by the token stream. |
| 777 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); | 777 *(reader->StringHandle()) ^= reader->ReadObjectImpl(); |
| 778 token_stream.SetPrivateKey(*(reader->StringHandle())); | 778 token_stream.SetPrivateKey(*(reader->StringHandle())); |
| 779 | 779 |
| 780 return token_stream.raw(); | 780 return token_stream.raw(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 792 writer->WriteInlinedObjectHeader(object_id); | 792 writer->WriteInlinedObjectHeader(object_id); |
| 793 | 793 |
| 794 // Write out the class and tags information. | 794 // Write out the class and tags information. |
| 795 writer->WriteVMIsolateObject(kTokenStreamCid); | 795 writer->WriteVMIsolateObject(kTokenStreamCid); |
| 796 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 796 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 797 | 797 |
| 798 // Write out the length field and the token stream. | 798 // Write out the length field and the token stream. |
| 799 RawExternalUint8Array* stream = ptr()->stream_; | 799 RawExternalUint8Array* stream = ptr()->stream_; |
| 800 intptr_t len = Smi::Value(stream->ptr()->length_); | 800 intptr_t len = Smi::Value(stream->ptr()->length_); |
| 801 writer->Write<RawObject*>(stream->ptr()->length_); | 801 writer->Write<RawObject*>(stream->ptr()->length_); |
| 802 writer->WriteBytes(stream->ptr()->external_data_->data(), len); | 802 writer->WriteBytes(stream->ptr()->data_, len); |
| 803 | 803 |
| 804 // Write out the literal/identifier token array. | 804 // Write out the literal/identifier token array. |
| 805 writer->WriteObjectImpl(ptr()->token_objects_); | 805 writer->WriteObjectImpl(ptr()->token_objects_); |
| 806 // Write out the private key in use by the token stream. | 806 // Write out the private key in use by the token stream. |
| 807 writer->WriteObjectImpl(ptr()->private_key_); | 807 writer->WriteObjectImpl(ptr()->private_key_); |
| 808 } | 808 } |
| 809 | 809 |
| 810 | 810 |
| 811 RawScript* Script::ReadFrom(SnapshotReader* reader, | 811 RawScript* Script::ReadFrom(SnapshotReader* reader, |
| 812 intptr_t object_id, | 812 intptr_t object_id, |
| (...skipping 1215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2028 | 2028 |
| 2029 #define EXTERNALARRAY_READ_FROM(name, lname, type) \ | 2029 #define EXTERNALARRAY_READ_FROM(name, lname, type) \ |
| 2030 RawExternal##name##Array* External##name##Array::ReadFrom( \ | 2030 RawExternal##name##Array* External##name##Array::ReadFrom( \ |
| 2031 SnapshotReader* reader, \ | 2031 SnapshotReader* reader, \ |
| 2032 intptr_t object_id, \ | 2032 intptr_t object_id, \ |
| 2033 intptr_t tags, \ | 2033 intptr_t tags, \ |
| 2034 Snapshot::Kind kind) { \ | 2034 Snapshot::Kind kind) { \ |
| 2035 ASSERT(kind != Snapshot::kFull); \ | 2035 ASSERT(kind != Snapshot::kFull); \ |
| 2036 intptr_t length = reader->ReadSmiValue(); \ | 2036 intptr_t length = reader->ReadSmiValue(); \ |
| 2037 type* data = reinterpret_cast<type*>(reader->ReadIntptrValue()); \ | 2037 type* data = reinterpret_cast<type*>(reader->ReadIntptrValue()); \ |
| 2038 const External##name##Array& obj = External##name##Array::Handle( \ |
| 2039 External##name##Array::New(data, length)); \ |
| 2038 void* peer = reinterpret_cast<void*>(reader->ReadIntptrValue()); \ | 2040 void* peer = reinterpret_cast<void*>(reader->ReadIntptrValue()); \ |
| 2039 Dart_PeerFinalizer callback = \ | 2041 Dart_WeakPersistentHandleFinalizer callback = \ |
| 2040 reinterpret_cast<Dart_PeerFinalizer>(reader->ReadIntptrValue()); \ | 2042 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( \ |
| 2041 return New(data, length, peer, callback, HEAP_SPACE(kind)); \ | 2043 reader->ReadIntptrValue()); \ |
| 2044 obj.AddFinalizer(peer, callback); \ |
| 2045 return obj.raw(); \ |
| 2042 } \ | 2046 } \ |
| 2043 | 2047 |
| 2044 | 2048 |
| 2045 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_READ_FROM) | 2049 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_READ_FROM) |
| 2046 #undef EXTERNALARRAY_READ_FROM | 2050 #undef EXTERNALARRAY_READ_FROM |
| 2047 | 2051 |
| 2048 | 2052 |
| 2049 template<typename ElementT> | 2053 template<typename ElementT> |
| 2050 static void ByteArrayWriteTo(SnapshotWriter* writer, | 2054 static void ByteArrayWriteTo(SnapshotWriter* writer, |
| 2051 intptr_t object_id, | 2055 intptr_t object_id, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2102 #define EXTERNALARRAY_WRITE_TO(name, lname, type) \ | 2106 #define EXTERNALARRAY_WRITE_TO(name, lname, type) \ |
| 2103 void RawExternal##name##Array::WriteTo(SnapshotWriter* writer, \ | 2107 void RawExternal##name##Array::WriteTo(SnapshotWriter* writer, \ |
| 2104 intptr_t object_id, \ | 2108 intptr_t object_id, \ |
| 2105 Snapshot::Kind kind) { \ | 2109 Snapshot::Kind kind) { \ |
| 2106 ByteArrayWriteTo(writer, \ | 2110 ByteArrayWriteTo(writer, \ |
| 2107 object_id, \ | 2111 object_id, \ |
| 2108 kind, \ | 2112 kind, \ |
| 2109 k##name##ArrayCid, \ | 2113 k##name##ArrayCid, \ |
| 2110 writer->GetObjectTags(this), \ | 2114 writer->GetObjectTags(this), \ |
| 2111 ptr()->length_, \ | 2115 ptr()->length_, \ |
| 2112 ptr()->external_data_->data()); \ | 2116 ptr()->data_); \ |
| 2113 } \ | 2117 } \ |
| 2114 | 2118 |
| 2115 | 2119 |
| 2116 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_WRITE_TO) | 2120 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_WRITE_TO) |
| 2117 #undef BYTEARRAY_WRITE_TO | 2121 #undef BYTEARRAY_WRITE_TO |
| 2118 #undef BYTEARRAY_TYPE_LIST | 2122 #undef BYTEARRAY_TYPE_LIST |
| 2119 | 2123 |
| 2120 | 2124 |
| 2121 RawDartFunction* DartFunction::ReadFrom(SnapshotReader* reader, | 2125 RawDartFunction* DartFunction::ReadFrom(SnapshotReader* reader, |
| 2122 intptr_t object_id, | 2126 intptr_t object_id, |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2240 // Write out the class and tags information. | 2244 // Write out the class and tags information. |
| 2241 writer->WriteIndexedObject(kWeakPropertyCid); | 2245 writer->WriteIndexedObject(kWeakPropertyCid); |
| 2242 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2246 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2243 | 2247 |
| 2244 // Write out all the other fields. | 2248 // Write out all the other fields. |
| 2245 writer->Write<RawObject*>(ptr()->key_); | 2249 writer->Write<RawObject*>(ptr()->key_); |
| 2246 writer->Write<RawObject*>(ptr()->value_); | 2250 writer->Write<RawObject*>(ptr()->value_); |
| 2247 } | 2251 } |
| 2248 | 2252 |
| 2249 } // namespace dart | 2253 } // namespace dart |
| OLD | NEW |