Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 1190143003: Fix for issue 23647 (https://github.com/dart-lang/sdk/issues/23647) (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address self review comments Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/object.h" 5 #include "vm/object.h"
6 #include "vm/object_store.h" 6 #include "vm/object_store.h"
7 #include "vm/snapshot.h" 7 #include "vm/snapshot.h"
8 #include "vm/stub_code.h" 8 #include "vm/stub_code.h"
9 #include "vm/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after
1698 // Check if the value could potentially fit in a Smi in our current 1698 // Check if the value could potentially fit in a Smi in our current
1699 // architecture, if so return the object as a Smi. 1699 // architecture, if so return the object as a Smi.
1700 if (Smi::IsValid(value)) { 1700 if (Smi::IsValid(value)) {
1701 return Smi::New(static_cast<intptr_t>(value)); 1701 return Smi::New(static_cast<intptr_t>(value));
1702 } 1702 }
1703 1703
1704 // Create a Mint object or get canonical one if it is a canonical constant. 1704 // Create a Mint object or get canonical one if it is a canonical constant.
1705 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null()); 1705 Mint& mint = Mint::ZoneHandle(reader->zone(), Mint::null());
1706 if (kind == Snapshot::kFull) { 1706 if (kind == Snapshot::kFull) {
1707 mint = reader->NewMint(value); 1707 mint = reader->NewMint(value);
1708 // Set the object tags.
1709 mint.set_tags(tags);
1708 } else { 1710 } else {
1709 // When reading a script snapshot we need to canonicalize only those object 1711 // When reading a script snapshot we need to canonicalize only those object
1710 // references that are objects from the core library (loaded from a 1712 // references that are objects from the core library (loaded from a
1711 // full snapshot). Objects that are only in the script need not be 1713 // full snapshot). Objects that are only in the script need not be
1712 // canonicalized as they are already canonical. 1714 // canonicalized as they are already canonical.
1713 // When reading a message snapshot we always have to canonicalize. 1715 // When reading a message snapshot we always have to canonicalize.
1714 if (RawObject::IsCanonical(tags) && 1716 if (RawObject::IsCanonical(tags) &&
1715 (RawObject::IsCreatedFromSnapshot(tags) || 1717 (RawObject::IsCreatedFromSnapshot(tags) ||
1716 (kind == Snapshot::kMessage))) { 1718 (kind == Snapshot::kMessage))) {
1717 mint = Mint::NewCanonical(value); 1719 mint = Mint::NewCanonical(value);
1720 ASSERT(mint.IsCanonical() &&
1721 (kind == Snapshot::kMessage ||
1722 RawObject::IsCreatedFromSnapshot(mint.raw()->ptr()->tags_)));
1718 } else { 1723 } else {
1719 mint = Mint::New(value, HEAP_SPACE(kind)); 1724 mint = Mint::New(value, HEAP_SPACE(kind));
1725 // Set the object tags.
1726 mint.set_tags(tags);
1720 } 1727 }
1721 } 1728 }
1722 reader->AddBackRef(object_id, &mint, kIsDeserialized); 1729 reader->AddBackRef(object_id, &mint, kIsDeserialized);
1723
1724 // Set the object tags.
1725 mint.set_tags(tags);
1726
1727 return mint.raw(); 1730 return mint.raw();
1728 } 1731 }
1729 1732
1730 1733
1731 void RawMint::WriteTo(SnapshotWriter* writer, 1734 void RawMint::WriteTo(SnapshotWriter* writer,
1732 intptr_t object_id, 1735 intptr_t object_id,
1733 Snapshot::Kind kind) { 1736 Snapshot::Kind kind) {
1734 ASSERT(writer != NULL); 1737 ASSERT(writer != NULL);
1735 1738
1736 // Write out the serialization header value for this object. 1739 // Write out the serialization header value for this object.
(...skipping 29 matching lines...) Expand all
1766 } 1769 }
1767 1770
1768 // If it is a canonical constant make it one. 1771 // If it is a canonical constant make it one.
1769 // When reading a full snapshot we don't need to canonicalize the object 1772 // When reading a full snapshot we don't need to canonicalize the object
1770 // as it would already be a canonical object. 1773 // as it would already be a canonical object.
1771 // When reading a script snapshot we need to canonicalize only those object 1774 // When reading a script snapshot we need to canonicalize only those object
1772 // references that are objects from the core library (loaded from a 1775 // references that are objects from the core library (loaded from a
1773 // full snapshot). Objects that are only in the script need not be 1776 // full snapshot). Objects that are only in the script need not be
1774 // canonicalized as they are already canonical. 1777 // canonicalized as they are already canonical.
1775 // When reading a message snapshot we always have to canonicalize the object. 1778 // When reading a message snapshot we always have to canonicalize the object.
1776 if ((kind != Snapshot::kFull) && RawObject::IsCanonical(tags) && 1779 if (kind == Snapshot::kFull) {
1777 (RawObject::IsCreatedFromSnapshot(tags) || 1780 // Set the object tags.
1778 (kind == Snapshot::kMessage))) { 1781 obj.set_tags(tags);
1782 } else if (RawObject::IsCanonical(tags) &&
1783 (RawObject::IsCreatedFromSnapshot(tags) ||
1784 (kind == Snapshot::kMessage))) {
1779 obj ^= obj.CheckAndCanonicalize(NULL); 1785 obj ^= obj.CheckAndCanonicalize(NULL);
1780 ASSERT(!obj.IsNull()); 1786 ASSERT(!obj.IsNull());
1787 ASSERT(obj.IsCanonical() &&
1788 (kind == Snapshot::kMessage ||
1789 RawObject::IsCreatedFromSnapshot(obj.raw()->ptr()->tags_)));
1790 } else {
1791 // Set the object tags.
1792 obj.set_tags(tags);
1781 } 1793 }
1782
1783 // Set the object tags.
1784 obj.set_tags(tags);
1785
1786 return obj.raw(); 1794 return obj.raw();
1787 } 1795 }
1788 1796
1789 1797
1790 void RawBigint::WriteTo(SnapshotWriter* writer, 1798 void RawBigint::WriteTo(SnapshotWriter* writer,
1791 intptr_t object_id, 1799 intptr_t object_id,
1792 Snapshot::Kind kind) { 1800 Snapshot::Kind kind) {
1793 ASSERT(writer != NULL); 1801 ASSERT(writer != NULL);
1794 1802
1795 // Write out the serialization header value for this object. 1803 // Write out the serialization header value for this object.
(...skipping 15 matching lines...) Expand all
1811 Snapshot::Kind kind) { 1819 Snapshot::Kind kind) {
1812 ASSERT(reader != NULL); 1820 ASSERT(reader != NULL);
1813 ASSERT(kind != Snapshot::kMessage); 1821 ASSERT(kind != Snapshot::kMessage);
1814 // Read the double value for the object. 1822 // Read the double value for the object.
1815 double value = reader->ReadDouble(); 1823 double value = reader->ReadDouble();
1816 1824
1817 // Create a Double object or get canonical one if it is a canonical constant. 1825 // Create a Double object or get canonical one if it is a canonical constant.
1818 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null()); 1826 Double& dbl = Double::ZoneHandle(reader->zone(), Double::null());
1819 if (kind == Snapshot::kFull) { 1827 if (kind == Snapshot::kFull) {
1820 dbl = reader->NewDouble(value); 1828 dbl = reader->NewDouble(value);
1829 // Set the object tags.
1830 dbl.set_tags(tags);
1821 } else { 1831 } else {
1822 // When reading a script snapshot we need to canonicalize only those object 1832 // When reading a script snapshot we need to canonicalize only those object
1823 // references that are objects from the core library (loaded from a 1833 // references that are objects from the core library (loaded from a
1824 // full snapshot). Objects that are only in the script need not be 1834 // full snapshot). Objects that are only in the script need not be
1825 // canonicalized as they are already canonical. 1835 // canonicalized as they are already canonical.
1826 if (RawObject::IsCanonical(tags) && 1836 if (RawObject::IsCanonical(tags) &&
1827 RawObject::IsCreatedFromSnapshot(tags)) { 1837 RawObject::IsCreatedFromSnapshot(tags)) {
1828 dbl = Double::NewCanonical(value); 1838 dbl = Double::NewCanonical(value);
1839 ASSERT(dbl.IsCanonical() &&
1840 (kind == Snapshot::kMessage ||
1841 RawObject::IsCreatedFromSnapshot(dbl.raw()->ptr()->tags_)));
1829 } else { 1842 } else {
1830 dbl = Double::New(value, HEAP_SPACE(kind)); 1843 dbl = Double::New(value, HEAP_SPACE(kind));
1844 // Set the object tags.
1845 dbl.set_tags(tags);
1831 } 1846 }
1832 } 1847 }
1833 reader->AddBackRef(object_id, &dbl, kIsDeserialized); 1848 reader->AddBackRef(object_id, &dbl, kIsDeserialized);
1834
1835 // Set the object tags.
1836 dbl.set_tags(tags);
1837
1838 return dbl.raw(); 1849 return dbl.raw();
1839 } 1850 }
1840 1851
1841 1852
1842 void RawDouble::WriteTo(SnapshotWriter* writer, 1853 void RawDouble::WriteTo(SnapshotWriter* writer,
1843 intptr_t object_id, 1854 intptr_t object_id,
1844 Snapshot::Kind kind) { 1855 Snapshot::Kind kind) {
1845 ASSERT(writer != NULL); 1856 ASSERT(writer != NULL);
1846 1857
1847 // Write out the serialization header value for this object. 1858 // Write out the serialization header value for this object.
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 // We do not allow objects with native fields in an isolate message. 2963 // We do not allow objects with native fields in an isolate message.
2953 writer->SetWriteException(Exceptions::kArgument, 2964 writer->SetWriteException(Exceptions::kArgument,
2954 "Illegal argument in isolate message" 2965 "Illegal argument in isolate message"
2955 " : (object is a UserTag)"); 2966 " : (object is a UserTag)");
2956 } else { 2967 } else {
2957 UNREACHABLE(); 2968 UNREACHABLE();
2958 } 2969 }
2959 } 2970 }
2960 2971
2961 } // namespace dart 2972 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | runtime/vm/snapshot.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698