| 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/stub_code.h" | 9 #include "vm/stub_code.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 writer->Write<RawObject*>(ptr()->length_); | 503 writer->Write<RawObject*>(ptr()->length_); |
| 504 | 504 |
| 505 // Write out the instantiations field, but only in a full snapshot. | 505 // Write out the instantiations field, but only in a full snapshot. |
| 506 if (kind == Snapshot::kFull) { | 506 if (kind == Snapshot::kFull) { |
| 507 writer->WriteObjectImpl(ptr()->instantiations_); | 507 writer->WriteObjectImpl(ptr()->instantiations_); |
| 508 } | 508 } |
| 509 | 509 |
| 510 // Write out the individual types. | 510 // Write out the individual types. |
| 511 intptr_t len = Smi::Value(ptr()->length_); | 511 intptr_t len = Smi::Value(ptr()->length_); |
| 512 for (intptr_t i = 0; i < len; i++) { | 512 for (intptr_t i = 0; i < len; i++) { |
| 513 writer->WriteObjectImpl(ptr()->types_[i]); | 513 writer->WriteObjectImpl(ptr()->types()[i]); |
| 514 } | 514 } |
| 515 } | 515 } |
| 516 | 516 |
| 517 | 517 |
| 518 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, | 518 RawPatchClass* PatchClass::ReadFrom(SnapshotReader* reader, |
| 519 intptr_t object_id, | 519 intptr_t object_id, |
| 520 intptr_t tags, | 520 intptr_t tags, |
| 521 Snapshot::Kind kind) { | 521 Snapshot::Kind kind) { |
| 522 ASSERT(reader != NULL); | 522 ASSERT(reader != NULL); |
| 523 ASSERT(((kind == Snapshot::kScript) && | 523 ASSERT(((kind == Snapshot::kScript) && |
| (...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 void RawOneByteString::WriteTo(SnapshotWriter* writer, | 1974 void RawOneByteString::WriteTo(SnapshotWriter* writer, |
| 1975 intptr_t object_id, | 1975 intptr_t object_id, |
| 1976 Snapshot::Kind kind) { | 1976 Snapshot::Kind kind) { |
| 1977 StringWriteTo(writer, | 1977 StringWriteTo(writer, |
| 1978 object_id, | 1978 object_id, |
| 1979 kind, | 1979 kind, |
| 1980 kOneByteStringCid, | 1980 kOneByteStringCid, |
| 1981 writer->GetObjectTags(this), | 1981 writer->GetObjectTags(this), |
| 1982 ptr()->length_, | 1982 ptr()->length_, |
| 1983 ptr()->hash_, | 1983 ptr()->hash_, |
| 1984 ptr()->data_); | 1984 ptr()->data()); |
| 1985 } | 1985 } |
| 1986 | 1986 |
| 1987 | 1987 |
| 1988 void RawTwoByteString::WriteTo(SnapshotWriter* writer, | 1988 void RawTwoByteString::WriteTo(SnapshotWriter* writer, |
| 1989 intptr_t object_id, | 1989 intptr_t object_id, |
| 1990 Snapshot::Kind kind) { | 1990 Snapshot::Kind kind) { |
| 1991 StringWriteTo(writer, | 1991 StringWriteTo(writer, |
| 1992 object_id, | 1992 object_id, |
| 1993 kind, | 1993 kind, |
| 1994 kTwoByteStringCid, | 1994 kTwoByteStringCid, |
| 1995 writer->GetObjectTags(this), | 1995 writer->GetObjectTags(this), |
| 1996 ptr()->length_, | 1996 ptr()->length_, |
| 1997 ptr()->hash_, | 1997 ptr()->hash_, |
| 1998 ptr()->data_); | 1998 ptr()->data()); |
| 1999 } | 1999 } |
| 2000 | 2000 |
| 2001 | 2001 |
| 2002 RawExternalOneByteString* ExternalOneByteString::ReadFrom( | 2002 RawExternalOneByteString* ExternalOneByteString::ReadFrom( |
| 2003 SnapshotReader* reader, | 2003 SnapshotReader* reader, |
| 2004 intptr_t object_id, | 2004 intptr_t object_id, |
| 2005 intptr_t tags, | 2005 intptr_t tags, |
| 2006 Snapshot::Kind kind) { | 2006 Snapshot::Kind kind) { |
| 2007 UNREACHABLE(); | 2007 UNREACHABLE(); |
| 2008 return ExternalOneByteString::null(); | 2008 return ExternalOneByteString::null(); |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 Dart_WeakPersistentHandleFinalizer callback = | 2388 Dart_WeakPersistentHandleFinalizer callback = |
| 2389 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( | 2389 reinterpret_cast<Dart_WeakPersistentHandleFinalizer>( |
| 2390 reader->ReadRawPointerValue()); | 2390 reader->ReadRawPointerValue()); |
| 2391 obj.AddFinalizer(peer, callback); | 2391 obj.AddFinalizer(peer, callback); |
| 2392 return obj.raw(); | 2392 return obj.raw(); |
| 2393 } | 2393 } |
| 2394 | 2394 |
| 2395 | 2395 |
| 2396 #define TYPED_DATA_WRITE(type) \ | 2396 #define TYPED_DATA_WRITE(type) \ |
| 2397 { \ | 2397 { \ |
| 2398 type* data = reinterpret_cast<type*>(ptr()->data_); \ | 2398 type* data = reinterpret_cast<type*>(ptr()->data()); \ |
| 2399 for (intptr_t i = 0; i < len; i++) { \ | 2399 for (intptr_t i = 0; i < len; i++) { \ |
| 2400 writer->Write(data[i]); \ | 2400 writer->Write(data[i]); \ |
| 2401 } \ | 2401 } \ |
| 2402 } \ | 2402 } \ |
| 2403 | 2403 |
| 2404 | 2404 |
| 2405 void RawTypedData::WriteTo(SnapshotWriter* writer, | 2405 void RawTypedData::WriteTo(SnapshotWriter* writer, |
| 2406 intptr_t object_id, | 2406 intptr_t object_id, |
| 2407 Snapshot::Kind kind) { | 2407 Snapshot::Kind kind) { |
| 2408 ASSERT(writer != NULL); | 2408 ASSERT(writer != NULL); |
| 2409 intptr_t tags = writer->GetObjectTags(this); | 2409 intptr_t tags = writer->GetObjectTags(this); |
| 2410 intptr_t cid = ClassIdTag::decode(tags); | 2410 intptr_t cid = ClassIdTag::decode(tags); |
| 2411 intptr_t len = Smi::Value(ptr()->length_); | 2411 intptr_t len = Smi::Value(ptr()->length_); |
| 2412 | 2412 |
| 2413 // Write out the serialization header value for this object. | 2413 // Write out the serialization header value for this object. |
| 2414 writer->WriteInlinedObjectHeader(object_id); | 2414 writer->WriteInlinedObjectHeader(object_id); |
| 2415 | 2415 |
| 2416 // Write out the class and tags information. | 2416 // Write out the class and tags information. |
| 2417 writer->WriteIndexedObject(cid); | 2417 writer->WriteIndexedObject(cid); |
| 2418 writer->WriteIntptrValue(tags); | 2418 writer->WriteIntptrValue(tags); |
| 2419 | 2419 |
| 2420 // Write out the length field. | 2420 // Write out the length field. |
| 2421 writer->Write<RawObject*>(ptr()->length_); | 2421 writer->Write<RawObject*>(ptr()->length_); |
| 2422 | 2422 |
| 2423 // Write out the array elements. | 2423 // Write out the array elements. |
| 2424 switch (cid) { | 2424 switch (cid) { |
| 2425 case kTypedDataInt8ArrayCid: | 2425 case kTypedDataInt8ArrayCid: |
| 2426 case kTypedDataUint8ArrayCid: | 2426 case kTypedDataUint8ArrayCid: |
| 2427 case kTypedDataUint8ClampedArrayCid: { | 2427 case kTypedDataUint8ClampedArrayCid: { |
| 2428 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data_); | 2428 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data()); |
| 2429 writer->WriteBytes(data, len); | 2429 writer->WriteBytes(data, len); |
| 2430 break; | 2430 break; |
| 2431 } | 2431 } |
| 2432 case kTypedDataInt16ArrayCid: | 2432 case kTypedDataInt16ArrayCid: |
| 2433 TYPED_DATA_WRITE(int16_t); | 2433 TYPED_DATA_WRITE(int16_t); |
| 2434 break; | 2434 break; |
| 2435 case kTypedDataUint16ArrayCid: | 2435 case kTypedDataUint16ArrayCid: |
| 2436 TYPED_DATA_WRITE(uint16_t); | 2436 TYPED_DATA_WRITE(uint16_t); |
| 2437 break; | 2437 break; |
| 2438 case kTypedDataInt32ArrayCid: | 2438 case kTypedDataInt32ArrayCid: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2452 break; | 2452 break; |
| 2453 case kTypedDataFloat64ArrayCid: | 2453 case kTypedDataFloat64ArrayCid: |
| 2454 TYPED_DATA_WRITE(double); // NOLINT. | 2454 TYPED_DATA_WRITE(double); // NOLINT. |
| 2455 break; | 2455 break; |
| 2456 default: | 2456 default: |
| 2457 UNREACHABLE(); | 2457 UNREACHABLE(); |
| 2458 } | 2458 } |
| 2459 } | 2459 } |
| 2460 | 2460 |
| 2461 | 2461 |
| 2462 #define TYPED_EXT_DATA_WRITE(type) \ |
| 2463 { \ |
| 2464 type* data = reinterpret_cast<type*>(ptr()->data_); \ |
| 2465 for (intptr_t i = 0; i < len; i++) { \ |
| 2466 writer->Write(data[i]); \ |
| 2467 } \ |
| 2468 } \ |
| 2469 |
| 2470 |
| 2462 #define EXT_TYPED_DATA_WRITE(cid, type) \ | 2471 #define EXT_TYPED_DATA_WRITE(cid, type) \ |
| 2463 writer->WriteIndexedObject(cid); \ | 2472 writer->WriteIndexedObject(cid); \ |
| 2464 writer->WriteIntptrValue(RawObject::ClassIdTag::update(cid, tags)); \ | 2473 writer->WriteIntptrValue(RawObject::ClassIdTag::update(cid, tags)); \ |
| 2465 writer->Write<RawObject*>(ptr()->length_); \ | 2474 writer->Write<RawObject*>(ptr()->length_); \ |
| 2466 TYPED_DATA_WRITE(type) \ | 2475 TYPED_EXT_DATA_WRITE(type) \ |
| 2467 | 2476 |
| 2468 | 2477 |
| 2469 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, | 2478 void RawExternalTypedData::WriteTo(SnapshotWriter* writer, |
| 2470 intptr_t object_id, | 2479 intptr_t object_id, |
| 2471 Snapshot::Kind kind) { | 2480 Snapshot::Kind kind) { |
| 2472 ASSERT(writer != NULL); | 2481 ASSERT(writer != NULL); |
| 2473 intptr_t tags = writer->GetObjectTags(this); | 2482 intptr_t tags = writer->GetObjectTags(this); |
| 2474 intptr_t cid = ClassIdTag::decode(tags); | 2483 intptr_t cid = ClassIdTag::decode(tags); |
| 2475 intptr_t len = Smi::Value(ptr()->length_); | 2484 intptr_t len = Smi::Value(ptr()->length_); |
| 2476 | 2485 |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2783 // We do not allow objects with native fields in an isolate message. | 2792 // We do not allow objects with native fields in an isolate message. |
| 2784 writer->SetWriteException(Exceptions::kArgument, | 2793 writer->SetWriteException(Exceptions::kArgument, |
| 2785 "Illegal argument in isolate message" | 2794 "Illegal argument in isolate message" |
| 2786 " : (object is a UserTag)"); | 2795 " : (object is a UserTag)"); |
| 2787 } else { | 2796 } else { |
| 2788 UNREACHABLE(); | 2797 UNREACHABLE(); |
| 2789 } | 2798 } |
| 2790 } | 2799 } |
| 2791 | 2800 |
| 2792 } // namespace dart | 2801 } // namespace dart |
| OLD | NEW |