| 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 } | 135 } |
| 136 | 136 |
| 137 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; | 137 WTF::ThreadSpecific<ThreadState*>* ThreadState::s_threadSpecific = nullptr; |
| 138 uintptr_t ThreadState::s_mainThreadStackStart = 0; | 138 uintptr_t ThreadState::s_mainThreadStackStart = 0; |
| 139 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; | 139 uintptr_t ThreadState::s_mainThreadUnderestimatedStackSize = 0; |
| 140 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; | 140 uint8_t ThreadState::s_mainThreadStateStorage[sizeof(ThreadState)]; |
| 141 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr; | 141 SafePointBarrier* ThreadState::s_safePointBarrier = nullptr; |
| 142 | 142 |
| 143 static Mutex& threadAttachMutex() | 143 static Mutex& threadAttachMutex() |
| 144 { | 144 { |
| 145 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); | 145 AtomicallyInitializedStaticReference(Mutex, mutex, (new Mutex)); |
| 146 return mutex; | 146 return mutex; |
| 147 } | 147 } |
| 148 | 148 |
| 149 static double lockingTimeout() | 149 static double lockingTimeout() |
| 150 { | 150 { |
| 151 // Wait time for parking all threads is at most 100 MS. | 151 // Wait time for parking all threads is at most 100 MS. |
| 152 return 0.100; | 152 return 0.100; |
| 153 } | 153 } |
| 154 | 154 |
| 155 | 155 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 } | 481 } |
| 482 | 482 |
| 483 void ThreadState::visitPersistentRoots(Visitor* visitor) | 483 void ThreadState::visitPersistentRoots(Visitor* visitor) |
| 484 { | 484 { |
| 485 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); | 485 TRACE_EVENT0("blink_gc", "ThreadState::visitPersistentRoots"); |
| 486 { | 486 { |
| 487 // All threads are at safepoints so this is not strictly necessary. | 487 // All threads are at safepoints so this is not strictly necessary. |
| 488 // However we acquire the mutex to make mutation and traversal of this | 488 // However we acquire the mutex to make mutation and traversal of this |
| 489 // list symmetrical. | 489 // list symmetrical. |
| 490 MutexLocker locker(globalRootsMutex()); | 490 MutexLocker locker(globalRootsMutex()); |
| 491 globalRoots()->trace(visitor); | 491 globalRoots().trace(visitor); |
| 492 } | 492 } |
| 493 | 493 |
| 494 for (ThreadState* state : attachedThreads()) | 494 for (ThreadState* state : attachedThreads()) |
| 495 state->visitPersistents(visitor); | 495 state->visitPersistents(visitor); |
| 496 } | 496 } |
| 497 | 497 |
| 498 void ThreadState::visitStackRoots(Visitor* visitor) | 498 void ThreadState::visitStackRoots(Visitor* visitor) |
| 499 { | 499 { |
| 500 TRACE_EVENT0("blink_gc", "ThreadState::visitStackRoots"); | 500 TRACE_EVENT0("blink_gc", "ThreadState::visitStackRoots"); |
| 501 for (ThreadState* state : attachedThreads()) | 501 for (ThreadState* state : attachedThreads()) |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 // registered as objects on orphaned pages. We cannot assert this here since | 677 // registered as objects on orphaned pages. We cannot assert this here since |
| 678 // we might have an off-heap collection. We assert it in | 678 // we might have an off-heap collection. We assert it in |
| 679 // Heap::pushWeakPointerCallback. | 679 // Heap::pushWeakPointerCallback. |
| 680 if (CallbackStack::Item* item = m_weakCallbackStack->pop()) { | 680 if (CallbackStack::Item* item = m_weakCallbackStack->pop()) { |
| 681 item->call(visitor); | 681 item->call(visitor); |
| 682 return true; | 682 return true; |
| 683 } | 683 } |
| 684 return false; | 684 return false; |
| 685 } | 685 } |
| 686 | 686 |
| 687 PersistentNode* ThreadState::globalRoots() | 687 PersistentNode& ThreadState::globalRoots() |
| 688 { | 688 { |
| 689 AtomicallyInitializedStatic(PersistentNode*, anchor = new PersistentAnchor); | 689 AtomicallyInitializedStaticReference(PersistentNode, anchor, new PersistentA
nchor); |
| 690 return anchor; | 690 return anchor; |
| 691 } | 691 } |
| 692 | 692 |
| 693 Mutex& ThreadState::globalRootsMutex() | 693 Mutex& ThreadState::globalRootsMutex() |
| 694 { | 694 { |
| 695 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); | 695 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); |
| 696 return mutex; | 696 return mutex; |
| 697 } | 697 } |
| 698 | 698 |
| 699 // FIXME: We should improve the GC heuristics. | 699 // FIXME: We should improve the GC heuristics. |
| 700 // These heuristics affect performance significantly. | 700 // These heuristics affect performance significantly. |
| 701 bool ThreadState::shouldGC() | 701 bool ThreadState::shouldGC() |
| 702 { | 702 { |
| 703 // Trigger garbage collection on a 50% increase in size since the last GC, | 703 // Trigger garbage collection on a 50% increase in size since the last GC, |
| 704 // but not for less than 512 KB. | 704 // but not for less than 512 KB. |
| 705 size_t newSize = Heap::allocatedObjectSize(); | 705 size_t newSize = Heap::allocatedObjectSize(); |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 return gcInfo; | 1164 return gcInfo; |
| 1165 } | 1165 } |
| 1166 } | 1166 } |
| 1167 if (needLockForIteration) | 1167 if (needLockForIteration) |
| 1168 threadAttachMutex().unlock(); | 1168 threadAttachMutex().unlock(); |
| 1169 return nullptr; | 1169 return nullptr; |
| 1170 } | 1170 } |
| 1171 #endif | 1171 #endif |
| 1172 | 1172 |
| 1173 } // namespace blink | 1173 } // namespace blink |
| OLD | NEW |