| 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 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 virtual size_t size() = 0; | 394 virtual size_t size() = 0; |
| 395 virtual bool isLargeObject() { return false; } | 395 virtual bool isLargeObject() { return false; } |
| 396 | 396 |
| 397 Address address() { return reinterpret_cast<Address>(this); } | 397 Address address() { return reinterpret_cast<Address>(this); } |
| 398 PageMemory* storage() const { return m_storage; } | 398 PageMemory* storage() const { return m_storage; } |
| 399 ThreadState* threadState() const { return m_threadState; } | 399 ThreadState* threadState() const { return m_threadState; } |
| 400 bool orphaned() { return !m_threadState; } | 400 bool orphaned() { return !m_threadState; } |
| 401 bool terminating() { return m_terminating; } | 401 bool terminating() { return m_terminating; } |
| 402 void setTerminating() { m_terminating = true; } | 402 void setTerminating() { m_terminating = true; } |
| 403 | 403 |
| 404 void markAsLazilySwept(); |
| 405 bool hasBeenLazilySwept() const; |
| 406 |
| 404 private: | 407 private: |
| 405 PageMemory* m_storage; | 408 PageMemory* m_storage; |
| 406 ThreadState* m_threadState; | 409 ThreadState* m_threadState; |
| 407 // Whether the page is part of a terminating thread or not. | 410 // Whether the page is part of a terminating thread or not. |
| 408 bool m_terminating; | 411 bool m_terminating; |
| 412 |
| 413 protected: |
| 414 // Track the (lazy) sweeping state of a page. The page's |
| 415 // ThreadState keeps a sweep token value, with the page being |
| 416 // updated with that value as it is swept. |
| 417 // |
| 418 // By comparing the ThreadState's current sweep token value with |
| 419 // the page's sweep status, its swept/unswept status can |
| 420 // readily be determined. |
| 421 // |
| 422 // 0 represents the unused/no-toggle state. |
| 423 unsigned m_sweepStatus : 2; |
| 409 }; | 424 }; |
| 410 | 425 |
| 411 class HeapPage final : public BaseHeapPage { | 426 class HeapPage final : public BaseHeapPage { |
| 412 public: | 427 public: |
| 413 HeapPage(PageMemory*, ThreadHeap*); | 428 HeapPage(PageMemory*, ThreadHeap*); |
| 414 | 429 |
| 415 Address payload() | 430 Address payload() |
| 416 { | 431 { |
| 417 return address() + sizeof(HeapPage) + headerPadding(); | 432 return address() + sizeof(HeapPage) + headerPadding(); |
| 418 } | 433 } |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 static void init(); | 826 static void init(); |
| 812 static void shutdown(); | 827 static void shutdown(); |
| 813 static void doShutdown(); | 828 static void doShutdown(); |
| 814 | 829 |
| 815 #if ENABLE(ASSERT) | 830 #if ENABLE(ASSERT) |
| 816 static BaseHeapPage* findPageFromAddress(Address); | 831 static BaseHeapPage* findPageFromAddress(Address); |
| 817 static BaseHeapPage* findPageFromAddress(void* pointer) { return findPageFro
mAddress(reinterpret_cast<Address>(pointer)); } | 832 static BaseHeapPage* findPageFromAddress(void* pointer) { return findPageFro
mAddress(reinterpret_cast<Address>(pointer)); } |
| 818 static bool containedInHeapOrOrphanedPage(void*); | 833 static bool containedInHeapOrOrphanedPage(void*); |
| 819 #endif | 834 #endif |
| 820 | 835 |
| 836 // Is the finalizable GC object still alive? If no GC is in progress, |
| 837 // it must be true. If a lazy sweep is in progress, it will be true if |
| 838 // the object has been marked. An unmarked object is otherwise |
| 839 // slated for finalization once swept, and false is returned. |
| 840 // |
| 841 // The predicate must not be used with already finalized object |
| 842 // references. |
| 843 static bool isFinalizedObjectAlive(const void*); |
| 844 |
| 821 // Push a trace callback on the marking stack. | 845 // Push a trace callback on the marking stack. |
| 822 static void pushTraceCallback(void* containerObject, TraceCallback); | 846 static void pushTraceCallback(void* containerObject, TraceCallback); |
| 823 | 847 |
| 824 // Push a trace callback on the post-marking callback stack. These | 848 // Push a trace callback on the post-marking callback stack. These |
| 825 // callbacks are called after normal marking (including ephemeron | 849 // callbacks are called after normal marking (including ephemeron |
| 826 // iteration). | 850 // iteration). |
| 827 static void pushPostMarkingCallback(void*, TraceCallback); | 851 static void pushPostMarkingCallback(void*, TraceCallback); |
| 828 | 852 |
| 829 // Add a weak pointer callback to the weak callback work list. General | 853 // Add a weak pointer callback to the weak callback work list. General |
| 830 // object pointer callbacks are added to a thread local weak callback work | 854 // object pointer callbacks are added to a thread local weak callback work |
| (...skipping 1565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2396 template<typename T, size_t inlineCapacity> | 2420 template<typename T, size_t inlineCapacity> |
| 2397 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; | 2421 struct GCInfoTrait<HeapVector<T, inlineCapacity>> : public GCInfoTrait<Vector<T,
inlineCapacity, HeapAllocator>> { }; |
| 2398 template<typename T, size_t inlineCapacity> | 2422 template<typename T, size_t inlineCapacity> |
| 2399 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; | 2423 struct GCInfoTrait<HeapDeque<T, inlineCapacity>> : public GCInfoTrait<Deque<T, i
nlineCapacity, HeapAllocator>> { }; |
| 2400 template<typename T, typename U, typename V> | 2424 template<typename T, typename U, typename V> |
| 2401 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; | 2425 struct GCInfoTrait<HeapHashCountedSet<T, U, V>> : public GCInfoTrait<HashCounted
Set<T, U, V, HeapAllocator>> { }; |
| 2402 | 2426 |
| 2403 } // namespace blink | 2427 } // namespace blink |
| 2404 | 2428 |
| 2405 #endif // Heap_h | 2429 #endif // Heap_h |
| OLD | NEW |