Closed Bug 1930952 Opened 3 months ago Closed 3 months ago

Add initial implementation for the Atomics.pause proposal

Categories

(Core :: JavaScript: Standard Library, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

No description provided.

Use the following instructions to implement Atomics.pause:

  1. Target platform is x86 / x86_64:
  • Use the pause instruction which is available since Pentium IV.
  1. Target platform is ARM32:
  • Use the yield hint instruction which is available since ARMv6.
  1. Target platform is ARM64:
  • Use the isb instruction.
  • ARM64 also provides a yield hint instruction, but current CPUs implement it
    as a nop instruction, so implementations in other languages have switched to
    isb, because it more closely matches the delay observed in x86's pause
    instruction.
  • See for example core::hint::spin_loop in Rust or Thread.onSpinWait() in Java.

The instructions are used in the next part.

Calling Atomics.pause without having inlining support will just lead to
decreased performance due to the overhead for a JS -> C++ call, so provide at
least inlining support when no arguments are passed. Suppporting the iteration
count argument may require CPU-specific tuning, so this is out-of-scope for
now.

Pushed by andre.bargull@gmail.com: https://hg.mozilla.org/integration/autoland/rev/3a80e137f7f2 Part 1: Initial implementation for the Atomics.pause proposal. r=iain https://hg.mozilla.org/integration/autoland/rev/b64f6933537d Part 2: Enable test262 tests for Atomics.pause. r=iain https://hg.mozilla.org/integration/autoland/rev/65f71c78b93b Part 3: Support encoding "pause" (x86) and "yield" (arm32) instructions. r=iain https://hg.mozilla.org/integration/autoland/rev/e299ddd84481 Part 4: Inline Atomics.pause when called with no arguments. r=iain
Regressions: 1931315
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: