| 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 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 | 458 |
| 459 // Write out the class and tags information. | 459 // Write out the class and tags information. |
| 460 writer->WriteVMIsolateObject(kPatchClassCid); | 460 writer->WriteVMIsolateObject(kPatchClassCid); |
| 461 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 461 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 462 // Write out all the object pointer fields. | 462 // Write out all the object pointer fields. |
| 463 SnapshotWriterVisitor visitor(writer); | 463 SnapshotWriterVisitor visitor(writer); |
| 464 visitor.VisitPointers(from(), to()); | 464 visitor.VisitPointers(from(), to()); |
| 465 } | 465 } |
| 466 | 466 |
| 467 | 467 |
| 468 RawClosureData* ClosureData::ReadFrom(SnapshotReader* reader, |
| 469 intptr_t object_id, |
| 470 intptr_t tags, |
| 471 Snapshot::Kind kind) { |
| 472 ASSERT(reader != NULL); |
| 473 ASSERT((kind != Snapshot::kMessage) && |
| 474 !RawObject::IsCreatedFromSnapshot(tags)); |
| 475 |
| 476 // Allocate closure data object. |
| 477 ClosureData& data = ClosureData::ZoneHandle( |
| 478 reader->isolate(), NEW_OBJECT(ClosureData)); |
| 479 reader->AddBackRef(object_id, &data, kIsDeserialized); |
| 480 |
| 481 // Set the object tags. |
| 482 data.set_tags(tags); |
| 483 |
| 484 // Set all the object fields. |
| 485 // TODO(5411462): Need to assert No GC can happen here, even though |
| 486 // allocations may happen. |
| 487 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
| 488 for (intptr_t i = 0; i <= num_flds; i++) { |
| 489 *(data.raw()->from() + i) = reader->ReadObjectRef(); |
| 490 } |
| 491 |
| 492 return data.raw(); |
| 493 } |
| 494 |
| 495 |
| 496 void RawClosureData::WriteTo(SnapshotWriter* writer, |
| 497 intptr_t object_id, |
| 498 Snapshot::Kind kind) { |
| 499 ASSERT(writer != NULL); |
| 500 ASSERT((kind != Snapshot::kMessage) && |
| 501 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))); |
| 502 |
| 503 // Write out the serialization header value for this object. |
| 504 writer->WriteInlinedObjectHeader(object_id); |
| 505 |
| 506 // Write out the class and tags information. |
| 507 writer->WriteVMIsolateObject(kClosureDataCid); |
| 508 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 509 |
| 510 // Write out all the object pointer fields. |
| 511 SnapshotWriterVisitor visitor(writer); |
| 512 visitor.VisitPointers(from(), to()); |
| 513 } |
| 514 |
| 515 |
| 468 RawFunction* Function::ReadFrom(SnapshotReader* reader, | 516 RawFunction* Function::ReadFrom(SnapshotReader* reader, |
| 469 intptr_t object_id, | 517 intptr_t object_id, |
| 470 intptr_t tags, | 518 intptr_t tags, |
| 471 Snapshot::Kind kind) { | 519 Snapshot::Kind kind) { |
| 472 ASSERT(reader != NULL); | 520 ASSERT(reader != NULL); |
| 473 ASSERT((kind != Snapshot::kMessage) && | 521 ASSERT((kind != Snapshot::kMessage) && |
| 474 !RawObject::IsCreatedFromSnapshot(tags)); | 522 !RawObject::IsCreatedFromSnapshot(tags)); |
| 475 | 523 |
| 476 // Allocate function object. | 524 // Allocate function object. |
| 477 Function& func = Function::ZoneHandle( | 525 Function& func = Function::ZoneHandle( |
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2182 // Write out the class and tags information. | 2230 // Write out the class and tags information. |
| 2183 writer->WriteIndexedObject(kWeakPropertyCid); | 2231 writer->WriteIndexedObject(kWeakPropertyCid); |
| 2184 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2232 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2185 | 2233 |
| 2186 // Write out all the other fields. | 2234 // Write out all the other fields. |
| 2187 writer->Write<RawObject*>(ptr()->key_); | 2235 writer->Write<RawObject*>(ptr()->key_); |
| 2188 writer->Write<RawObject*>(ptr()->value_); | 2236 writer->Write<RawObject*>(ptr()->value_); |
| 2189 } | 2237 } |
| 2190 | 2238 |
| 2191 } // namespace dart | 2239 } // namespace dart |
| OLD | NEW |