Changeset 181469 in webkit


Ignore:
Timestamp:
Mar 12, 2015 8:02:16 PM (9 years ago)
Author:
mark.lam@apple.com
Message:

Change the DFG crashLock to use std::atomic.
<https://webkit.org/b/142649>

Reviewed by Filip Pizlo.

  • dfg/DFGCommon.cpp:

(JSC::DFG::startCrashing):
(JSC::DFG::isCrashing):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r181467 r181469  
     12015-03-12  Mark Lam  <mark.lam@apple.com>
     2
     3        Change the DFG crashLock to use std::atomic.
     4        <https://webkit.org/b/142649>
     5
     6        Reviewed by Filip Pizlo.
     7
     8        * dfg/DFGCommon.cpp:
     9        (JSC::DFG::startCrashing):
     10        (JSC::DFG::isCrashing):
     11
    1122015-03-12  Filip Pizlo  <fpizlo@apple.com>
    213
  • trunk/Source/JavaScriptCore/dfg/DFGCommon.cpp

    r180279 r181469  
    3535namespace JSC { namespace DFG {
    3636
    37 static unsigned crashLock;
     37static std::atomic<unsigned> crashLock;
    3838
    3939void startCrashing()
    4040{
    41 #if ENABLE(COMPARE_AND_SWAP)
    42     while (!WTF::weakCompareAndSwap(&crashLock, 0, 1))
     41    unsigned expected = 0;
     42    while (!crashLock.compare_exchange_weak(expected, 1, std::memory_order_acquire)) {
    4343        std::this_thread::yield();
    44 #else
    45     crashLock = 1;
    46 #endif
     44        expected = 0;
     45    }
    4746}
    4847
    4948bool isCrashing()
    5049{
    51     return !!crashLock;
     50    return !!crashLock.load(std::memory_order_acquire);
    5251}
    5352
Note: See TracChangeset for help on using the changeset viewer.