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

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

Issue 10375007: Revert "Implement {Int,Uint}{8,16,32,64} and Float{32,64} typed arrays." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 7 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 | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot_test.cc » ('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 1795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 1806
1807 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader, 1807 RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader,
1808 intptr_t object_id, 1808 intptr_t object_id,
1809 intptr_t tags, 1809 intptr_t tags,
1810 Snapshot::Kind kind) { 1810 Snapshot::Kind kind) {
1811 UNREACHABLE(); // ByteArray is an abstract class. 1811 UNREACHABLE(); // ByteArray is an abstract class.
1812 return ByteArray::null(); 1812 return ByteArray::null();
1813 } 1813 }
1814 1814
1815 1815
1816 template<typename HandleT, typename RawT, typename ElementT> 1816 RawInternalByteArray* InternalByteArray::ReadFrom(SnapshotReader* reader,
1817 RawT* ByteArray::ReadFromImpl(SnapshotReader* reader, 1817 intptr_t object_id,
1818 intptr_t object_id, 1818 intptr_t tags,
1819 intptr_t tags, 1819 Snapshot::Kind kind) {
1820 Snapshot::Kind kind) {
1821 ASSERT(reader != NULL); 1820 ASSERT(reader != NULL);
1822 1821
1822 // Read the length so that we can determine instance size to allocate.
1823 intptr_t len = reader->ReadSmiValue(); 1823 intptr_t len = reader->ReadSmiValue();
1824 Heap::Space space = (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew; 1824 Heap::Space space = (kind == Snapshot::kFull) ? Heap::kOld : Heap::kNew;
1825 HandleT& result = 1825 InternalByteArray& result =
1826 HandleT::ZoneHandle(reader->isolate(), HandleT::New(len, space)); 1826 InternalByteArray::ZoneHandle(reader->isolate(),
1827 InternalByteArray::New(len, space));
1827 reader->AddBackwardReference(object_id, &result); 1828 reader->AddBackwardReference(object_id, &result);
1828 1829
1829 // Set the object tags. 1830 // Set the object tags.
1830 result.set_tags(tags); 1831 result.set_tags(tags);
1831 1832
1832 // Setup the array elements. 1833 // Setup the array elements.
1833 for (intptr_t i = 0; i < len; ++i) { 1834 for (intptr_t i = 0; i < len; i++) {
1834 result.SetAt(i, reader->Read<ElementT>()); 1835 result.SetAt<uint8_t>(i, reader->Read<uint8_t>());
1835 } 1836 }
1836 return result.raw(); 1837 return result.raw();
1837 } 1838 }
1838 1839
1839 1840
1840 RawInt8Array* Int8Array::ReadFrom(SnapshotReader* reader, 1841 RawExternalByteArray* ExternalByteArray::ReadFrom(SnapshotReader* reader,
1841 intptr_t object_id,
1842 intptr_t tags,
1843 Snapshot::Kind kind) {
1844 return ReadFromImpl<Int8Array, RawInt8Array, int8_t>(reader,
1845 object_id,
1846 tags,
1847 kind);
1848 }
1849
1850
1851 RawUint8Array* Uint8Array::ReadFrom(SnapshotReader* reader,
1852 intptr_t object_id,
1853 intptr_t tags,
1854 Snapshot::Kind kind) {
1855 return ReadFromImpl<Uint8Array, RawUint8Array, uint8_t>(reader,
1856 object_id,
1857 tags,
1858 kind);
1859 }
1860
1861
1862 RawInt16Array* Int16Array::ReadFrom(SnapshotReader* reader,
1863 intptr_t object_id,
1864 intptr_t tags,
1865 Snapshot::Kind kind) {
1866 return ReadFromImpl<Int16Array, RawInt16Array, int16_t>(reader,
1867 object_id,
1868 tags,
1869 kind);
1870 }
1871
1872
1873 RawUint16Array* Uint16Array::ReadFrom(SnapshotReader* reader,
1874 intptr_t object_id,
1875 intptr_t tags,
1876 Snapshot::Kind kind) {
1877 return ReadFromImpl<Uint16Array, RawUint16Array, uint16_t>(reader,
1878 object_id,
1879 tags,
1880 kind);
1881 }
1882
1883
1884 RawInt32Array* Int32Array::ReadFrom(SnapshotReader* reader,
1885 intptr_t object_id,
1886 intptr_t tags,
1887 Snapshot::Kind kind) {
1888 return ReadFromImpl<Int32Array, RawInt32Array, int32_t>(reader,
1889 object_id,
1890 tags,
1891 kind);
1892 }
1893
1894
1895 RawUint32Array* Uint32Array::ReadFrom(SnapshotReader* reader,
1896 intptr_t object_id,
1897 intptr_t tags,
1898 Snapshot::Kind kind) {
1899 return ReadFromImpl<Uint32Array, RawUint32Array, uint32_t>(reader,
1900 object_id,
1901 tags,
1902 kind);
1903 }
1904
1905
1906 RawInt64Array* Int64Array::ReadFrom(SnapshotReader* reader,
1907 intptr_t object_id,
1908 intptr_t tags,
1909 Snapshot::Kind kind) {
1910 return ReadFromImpl<Int64Array, RawInt64Array, int64_t>(reader,
1911 object_id,
1912 tags,
1913 kind);
1914 }
1915
1916
1917 RawUint64Array* Uint64Array::ReadFrom(SnapshotReader* reader,
1918 intptr_t object_id,
1919 intptr_t tags,
1920 Snapshot::Kind kind) {
1921 return ReadFromImpl<Uint64Array, RawUint64Array, uint64_t>(reader,
1922 object_id,
1923 tags,
1924 kind);
1925 }
1926
1927
1928 RawFloat32Array* Float32Array::ReadFrom(SnapshotReader* reader,
1929 intptr_t object_id,
1930 intptr_t tags,
1931 Snapshot::Kind kind) {
1932 return ReadFromImpl<Float32Array, RawFloat32Array, float>(reader,
1933 object_id,
1934 tags,
1935 kind);
1936 }
1937
1938
1939 RawFloat64Array* Float64Array::ReadFrom(SnapshotReader* reader,
1940 intptr_t object_id,
1941 intptr_t tags,
1942 Snapshot::Kind kind) {
1943 return ReadFromImpl<Float64Array, RawFloat64Array, double>(reader,
1944 object_id,
1945 tags,
1946 kind);
1947 }
1948
1949
1950 RawExternalInt8Array* ExternalInt8Array::ReadFrom(SnapshotReader* reader,
1951 intptr_t object_id, 1842 intptr_t object_id,
1952 intptr_t tags, 1843 intptr_t tags,
1953 Snapshot::Kind kind) { 1844 Snapshot::Kind kind) {
1954 UNREACHABLE(); 1845 UNREACHABLE();
1955 return ExternalInt8Array::null(); 1846 return ExternalByteArray::null();
1956 } 1847 }
1957 1848
1958 1849
1959 RawExternalUint8Array* ExternalUint8Array::ReadFrom(SnapshotReader* reader,
1960 intptr_t object_id,
1961 intptr_t tags,
1962 Snapshot::Kind kind) {
1963 UNREACHABLE();
1964 return ExternalUint8Array::null();
1965 }
1966
1967
1968 RawExternalInt16Array* ExternalInt16Array::ReadFrom(SnapshotReader* reader,
1969 intptr_t object_id,
1970 intptr_t tags,
1971 Snapshot::Kind kind) {
1972 UNREACHABLE();
1973 return ExternalInt16Array::null();
1974 }
1975
1976
1977 RawExternalUint16Array* ExternalUint16Array::ReadFrom(SnapshotReader* reader,
1978 intptr_t object_id,
1979 intptr_t tags,
1980 Snapshot::Kind kind) {
1981 UNREACHABLE();
1982 return ExternalUint16Array::null();
1983 }
1984
1985
1986 RawExternalInt32Array* ExternalInt32Array::ReadFrom(SnapshotReader* reader,
1987 intptr_t object_id,
1988 intptr_t tags,
1989 Snapshot::Kind kind) {
1990 UNREACHABLE();
1991 return ExternalInt32Array::null();
1992 }
1993
1994
1995 RawExternalUint32Array* ExternalUint32Array::ReadFrom(SnapshotReader* reader,
1996 intptr_t object_id,
1997 intptr_t tags,
1998 Snapshot::Kind kind) {
1999 UNREACHABLE();
2000 return ExternalUint32Array::null();
2001 }
2002
2003
2004 RawExternalInt64Array* ExternalInt64Array::ReadFrom(SnapshotReader* reader,
2005 intptr_t object_id,
2006 intptr_t tags,
2007 Snapshot::Kind kind) {
2008 UNREACHABLE();
2009 return ExternalInt64Array::null();
2010 }
2011
2012
2013 RawExternalUint64Array* ExternalUint64Array::ReadFrom(SnapshotReader* reader,
2014 intptr_t object_id,
2015 intptr_t tags,
2016 Snapshot::Kind kind) {
2017 UNREACHABLE();
2018 return ExternalUint64Array::null();
2019 }
2020
2021
2022 RawExternalFloat32Array* ExternalFloat32Array::ReadFrom(SnapshotReader* reader,
2023 intptr_t object_id,
2024 intptr_t tags,
2025 Snapshot::Kind kind) {
2026 UNREACHABLE();
2027 return ExternalFloat32Array::null();
2028 }
2029
2030
2031 RawExternalFloat64Array* ExternalFloat64Array::ReadFrom(SnapshotReader* reader,
2032 intptr_t object_id,
2033 intptr_t tags,
2034 Snapshot::Kind kind) {
2035 UNREACHABLE();
2036 return ExternalFloat64Array::null();
2037 }
2038
2039
2040 static void ByteArrayWriteTo(SnapshotWriter* writer, 1850 static void ByteArrayWriteTo(SnapshotWriter* writer,
2041 intptr_t object_id, 1851 intptr_t object_id,
2042 Snapshot::Kind kind, 1852 Snapshot::Kind kind,
2043 intptr_t byte_array_kind, 1853 intptr_t byte_array_kind,
2044 intptr_t tags, 1854 intptr_t tags,
2045 RawSmi* length, 1855 RawSmi* length,
2046 uint8_t* data) { 1856 uint8_t* data) {
2047 ASSERT(writer != NULL); 1857 ASSERT(writer != NULL);
2048 intptr_t len = Smi::Value(length); 1858 intptr_t len = Smi::Value(length);
2049 1859
(...skipping 13 matching lines...) Expand all
2063 } 1873 }
2064 1874
2065 1875
2066 void RawByteArray::WriteTo(SnapshotWriter* writer, 1876 void RawByteArray::WriteTo(SnapshotWriter* writer,
2067 intptr_t object_id, 1877 intptr_t object_id,
2068 Snapshot::Kind kind) { 1878 Snapshot::Kind kind) {
2069 UNREACHABLE(); // ByteArray is an abstract class 1879 UNREACHABLE(); // ByteArray is an abstract class
2070 } 1880 }
2071 1881
2072 1882
2073 void RawInt8Array::WriteTo(SnapshotWriter* writer, 1883 void RawInternalByteArray::WriteTo(SnapshotWriter* writer,
2074 intptr_t object_id,
2075 Snapshot::Kind kind) {
2076 ByteArrayWriteTo(writer,
2077 object_id,
2078 kind,
2079 ObjectStore::kInt8ArrayClass,
2080 ptr()->tags_,
2081 ptr()->length_,
2082 reinterpret_cast<uint8_t*>(ptr()->data_));
2083 }
2084
2085
2086 void RawUint8Array::WriteTo(SnapshotWriter* writer,
2087 intptr_t object_id, 1884 intptr_t object_id,
2088 Snapshot::Kind kind) { 1885 Snapshot::Kind kind) {
2089 ByteArrayWriteTo(writer, 1886 ByteArrayWriteTo(writer,
2090 object_id, 1887 object_id,
2091 kind, 1888 kind,
2092 ObjectStore::kUint8ArrayClass, 1889 ObjectStore::kInternalByteArrayClass,
2093 ptr()->tags_, 1890 ptr()->tags_,
2094 ptr()->length_, 1891 ptr()->length_,
2095 reinterpret_cast<uint8_t*>(ptr()->data_)); 1892 ptr()->data());
2096 } 1893 }
2097 1894
2098 1895
2099 void RawInt16Array::WriteTo(SnapshotWriter* writer, 1896 void RawExternalByteArray::WriteTo(SnapshotWriter* writer,
2100 intptr_t object_id, 1897 intptr_t object_id,
2101 Snapshot::Kind kind) { 1898 Snapshot::Kind kind) {
1899 // Serialize as an internal byte array.
2102 ByteArrayWriteTo(writer, 1900 ByteArrayWriteTo(writer,
2103 object_id, 1901 object_id,
2104 kind, 1902 kind,
2105 ObjectStore::kInt16ArrayClass, 1903 ObjectStore::kInternalByteArrayClass,
2106 ptr()->tags_, 1904 ptr()->tags_,
2107 ptr()->length_, 1905 ptr()->length_,
2108 reinterpret_cast<uint8_t*>(ptr()->data_)); 1906 ptr()->external_data_->data());
2109 } 1907 }
2110 1908
2111 1909
2112 void RawUint16Array::WriteTo(SnapshotWriter* writer,
2113 intptr_t object_id,
2114 Snapshot::Kind kind) {
2115 ByteArrayWriteTo(writer,
2116 object_id,
2117 kind,
2118 ObjectStore::kUint16ArrayClass,
2119 ptr()->tags_,
2120 ptr()->length_,
2121 reinterpret_cast<uint8_t*>(ptr()->data_));
2122 }
2123
2124
2125 void RawInt32Array::WriteTo(SnapshotWriter* writer,
2126 intptr_t object_id,
2127 Snapshot::Kind kind) {
2128 ByteArrayWriteTo(writer,
2129 object_id,
2130 kind,
2131 ObjectStore::kInt32ArrayClass,
2132 ptr()->tags_,
2133 ptr()->length_,
2134 reinterpret_cast<uint8_t*>(ptr()->data_));
2135 }
2136
2137
2138 void RawUint32Array::WriteTo(SnapshotWriter* writer,
2139 intptr_t object_id,
2140 Snapshot::Kind kind) {
2141 ByteArrayWriteTo(writer,
2142 object_id,
2143 kind,
2144 ObjectStore::kUint32ArrayClass,
2145 ptr()->tags_,
2146 ptr()->length_,
2147 reinterpret_cast<uint8_t*>(ptr()->data_));
2148 }
2149
2150
2151 void RawInt64Array::WriteTo(SnapshotWriter* writer,
2152 intptr_t object_id,
2153 Snapshot::Kind kind) {
2154 ByteArrayWriteTo(writer,
2155 object_id,
2156 kind,
2157 ObjectStore::kInt64ArrayClass,
2158 ptr()->tags_,
2159 ptr()->length_,
2160 reinterpret_cast<uint8_t*>(ptr()->data_));
2161 }
2162
2163
2164 void RawUint64Array::WriteTo(SnapshotWriter* writer,
2165 intptr_t object_id,
2166 Snapshot::Kind kind) {
2167 ByteArrayWriteTo(writer,
2168 object_id,
2169 kind,
2170 ObjectStore::kUint64ArrayClass,
2171 ptr()->tags_,
2172 ptr()->length_,
2173 reinterpret_cast<uint8_t*>(ptr()->data_));
2174 }
2175
2176
2177 void RawFloat32Array::WriteTo(SnapshotWriter* writer,
2178 intptr_t object_id,
2179 Snapshot::Kind kind) {
2180 ByteArrayWriteTo(writer,
2181 object_id,
2182 kind,
2183 ObjectStore::kFloat32ArrayClass,
2184 ptr()->tags_,
2185 ptr()->length_,
2186 reinterpret_cast<uint8_t*>(ptr()->data_));
2187 }
2188
2189
2190 void RawFloat64Array::WriteTo(SnapshotWriter* writer,
2191 intptr_t object_id,
2192 Snapshot::Kind kind) {
2193 ByteArrayWriteTo(writer,
2194 object_id,
2195 kind,
2196 ObjectStore::kFloat64ArrayClass,
2197 ptr()->tags_,
2198 ptr()->length_,
2199 reinterpret_cast<uint8_t*>(ptr()->data_));
2200 }
2201
2202
2203 void RawExternalInt8Array::WriteTo(SnapshotWriter* writer,
2204 intptr_t object_id,
2205 Snapshot::Kind kind) {
2206 ByteArrayWriteTo(writer,
2207 object_id,
2208 kind,
2209 ObjectStore::kInt8ArrayClass,
2210 ptr()->tags_,
2211 ptr()->length_,
2212 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2213 }
2214
2215
2216 void RawExternalUint8Array::WriteTo(SnapshotWriter* writer,
2217 intptr_t object_id,
2218 Snapshot::Kind kind) {
2219 // Serialize as a non-external int8 array.
2220 ByteArrayWriteTo(writer,
2221 object_id,
2222 kind,
2223 ObjectStore::kUint8ArrayClass,
2224 ptr()->tags_,
2225 ptr()->length_,
2226 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2227 }
2228
2229
2230 void RawExternalInt16Array::WriteTo(SnapshotWriter* writer,
2231 intptr_t object_id,
2232 Snapshot::Kind kind) {
2233 // Serialize as a non-external int16 array.
2234 ByteArrayWriteTo(writer,
2235 object_id,
2236 kind,
2237 ObjectStore::kInt16ArrayClass,
2238 ptr()->tags_,
2239 ptr()->length_,
2240 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2241 }
2242
2243
2244 void RawExternalUint16Array::WriteTo(SnapshotWriter* writer,
2245 intptr_t object_id,
2246 Snapshot::Kind kind) {
2247 // Serialize as a non-external uint16 array.
2248 ByteArrayWriteTo(writer,
2249 object_id,
2250 kind,
2251 ObjectStore::kUint16ArrayClass,
2252 ptr()->tags_,
2253 ptr()->length_,
2254 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2255 }
2256
2257
2258 void RawExternalInt32Array::WriteTo(SnapshotWriter* writer,
2259 intptr_t object_id,
2260 Snapshot::Kind kind) {
2261 // Serialize as a non-external int32 array.
2262 ByteArrayWriteTo(writer,
2263 object_id,
2264 kind,
2265 ObjectStore::kInt32ArrayClass,
2266 ptr()->tags_,
2267 ptr()->length_,
2268 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2269 }
2270
2271
2272 void RawExternalUint32Array::WriteTo(SnapshotWriter* writer,
2273 intptr_t object_id,
2274 Snapshot::Kind kind) {
2275 // Serialize as a non-external uint32 array.
2276 ByteArrayWriteTo(writer,
2277 object_id,
2278 kind,
2279 ObjectStore::kUint32ArrayClass,
2280 ptr()->tags_,
2281 ptr()->length_,
2282 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2283 }
2284
2285
2286 void RawExternalInt64Array::WriteTo(SnapshotWriter* writer,
2287 intptr_t object_id,
2288 Snapshot::Kind kind) {
2289 // Serialize as a non-external int64 array.
2290 ByteArrayWriteTo(writer,
2291 object_id,
2292 kind,
2293 ObjectStore::kInt64ArrayClass,
2294 ptr()->tags_,
2295 ptr()->length_,
2296 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2297 }
2298
2299
2300 void RawExternalUint64Array::WriteTo(SnapshotWriter* writer,
2301 intptr_t object_id,
2302 Snapshot::Kind kind) {
2303 // Serialize as a non-external uint64 array.
2304 ByteArrayWriteTo(writer,
2305 object_id,
2306 kind,
2307 ObjectStore::kUint64ArrayClass,
2308 ptr()->tags_,
2309 ptr()->length_,
2310 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2311 }
2312
2313
2314 void RawExternalFloat32Array::WriteTo(SnapshotWriter* writer,
2315 intptr_t object_id,
2316 Snapshot::Kind kind) {
2317 // Serialize as a non-external float32 array.
2318 ByteArrayWriteTo(writer,
2319 object_id,
2320 kind,
2321 ObjectStore::kFloat32ArrayClass,
2322 ptr()->tags_,
2323 ptr()->length_,
2324 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2325 }
2326
2327
2328 void RawExternalFloat64Array::WriteTo(SnapshotWriter* writer,
2329 intptr_t object_id,
2330 Snapshot::Kind kind) {
2331 // Serialize as a non-external float64 array.
2332 ByteArrayWriteTo(writer,
2333 object_id,
2334 kind,
2335 ObjectStore::kFloat64ArrayClass,
2336 ptr()->tags_,
2337 ptr()->length_,
2338 reinterpret_cast<uint8_t*>(ptr()->external_data_->data()));
2339 }
2340
2341
2342 RawClosure* Closure::ReadFrom(SnapshotReader* reader, 1910 RawClosure* Closure::ReadFrom(SnapshotReader* reader,
2343 intptr_t object_id, 1911 intptr_t object_id,
2344 intptr_t tags, 1912 intptr_t tags,
2345 Snapshot::Kind kind) { 1913 Snapshot::Kind kind) {
2346 UNIMPLEMENTED(); 1914 UNIMPLEMENTED();
2347 return Closure::null(); 1915 return Closure::null();
2348 } 1916 }
2349 1917
2350 1918
2351 void RawClosure::WriteTo(SnapshotWriter* writer, 1919 void RawClosure::WriteTo(SnapshotWriter* writer,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 writer->Write<RawObject*>(ptr()->num_bracket_expressions_); 1990 writer->Write<RawObject*>(ptr()->num_bracket_expressions_);
2423 writer->WriteObject(ptr()->pattern_); 1991 writer->WriteObject(ptr()->pattern_);
2424 writer->WriteIntptrValue(ptr()->type_); 1992 writer->WriteIntptrValue(ptr()->type_);
2425 writer->WriteIntptrValue(ptr()->flags_); 1993 writer->WriteIntptrValue(ptr()->flags_);
2426 1994
2427 // Do not write out the data part which is native. 1995 // Do not write out the data part which is native.
2428 } 1996 }
2429 1997
2430 1998
2431 } // namespace dart 1999 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698