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 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 5331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5342 ASSERT(!IsNull()); | 5342 ASSERT(!IsNull()); |
| 5343 return Smi::Value(raw_ptr()->length_); | 5343 return Smi::Value(raw_ptr()->length_); |
| 5344 } | 5344 } |
| 5345 | 5345 |
| 5346 intptr_t ElementSizeInBytes() const { | 5346 intptr_t ElementSizeInBytes() const { |
| 5347 intptr_t cid = raw()->GetClassId(); | 5347 intptr_t cid = raw()->GetClassId(); |
| 5348 return ElementSizeInBytes(cid); | 5348 return ElementSizeInBytes(cid); |
| 5349 } | 5349 } |
| 5350 | 5350 |
| 5351 | 5351 |
| 5352 TypeDataElementType ElementType() const { | 5352 TypedDataElementType ElementType() const { |
|
zra
2013/08/02 21:22:22
Is this renaming related to the Random fix?
| |
| 5353 intptr_t cid = raw()->GetClassId(); | 5353 intptr_t cid = raw()->GetClassId(); |
| 5354 return ElementType(cid); | 5354 return ElementType(cid); |
| 5355 } | 5355 } |
| 5356 | 5356 |
| 5357 intptr_t LengthInBytes() const { | 5357 intptr_t LengthInBytes() const { |
| 5358 intptr_t cid = raw()->GetClassId(); | 5358 intptr_t cid = raw()->GetClassId(); |
| 5359 return (ElementSizeInBytes(cid) * Length()); | 5359 return (ElementSizeInBytes(cid) * Length()); |
| 5360 } | 5360 } |
| 5361 | 5361 |
| 5362 void* DataAddr(intptr_t byte_offset) const { | 5362 void* DataAddr(intptr_t byte_offset) const { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 5376 TYPED_GETTER_SETTER(Int16, int16_t) | 5376 TYPED_GETTER_SETTER(Int16, int16_t) |
| 5377 TYPED_GETTER_SETTER(Uint16, uint16_t) | 5377 TYPED_GETTER_SETTER(Uint16, uint16_t) |
| 5378 TYPED_GETTER_SETTER(Int32, int32_t) | 5378 TYPED_GETTER_SETTER(Int32, int32_t) |
| 5379 TYPED_GETTER_SETTER(Uint32, uint32_t) | 5379 TYPED_GETTER_SETTER(Uint32, uint32_t) |
| 5380 TYPED_GETTER_SETTER(Int64, int64_t) | 5380 TYPED_GETTER_SETTER(Int64, int64_t) |
| 5381 TYPED_GETTER_SETTER(Uint64, uint64_t) | 5381 TYPED_GETTER_SETTER(Uint64, uint64_t) |
| 5382 TYPED_GETTER_SETTER(Float32, float) | 5382 TYPED_GETTER_SETTER(Float32, float) |
| 5383 TYPED_GETTER_SETTER(Float64, double) | 5383 TYPED_GETTER_SETTER(Float64, double) |
| 5384 TYPED_GETTER_SETTER(Float32x4, simd128_value_t) | 5384 TYPED_GETTER_SETTER(Float32x4, simd128_value_t) |
| 5385 | 5385 |
| 5386 #undef TYPED_GETTER_SETTER | |
| 5387 | |
| 5386 static intptr_t length_offset() { | 5388 static intptr_t length_offset() { |
| 5387 return OFFSET_OF(RawTypedData, length_); | 5389 return OFFSET_OF(RawTypedData, length_); |
| 5388 } | 5390 } |
| 5389 | 5391 |
| 5390 static intptr_t data_offset() { | 5392 static intptr_t data_offset() { |
| 5391 return OFFSET_OF(RawTypedData, data_); | 5393 return OFFSET_OF(RawTypedData, data_); |
| 5392 } | 5394 } |
| 5393 | 5395 |
| 5394 static intptr_t InstanceSize() { | 5396 static intptr_t InstanceSize() { |
| 5395 ASSERT(sizeof(RawTypedData) == OFFSET_OF(RawTypedData, data_)); | 5397 ASSERT(sizeof(RawTypedData) == OFFSET_OF(RawTypedData, data_)); |
| 5396 return 0; | 5398 return 0; |
| 5397 } | 5399 } |
| 5398 | 5400 |
| 5399 static intptr_t InstanceSize(intptr_t lengthInBytes) { | 5401 static intptr_t InstanceSize(intptr_t lengthInBytes) { |
| 5400 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); | 5402 ASSERT(0 <= lengthInBytes && lengthInBytes <= kSmiMax); |
| 5401 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); | 5403 return RoundedAllocationSize(sizeof(RawTypedData) + lengthInBytes); |
| 5402 } | 5404 } |
| 5403 | 5405 |
| 5404 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5406 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 5405 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 5407 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 5406 return element_size[ElementType(class_id)]; | 5408 return element_size[ElementType(class_id)]; |
| 5407 } | 5409 } |
| 5408 | 5410 |
| 5409 static TypeDataElementType ElementType(intptr_t class_id) { | 5411 static TypedDataElementType ElementType(intptr_t class_id) { |
| 5410 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 5412 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 5411 return static_cast<TypeDataElementType>( | 5413 return static_cast<TypedDataElementType>( |
| 5412 class_id - kTypedDataInt8ArrayCid); | 5414 class_id - kTypedDataInt8ArrayCid); |
| 5413 } | 5415 } |
| 5414 | 5416 |
| 5415 static intptr_t MaxElements(intptr_t class_id) { | 5417 static intptr_t MaxElements(intptr_t class_id) { |
| 5416 ASSERT(RawObject::IsTypedDataClassId(class_id)); | 5418 ASSERT(RawObject::IsTypedDataClassId(class_id)); |
| 5417 return (kSmiMax / ElementSizeInBytes(class_id)); | 5419 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 5418 } | 5420 } |
| 5419 | 5421 |
| 5420 static RawTypedData* New(intptr_t class_id, | 5422 static RawTypedData* New(intptr_t class_id, |
| 5421 intptr_t len, | 5423 intptr_t len, |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5468 intptr_t Length() const { | 5470 intptr_t Length() const { |
| 5469 ASSERT(!IsNull()); | 5471 ASSERT(!IsNull()); |
| 5470 return Smi::Value(raw_ptr()->length_); | 5472 return Smi::Value(raw_ptr()->length_); |
| 5471 } | 5473 } |
| 5472 | 5474 |
| 5473 intptr_t ElementSizeInBytes() const { | 5475 intptr_t ElementSizeInBytes() const { |
| 5474 intptr_t cid = raw()->GetClassId(); | 5476 intptr_t cid = raw()->GetClassId(); |
| 5475 return ElementSizeInBytes(cid); | 5477 return ElementSizeInBytes(cid); |
| 5476 } | 5478 } |
| 5477 | 5479 |
| 5478 TypeDataElementType ElementType() const { | 5480 TypedDataElementType ElementType() const { |
| 5479 intptr_t cid = raw()->GetClassId(); | 5481 intptr_t cid = raw()->GetClassId(); |
| 5480 return ElementType(cid); | 5482 return ElementType(cid); |
| 5481 } | 5483 } |
| 5482 | 5484 |
| 5483 intptr_t LengthInBytes() const { | 5485 intptr_t LengthInBytes() const { |
| 5484 intptr_t cid = raw()->GetClassId(); | 5486 intptr_t cid = raw()->GetClassId(); |
| 5485 return (ElementSizeInBytes(cid) * Length()); | 5487 return (ElementSizeInBytes(cid) * Length()); |
| 5486 } | 5488 } |
| 5487 | 5489 |
| 5488 void* GetPeer() const { | 5490 void* GetPeer() const { |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 5506 TYPED_GETTER_SETTER(Int16, int16_t) | 5508 TYPED_GETTER_SETTER(Int16, int16_t) |
| 5507 TYPED_GETTER_SETTER(Uint16, uint16_t) | 5509 TYPED_GETTER_SETTER(Uint16, uint16_t) |
| 5508 TYPED_GETTER_SETTER(Int32, int32_t) | 5510 TYPED_GETTER_SETTER(Int32, int32_t) |
| 5509 TYPED_GETTER_SETTER(Uint32, uint32_t) | 5511 TYPED_GETTER_SETTER(Uint32, uint32_t) |
| 5510 TYPED_GETTER_SETTER(Int64, int64_t) | 5512 TYPED_GETTER_SETTER(Int64, int64_t) |
| 5511 TYPED_GETTER_SETTER(Uint64, uint64_t) | 5513 TYPED_GETTER_SETTER(Uint64, uint64_t) |
| 5512 TYPED_GETTER_SETTER(Float32, float) | 5514 TYPED_GETTER_SETTER(Float32, float) |
| 5513 TYPED_GETTER_SETTER(Float64, double) | 5515 TYPED_GETTER_SETTER(Float64, double) |
| 5514 TYPED_GETTER_SETTER(Float32x4, simd128_value_t); | 5516 TYPED_GETTER_SETTER(Float32x4, simd128_value_t); |
| 5515 | 5517 |
| 5518 #undef TYPED_GETTER_SETTER | |
| 5519 | |
| 5516 FinalizablePersistentHandle* AddFinalizer( | 5520 FinalizablePersistentHandle* AddFinalizer( |
| 5517 void* peer, Dart_WeakPersistentHandleFinalizer callback) const; | 5521 void* peer, Dart_WeakPersistentHandleFinalizer callback) const; |
| 5518 | 5522 |
| 5519 static intptr_t length_offset() { | 5523 static intptr_t length_offset() { |
| 5520 return OFFSET_OF(RawExternalTypedData, length_); | 5524 return OFFSET_OF(RawExternalTypedData, length_); |
| 5521 } | 5525 } |
| 5522 | 5526 |
| 5523 static intptr_t data_offset() { | 5527 static intptr_t data_offset() { |
| 5524 return OFFSET_OF(RawExternalTypedData, data_); | 5528 return OFFSET_OF(RawExternalTypedData, data_); |
| 5525 } | 5529 } |
| 5526 | 5530 |
| 5527 static intptr_t InstanceSize() { | 5531 static intptr_t InstanceSize() { |
| 5528 return RoundedAllocationSize(sizeof(RawExternalTypedData)); | 5532 return RoundedAllocationSize(sizeof(RawExternalTypedData)); |
| 5529 } | 5533 } |
| 5530 | 5534 |
| 5531 static intptr_t ElementSizeInBytes(intptr_t class_id) { | 5535 static intptr_t ElementSizeInBytes(intptr_t class_id) { |
| 5532 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5536 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5533 return TypedData::element_size[ElementType(class_id)]; | 5537 return TypedData::element_size[ElementType(class_id)]; |
| 5534 } | 5538 } |
| 5535 | 5539 |
| 5536 static TypeDataElementType ElementType(intptr_t class_id) { | 5540 static TypedDataElementType ElementType(intptr_t class_id) { |
| 5537 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5541 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5538 return static_cast<TypeDataElementType>( | 5542 return static_cast<TypedDataElementType>( |
| 5539 class_id - kExternalTypedDataInt8ArrayCid); | 5543 class_id - kExternalTypedDataInt8ArrayCid); |
| 5540 } | 5544 } |
| 5541 | 5545 |
| 5542 static intptr_t MaxElements(intptr_t class_id) { | 5546 static intptr_t MaxElements(intptr_t class_id) { |
| 5543 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); | 5547 ASSERT(RawObject::IsExternalTypedDataClassId(class_id)); |
| 5544 return (kSmiMax / ElementSizeInBytes(class_id)); | 5548 return (kSmiMax / ElementSizeInBytes(class_id)); |
| 5545 } | 5549 } |
| 5546 | 5550 |
| 5547 static RawExternalTypedData* New(intptr_t class_id, | 5551 static RawExternalTypedData* New(intptr_t class_id, |
| 5548 uint8_t* data, | 5552 uint8_t* data, |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6035 | 6039 |
| 6036 | 6040 |
| 6037 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6041 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6038 intptr_t index) { | 6042 intptr_t index) { |
| 6039 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6043 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6040 } | 6044 } |
| 6041 | 6045 |
| 6042 } // namespace dart | 6046 } // namespace dart |
| 6043 | 6047 |
| 6044 #endif // VM_OBJECT_H_ | 6048 #endif // VM_OBJECT_H_ |
| OLD | NEW |