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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
772 } | 772 } |
773 if (object_id == kVoidType) { | 773 if (object_id == kVoidType) { |
774 return Object::void_type(); | 774 return Object::void_type(); |
775 } | 775 } |
776 if (object_id == kTrueValue) { | 776 if (object_id == kTrueValue) { |
777 return Bool::True().raw(); | 777 return Bool::True().raw(); |
778 } | 778 } |
779 if (object_id == kFalseValue) { | 779 if (object_id == kFalseValue) { |
780 return Bool::False().raw(); | 780 return Bool::False().raw(); |
781 } | 781 } |
782 if (object_id == kDoubleObject) { | |
783 ASSERT(kind_ == Snapshot::kMessage); | |
784 return Double::New(ReadDouble()); | |
785 } | |
782 intptr_t class_id = ClassIdFromObjectId(object_id); | 786 intptr_t class_id = ClassIdFromObjectId(object_id); |
783 if (IsSingletonClassId(class_id)) { | 787 if (IsSingletonClassId(class_id)) { |
784 return isolate()->class_table()->At(class_id); // get singleton class. | 788 return isolate()->class_table()->At(class_id); // get singleton class. |
785 } else { | 789 } else { |
786 ASSERT(Symbols::IsVMSymbolId(object_id)); | 790 ASSERT(Symbols::IsVMSymbolId(object_id)); |
787 return Symbols::GetVMSymbol(object_id); // return VM symbol. | 791 return Symbols::GetVMSymbol(object_id); // return VM symbol. |
788 } | 792 } |
789 UNREACHABLE(); | 793 UNREACHABLE(); |
790 return Object::null(); | 794 return Object::null(); |
791 } | 795 } |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 // - Object that has already been written: (negative id in stream | 0x3) | 1205 // - Object that has already been written: (negative id in stream | 0x3) |
1202 | 1206 |
1203 NoGCScope no_gc; | 1207 NoGCScope no_gc; |
1204 | 1208 |
1205 // First check if it is a Smi (i.e not a heap object). | 1209 // First check if it is a Smi (i.e not a heap object). |
1206 if (!rawobj->IsHeapObject()) { | 1210 if (!rawobj->IsHeapObject()) { |
1207 Write<int64_t>(reinterpret_cast<intptr_t>(rawobj)); | 1211 Write<int64_t>(reinterpret_cast<intptr_t>(rawobj)); |
1208 return true; | 1212 return true; |
1209 } | 1213 } |
1210 | 1214 |
1215 if ((kind_ == Snapshot::kMessage) && (rawobj->GetClassId() == kDoubleCid)) { | |
1216 WriteVMIsolateObject(kDoubleObject); | |
1217 RawDouble* rd = reinterpret_cast<RawDouble*>(rawobj); | |
1218 WriteDouble(rd->ptr()->value_); | |
1219 return true; | |
1220 } | |
siva
2014/04/03 00:23:16
We should probably consider caching the class id i
Ivan Posva
2014/04/03 00:58:02
Done.
| |
1221 | |
1211 // Check if object has already been serialized, in that case just write | 1222 // Check if object has already been serialized, in that case just write |
1212 // the object id out. | 1223 // the object id out. |
1213 uword tags = rawobj->ptr()->tags_; | 1224 uword tags = rawobj->ptr()->tags_; |
1214 if (SerializedHeaderTag::decode(tags) == kObjectId) { | 1225 if (SerializedHeaderTag::decode(tags) == kObjectId) { |
1215 intptr_t id = SerializedHeaderData::decode(tags); | 1226 intptr_t id = SerializedHeaderData::decode(tags); |
1216 WriteIndexedObject(id); | 1227 WriteIndexedObject(id); |
1217 return true; | 1228 return true; |
1218 } | 1229 } |
1219 | 1230 |
1220 // Now check if it is an object from the VM isolate (NOTE: premarked objects | 1231 // Now check if it is an object from the VM isolate (NOTE: premarked objects |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1560 NoGCScope no_gc; | 1571 NoGCScope no_gc; |
1561 WriteObject(obj.raw()); | 1572 WriteObject(obj.raw()); |
1562 UnmarkAll(); | 1573 UnmarkAll(); |
1563 } else { | 1574 } else { |
1564 ThrowException(exception_type(), exception_msg()); | 1575 ThrowException(exception_type(), exception_msg()); |
1565 } | 1576 } |
1566 } | 1577 } |
1567 | 1578 |
1568 | 1579 |
1569 } // namespace dart | 1580 } // namespace dart |
OLD | NEW |