| 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 1756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 } | 1767 } |
| 1768 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2)); | 1768 writer->WriteBytes(reinterpret_cast<const uint8_t*>(&(str[2])), (len - 2)); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 | 1771 |
| 1772 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 1772 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
| 1773 intptr_t object_id, | 1773 intptr_t object_id, |
| 1774 intptr_t tags, | 1774 intptr_t tags, |
| 1775 Snapshot::Kind kind) { | 1775 Snapshot::Kind kind) { |
| 1776 ASSERT(reader != NULL); | 1776 ASSERT(reader != NULL); |
| 1777 ASSERT(kind != Snapshot::kMessage); |
| 1777 // Read the double value for the object. | 1778 // Read the double value for the object. |
| 1778 double value = reader->Read<double>(); | 1779 double value = reader->ReadDouble(); |
| 1779 | 1780 |
| 1780 // Create a Double object or get canonical one if it is a canonical constant. | 1781 // Create a Double object or get canonical one if it is a canonical constant. |
| 1781 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null()); | 1782 Double& dbl = Double::ZoneHandle(reader->isolate(), Double::null()); |
| 1782 if (kind == Snapshot::kFull) { | 1783 if (kind == Snapshot::kFull) { |
| 1783 dbl = reader->NewDouble(value); | 1784 dbl = reader->NewDouble(value); |
| 1784 } else { | 1785 } else { |
| 1785 // When reading a script snapshot we need to canonicalize only those object | 1786 // When reading a script snapshot we need to canonicalize only those object |
| 1786 // references that are objects from the core library (loaded from a | 1787 // references that are objects from the core library (loaded from a |
| 1787 // full snapshot). Objects that are only in the script need not be | 1788 // full snapshot). Objects that are only in the script need not be |
| 1788 // canonicalized as they are already canonical. | 1789 // canonicalized as they are already canonical. |
| 1789 // When reading a message snapshot we always have to canonicalize. | |
| 1790 if (RawObject::IsCanonical(tags) && | 1790 if (RawObject::IsCanonical(tags) && |
| 1791 (RawObject::IsCreatedFromSnapshot(tags) || | 1791 RawObject::IsCreatedFromSnapshot(tags)) { |
| 1792 (kind == Snapshot::kMessage))) { | |
| 1793 dbl = Double::NewCanonical(value); | 1792 dbl = Double::NewCanonical(value); |
| 1794 } else { | 1793 } else { |
| 1795 dbl = Double::New(value, HEAP_SPACE(kind)); | 1794 dbl = Double::New(value, HEAP_SPACE(kind)); |
| 1796 } | 1795 } |
| 1797 } | 1796 } |
| 1798 reader->AddBackRef(object_id, &dbl, kIsDeserialized); | 1797 reader->AddBackRef(object_id, &dbl, kIsDeserialized); |
| 1799 | 1798 |
| 1800 // Set the object tags. | 1799 // Set the object tags. |
| 1801 dbl.set_tags(tags); | 1800 dbl.set_tags(tags); |
| 1802 | 1801 |
| 1803 return dbl.raw(); | 1802 return dbl.raw(); |
| 1804 } | 1803 } |
| 1805 | 1804 |
| 1806 | 1805 |
| 1807 void RawDouble::WriteTo(SnapshotWriter* writer, | 1806 void RawDouble::WriteTo(SnapshotWriter* writer, |
| 1808 intptr_t object_id, | 1807 intptr_t object_id, |
| 1809 Snapshot::Kind kind) { | 1808 Snapshot::Kind kind) { |
| 1810 ASSERT(writer != NULL); | 1809 ASSERT(writer != NULL); |
| 1811 | 1810 |
| 1812 // Write out the serialization header value for this object. | 1811 // Write out the serialization header value for this object. |
| 1813 writer->WriteInlinedObjectHeader(object_id); | 1812 writer->WriteInlinedObjectHeader(object_id); |
| 1814 | 1813 |
| 1815 // Write out the class and tags information. | 1814 // Write out the class and tags information. |
| 1816 writer->WriteIndexedObject(kDoubleCid); | 1815 writer->WriteIndexedObject(kDoubleCid); |
| 1817 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 1816 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 1818 | 1817 |
| 1819 // Write out the double value. | 1818 // Write out the double value. |
| 1820 writer->Write<double>(ptr()->value_); | 1819 writer->WriteDouble(ptr()->value_); |
| 1821 } | 1820 } |
| 1822 | 1821 |
| 1823 | 1822 |
| 1824 RawString* String::ReadFrom(SnapshotReader* reader, | 1823 RawString* String::ReadFrom(SnapshotReader* reader, |
| 1825 intptr_t object_id, | 1824 intptr_t object_id, |
| 1826 intptr_t tags, | 1825 intptr_t tags, |
| 1827 Snapshot::Kind kind) { | 1826 Snapshot::Kind kind) { |
| 1828 UNREACHABLE(); // String is an abstract class. | 1827 UNREACHABLE(); // String is an abstract class. |
| 1829 return String::null(); | 1828 return String::null(); |
| 1830 } | 1829 } |
| (...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2688 // We do not allow objects with native fields in an isolate message. | 2687 // We do not allow objects with native fields in an isolate message. |
| 2689 writer->SetWriteException(Exceptions::kArgument, | 2688 writer->SetWriteException(Exceptions::kArgument, |
| 2690 "Illegal argument in isolate message" | 2689 "Illegal argument in isolate message" |
| 2691 " : (object is a MirrorReference)"); | 2690 " : (object is a MirrorReference)"); |
| 2692 } else { | 2691 } else { |
| 2693 UNREACHABLE(); | 2692 UNREACHABLE(); |
| 2694 } | 2693 } |
| 2695 } | 2694 } |
| 2696 | 2695 |
| 2697 } // namespace dart | 2696 } // namespace dart |
| OLD | NEW |