Changeset 181541 in webkit
- Timestamp:
- Mar 16, 2015, 4:21:37 AM (11 years ago)
- Location:
- releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/CodeBlock.cpp (modified) (1 diff)
-
bytecode/CodeBlock.h (modified) (2 diffs)
-
heap/CodeBlockSet.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/ChangeLog
r181538 r181541 1 2015-03-12 Mark Lam <mark.lam@apple.com> 2 3 Use std::atomic for CodeBlock::m_visitAggregateHasBeenCalled. 4 <https://webkit.org/b/142640> 5 6 Reviewed by Mark Hahnenberg. 7 8 We used to spin our own compare and swap on a uint8_t. Now that we can 9 use C++11, let's use std::atomic instead. 10 11 * bytecode/CodeBlock.cpp: 12 (JSC::CodeBlock::visitAggregate): 13 - The CAS here needs std::memory_order_acquire ordering because it 14 requires lock acquisition semantics to visit the CodeBlock. 15 16 * bytecode/CodeBlock.h: 17 (JSC::CodeBlockSet::mark): 18 * heap/CodeBlockSet.cpp: 19 (JSC::CodeBlockSet::clearMarksForFullCollection): 20 (JSC::CodeBlockSet::clearMarksForEdenCollection): 21 - These can go with relaxed ordering because they are all done before 22 the GC starts parallel marking. 23 1 24 2015-03-12 Csaba Osztrogonác <ossy@webkit.org> 2 25 -
releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r181533 r181541 2207 2207 #if ENABLE(PARALLEL_GC) 2208 2208 // I may be asked to scan myself more than once, and it may even happen concurrently. 2209 // To this end, use a CAS loop to check if I've been called already. Only one thread 2210 // may proceed past this point - whichever one wins the CAS race. 2211 unsigned oldValue; 2212 do { 2213 oldValue = m_visitAggregateHasBeenCalled; 2214 if (oldValue) { 2215 // Looks like someone else won! Return immediately to ensure that we don't 2216 // trace the same CodeBlock concurrently. Doing so is hazardous since we will 2217 // be mutating the state of ValueProfiles, which contain JSValues, which can 2218 // have word-tearing on 32-bit, leading to awesome timing-dependent crashes 2219 // that are nearly impossible to track down. 2220 2221 // Also note that it must be safe to return early as soon as we see the 2222 // value true (well, (unsigned)1), since once a GC thread is in this method 2223 // and has won the CAS race (i.e. was responsible for setting the value true) 2224 // it will definitely complete the rest of this method before declaring 2225 // termination. 2226 return; 2227 } 2228 } while (!WTF::weakCompareAndSwap(&m_visitAggregateHasBeenCalled, 0, 1)); 2209 // To this end, use an atomic operation to check (and set) if I've been called already. 2210 // Only one thread may proceed past this point - whichever one wins the atomic set race. 2211 bool expected = false; 2212 bool setByMe = m_visitAggregateHasBeenCalled.compare_exchange_strong(expected, true, std::memory_order_acquire); 2213 if (!setByMe) 2214 return; 2229 2215 #endif // ENABLE(PARALLEL_GC) 2230 2216 -
releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/bytecode/CodeBlock.h
r181533 r181541 1057 1057 bool m_needsActivation; 1058 1058 bool m_mayBeExecuting; 1059 uint8_tm_visitAggregateHasBeenCalled;1059 std::atomic<bool> m_visitAggregateHasBeenCalled; 1060 1060 1061 1061 RefPtr<SourceProvider> m_source; … … 1292 1292 codeBlock->m_mayBeExecuting = true; 1293 1293 // We might not have cleared the marks for this CodeBlock, but we need to visit it. 1294 codeBlock->m_visitAggregateHasBeenCalled = false;1294 codeBlock->m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 1295 1295 #if ENABLE(GGC) 1296 1296 m_currentlyExecuting.append(codeBlock); -
releases/WebKitGTK/webkit-2.8/Source/JavaScriptCore/heap/CodeBlockSet.cpp
r179359 r181541 66 66 for (CodeBlock* codeBlock : m_oldCodeBlocks) { 67 67 codeBlock->m_mayBeExecuting = false; 68 codeBlock->m_visitAggregateHasBeenCalled = false;68 codeBlock->m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 69 69 } 70 70 … … 83 83 executable->forEachCodeBlock([](CodeBlock* codeBlock) { 84 84 codeBlock->m_mayBeExecuting = false; 85 codeBlock->m_visitAggregateHasBeenCalled = false;85 codeBlock->m_visitAggregateHasBeenCalled.store(false, std::memory_order_relaxed); 86 86 }); 87 87 }
Note:
See TracChangeset
for help on using the changeset viewer.