Branch: refs/heads/webkitglib/2.54
  Home:   https://github.com/WebKit/WebKit
  Commit: 30084183ed393374d7184bb2d55fd2c3be2100c1
      
https://github.com/WebKit/WebKit/commit/30084183ed393374d7184bb2d55fd2c3be2100c1
  Author: Justin Michaud <[email protected]>
  Date:   2026-09-10 (Thu, 10 Sep 2026)

  Changed paths:
    M Source/JavaScriptCore/heap/Heap.cpp
    M Source/JavaScriptCore/runtime/JSLock.cpp
    M Source/WTF/WTF.xcodeproj/project.pbxproj
    M Source/WTF/wtf/CMakeLists.txt
    M Source/WTF/wtf/LockAlgorithmInlines.h
    A Source/WTF/wtf/SpinBackoff.h
    M Source/WTF/wtf/WordLock.cpp
    M Source/WTF/wtf/posix/ThreadingPOSIX.cpp
    M Source/bmalloc/CMakeLists.txt
    M Source/bmalloc/bmalloc.xcodeproj/project.pbxproj
    M Source/bmalloc/bmalloc/Mutex.cpp
    A Source/bmalloc/bmalloc/SpinBackoff.h

  Log Message:
  -----------
  Cherry-pick 320724@main (249ede976fcc). 
https://bugs.webkit.org/show_bug.cgi?id=321012

    Replace sched_yield with nanosleep and abstract away spin lock logic on all 
platforms
    https://bugs.webkit.org/show_bug.cgi?id=321012

    Reviewed by Yusuke Suzuki.

    sched_yield is not so helpful, since it isn't guaranteed
    to actually yield (unlike the macOS thread_switch) and can
    cause deadlocks.

    Darwin's tier setup remains mostly unchanged:

    Tier 1: spinloop
    Tier 2: thread_switch
    Tier 3: Parking lot if available (i.e, nothing for bmalloc)

    or

    Tier 1: spinloop
    Tier 2A: pause (avoid hammering the cache)
    Tier 2B: thread_switch

    (depending on the location)

    Linux now has:
    Tier 1: spinloop
    Tier 2: waiting with backoff to avoid hammering the cache
    Tier 3: parking lot OR thread_yield

    Thread::yield now definitely always yields, but it is slower.

    We acomplish this by making SpinBackoff, which abstracts this logic
    away.

    We then extend it to a few other places for consistency.

    This is measured to be perf-neutral on MBA M4, Neoverse N1 (linux) and 
RPI4/5 64-bit.

    * Source/JavaScriptCore/heap/Heap.cpp:
    (JSC::Heap::clearConcurrentRetainedDataIfPossible):
    * Source/JavaScriptCore/runtime/JSLock.cpp:
    (JSC::JSLock::grabAllLocks):
    * Source/WTF/WTF.xcodeproj/project.pbxproj:
    * Source/WTF/wtf/CMakeLists.txt:
    * Source/WTF/wtf/LockAlgorithmInlines.h:
    (WTF::Hooks>::lockSlow):
    * Source/WTF/wtf/SpinBackoff.h: Added.
    (WTF::SpinBackoff::shouldParkAfterSpinOnce):
    (WTF::SpinBackoff::spinOnce):
    * Source/WTF/wtf/WordLock.cpp:
    (WTF::WordLock::lockSlow):
    (WTF::WordLock::unlockSlow):
    * Source/WTF/wtf/posix/ThreadingPOSIX.cpp:
    (WTF::Thread::yield):
    * Source/bmalloc/CMakeLists.txt:
    * Source/bmalloc/bmalloc.xcodeproj/project.pbxproj:
    * Source/bmalloc/bmalloc/Mutex.cpp:
    (bmalloc::Mutex::lockSlowCase):
    (bmalloc::yield): Deleted.
    * Source/bmalloc/bmalloc/SpinBackoff.h: Added.
    (bmalloc::SpinBackoff::shouldParkAfterSpinOnce):
    (bmalloc::SpinBackoff::spinOnce):
    (bmalloc::SpinBackoff::cpuPause):
    (bmalloc::SpinBackoff::platformYield):
    (bmalloc::SpinBackoff::yield):

    Canonical link: https://commits.webkit.org/320724@main

Canonical link: https://commits.webkit.org/317695.254@webkitglib/2.54



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to