OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 m_raw = nullptr; | 764 m_raw = nullptr; |
765 return *this; | 765 return *this; |
766 } | 766 } |
767 | 767 |
768 void swap(Member<T>& other) | 768 void swap(Member<T>& other) |
769 { | 769 { |
770 std::swap(m_raw, other.m_raw); | 770 std::swap(m_raw, other.m_raw); |
771 checkPointer(); | 771 checkPointer(); |
772 } | 772 } |
773 | 773 |
774 T* get() const { return m_raw; } | 774 T* get() const |
775 { | |
776 static_assert(IsFullyDefined<T>::value, "T is not fully defined."); | |
haraken
2015/11/19 01:37:26
Would you replace other static_assert(sizeof(T)) i
peria
2015/11/19 03:57:51
Acknowledged.
| |
777 return m_raw; | |
778 } | |
775 | 779 |
776 void clear() { m_raw = nullptr; } | 780 void clear() { m_raw = nullptr; } |
777 | 781 |
778 | 782 |
779 protected: | 783 protected: |
780 void checkPointer() | 784 void checkPointer() |
781 { | 785 { |
786 static_assert(IsFullyDefined<T>::value, "T is not fully defined."); | |
782 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) | 787 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) |
783 if (!m_raw) | 788 if (!m_raw) |
784 return; | 789 return; |
785 // HashTable can store a special value (which is not aligned to the | 790 // HashTable can store a special value (which is not aligned to the |
786 // allocation granularity) to Member<> to represent a deleted entry. | 791 // allocation granularity) to Member<> to represent a deleted entry. |
787 // Thus we treat a pointer that is not aligned to the granularity | 792 // Thus we treat a pointer that is not aligned to the granularity |
788 // as a valid pointer. | 793 // as a valid pointer. |
789 if (reinterpret_cast<intptr_t>(m_raw) % allocationGranularity) | 794 if (reinterpret_cast<intptr_t>(m_raw) % allocationGranularity) |
790 return; | 795 return; |
791 | 796 |
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1504 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. | 1509 // TODO(sof): extend WTF::FunctionWrapper call overloading to also handle (C rossThread)WeakPersistent. |
1505 static T* unwrap(const StorageType& value) { return value.get(); } | 1510 static T* unwrap(const StorageType& value) { return value.get(); } |
1506 }; | 1511 }; |
1507 | 1512 |
1508 template<typename T> | 1513 template<typename T> |
1509 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; | 1514 PassRefPtr<T> adoptRef(blink::RefCountedGarbageCollected<T>*) = delete; |
1510 | 1515 |
1511 } // namespace WTF | 1516 } // namespace WTF |
1512 | 1517 |
1513 #endif | 1518 #endif |
OLD | NEW |