| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 ptr()->tags_ = RememberedBit::update(false, tags); | 388 ptr()->tags_ = RememberedBit::update(false, tags); |
| 389 } | 389 } |
| 390 | 390 |
| 391 bool IsDartInstance() { | 391 bool IsDartInstance() { |
| 392 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); | 392 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); |
| 393 } | 393 } |
| 394 bool IsFreeListElement() { | 394 bool IsFreeListElement() { |
| 395 return ((GetClassId() == kFreeListElement)); | 395 return ((GetClassId() == kFreeListElement)); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Uses the class table of the current isolate, when needed. |
| 398 intptr_t Size() const { | 399 intptr_t Size() const { |
| 399 uword tags = ptr()->tags_; | 400 uword tags = ptr()->tags_; |
| 400 intptr_t result = SizeTag::decode(tags); | 401 intptr_t result = SizeTag::decode(tags); |
| 401 if (result != 0) { | 402 if (result != 0) { |
| 402 ASSERT(result == SizeFromClass()); | 403 ASSERT(result == SizeFromClass()); |
| 403 return result; | 404 return result; |
| 404 } | 405 } |
| 405 result = SizeFromClass(); | 406 result = SizeFromClass(); |
| 406 ASSERT(result > SizeTag::kMaxSizeTag); | 407 ASSERT(result > SizeTag::kMaxSizeTag); |
| 407 return result; | 408 return result; |
| 408 } | 409 } |
| 409 | 410 |
| 411 // Like above, but avoids Thread/Isolate::Current. |
| 412 intptr_t Size(const ClassTable* class_table) const { |
| 413 uword tags = ptr()->tags_; |
| 414 intptr_t result = SizeTag::decode(tags); |
| 415 if (result != 0) { |
| 416 ASSERT(result == SizeFromClass(class_table)); |
| 417 return result; |
| 418 } |
| 419 result = SizeFromClass(class_table); |
| 420 ASSERT(result > SizeTag::kMaxSizeTag); |
| 421 return result; |
| 422 } |
| 423 |
| 410 bool Contains(uword addr) const { | 424 bool Contains(uword addr) const { |
| 411 intptr_t this_size = Size(); | 425 intptr_t this_size = Size(); |
| 412 uword this_addr = RawObject::ToAddr(this); | 426 uword this_addr = RawObject::ToAddr(this); |
| 413 return (addr >= this_addr) && (addr < (this_addr + this_size)); | 427 return (addr >= this_addr) && (addr < (this_addr + this_size)); |
| 414 } | 428 } |
| 415 | 429 |
| 416 void Validate(Isolate* isolate) const; | 430 void Validate(Isolate* isolate) const; |
| 417 intptr_t VisitPointers(ObjectPointerVisitor* visitor); | 431 intptr_t VisitPointers(ObjectPointerVisitor* visitor); |
| 418 bool FindObject(FindObjectVisitor* visitor); | 432 bool FindObject(FindObjectVisitor* visitor); |
| 419 | 433 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT | 484 BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT |
| 471 | 485 |
| 472 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). | 486 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). |
| 473 RawObject* ptr() const { | 487 RawObject* ptr() const { |
| 474 ASSERT(IsHeapObject()); | 488 ASSERT(IsHeapObject()); |
| 475 return reinterpret_cast<RawObject*>( | 489 return reinterpret_cast<RawObject*>( |
| 476 reinterpret_cast<uword>(this) - kHeapObjectTag); | 490 reinterpret_cast<uword>(this) - kHeapObjectTag); |
| 477 } | 491 } |
| 478 | 492 |
| 479 intptr_t SizeFromClass() const; | 493 intptr_t SizeFromClass() const; |
| 494 intptr_t SizeFromClass(const ClassTable* class_table) const; |
| 480 | 495 |
| 481 intptr_t GetClassId() const { | 496 intptr_t GetClassId() const { |
| 482 uword tags = ptr()->tags_; | 497 uword tags = ptr()->tags_; |
| 483 return ClassIdTag::decode(tags); | 498 return ClassIdTag::decode(tags); |
| 484 } | 499 } |
| 485 | 500 |
| 486 template<class TagBitField> | 501 template<class TagBitField> |
| 487 void UpdateTagBit(bool value) { | 502 void UpdateTagBit(bool value) { |
| 488 uword tags = ptr()->tags_; | 503 uword tags = ptr()->tags_; |
| 489 uword old_tags; | 504 uword old_tags; |
| (...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == | 2191 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == |
| 2177 kTypedDataInt8ArrayViewCid + 15); | 2192 kTypedDataInt8ArrayViewCid + 15); |
| 2178 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); | 2193 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); |
| 2179 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); | 2194 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); |
| 2180 return (kNullCid - kTypedDataInt8ArrayCid); | 2195 return (kNullCid - kTypedDataInt8ArrayCid); |
| 2181 } | 2196 } |
| 2182 | 2197 |
| 2183 } // namespace dart | 2198 } // namespace dart |
| 2184 | 2199 |
| 2185 #endif // VM_RAW_OBJECT_H_ | 2200 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |