| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 static_assert(sizeof(T), "T must be fully defined"); | 97 static_assert(sizeof(T), "T must be fully defined"); |
| 98 return HeapObjectHeader::fromPayload(object)->isMarked(); | 98 return HeapObjectHeader::fromPayload(object)->isMarked(); |
| 99 } | 99 } |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 template <typename T> | 102 template <typename T> |
| 103 class ObjectAliveTrait<T, true> { | 103 class ObjectAliveTrait<T, true> { |
| 104 STATIC_ONLY(ObjectAliveTrait); | 104 STATIC_ONLY(ObjectAliveTrait); |
| 105 | 105 |
| 106 public: | 106 public: |
| 107 NO_LAZY_SWEEP_SANITIZE_ADDRESS | |
| 108 static bool isHeapObjectAlive(T* object) { | 107 static bool isHeapObjectAlive(T* object) { |
| 109 static_assert(sizeof(T), "T must be fully defined"); | 108 static_assert(sizeof(T), "T must be fully defined"); |
| 110 return object->isHeapObjectAlive(); | 109 return object->isHeapObjectAlive(); |
| 111 } | 110 } |
| 112 }; | 111 }; |
| 113 | 112 |
| 114 class PLATFORM_EXPORT ProcessHeap { | 113 class PLATFORM_EXPORT ProcessHeap { |
| 115 STATIC_ONLY(ProcessHeap); | 114 STATIC_ONLY(ProcessHeap); |
| 116 | 115 |
| 117 public: | 116 public: |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 315 |
| 317 // Is the finalizable GC object still alive, but slated for lazy sweeping? | 316 // Is the finalizable GC object still alive, but slated for lazy sweeping? |
| 318 // If a lazy sweep is in progress, returns true if the object was found | 317 // If a lazy sweep is in progress, returns true if the object was found |
| 319 // to be not reachable during the marking phase, but it has yet to be swept | 318 // to be not reachable during the marking phase, but it has yet to be swept |
| 320 // and finalized. The predicate returns false in all other cases. | 319 // and finalized. The predicate returns false in all other cases. |
| 321 // | 320 // |
| 322 // Holding a reference to an already-dead object is not a valid state | 321 // Holding a reference to an already-dead object is not a valid state |
| 323 // to be in; willObjectBeLazilySwept() has undefined behavior if passed | 322 // to be in; willObjectBeLazilySwept() has undefined behavior if passed |
| 324 // such a reference. | 323 // such a reference. |
| 325 template <typename T> | 324 template <typename T> |
| 326 NO_LAZY_SWEEP_SANITIZE_ADDRESS static bool willObjectBeLazilySwept( | 325 static bool willObjectBeLazilySwept(const T* objectPointer) { |
| 327 const T* objectPointer) { | |
| 328 static_assert(IsGarbageCollectedType<T>::value, | 326 static_assert(IsGarbageCollectedType<T>::value, |
| 329 "only objects deriving from GarbageCollected can be used."); | 327 "only objects deriving from GarbageCollected can be used."); |
| 330 BasePage* page = pageFromObject(objectPointer); | 328 BasePage* page = pageFromObject(objectPointer); |
| 331 // Page has been swept and it is still alive. | 329 // Page has been swept and it is still alive. |
| 332 if (page->hasBeenSwept()) | 330 if (page->hasBeenSwept()) |
| 333 return false; | 331 return false; |
| 334 ASSERT(page->arena()->getThreadState()->isSweepingInProgress()); | 332 ASSERT(page->arena()->getThreadState()->isSweepingInProgress()); |
| 335 | 333 |
| 336 // If marked and alive, the object hasn't yet been swept..and won't | 334 // If marked and alive, the object hasn't yet been swept..and won't |
| 337 // be once its page is processed. | 335 // be once its page is processed. |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 template <typename T> | 670 template <typename T> |
| 673 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { | 671 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { |
| 674 T** cell = reinterpret_cast<T**>(object); | 672 T** cell = reinterpret_cast<T**>(object); |
| 675 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 673 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
| 676 *cell = nullptr; | 674 *cell = nullptr; |
| 677 } | 675 } |
| 678 | 676 |
| 679 } // namespace blink | 677 } // namespace blink |
| 680 | 678 |
| 681 #endif // Heap_h | 679 #endif // Heap_h |
| OLD | NEW |