| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 m_persistentNode = nullptr; | 268 m_persistentNode = nullptr; |
| 269 } | 269 } |
| 270 | 270 |
| 271 void checkPointer() | 271 void checkPointer() |
| 272 { | 272 { |
| 273 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) | 273 #if ENABLE(ASSERT) && defined(ADDRESS_SANITIZER) |
| 274 if (!m_raw) | 274 if (!m_raw) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 // ThreadHeap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable | 277 // Heap::isHeapObjectAlive(m_raw) checks that m_raw is a traceable |
| 278 // object. In other words, it checks that the pointer is either of: | 278 // object. In other words, it checks that the pointer is either of: |
| 279 // | 279 // |
| 280 // (a) a pointer to the head of an on-heap object. | 280 // (a) a pointer to the head of an on-heap object. |
| 281 // (b) a pointer to the head of an on-heap mixin object. | 281 // (b) a pointer to the head of an on-heap mixin object. |
| 282 // | 282 // |
| 283 // Otherwise, ThreadHeap::isHeapObjectAlive will crash when it calls | 283 // Otherwise, Heap::isHeapObjectAlive will crash when it calls |
| 284 // header->checkHeader(). | 284 // header->checkHeader(). |
| 285 ThreadHeap::isHeapObjectAlive(m_raw); | 285 Heap::isHeapObjectAlive(m_raw); |
| 286 #endif | 286 #endif |
| 287 } | 287 } |
| 288 | 288 |
| 289 // m_raw is accessed most, so put it at the first field. | 289 // m_raw is accessed most, so put it at the first field. |
| 290 T* m_raw; | 290 T* m_raw; |
| 291 PersistentNode* m_persistentNode = nullptr; | 291 PersistentNode* m_persistentNode = nullptr; |
| 292 #if ENABLE(ASSERT) | 292 #if ENABLE(ASSERT) |
| 293 ThreadState* m_state = nullptr; | 293 ThreadState* m_state = nullptr; |
| 294 #endif | 294 #endif |
| 295 }; | 295 }; |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 // as a valid pointer. | 837 // as a valid pointer. |
| 838 if (reinterpret_cast<intptr_t>(m_raw) % allocationGranularity) | 838 if (reinterpret_cast<intptr_t>(m_raw) % allocationGranularity) |
| 839 return; | 839 return; |
| 840 | 840 |
| 841 // TODO(haraken): What we really want to check here is that the pointer | 841 // TODO(haraken): What we really want to check here is that the pointer |
| 842 // is a traceable object. In other words, the pointer is either of: | 842 // is a traceable object. In other words, the pointer is either of: |
| 843 // | 843 // |
| 844 // (a) a pointer to the head of an on-heap object. | 844 // (a) a pointer to the head of an on-heap object. |
| 845 // (b) a pointer to the head of an on-heap mixin object. | 845 // (b) a pointer to the head of an on-heap mixin object. |
| 846 // | 846 // |
| 847 // We can check it by calling ThreadHeap::isHeapObjectAlive(m_raw), | 847 // We can check it by calling Heap::isHeapObjectAlive(m_raw), |
| 848 // but we cannot call it here because it requires to include T.h. | 848 // but we cannot call it here because it requires to include T.h. |
| 849 // So we currently only try to implement the check for (a), but do | 849 // So we currently only try to implement the check for (a), but do |
| 850 // not insist that T's definition is in scope. | 850 // not insist that T's definition is in scope. |
| 851 if (IsFullyDefined<T>::value && !IsGarbageCollectedMixin<T>::value) | 851 if (IsFullyDefined<T>::value && !IsGarbageCollectedMixin<T>::value) |
| 852 ASSERT(HeapObjectHeader::fromPayload(m_raw)->checkHeader()); | 852 ASSERT(HeapObjectHeader::fromPayload(m_raw)->checkHeader()); |
| 853 #endif | 853 #endif |
| 854 } | 854 } |
| 855 | 855 |
| 856 T* m_raw; | 856 T* m_raw; |
| 857 | 857 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 // into it. | 1293 // into it. |
| 1294 // | 1294 // |
| 1295 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like | 1295 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like |
| 1296 // CrossThreadWeakPersistent<>. | 1296 // CrossThreadWeakPersistent<>. |
| 1297 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } | 1297 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } |
| 1298 }; | 1298 }; |
| 1299 | 1299 |
| 1300 } // namespace WTF | 1300 } // namespace WTF |
| 1301 | 1301 |
| 1302 #endif | 1302 #endif |
| OLD | NEW |