Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 9f672ca021c275f16c00128faaf983f3390b8499
      
https://github.com/WebKit/WebKit/commit/9f672ca021c275f16c00128faaf983f3390b8499
  Author: Mark Lam <[email protected]>
  Date:   2026-02-25 (Wed, 25 Feb 2026)

  Changed paths:
    M Source/WTF/wtf/Atomics.h

  Log Message:
  -----------
  Regression(302941@main): inline asm in WTF::opaque() needs to be volatile.
https://bugs.webkit.org/show_bug.cgi?id=308660
rdar://171189396

Reviewed by Dan Hecht.

Otherwise, compiler optimizations may elide or relocate the asm statement.

See https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/Extended-Asm.html:
```
If an asm has output operands, GCC assumes for optimization purposes the 
instruction has no side
effects except to change the output operands. This does not mean instructions 
with a side effect
cannot be used, but you must be careful, because the compiler may eliminate 
them if the output
operands aren't used, or move them out of loops, or replace two with one if 
they constitute a
common subexpression. Also, if your instruction does have a side effect on a 
variable that
otherwise appears not to change, the old value of the variable may be reused 
later if it happens
to be found in a register.

You can prevent an asm instruction from being deleted by writing the keyword 
volatile after the
asm. For example:

     #define get_and_set_priority(new)              \
     ({ int __old;                                  \
        asm volatile ("get_and_set_priority %0, %1" \
                      : "=g" (__old) : "g" (new));  \
        __old; })
```

This bug introduces race conditions into the code that are difficult to test 
for.  This fix is
also effectively a partial revert of 302941@main.  Hence, no new test.

* Source/WTF/wtf/Atomics.h:
(WTF::opaque):

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



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

Reply via email to