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_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/atomic.h" | 9 #include "vm/atomic.h" |
| 10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 uword tags = ptr()->tags_; | 426 uword tags = ptr()->tags_; |
| 427 ptr()->tags_ = RememberedBit::update(false, tags); | 427 ptr()->tags_ = RememberedBit::update(false, tags); |
| 428 } | 428 } |
| 429 // Returns false if the bit was already set. | 429 // Returns false if the bit was already set. |
| 430 // TODO(koda): Add "must use result" annotation here, after we add support. | 430 // TODO(koda): Add "must use result" annotation here, after we add support. |
| 431 bool TryAcquireRememberedBit() { | 431 bool TryAcquireRememberedBit() { |
| 432 return TryAcquireTagBit<RememberedBit>(); | 432 return TryAcquireTagBit<RememberedBit>(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 #define DEFINE_IS_CID(clazz) \ | 435 #define DEFINE_IS_CID(clazz) \ |
| 436 bool Is##clazz() { return ((GetClassId() == k##clazz##Cid)); } | 436 bool Is##clazz() const { return ((GetClassId() == k##clazz##Cid)); } |
| 437 CLASS_LIST(DEFINE_IS_CID) | 437 CLASS_LIST(DEFINE_IS_CID) |
| 438 #undef DEFINE_IS_CID | 438 #undef DEFINE_IS_CID |
| 439 | 439 |
| 440 #define DEFINE_IS_CID(clazz) \ | 440 #define DEFINE_IS_CID(clazz) \ |
| 441 bool IsTypedData##clazz() { \ | 441 bool IsTypedData##clazz() const { \ |
| 442 return ((GetClassId() == kTypedData##clazz##Cid)); \ | 442 return ((GetClassId() == kTypedData##clazz##Cid)); \ |
| 443 } \ | 443 } \ |
| 444 bool IsTypedDataView##clazz() { \ | 444 bool IsTypedDataView##clazz() const { \ |
|
rmacnak
2016/05/05 18:15:15
IsTypedData##clazz##View then?
| |
| 445 return ((GetClassId() == kTypedDataView##clazz##Cid)); \ | 445 return ((GetClassId() == kTypedData##clazz##ViewCid)); \ |
| 446 } \ | 446 } \ |
| 447 bool IsExternalTypedData##clazz() { \ | 447 bool IsExternalTypedData##clazz() const { \ |
| 448 return ((GetClassId() == kExternalTypedData##clazz##Cid)); \ | 448 return ((GetClassId() == kExternalTypedData##clazz##Cid)); \ |
| 449 } \ | 449 } |
| 450 CLASS_LIST_TYPED_DATA(DEFINE_IS_CID) | 450 CLASS_LIST_TYPED_DATA(DEFINE_IS_CID) |
| 451 #undef DEFINE_IS_CID | 451 #undef DEFINE_IS_CID |
| 452 | 452 |
| 453 bool IsDartInstance() { | 453 bool IsStringInstance() const { |
| 454 return IsStringClassId(GetClassId()); | |
| 455 } | |
| 456 bool IsDartInstance() const { | |
| 454 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); | 457 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); |
| 455 } | 458 } |
| 456 bool IsFreeListElement() { | 459 bool IsFreeListElement() const { |
| 457 return ((GetClassId() == kFreeListElement)); | 460 return ((GetClassId() == kFreeListElement)); |
| 458 } | 461 } |
| 459 | 462 |
| 460 intptr_t Size() const { | 463 intptr_t Size() const { |
| 461 uword tags = ptr()->tags_; | 464 uword tags = ptr()->tags_; |
| 462 intptr_t result = SizeTag::decode(tags); | 465 intptr_t result = SizeTag::decode(tags); |
| 463 if (result != 0) { | 466 if (result != 0) { |
| 464 ASSERT(result == SizeFromClass()); | 467 ASSERT(result == SizeFromClass()); |
| 465 return result; | 468 return result; |
| 466 } | 469 } |
| (...skipping 1961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2428 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2431 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2429 kTypedDataInt8ArrayViewCid + 15); | 2432 kTypedDataInt8ArrayViewCid + 15); |
| 2430 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2433 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2431 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2434 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2432 return (kNullCid - kTypedDataInt8ArrayCid); | 2435 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2433 } | 2436 } |
| 2434 | 2437 |
| 2435 } // namespace dart | 2438 } // namespace dart |
| 2436 | 2439 |
| 2437 #endif // VM_RAW_OBJECT_H_ | 2440 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |