Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 901eee6dc6808ebe82d145b1fcddc5c95a91870a
      
https://github.com/WebKit/WebKit/commit/901eee6dc6808ebe82d145b1fcddc5c95a91870a
  Author: Yijia Huang <yijia_hu...@apple.com>
  Date:   2024-09-03 (Tue, 03 Sep 2024)

  Changed paths:
    A JSTests/stress/atomics-strong-cas.js
    M Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h

  Log Message:
  -----------
  [JSC] Fix checkAliasOfEAX for AIR code generation and apply it for 64bit 
atomicStrongCAS
https://bugs.webkit.org/show_bug.cgi?id=279083
rdar://134963217

Reviewed by Yusuke Suzuki.

The X86 'atomicStrongCAS' requires three arguments: 'expectedAndResult',
'newValue', and 'address'. This operation checks if the expected value matches
the value in memory, and if so, it replaces it with the new value. Otherwise,
it loads the memory value into the result. This can be done using cmpxchg[1]
with some additional handling.

If `expectedAndResult` is not in `eax`, a double swap is needed to perform 
`cmpxchg`
and load the result correctly. However, if `newValue` is in `eax`, the first 
swap will
overwrite it. That issue was fixed at [2] by using the scratch register.

The current issue is that 'atomicStrongCAS' is also used in AIR code 
generation, which
doesn't allow for a scratch register. However, by reviewing the usage of 
`atomicStrongCAS`
in AIR for X86, it turns out that `eax` is always used as expectedAndResult. In 
this case,
there's no clobbering issue with `newValue` since the double swap between 
`expectedAndResult`
and `eax` won't occur.

This patch does two things:
1. Propose a simple fix by adding another alias check between 
`expectedAndResult` and `eax`
   for the fast path in `checkAliasOfEAX` to avoid the use of the scratch 
register.
2. Apply `checkAliasOfEAX` for 64-bit `atomicStrongCAS`.

[1] https://www.felixcloutier.com/x86/cmpxchg
[2] https://commits.webkit.org/281565@main

* Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::checkAliasOfEAX):
(JSC::MacroAssemblerX86_64::atomicStrongCAS8):
(JSC::MacroAssemblerX86_64::atomicStrongCAS16):
(JSC::MacroAssemblerX86_64::atomicStrongCAS32):
(JSC::MacroAssemblerX86_64::branchAtomicStrongCAS8):
(JSC::MacroAssemblerX86_64::branchAtomicStrongCAS16):
(JSC::MacroAssemblerX86_64::branchAtomicStrongCAS32):
(JSC::MacroAssemblerX86_64::atomicStrongCAS64):
(JSC::MacroAssemblerX86_64::branchAtomicStrongCAS64):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to