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 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // Write out the class and tags information. | 506 // Write out the class and tags information. |
507 writer->WriteVMIsolateObject(kClosureDataCid); | 507 writer->WriteVMIsolateObject(kClosureDataCid); |
508 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 508 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
509 | 509 |
510 // Write out all the object pointer fields. | 510 // Write out all the object pointer fields. |
511 SnapshotWriterVisitor visitor(writer); | 511 SnapshotWriterVisitor visitor(writer); |
512 visitor.VisitPointers(from(), to()); | 512 visitor.VisitPointers(from(), to()); |
513 } | 513 } |
514 | 514 |
515 | 515 |
| 516 RawRedirectionData* RedirectionData::ReadFrom(SnapshotReader* reader, |
| 517 intptr_t object_id, |
| 518 intptr_t tags, |
| 519 Snapshot::Kind kind) { |
| 520 ASSERT(reader != NULL); |
| 521 ASSERT((kind != Snapshot::kMessage) && |
| 522 !RawObject::IsCreatedFromSnapshot(tags)); |
| 523 |
| 524 // Allocate redirection data object. |
| 525 RedirectionData& data = RedirectionData::ZoneHandle( |
| 526 reader->isolate(), NEW_OBJECT(RedirectionData)); |
| 527 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 528 |
| 529 // Set the object tags. |
| 530 data.set_tags(tags); |
| 531 |
| 532 // Set all the object fields. |
| 533 // TODO(5411462): Need to assert No GC can happen here, even though |
| 534 // allocations may happen. |
| 535 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
| 536 for (intptr_t i = 0; i <= num_flds; i++) { |
| 537 *(data.raw()->from() + i) = reader->ReadObjectRef(); |
| 538 } |
| 539 |
| 540 return data.raw(); |
| 541 } |
| 542 |
| 543 |
| 544 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
| 545 intptr_t object_id, |
| 546 Snapshot::Kind kind) { |
| 547 ASSERT(writer != NULL); |
| 548 ASSERT((kind != Snapshot::kMessage) && |
| 549 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 550 |
| 551 // Write out the serialization header value for this object. |
| 552 writer->WriteInlinedObjectHeader(object_id); |
| 553 |
| 554 // Write out the class and tags information. |
| 555 writer->WriteVMIsolateObject(kRedirectionDataCid); |
| 556 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 557 |
| 558 // Write out all the object pointer fields. |
| 559 SnapshotWriterVisitor visitor(writer); |
| 560 visitor.VisitPointers(from(), to()); |
| 561 } |
| 562 |
| 563 |
516 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 564 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
517 intptr_t object_id, | 565 intptr_t object_id, |
518 intptr_t tags, | 566 intptr_t tags, |
519 Snapshot::Kind kind) { | 567 Snapshot::Kind kind) { |
520 ASSERT(reader != NULL); | 568 ASSERT(reader != NULL); |
521 ASSERT((kind != Snapshot::kMessage) && | 569 ASSERT((kind != Snapshot::kMessage) && |
522 !RawObject::IsCreatedFromSnapshot(tags)); | 570 !RawObject::IsCreatedFromSnapshot(tags)); |
523 | 571 |
524 // Allocate function object. | 572 // Allocate function object. |
525 Function& func = Function::ZoneHandle( | 573 Function& func = Function::ZoneHandle( |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2228 // Write out the class and tags information. | 2276 // Write out the class and tags information. |
2229 writer->WriteIndexedObject(kWeakPropertyCid); | 2277 writer->WriteIndexedObject(kWeakPropertyCid); |
2230 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2278 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
2231 | 2279 |
2232 // Write out all the other fields. | 2280 // Write out all the other fields. |
2233 writer->Write<RawObject*>(ptr()->key_); | 2281 writer->Write<RawObject*>(ptr()->key_); |
2234 writer->Write<RawObject*>(ptr()->value_); | 2282 writer->Write<RawObject*>(ptr()->value_); |
2235 } | 2283 } |
2236 | 2284 |
2237 } // namespace dart | 2285 } // namespace dart |
OLD | NEW |