Chromium Code Reviews| 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/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 | 143 |
| 144 SnapshotReader::SnapshotReader(const uint8_t* buffer, | 144 SnapshotReader::SnapshotReader(const uint8_t* buffer, |
| 145 intptr_t size, | 145 intptr_t size, |
| 146 Snapshot::Kind kind, | 146 Snapshot::Kind kind, |
| 147 Isolate* isolate) | 147 Isolate* isolate) |
| 148 : BaseReader(buffer, size), | 148 : BaseReader(buffer, size), |
| 149 kind_(kind), | 149 kind_(kind), |
| 150 isolate_(isolate), | 150 isolate_(isolate), |
| 151 cls_(Class::Handle()), | 151 cls_(Class::Handle()), |
| 152 obj_(Object::Handle()), | 152 obj_(Object::Handle()), |
| 153 array_(Array::Handle()), | |
| 154 field_(Field::Handle()), | |
| 153 str_(String::Handle()), | 155 str_(String::Handle()), |
| 154 library_(Library::Handle()), | 156 library_(Library::Handle()), |
| 155 type_(AbstractType::Handle()), | 157 type_(AbstractType::Handle()), |
| 156 type_arguments_(AbstractTypeArguments::Handle()), | 158 type_arguments_(AbstractTypeArguments::Handle()), |
| 157 tokens_(Array::Handle()), | 159 tokens_(Array::Handle()), |
| 158 stream_(TokenStream::Handle()), | 160 stream_(TokenStream::Handle()), |
| 159 data_(ExternalTypedData::Handle()), | 161 data_(ExternalTypedData::Handle()), |
| 160 error_(UnhandledException::Handle()), | 162 error_(UnhandledException::Handle()), |
| 161 backward_references_((kind == Snapshot::kFull) ? | 163 backward_references_((kind == Snapshot::kFull) ? |
| 162 kNumInitialReferencesInFullSnapshot : | 164 kNumInitialReferencesInFullSnapshot : |
| (...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 *result ^= Object::Allocate(cls_.id(), | 784 *result ^= Object::Allocate(cls_.id(), |
| 783 instance_size, | 785 instance_size, |
| 784 HEAP_SPACE(kind_)); | 786 HEAP_SPACE(kind_)); |
| 785 } | 787 } |
| 786 } else { | 788 } else { |
| 787 cls_ ^= ReadObjectImpl(); | 789 cls_ ^= ReadObjectImpl(); |
| 788 ASSERT(!cls_.IsNull()); | 790 ASSERT(!cls_.IsNull()); |
| 789 instance_size = cls_.instance_size(); | 791 instance_size = cls_.instance_size(); |
| 790 } | 792 } |
| 791 intptr_t offset = Object::InstanceSize(); | 793 intptr_t offset = Object::InstanceSize(); |
| 794 intptr_t result_cid = result->GetClassId(); | |
| 792 while (offset < instance_size) { | 795 while (offset < instance_size) { |
| 793 obj_ = ReadObjectRef(); | 796 obj_ = ReadObjectRef(); |
| 794 result->SetFieldAtOffset(offset, obj_); | 797 result->SetFieldAtOffset(offset, obj_); |
| 798 if (kind_ == Snapshot::kMessage) { | |
| 799 cls_ = isolate()->class_table()->At(result_cid); | |
|
Ivan Posva
2013/11/01 04:50:05
You want to look this up only once and not for eve
Florian Schneider
2013/11/01 10:39:27
Done. Added TODO.
| |
| 800 array_ = cls_.OffsetToFieldMap(); | |
|
Ivan Posva
2013/11/01 04:50:05
ditto
Florian Schneider
2013/11/01 10:39:27
Done.
| |
| 801 field_ ^= array_.At(offset / kWordSize); | |
|
Ivan Posva
2013/11/01 04:50:05
offset >> kWordSizeLog2
Florian Schneider
2013/11/01 10:39:27
Done.
| |
| 802 // Entries can be null because offset can be outside of instance fields | |
| 803 // due to rounded allocation size. | |
| 804 if (!field_.IsNull()) { | |
| 805 ASSERT(field_.Offset() == offset); | |
| 806 field_.UpdateGuardedCidAndLength(obj_); | |
| 807 } | |
| 808 } | |
|
Ivan Posva
2013/11/01 04:50:05
We also wanted to assert that when deserializing o
Florian Schneider
2013/11/01 10:39:27
Added TODO. I'll think about how to assert this fo
| |
| 795 offset += kWordSize; | 809 offset += kWordSize; |
| 796 } | 810 } |
| 797 if (kind_ == Snapshot::kFull) { | 811 if (kind_ == Snapshot::kFull) { |
| 798 result->SetCreatedFromSnapshot(); | 812 result->SetCreatedFromSnapshot(); |
| 799 } else if (result->IsCanonical()) { | 813 } else if (result->IsCanonical()) { |
| 800 *result = result->CheckAndCanonicalize(NULL); | 814 *result = result->CheckAndCanonicalize(NULL); |
| 801 ASSERT(!result->IsNull()); | 815 ASSERT(!result->IsNull()); |
| 802 } | 816 } |
| 803 return result->raw(); | 817 return result->raw(); |
| 804 } | 818 } |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1486 UnmarkAll(); | 1500 UnmarkAll(); |
| 1487 isolate->set_long_jump_base(base); | 1501 isolate->set_long_jump_base(base); |
| 1488 } else { | 1502 } else { |
| 1489 isolate->set_long_jump_base(base); | 1503 isolate->set_long_jump_base(base); |
| 1490 ThrowException(exception_type(), exception_msg()); | 1504 ThrowException(exception_type(), exception_msg()); |
| 1491 } | 1505 } |
| 1492 } | 1506 } |
| 1493 | 1507 |
| 1494 | 1508 |
| 1495 } // namespace dart | 1509 } // namespace dart |
| OLD | NEW |