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/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/visitor.h" | 9 #include "vm/visitor.h" |
| 10 | 10 |
| (...skipping 1758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1769 | 1769 |
| 1770 // Setup the array elements. | 1770 // Setup the array elements. |
| 1771 for (intptr_t i = 0; i < len; ++i) { | 1771 for (intptr_t i = 0; i < len; ++i) { |
| 1772 result.SetAt(i, reader->Read<ElementT>()); | 1772 result.SetAt(i, reader->Read<ElementT>()); |
| 1773 } | 1773 } |
| 1774 return result.raw(); | 1774 return result.raw(); |
| 1775 } | 1775 } |
| 1776 | 1776 |
| 1777 | 1777 |
| 1778 #define BYTEARRAY_TYPE_LIST(V) \ | 1778 #define BYTEARRAY_TYPE_LIST(V) \ |
| 1779 V(Int8, int8_t) \ | 1779 V(Int8, int8, int8_t) \ |
| 1780 V(Uint8, uint8_t) \ | 1780 V(Uint8, uint8, uint8_t) \ |
| 1781 V(Int16, int16_t) \ | 1781 V(Int16, int16, int16_t) \ |
| 1782 V(Uint16, uint16_t) \ | 1782 V(Uint16, uint16, uint16_t) \ |
| 1783 V(Int32, int32_t) \ | 1783 V(Int32, int32, int32_t) \ |
| 1784 V(Uint32, uint32_t) \ | 1784 V(Uint32, uint32, uint32_t) \ |
| 1785 V(Int64, int64_t) \ | 1785 V(Int64, int64, int64_t) \ |
| 1786 V(Uint64, uint64_t) \ | 1786 V(Uint64, uint64, uint64_t) \ |
| 1787 V(Float32, float) \ | 1787 V(Float32, float32, float) \ |
| 1788 V(Float64, double) \ | 1788 V(Float64, float64, double) \ |
| 1789 | 1789 |
| 1790 | 1790 |
| 1791 #define BYTEARRAY_READ_FROM(name, type) \ | 1791 #define BYTEARRAY_READ_FROM(name, lname, type) \ |
| 1792 Raw##name##Array* name##Array::ReadFrom(SnapshotReader* reader, \ | 1792 Raw##name##Array* name##Array::ReadFrom(SnapshotReader* reader, \ |
| 1793 intptr_t object_id, \ | 1793 intptr_t object_id, \ |
| 1794 intptr_t tags, \ | 1794 intptr_t tags, \ |
| 1795 Snapshot::Kind kind) { \ | 1795 Snapshot::Kind kind) { \ |
| 1796 return ReadFromImpl<name##Array, Raw##name##Array, type>(reader, \ | 1796 return ReadFromImpl<name##Array, Raw##name##Array, type>(reader, \ |
| 1797 object_id, \ | 1797 object_id, \ |
| 1798 tags, \ | 1798 tags, \ |
| 1799 kind); \ | 1799 kind); \ |
| 1800 } \ | 1800 } \ |
| 1801 | 1801 |
| 1802 | 1802 |
| 1803 BYTEARRAY_TYPE_LIST(BYTEARRAY_READ_FROM) | 1803 BYTEARRAY_TYPE_LIST(BYTEARRAY_READ_FROM) |
| 1804 #undef BYTEARRAY_READ_FROM | 1804 #undef BYTEARRAY_READ_FROM |
| 1805 | 1805 |
| 1806 | 1806 |
| 1807 #define EXTERNALARRAY_READ_FROM(name, type) \ | 1807 #define EXTERNALARRAY_READ_FROM(name, lname, type) \ |
| 1808 RawExternal##name##Array* External##name##Array::ReadFrom( \ | 1808 RawExternal##name##Array* External##name##Array::ReadFrom( \ |
| 1809 SnapshotReader* reader, \ | 1809 SnapshotReader* reader, \ |
| 1810 intptr_t object_id, \ | 1810 intptr_t object_id, \ |
| 1811 intptr_t tags, \ | 1811 intptr_t tags, \ |
| 1812 Snapshot::Kind kind) { \ | 1812 Snapshot::Kind kind) { \ |
|
siva
2012/06/28 16:44:05
ASSERT(kind != Snapshot::kFull);
or
if (kind == Sn
Mads Ager (google)
2012/06/28 18:06:51
Added the ASSERT. Thanks!
| |
| 1813 UNREACHABLE(); \ | 1813 intptr_t length = reader->ReadSmiValue(); \ |
| 1814 return External##name##Array::null(); \ | 1814 type* data = reinterpret_cast<type*>(reader->ReadIntptrValue()); \ |
| 1815 void* peer = reinterpret_cast<void*>(reader->ReadIntptrValue()); \ | |
| 1816 Dart_PeerFinalizer callback = \ | |
| 1817 reinterpret_cast<Dart_PeerFinalizer>(reader->ReadIntptrValue()); \ | |
| 1818 const Class& cls = Class::Handle( \ | |
| 1819 reader->isolate()->object_store()->external_##lname##_array_class()); \ | |
| 1820 return NewExternalImpl<External##name##Array, RawExternal##name##Array>( \ | |
| 1821 cls, data, length, peer, callback, Heap::kNew); \ | |
| 1815 } \ | 1822 } \ |
| 1816 | 1823 |
| 1817 | 1824 |
| 1818 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_READ_FROM) | 1825 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_READ_FROM) |
| 1819 #undef EXTERNALARRAY_READ_FROM | 1826 #undef EXTERNALARRAY_READ_FROM |
| 1820 | 1827 |
| 1821 | 1828 |
| 1822 static void ByteArrayWriteTo(SnapshotWriter* writer, | 1829 static void ByteArrayWriteTo(SnapshotWriter* writer, |
| 1823 intptr_t object_id, | 1830 intptr_t object_id, |
| 1824 Snapshot::Kind kind, | 1831 Snapshot::Kind kind, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 1845 } | 1852 } |
| 1846 | 1853 |
| 1847 | 1854 |
| 1848 void RawByteArray::WriteTo(SnapshotWriter* writer, | 1855 void RawByteArray::WriteTo(SnapshotWriter* writer, |
| 1849 intptr_t object_id, | 1856 intptr_t object_id, |
| 1850 Snapshot::Kind kind) { | 1857 Snapshot::Kind kind) { |
| 1851 UNREACHABLE(); // ByteArray is an abstract class | 1858 UNREACHABLE(); // ByteArray is an abstract class |
| 1852 } | 1859 } |
| 1853 | 1860 |
| 1854 | 1861 |
| 1855 #define BYTEARRAY_WRITE_TO(name, type) \ | 1862 #define BYTEARRAY_WRITE_TO(name, lname, type) \ |
| 1856 void Raw##name##Array::WriteTo(SnapshotWriter* writer, \ | 1863 void Raw##name##Array::WriteTo(SnapshotWriter* writer, \ |
| 1857 intptr_t object_id, \ | 1864 intptr_t object_id, \ |
| 1858 Snapshot::Kind kind) { \ | 1865 Snapshot::Kind kind) { \ |
| 1859 ByteArrayWriteTo(writer, \ | 1866 ByteArrayWriteTo(writer, \ |
| 1860 object_id, \ | 1867 object_id, \ |
| 1861 kind, \ | 1868 kind, \ |
| 1862 ObjectStore::k##name##ArrayClass, \ | 1869 ObjectStore::k##name##ArrayClass, \ |
| 1863 writer->GetObjectTags(this), \ | 1870 writer->GetObjectTags(this), \ |
| 1864 ptr()->length_, \ | 1871 ptr()->length_, \ |
| 1865 reinterpret_cast<uint8_t*>(ptr()->data_)); \ | 1872 reinterpret_cast<uint8_t*>(ptr()->data_)); \ |
| 1866 } \ | 1873 } \ |
| 1867 | 1874 |
| 1868 | 1875 |
| 1869 BYTEARRAY_TYPE_LIST(BYTEARRAY_WRITE_TO) | 1876 BYTEARRAY_TYPE_LIST(BYTEARRAY_WRITE_TO) |
| 1870 #undef BYTEARRAY_WRITE_TO | 1877 #undef BYTEARRAY_WRITE_TO |
| 1871 | 1878 |
| 1872 | 1879 |
| 1873 #define EXTERNALARRAY_WRITE_TO(name, type) \ | 1880 #define EXTERNALARRAY_WRITE_TO(name, lname, type) \ |
| 1874 void RawExternal##name##Array::WriteTo(SnapshotWriter* writer, \ | 1881 void RawExternal##name##Array::WriteTo(SnapshotWriter* writer, \ |
| 1875 intptr_t object_id, \ | 1882 intptr_t object_id, \ |
| 1876 Snapshot::Kind kind) { \ | 1883 Snapshot::Kind kind) { \ |
| 1877 ByteArrayWriteTo(writer, \ | 1884 ByteArrayWriteTo(writer, \ |
| 1878 object_id, \ | 1885 object_id, \ |
| 1879 kind, \ | 1886 kind, \ |
| 1880 ObjectStore::k##name##ArrayClass, \ | 1887 ObjectStore::k##name##ArrayClass, \ |
| 1881 writer->GetObjectTags(this), \ | 1888 writer->GetObjectTags(this), \ |
| 1882 ptr()->length_, \ | 1889 ptr()->length_, \ |
| 1883 reinterpret_cast<uint8_t*>(ptr()->external_data_->data())); \ | 1890 reinterpret_cast<uint8_t*>(ptr()->external_data_->data())); \ |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1973 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); | 1980 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); |
| 1974 writer->WriteObjectImpl(ptr()->pattern_); | 1981 writer->WriteObjectImpl(ptr()->pattern_); |
| 1975 writer->WriteIntptrValue(ptr()->type_); | 1982 writer->WriteIntptrValue(ptr()->type_); |
| 1976 writer->WriteIntptrValue(ptr()->flags_); | 1983 writer->WriteIntptrValue(ptr()->flags_); |
| 1977 | 1984 |
| 1978 // Do not write out the data part which is native. | 1985 // Do not write out the data part which is native. |
| 1979 } | 1986 } |
| 1980 | 1987 |
| 1981 | 1988 |
| 1982 } // namespace dart | 1989 } // namespace dart |
| OLD | NEW |