| 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 RUNTIME_VM_RAW_OBJECT_H_ | 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_ |
| 6 #define RUNTIME_VM_RAW_OBJECT_H_ | 6 #define RUNTIME_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 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 return ((GetClassId() == kForwardingCorpse)); | 428 return ((GetClassId() == kForwardingCorpse)); |
| 429 } | 429 } |
| 430 bool IsPseudoObject() const { | 430 bool IsPseudoObject() const { |
| 431 return IsFreeListElement() || IsForwardingCorpse(); | 431 return IsFreeListElement() || IsForwardingCorpse(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 intptr_t Size() const { | 434 intptr_t Size() const { |
| 435 uword tags = ptr()->tags_; | 435 uword tags = ptr()->tags_; |
| 436 intptr_t result = SizeTag::decode(tags); | 436 intptr_t result = SizeTag::decode(tags); |
| 437 if (result != 0) { | 437 if (result != 0) { |
| 438 ASSERT(result == SizeFromClass()); | 438 #if defined(DEBUG) |
| 439 // TODO(22501) Array::MakeArray has a race with this code: we might have |
| 440 // loaded tags field and then MakeArray could have updated it leading |
| 441 // to inconsistency between SizeFromClass() and SizeTag::decode(tags). |
| 442 // We are working around it by reloading tags_ and recomputing |
| 443 // size from tags. |
| 444 const intptr_t size_from_class = SizeFromClass(); |
| 445 if ((result > size_from_class) && (GetClassId() == kArrayCid) && |
| 446 (ptr()->tags_ != tags)) { |
| 447 result = SizeTag::decode(ptr()->tags_); |
| 448 } |
| 449 ASSERT(result == size_from_class); |
| 450 #endif |
| 439 return result; | 451 return result; |
| 440 } | 452 } |
| 441 result = SizeFromClass(); | 453 result = SizeFromClass(); |
| 442 ASSERT(result > SizeTag::kMaxSizeTag); | 454 ASSERT(result > SizeTag::kMaxSizeTag); |
| 443 return result; | 455 return result; |
| 444 } | 456 } |
| 445 | 457 |
| 446 bool Contains(uword addr) const { | 458 bool Contains(uword addr) const { |
| 447 intptr_t this_size = Size(); | 459 intptr_t this_size = Size(); |
| 448 uword this_addr = RawObject::ToAddr(this); | 460 uword this_addr = RawObject::ToAddr(this); |
| (...skipping 1975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2424 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2436 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2425 kTypedDataInt8ArrayViewCid + 15); | 2437 kTypedDataInt8ArrayViewCid + 15); |
| 2426 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2438 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2427 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2439 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2428 return (kNullCid - kTypedDataInt8ArrayCid); | 2440 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2429 } | 2441 } |
| 2430 | 2442 |
| 2431 } // namespace dart | 2443 } // namespace dart |
| 2432 | 2444 |
| 2433 #endif // RUNTIME_VM_RAW_OBJECT_H_ | 2445 #endif // RUNTIME_VM_RAW_OBJECT_H_ |
| OLD | NEW |