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

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

Issue 148043003: Add Float64x2, Float64x2List, etc... with runtime and dart2js implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
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/symbols.h" 9 #include "vm/symbols.h"
10 #include "vm/visitor.h" 10 #include "vm/visitor.h"
(...skipping 2191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 2202
2203 // Write out the used length field. 2203 // Write out the used length field.
2204 writer->Write<RawObject*>(ptr()->length_); 2204 writer->Write<RawObject*>(ptr()->length_);
2205 2205
2206 // Write out the Array object. 2206 // Write out the Array object.
2207 writer->WriteObjectImpl(ptr()->data_); 2207 writer->WriteObjectImpl(ptr()->data_);
2208 } 2208 }
2209 2209
2210 2210
2211 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader, 2211 RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader,
2212 intptr_t object_id, 2212 intptr_t object_id,
2213 intptr_t tags, 2213 intptr_t tags,
2214 Snapshot::Kind kind) { 2214 Snapshot::Kind kind) {
2215 ASSERT(reader != NULL); 2215 ASSERT(reader != NULL);
2216 // Read the values. 2216 // Read the values.
2217 float value0 = reader->Read<float>(); 2217 float value0 = reader->Read<float>();
2218 float value1 = reader->Read<float>(); 2218 float value1 = reader->Read<float>();
2219 float value2 = reader->Read<float>(); 2219 float value2 = reader->Read<float>();
2220 float value3 = reader->Read<float>(); 2220 float value3 = reader->Read<float>();
2221 2221
2222 // Create a Float32x4 object. 2222 // Create a Float32x4 object.
2223 Float32x4& simd = Float32x4::ZoneHandle(reader->isolate(), 2223 Float32x4& simd = Float32x4::ZoneHandle(reader->isolate(),
2224 Float32x4::null()); 2224 Float32x4::null());
2225 if (kind == Snapshot::kFull) { 2225 if (kind == Snapshot::kFull) {
2226 simd = reader->NewFloat32x4(value0, value1, value2, value3); 2226 simd = reader->NewFloat32x4(value0, value1, value2, value3);
2227 } else { 2227 } else {
2228 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 2228 simd = Float32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
2229 } 2229 }
2230 reader->AddBackRef(object_id, &simd, kIsDeserialized); 2230 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2231 // Set the object tags. 2231 // Set the object tags.
2232 simd.set_tags(tags); 2232 simd.set_tags(tags);
2233 return simd.raw(); 2233 return simd.raw();
2234 } 2234 }
2235 2235
2236 2236
2237 void RawFloat32x4::WriteTo(SnapshotWriter* writer, 2237 void RawFloat32x4::WriteTo(SnapshotWriter* writer,
2238 intptr_t object_id, 2238 intptr_t object_id,
2239 Snapshot::Kind kind) { 2239 Snapshot::Kind kind) {
2240 ASSERT(writer != NULL); 2240 ASSERT(writer != NULL);
2241 2241
2242 // Write out the serialization header value for this object. 2242 // Write out the serialization header value for this object.
2243 writer->WriteInlinedObjectHeader(object_id); 2243 writer->WriteInlinedObjectHeader(object_id);
2244 2244
2245 // Write out the class and tags information. 2245 // Write out the class and tags information.
2246 writer->WriteIndexedObject(kFloat32x4Cid); 2246 writer->WriteIndexedObject(kFloat32x4Cid);
2247 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2247 writer->WriteIntptrValue(writer->GetObjectTags(this));
2248 2248
2249 // Write out the float values. 2249 // Write out the float values.
2250 writer->Write<float>(ptr()->value_[0]); 2250 writer->Write<float>(ptr()->value_[0]);
2251 writer->Write<float>(ptr()->value_[1]); 2251 writer->Write<float>(ptr()->value_[1]);
2252 writer->Write<float>(ptr()->value_[2]); 2252 writer->Write<float>(ptr()->value_[2]);
2253 writer->Write<float>(ptr()->value_[3]); 2253 writer->Write<float>(ptr()->value_[3]);
2254 } 2254 }
2255 2255
2256 2256
2257 RawInt32x4* Int32x4::ReadFrom(SnapshotReader* reader, 2257 RawInt32x4* Int32x4::ReadFrom(SnapshotReader* reader,
2258 intptr_t object_id, 2258 intptr_t object_id,
2259 intptr_t tags, 2259 intptr_t tags,
2260 Snapshot::Kind kind) { 2260 Snapshot::Kind kind) {
2261 ASSERT(reader != NULL); 2261 ASSERT(reader != NULL);
2262 // Read the values. 2262 // Read the values.
2263 uint32_t value0 = reader->Read<uint32_t>(); 2263 uint32_t value0 = reader->Read<uint32_t>();
2264 uint32_t value1 = reader->Read<uint32_t>(); 2264 uint32_t value1 = reader->Read<uint32_t>();
2265 uint32_t value2 = reader->Read<uint32_t>(); 2265 uint32_t value2 = reader->Read<uint32_t>();
2266 uint32_t value3 = reader->Read<uint32_t>(); 2266 uint32_t value3 = reader->Read<uint32_t>();
2267 2267
2268 // Create a Float32x4 object. 2268 // Create a Float32x4 object.
2269 Int32x4& simd = Int32x4::ZoneHandle(reader->isolate(), Int32x4::null()); 2269 Int32x4& simd = Int32x4::ZoneHandle(reader->isolate(), Int32x4::null());
2270 2270
2271 if (kind == Snapshot::kFull) { 2271 if (kind == Snapshot::kFull) {
2272 simd = reader->NewInt32x4(value0, value1, value2, value3); 2272 simd = reader->NewInt32x4(value0, value1, value2, value3);
2273 } else { 2273 } else {
2274 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind)); 2274 simd = Int32x4::New(value0, value1, value2, value3, HEAP_SPACE(kind));
2275 } 2275 }
2276 reader->AddBackRef(object_id, &simd, kIsDeserialized); 2276 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2277 // Set the object tags. 2277 // Set the object tags.
2278 simd.set_tags(tags); 2278 simd.set_tags(tags);
2279 return simd.raw(); 2279 return simd.raw();
2280 } 2280 }
2281 2281
2282 2282
2283 void RawInt32x4::WriteTo(SnapshotWriter* writer, 2283 void RawInt32x4::WriteTo(SnapshotWriter* writer,
2284 intptr_t object_id, 2284 intptr_t object_id,
2285 Snapshot::Kind kind) { 2285 Snapshot::Kind kind) {
2286 ASSERT(writer != NULL); 2286 ASSERT(writer != NULL);
2287 2287
2288 // Write out the serialization header value for this object. 2288 // Write out the serialization header value for this object.
2289 writer->WriteInlinedObjectHeader(object_id); 2289 writer->WriteInlinedObjectHeader(object_id);
2290 2290
2291 // Write out the class and tags information. 2291 // Write out the class and tags information.
2292 writer->WriteIndexedObject(kInt32x4Cid); 2292 writer->WriteIndexedObject(kInt32x4Cid);
2293 writer->WriteIntptrValue(writer->GetObjectTags(this)); 2293 writer->WriteIntptrValue(writer->GetObjectTags(this));
2294 2294
2295 // Write out the mask values. 2295 // Write out the mask values.
2296 writer->Write<uint32_t>(ptr()->value_[0]); 2296 writer->Write<uint32_t>(ptr()->value_[0]);
2297 writer->Write<uint32_t>(ptr()->value_[1]); 2297 writer->Write<uint32_t>(ptr()->value_[1]);
2298 writer->Write<uint32_t>(ptr()->value_[2]); 2298 writer->Write<uint32_t>(ptr()->value_[2]);
2299 writer->Write<uint32_t>(ptr()->value_[3]); 2299 writer->Write<uint32_t>(ptr()->value_[3]);
2300 } 2300 }
2301 2301
2302 2302
2303 RawFloat64x2* Float64x2::ReadFrom(SnapshotReader* reader,
2304 intptr_t object_id,
2305 intptr_t tags,
2306 Snapshot::Kind kind) {
2307 ASSERT(reader != NULL);
2308 // Read the values.
2309 double value0 = reader->Read<double>();
2310 double value1 = reader->Read<double>();
2311
2312 // Create a Float64x2 object.
2313 Float64x2& simd = Float64x2::ZoneHandle(reader->isolate(),
2314 Float64x2::null());
2315 if (kind == Snapshot::kFull) {
2316 simd = reader->NewFloat64x2(value0, value1);
2317 } else {
2318 simd = Float64x2::New(value0, value1, HEAP_SPACE(kind));
2319 }
2320 reader->AddBackRef(object_id, &simd, kIsDeserialized);
2321 // Set the object tags.
2322 simd.set_tags(tags);
2323 return simd.raw();
2324 }
2325
2326
2327 void RawFloat64x2::WriteTo(SnapshotWriter* writer,
2328 intptr_t object_id,
2329 Snapshot::Kind kind) {
2330 ASSERT(writer != NULL);
2331
2332 // Write out the serialization header value for this object.
2333 writer->WriteInlinedObjectHeader(object_id);
2334
2335 // Write out the class and tags information.
2336 writer->WriteIndexedObject(kFloat64x2Cid);
2337 writer->WriteIntptrValue(writer->GetObjectTags(this));
2338
2339 // Write out the float values.
2340 writer->Write<double>(ptr()->value_[0]);
2341 writer->Write<double>(ptr()->value_[1]);
2342 }
2343
2344
2303 #define TYPED_DATA_READ(setter, type) \ 2345 #define TYPED_DATA_READ(setter, type) \
2304 for (intptr_t i = 0; i < lengthInBytes; i += element_size) { \ 2346 for (intptr_t i = 0; i < lengthInBytes; i += element_size) { \
2305 result.Set##setter(i, reader->Read<type>()); \ 2347 result.Set##setter(i, reader->Read<type>()); \
2306 } \ 2348 } \
2307 2349
2308 2350
2309 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, 2351 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader,
2310 intptr_t object_id, 2352 intptr_t object_id,
2311 intptr_t tags, 2353 intptr_t tags,
2312 Snapshot::Kind kind) { 2354 Snapshot::Kind kind) {
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 // We do not allow objects with native fields in an isolate message. 2730 // We do not allow objects with native fields in an isolate message.
2689 writer->SetWriteException(Exceptions::kArgument, 2731 writer->SetWriteException(Exceptions::kArgument,
2690 "Illegal argument in isolate message" 2732 "Illegal argument in isolate message"
2691 " : (object is a MirrorReference)"); 2733 " : (object is a MirrorReference)");
2692 } else { 2734 } else {
2693 UNREACHABLE(); 2735 UNREACHABLE();
2694 } 2736 }
2695 } 2737 }
2696 2738
2697 } // namespace dart 2739 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698