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/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2285 writer->WriteIndexedObject(kFloat64x2Cid); | 2285 writer->WriteIndexedObject(kFloat64x2Cid); |
| 2286 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 2286 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
| 2287 | 2287 |
| 2288 // Write out the float values. | 2288 // Write out the float values. |
| 2289 writer->Write<double>(ptr()->value_[0]); | 2289 writer->Write<double>(ptr()->value_[0]); |
| 2290 writer->Write<double>(ptr()->value_[1]); | 2290 writer->Write<double>(ptr()->value_[1]); |
| 2291 } | 2291 } |
| 2292 | 2292 |
| 2293 | 2293 |
| 2294 #define TYPED_DATA_READ(setter, type) \ | 2294 #define TYPED_DATA_READ(setter, type) \ |
| 2295 for (intptr_t i = 0; i < lengthInBytes; i += element_size) { \ | 2295 for (intptr_t i = 0; i < length_in_bytes; i += element_size) { \ |
| 2296 result.Set##setter(i, reader->Read<type>()); \ | 2296 result.Set##setter(i, reader->Read<type>()); \ |
| 2297 } \ | 2297 } \ |
| 2298 | 2298 |
| 2299 | 2299 |
| 2300 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, | 2300 RawTypedData* TypedData::ReadFrom(SnapshotReader* reader, |
| 2301 intptr_t object_id, | 2301 intptr_t object_id, |
| 2302 intptr_t tags, | 2302 intptr_t tags, |
| 2303 Snapshot::Kind kind) { | 2303 Snapshot::Kind kind) { |
| 2304 ASSERT(reader != NULL); | 2304 ASSERT(reader != NULL); |
| 2305 | 2305 |
| 2306 intptr_t cid = RawObject::ClassIdTag::decode(tags); | 2306 intptr_t cid = RawObject::ClassIdTag::decode(tags); |
| 2307 intptr_t len = reader->ReadSmiValue(); | 2307 intptr_t len = reader->ReadSmiValue(); |
| 2308 TypedData& result = TypedData::ZoneHandle( | 2308 TypedData& result = TypedData::ZoneHandle( |
| 2309 reader->isolate(), TypedData::New(cid, len, HEAP_SPACE(kind))); | 2309 reader->isolate(), TypedData::New(cid, len, HEAP_SPACE(kind))); |
| 2310 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2310 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 2311 | 2311 |
| 2312 // Set the object tags. | 2312 // Set the object tags. |
| 2313 result.set_tags(tags); | 2313 result.set_tags(tags); |
| 2314 | 2314 |
| 2315 // Setup the array elements. | 2315 // Setup the array elements. |
| 2316 intptr_t element_size = ElementSizeInBytes(cid); | 2316 intptr_t element_size = ElementSizeInBytes(cid); |
| 2317 intptr_t lengthInBytes = len * element_size; | 2317 intptr_t length_in_bytes = len * element_size; |
| 2318 switch (cid) { | 2318 switch (cid) { |
| 2319 case kTypedDataInt8ArrayCid: | 2319 case kTypedDataInt8ArrayCid: |
| 2320 TYPED_DATA_READ(Int8, int8_t); | 2320 case kTypedDataUint8ArrayCid: |
| 2321 case kTypedDataUint8ClampedArrayCid: { | |
| 2322 uint8_t* data = reinterpret_cast<uint8_t*>(result.DataAddr(0)); | |
| 2323 reader->ReadBytes(data, length_in_bytes); | |
| 2321 break; | 2324 break; |
| 2322 case kTypedDataUint8ArrayCid: | 2325 } |
| 2323 TYPED_DATA_READ(Uint8, uint8_t); | |
| 2324 break; | |
| 2325 case kTypedDataUint8ClampedArrayCid: | |
| 2326 TYPED_DATA_READ(Uint8, uint8_t); | |
| 2327 break; | |
| 2328 case kTypedDataInt16ArrayCid: | 2326 case kTypedDataInt16ArrayCid: |
| 2329 TYPED_DATA_READ(Int16, int16_t); | 2327 TYPED_DATA_READ(Int16, int16_t); |
| 2330 break; | 2328 break; |
| 2331 case kTypedDataUint16ArrayCid: | 2329 case kTypedDataUint16ArrayCid: |
| 2332 TYPED_DATA_READ(Uint16, uint16_t); | 2330 TYPED_DATA_READ(Uint16, uint16_t); |
| 2333 break; | 2331 break; |
| 2334 case kTypedDataInt32ArrayCid: | 2332 case kTypedDataInt32ArrayCid: |
| 2335 TYPED_DATA_READ(Int32, int32_t); | 2333 TYPED_DATA_READ(Int32, int32_t); |
| 2336 break; | 2334 break; |
| 2337 case kTypedDataUint32ArrayCid: | 2335 case kTypedDataUint32ArrayCid: |
| 2338 TYPED_DATA_READ(Uint32, uint32_t); | 2336 TYPED_DATA_READ(Uint32, uint32_t); |
| 2339 break; | 2337 break; |
| 2340 case kTypedDataInt64ArrayCid: | 2338 case kTypedDataInt64ArrayCid: |
| 2341 TYPED_DATA_READ(Int64, int64_t); | 2339 TYPED_DATA_READ(Int64, int64_t); |
| 2342 break; | 2340 break; |
| 2343 case kTypedDataUint64ArrayCid: | 2341 case kTypedDataUint64ArrayCid: |
| 2344 TYPED_DATA_READ(Uint64, uint64_t); | 2342 TYPED_DATA_READ(Uint64, uint64_t); |
| 2345 break; | 2343 break; |
| 2346 case kTypedDataFloat32ArrayCid: | 2344 case kTypedDataFloat32ArrayCid: |
|
Ivan Posva
2014/04/03 05:41:02
You should consider doing the same for Float32 and
| |
| 2347 TYPED_DATA_READ(Float32, float); | 2345 TYPED_DATA_READ(Float32, float); |
| 2348 break; | 2346 break; |
| 2349 case kTypedDataFloat64ArrayCid: | 2347 case kTypedDataFloat64ArrayCid: |
| 2350 TYPED_DATA_READ(Float64, double); | 2348 TYPED_DATA_READ(Float64, double); |
| 2351 break; | 2349 break; |
| 2352 default: | 2350 default: |
| 2353 UNREACHABLE(); | 2351 UNREACHABLE(); |
| 2354 } | 2352 } |
| 2355 return result.raw(); | 2353 return result.raw(); |
| 2356 } | 2354 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2399 // Write out the class and tags information. | 2397 // Write out the class and tags information. |
| 2400 writer->WriteIndexedObject(cid); | 2398 writer->WriteIndexedObject(cid); |
| 2401 writer->WriteIntptrValue(tags); | 2399 writer->WriteIntptrValue(tags); |
| 2402 | 2400 |
| 2403 // Write out the length field. | 2401 // Write out the length field. |
| 2404 writer->Write<RawObject*>(ptr()->length_); | 2402 writer->Write<RawObject*>(ptr()->length_); |
| 2405 | 2403 |
| 2406 // Write out the array elements. | 2404 // Write out the array elements. |
| 2407 switch (cid) { | 2405 switch (cid) { |
| 2408 case kTypedDataInt8ArrayCid: | 2406 case kTypedDataInt8ArrayCid: |
| 2409 TYPED_DATA_WRITE(int8_t); | 2407 case kTypedDataUint8ArrayCid: |
| 2408 case kTypedDataUint8ClampedArrayCid: { | |
| 2409 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data_); | |
| 2410 writer->WriteBytes(data, len); | |
| 2410 break; | 2411 break; |
| 2411 case kTypedDataUint8ArrayCid: | 2412 } |
| 2412 TYPED_DATA_WRITE(uint8_t); | |
| 2413 break; | |
| 2414 case kTypedDataUint8ClampedArrayCid: | |
| 2415 TYPED_DATA_WRITE(uint8_t); | |
| 2416 break; | |
| 2417 case kTypedDataInt16ArrayCid: | 2413 case kTypedDataInt16ArrayCid: |
| 2418 TYPED_DATA_WRITE(int16_t); | 2414 TYPED_DATA_WRITE(int16_t); |
| 2419 break; | 2415 break; |
| 2420 case kTypedDataUint16ArrayCid: | 2416 case kTypedDataUint16ArrayCid: |
| 2421 TYPED_DATA_WRITE(uint16_t); | 2417 TYPED_DATA_WRITE(uint16_t); |
| 2422 break; | 2418 break; |
| 2423 case kTypedDataInt32ArrayCid: | 2419 case kTypedDataInt32ArrayCid: |
| 2424 TYPED_DATA_WRITE(int32_t); | 2420 TYPED_DATA_WRITE(int32_t); |
| 2425 break; | 2421 break; |
| 2426 case kTypedDataUint32ArrayCid: | 2422 case kTypedDataUint32ArrayCid: |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2679 // We do not allow objects with native fields in an isolate message. | 2675 // We do not allow objects with native fields in an isolate message. |
| 2680 writer->SetWriteException(Exceptions::kArgument, | 2676 writer->SetWriteException(Exceptions::kArgument, |
| 2681 "Illegal argument in isolate message" | 2677 "Illegal argument in isolate message" |
| 2682 " : (object is a MirrorReference)"); | 2678 " : (object is a MirrorReference)"); |
| 2683 } else { | 2679 } else { |
| 2684 UNREACHABLE(); | 2680 UNREACHABLE(); |
| 2685 } | 2681 } |
| 2686 } | 2682 } |
| 2687 | 2683 |
| 2688 } // namespace dart | 2684 } // namespace dart |
| OLD | NEW |