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