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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 template <typename T> | 240 template <typename T> |
241 static inline bool isHeapObjectAlive(T* object) { | 241 static inline bool isHeapObjectAlive(T* object) { |
242 static_assert(sizeof(T), "T must be fully defined"); | 242 static_assert(sizeof(T), "T must be fully defined"); |
243 // The strongification of collections relies on the fact that once a | 243 // The strongification of collections relies on the fact that once a |
244 // collection has been strongified, there is no way that it can contain | 244 // collection has been strongified, there is no way that it can contain |
245 // non-live entries, so no entries will be removed. Since you can't set | 245 // non-live entries, so no entries will be removed. Since you can't set |
246 // the mark bit on a null pointer, that means that null pointers are | 246 // the mark bit on a null pointer, that means that null pointers are |
247 // always 'alive'. | 247 // always 'alive'. |
248 if (!object) | 248 if (!object) |
249 return true; | 249 return true; |
250 // TODO(keishi): some tests create CrossThreadPersistent on non attached thr
eads. | 250 // TODO(keishi): some tests create CrossThreadPersistent on non attached |
| 251 // threads. |
251 if (!ThreadState::current()) | 252 if (!ThreadState::current()) |
252 return true; | 253 return true; |
253 if (&ThreadState::current()->heap() != | 254 if (&ThreadState::current()->heap() != |
254 &pageFromObject(object)->arena()->getThreadState()->heap()) | 255 &pageFromObject(object)->arena()->getThreadState()->heap()) |
255 return true; | 256 return true; |
256 return ObjectAliveTrait<T>::isHeapObjectAlive(object); | 257 return ObjectAliveTrait<T>::isHeapObjectAlive(object); |
257 } | 258 } |
258 template <typename T> | 259 template <typename T> |
259 static inline bool isHeapObjectAlive(const Member<T>& member) { | 260 static inline bool isHeapObjectAlive(const Member<T>& member) { |
260 return isHeapObjectAlive(member.get()); | 261 return isHeapObjectAlive(member.get()); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 template <typename T> | 673 template <typename T> |
673 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { | 674 void VisitorHelper<Derived>::handleWeakCell(Visitor* self, void* object) { |
674 T** cell = reinterpret_cast<T**>(object); | 675 T** cell = reinterpret_cast<T**>(object); |
675 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) | 676 if (*cell && !ObjectAliveTrait<T>::isHeapObjectAlive(*cell)) |
676 *cell = nullptr; | 677 *cell = nullptr; |
677 } | 678 } |
678 | 679 |
679 } // namespace blink | 680 } // namespace blink |
680 | 681 |
681 #endif // Heap_h | 682 #endif // Heap_h |
OLD | NEW |