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

Side by Side Diff: vm/raw_object_snapshot.cc

Issue 10446112: Refactor snapshot writing code in preparation for the change to remove recursive calls to WriteObje… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | vm/snapshot.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 result.set_tags(tags); 1808 result.set_tags(tags);
1809 1809
1810 // Setup the array elements. 1810 // Setup the array elements.
1811 for (intptr_t i = 0; i < len; ++i) { 1811 for (intptr_t i = 0; i < len; ++i) {
1812 result.SetAt(i, reader->Read<ElementT>()); 1812 result.SetAt(i, reader->Read<ElementT>());
1813 } 1813 }
1814 return result.raw(); 1814 return result.raw();
1815 } 1815 }
1816 1816
1817 1817
1818 RawInt8Array* Int8Array::ReadFrom(SnapshotReader* reader, 1818 #define BYTEARRAY_TYPE_LIST(V) \
1819 intptr_t object_id, 1819 V(Int8, int8_t) \
1820 intptr_t tags, 1820 V(Uint8, uint8_t) \
1821 Snapshot::Kind kind) { 1821 V(Int16, int16_t) \
1822 return ReadFromImpl<Int8Array, RawInt8Array, int8_t>(reader, 1822 V(Uint16, uint16_t) \
1823 object_id, 1823 V(Int32, int32_t) \
1824 tags, 1824 V(Uint32, uint32_t) \
1825 kind); 1825 V(Int64, int64_t) \
1826 } 1826 V(Uint64, uint64_t) \
1827 V(Float32, float) \
1828 V(Float64, double) \
1827 1829
1828 1830
1829 RawUint8Array* Uint8Array::ReadFrom(SnapshotReader* reader, 1831 #define BYTEARRAY_READ_FROM(name, type) \
1830 intptr_t object_id, 1832 Raw##name##Array* name##Array::ReadFrom(SnapshotReader* reader, \
1831 intptr_t tags, 1833 intptr_t object_id, \
1832 Snapshot::Kind kind) { 1834 intptr_t tags, \
1833 return ReadFromImpl<Uint8Array, RawUint8Array, uint8_t>(reader, 1835 Snapshot::Kind kind) { \
1834 object_id, 1836 return ReadFromImpl<name##Array, Raw##name##Array, type>(reader, \
1835 tags, 1837 object_id, \
1836 kind); 1838 tags, \
1837 } 1839 kind); \
1840 } \
1838 1841
1839 1842
1840 RawInt16Array* Int16Array::ReadFrom(SnapshotReader* reader, 1843 BYTEARRAY_TYPE_LIST(BYTEARRAY_READ_FROM)
1841 intptr_t object_id, 1844 #undef BYTEARRAY_READ_FROM
1842 intptr_t tags,
1843 Snapshot::Kind kind) {
1844 return ReadFromImpl<Int16Array, RawInt16Array, int16_t>(reader,
1845 object_id,
1846 tags,
1847 kind);
1848 }
1849 1845
1850 1846
1851 RawUint16Array* Uint16Array::ReadFrom(SnapshotReader* reader, 1847 #define EXTERNALARRAY_READ_FROM(name, type) \
1852 intptr_t object_id, 1848 RawExternal##name##Array* External##name##Array::ReadFrom( \
1853 intptr_t tags, 1849 SnapshotReader* reader, \
1854 Snapshot::Kind kind) { 1850 intptr_t object_id, \
1855 return ReadFromImpl<Uint16Array, RawUint16Array, uint16_t>(reader, 1851 intptr_t tags, \
1856 object_id, 1852 Snapshot::Kind kind) { \
1857 tags, 1853 UNREACHABLE(); \
1858 kind); 1854 return External##name##Array::null(); \
1859 } 1855 } \
1860 1856
1861 1857
1862 RawInt32Array* Int32Array::ReadFrom(SnapshotReader* reader, 1858 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_READ_FROM)
1863 intptr_t object_id, 1859 #undef EXTERNALARRAY_READ_FROM
1864 intptr_t tags,
1865 Snapshot::Kind kind) {
1866 return ReadFromImpl<Int32Array, RawInt32Array, int32_t>(reader,
1867 object_id,
1868 tags,
1869 kind);
1870 }
1871
1872
1873 RawUint32Array* Uint32Array::ReadFrom(SnapshotReader* reader,
1874 intptr_t object_id,
1875 intptr_t tags,
1876 Snapshot::Kind kind) {
1877 return ReadFromImpl<Uint32Array, RawUint32Array, uint32_t>(reader,
1878 object_id,
1879 tags,
1880 kind);
1881 }
1882
1883
1884 RawInt64Array* Int64Array::ReadFrom(SnapshotReader* reader,
1885 intptr_t object_id,
1886 intptr_t tags,
1887 Snapshot::Kind kind) {
1888 return ReadFromImpl<Int64Array, RawInt64Array, int64_t>(reader,
1889 object_id,
1890 tags,
1891 kind);
1892 }
1893
1894
1895 RawUint64Array* Uint64Array::ReadFrom(SnapshotReader* reader,
1896 intptr_t object_id,
1897 intptr_t tags,
1898 Snapshot::Kind kind) {
1899 return ReadFromImpl<Uint64Array, RawUint64Array, uint64_t>(reader,
1900 object_id,
1901 tags,
1902 kind);
1903 }
1904
1905
1906 RawFloat32Array* Float32Array::ReadFrom(SnapshotReader* reader,
1907 intptr_t object_id,
1908 intptr_t tags,
1909 Snapshot::Kind kind) {
1910 return ReadFromImpl<Float32Array, RawFloat32Array, float>(reader,
1911 object_id,
1912 tags,
1913 kind);
1914 }
1915
1916
1917 RawFloat64Array* Float64Array::ReadFrom(SnapshotReader* reader,
1918 intptr_t object_id,
1919 intptr_t tags,
1920 Snapshot::Kind kind) {
1921 return ReadFromImpl<Float64Array, RawFloat64Array, double>(reader,
1922 object_id,
1923 tags,
1924 kind);
1925 }
1926
1927
1928 RawExternalInt8Array* ExternalInt8Array::ReadFrom(SnapshotReader* reader,
1929 intptr_t object_id,
1930 intptr_t tags,
1931 Snapshot::Kind kind) {
1932 UNREACHABLE();
1933 return ExternalInt8Array::null();
1934 }
1935
1936
1937 RawExternalUint8Array* ExternalUint8Array::ReadFrom(SnapshotReader* reader,
1938 intptr_t object_id,
1939 intptr_t tags,
1940 Snapshot::Kind kind) {
1941 UNREACHABLE();
1942 return ExternalUint8Array::null();
1943 }
1944
1945
1946 RawExternalInt16Array* ExternalInt16Array::ReadFrom(SnapshotReader* reader,
1947 intptr_t object_id,
1948 intptr_t tags,
1949 Snapshot::Kind kind) {
1950 UNREACHABLE();
1951 return ExternalInt16Array::null();
1952 }
1953
1954
1955 RawExternalUint16Array* ExternalUint16Array::ReadFrom(SnapshotReader* reader,
1956 intptr_t object_id,
1957 intptr_t tags,
1958 Snapshot::Kind kind) {
1959 UNREACHABLE();
1960 return ExternalUint16Array::null();
1961 }
1962
1963
1964 RawExternalInt32Array* ExternalInt32Array::ReadFrom(SnapshotReader* reader,
1965 intptr_t object_id,
1966 intptr_t tags,
1967 Snapshot::Kind kind) {
1968 UNREACHABLE();
1969 return ExternalInt32Array::null();
1970 }
1971
1972
1973 RawExternalUint32Array* ExternalUint32Array::ReadFrom(SnapshotReader* reader,
1974 intptr_t object_id,
1975 intptr_t tags,
1976 Snapshot::Kind kind) {
1977 UNREACHABLE();
1978 return ExternalUint32Array::null();
1979 }
1980
1981
1982 RawExternalInt64Array* ExternalInt64Array::ReadFrom(SnapshotReader* reader,
1983 intptr_t object_id,
1984 intptr_t tags,
1985 Snapshot::Kind kind) {
1986 UNREACHABLE();
1987 return ExternalInt64Array::null();
1988 }
1989
1990
1991 RawExternalUint64Array* ExternalUint64Array::ReadFrom(SnapshotReader* reader,
1992 intptr_t object_id,
1993 intptr_t tags,
1994 Snapshot::Kind kind) {
1995 UNREACHABLE();
1996 return ExternalUint64Array::null();
1997 }
1998
1999
2000 RawExternalFloat32Array* ExternalFloat32Array::ReadFrom(SnapshotReader* reader,
2001 intptr_t object_id,
2002 intptr_t tags,
2003 Snapshot::Kind kind) {
2004 UNREACHABLE();
2005 return ExternalFloat32Array::null();
2006 }
2007
2008
2009 RawExternalFloat64Array* ExternalFloat64Array::ReadFrom(SnapshotReader* reader,
2010 intptr_t object_id,
2011 intptr_t tags,
2012 Snapshot::Kind kind) {
2013 UNREACHABLE();
2014 return ExternalFloat64Array::null();
2015 }
2016 1860
2017 1861
2018 static void ByteArrayWriteTo(SnapshotWriter* writer, 1862 static void ByteArrayWriteTo(SnapshotWriter* writer,
2019 intptr_t object_id, 1863 intptr_t object_id,
2020 Snapshot::Kind kind, 1864 Snapshot::Kind kind,
2021 intptr_t byte_array_kind, 1865 intptr_t byte_array_kind,
2022 intptr_t tags, 1866 intptr_t tags,
2023 RawSmi* length, 1867 RawSmi* length,
2024 uint8_t* data) { 1868 uint8_t* data) {
2025 ASSERT(writer != NULL); 1869 ASSERT(writer != NULL);
(...skipping 15 matching lines...) Expand all
2041 } 1885 }
2042 1886
2043 1887
2044 void RawByteArray::WriteTo(SnapshotWriter* writer, 1888 void RawByteArray::WriteTo(SnapshotWriter* writer,
2045 intptr_t object_id, 1889 intptr_t object_id,
2046 Snapshot::Kind kind) { 1890 Snapshot::Kind kind) {
2047 UNREACHABLE(); // ByteArray is an abstract class 1891 UNREACHABLE(); // ByteArray is an abstract class
2048 } 1892 }
2049 1893
2050 1894
2051 void RawInt8Array::WriteTo(SnapshotWriter* writer, 1895 #define BYTEARRAY_WRITE_TO(name, type) \
2052 intptr_t object_id, 1896 void Raw##name##Array::WriteTo(SnapshotWriter* writer, \
2053 Snapshot::Kind kind) { 1897 intptr_t object_id, \
2054 ByteArrayWriteTo(writer, 1898 Snapshot::Kind kind) { \
2055 object_id, 1899 ByteArrayWriteTo(writer, \
2056 kind, 1900 object_id, \
2057 ObjectStore::kInt8ArrayClass, 1901 kind, \
2058 writer->GetObjectTags(this), 1902 ObjectStore::k##name##ArrayClass, \
2059 ptr()->length_, 1903 writer->GetObjectTags(this), \
2060 reinterpret_cast<uint8_t*>(ptr()->data_)); 1904 ptr()->length_, \
2061 } 1905 reinterpret_cast<uint8_t*>(ptr()->data_)); \
1906 } \
2062 1907
2063 1908
2064 void RawUint8Array::WriteTo(SnapshotWriter* writer, 1909 BYTEARRAY_TYPE_LIST(BYTEARRAY_WRITE_TO)
2065 intptr_t object_id, 1910 #undef BYTEARRAY_WRITE_TO
2066 Snapshot::Kind kind) {
2067 ByteArrayWriteTo(writer,
2068 object_id,
2069 kind,
2070 ObjectStore::kUint8ArrayClass,
2071 writer->GetObjectTags(this),
2072 ptr()->length_,
2073 reinterpret_cast<uint8_t*>(ptr()->data_));
2074 }
2075 1911
2076 1912
2077 void RawInt16Array::WriteTo(SnapshotWriter* writer, 1913 #define EXTERNALARRAY_WRITE_TO(name, type) \
2078 intptr_t object_id, 1914 void RawExternal##name##Array::WriteTo(SnapshotWriter* writer, \
2079 Snapshot::Kind kind) { 1915 intptr_t object_id, \
2080 ByteArrayWriteTo(writer, 1916 Snapshot::Kind kind) { \
2081 object_id, 1917 ByteArrayWriteTo(writer, \
2082 kind, 1918 object_id, \
2083 ObjectStore::kInt16ArrayClass, 1919 kind, \
2084 writer->GetObjectTags(this), 1920 ObjectStore::k##name##ArrayClass, \
2085 ptr()->length_, 1921 writer->GetObjectTags(this), \
2086 reinterpret_cast<uint8_t*>(ptr()->data_)); 1922 ptr()->length_, \
2087 } 1923 reinterpret_cast<uint8_t*>(ptr()->external_data_->data())); \
1924 } \
2088 1925
2089 1926
2090 void RawUint16Array::WriteTo(SnapshotWriter* writer, 1927 BYTEARRAY_TYPE_LIST(EXTERNALARRAY_WRITE_TO)
2091 intptr_t object_id, 1928 #undef BYTEARRAY_WRITE_TO
2092 Snapshot::Kind kind) { 1929 #undef BYTEARRAY_TYPE_LIST
2093 ByteArrayWriteTo(writer,
2094 object_id,
2095 kind,
2096 ObjectStore::kUint16ArrayClass,
2097 writer->GetObjectTags(this),
2098 ptr()->length_,
2099 reinterpret_cast<uint8_t*>(ptr()->data_));
2100 }
2101
2102
2103 void RawInt32Array::WriteTo(SnapshotWriter* writer,
2104 intptr_t object_id,
2105 Snapshot::Kind kind) {
2106 ByteArrayWriteTo(writer,
2107 object_id,
2108 kind,
2109 ObjectStore::kInt32ArrayClass,
2110 writer->GetObjectTags(this),
2111 ptr()->length_,
2112 reinterpret_cast<uint8_t*>(ptr()->data_));
2113 }
2114
2115
2116 void RawUint32Array::WriteTo(SnapshotWriter* writer,
2117 intptr_t object_id,
2118 Snapshot::Kind kind) {
2119 ByteArrayWriteTo(writer,
2120 object_id,
2121 kind,
2122 ObjectStore::kUint32ArrayClass,
2123 writer->GetObjectTags(this),
2124 ptr()->length_,
2125 reinterpret_cast<uint8_t*>(ptr()->data_));
2126 }
2127
2128
2129 void RawInt64Array::WriteTo(SnapshotWriter* writer,
2130 intptr_t object_id,
2131 Snapshot::Kind kind) {
2132 ByteArrayWriteTo(writer,
2133 object_id,
2134 kind,
2135 ObjectStore::kInt64ArrayClass,
2136 writer->GetObjectTags(this),
2137 ptr()->length_,
2138 reinterpret_cast<uint8_t*>(ptr()->data_));
2139 }
2140
2141
2142 void RawUint64Array::WriteTo(SnapshotWriter* writer,
2143 intptr_t object_id,
2144 Snapshot::Kind kind) {
2145 ByteArrayWriteTo(writer,
2146 object_id,
2147 kind,
2148 ObjectStore::kUint64ArrayClass,
2149 writer->GetObjectTags(this),
2150 ptr()->length_,
2151 reinterpret_cast<uint8_t*>(ptr()->data_));
2152 }
2153
2154
2155 void RawFloat32Array::WriteTo(SnapshotWriter* writer,
2156 intptr_t object_id,
2157 Snapshot::Kind kind) {
2158 ByteArrayWriteTo(writer,
2159 object_id,
2160 kind,
2161 ObjectStore::kFloat32ArrayClass,
2162 writer->GetObjectTags(this),
2163 ptr()->length_,
2164 reinterpret_cast<uint8_t*>(ptr()->data_));
2165 }
2166
2167
2168 void RawFloat64Array::WriteTo(SnapshotWriter* writer,
2169 intptr_t object_id,
2170 Snapshot::Kind kind) {
2171 ByteArrayWriteTo(writer,
2172 object_id,
2173 kind,
2174 ObjectStore::kFloat64ArrayClass,
2175 writer->GetObjectTags(this),
2176 ptr()->length_,
2177 reinterpret_cast<uint8_t*>(ptr()->data_));
2178 }
2179
2180
2181 void RawExternalInt8Array::WriteTo(SnapshotWriter* writer,
2182 intptr_t object_id,
2183 Snapshot::Kind kind) {
2184 ByteArrayWriteTo(writer,
2185 object_id,
2186 kind,
2187 ObjectStore::kInt8ArrayClass,
2188 writer->GetObjectTags(this),
2189 ptr()->length_,
2190 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2191 }
2192
2193
2194 void RawExternalUint8Array::WriteTo(SnapshotWriter* writer,
2195 intptr_t object_id,
2196 Snapshot::Kind kind) {
2197 // Serialize as a non-external int8 array.
2198 ByteArrayWriteTo(writer,
2199 object_id,
2200 kind,
2201 ObjectStore::kUint8ArrayClass,
2202 writer->GetObjectTags(this),
2203 ptr()->length_,
2204 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2205 }
2206
2207
2208 void RawExternalInt16Array::WriteTo(SnapshotWriter* writer,
2209 intptr_t object_id,
2210 Snapshot::Kind kind) {
2211 // Serialize as a non-external int16 array.
2212 ByteArrayWriteTo(writer,
2213 object_id,
2214 kind,
2215 ObjectStore::kInt16ArrayClass,
2216 writer->GetObjectTags(this),
2217 ptr()->length_,
2218 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2219 }
2220
2221
2222 void RawExternalUint16Array::WriteTo(SnapshotWriter* writer,
2223 intptr_t object_id,
2224 Snapshot::Kind kind) {
2225 // Serialize as a non-external uint16 array.
2226 ByteArrayWriteTo(writer,
2227 object_id,
2228 kind,
2229 ObjectStore::kUint16ArrayClass,
2230 writer->GetObjectTags(this),
2231 ptr()->length_,
2232 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2233 }
2234
2235
2236 void RawExternalInt32Array::WriteTo(SnapshotWriter* writer,
2237 intptr_t object_id,
2238 Snapshot::Kind kind) {
2239 // Serialize as a non-external int32 array.
2240 ByteArrayWriteTo(writer,
2241 object_id,
2242 kind,
2243 ObjectStore::kInt32ArrayClass,
2244 writer->GetObjectTags(this),
2245 ptr()->length_,
2246 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2247 }
2248
2249
2250 void RawExternalUint32Array::WriteTo(SnapshotWriter* writer,
2251 intptr_t object_id,
2252 Snapshot::Kind kind) {
2253 // Serialize as a non-external uint32 array.
2254 ByteArrayWriteTo(writer,
2255 object_id,
2256 kind,
2257 ObjectStore::kUint32ArrayClass,
2258 writer->GetObjectTags(this),
2259 ptr()->length_,
2260 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2261 }
2262
2263
2264 void RawExternalInt64Array::WriteTo(SnapshotWriter* writer,
2265 intptr_t object_id,
2266 Snapshot::Kind kind) {
2267 // Serialize as a non-external int64 array.
2268 ByteArrayWriteTo(writer,
2269 object_id,
2270 kind,
2271 ObjectStore::kInt64ArrayClass,
2272 writer->GetObjectTags(this),
2273 ptr()->length_,
2274 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2275 }
2276
2277
2278 void RawExternalUint64Array::WriteTo(SnapshotWriter* writer,
2279 intptr_t object_id,
2280 Snapshot::Kind kind) {
2281 // Serialize as a non-external uint64 array.
2282 ByteArrayWriteTo(writer,
2283 object_id,
2284 kind,
2285 ObjectStore::kUint64ArrayClass,
2286 writer->GetObjectTags(this),
2287 ptr()->length_,
2288 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2289 }
2290
2291
2292 void RawExternalFloat32Array::WriteTo(SnapshotWriter* writer,
2293 intptr_t object_id,
2294 Snapshot::Kind kind) {
2295 // Serialize as a non-external float32 array.
2296 ByteArrayWriteTo(writer,
2297 object_id,
2298 kind,
2299 ObjectStore::kFloat32ArrayClass,
2300 writer->GetObjectTags(this),
2301 ptr()->length_,
2302 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2303 }
2304
2305
2306 void RawExternalFloat64Array::WriteTo(SnapshotWriter* writer,
2307 intptr_t object_id,
2308 Snapshot::Kind kind) {
2309 // Serialize as a non-external float64 array.
2310 ByteArrayWriteTo(writer,
2311 object_id,
2312 kind,
2313 ObjectStore::kFloat64ArrayClass,
2314 writer->GetObjectTags(this),
2315 ptr()->length_,
2316 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2317 }
2318 1930
2319 1931
2320 RawClosure* Closure::ReadFrom(SnapshotReader* reader, 1932 RawClosure* Closure::ReadFrom(SnapshotReader* reader,
2321 intptr_t object_id, 1933 intptr_t object_id,
2322 intptr_t tags, 1934 intptr_t tags,
2323 Snapshot::Kind kind) { 1935 Snapshot::Kind kind) {
2324 UNIMPLEMENTED(); 1936 UNIMPLEMENTED();
2325 return Closure::null(); 1937 return Closure::null();
2326 } 1938 }
2327 1939
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 2013 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
2402 writer->WriteObject(ptr()->pattern_); 2014 writer->WriteObject(ptr()->pattern_);
2403 writer->WriteIntptrValue(ptr()->type_); 2015 writer->WriteIntptrValue(ptr()->type_);
2404 writer->WriteIntptrValue(ptr()->flags_); 2016 writer->WriteIntptrValue(ptr()->flags_);
2405 2017
2406 // Do not write out the data part which is native. 2018 // Do not write out the data part which is native.
2407 } 2019 }
2408 2020
2409 2021
2410 } // namespace dart 2022 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698