Skip to content

Commit

Permalink
Bug 1940795: Don't tear aligned subwords in AtomicMemcpy. r=spidermon…
Browse files Browse the repository at this point in the history
…key-reviewers,jandem

Reads/writes to integer typed arrays mustn't tear, so they can't be split into
single byte operations.

Replace single byte copy loops with `AtomicCopy{Down,Up}NoTearIfAlignedUnsynchronized`,
which performs additional checks when aligned word or dword copying is needed.

Test262 tests: <tc39/test262#4369>

Differential Revision: https://phabricator.services.mozilla.com/D233710

UltraBlame original commit: 968d34f043635337c9ab03c4c3f975c39e52f057
  • Loading branch information
marco-c committed Jan 16, 2025
1 parent 8b604fb commit 0455d19
Show file tree
Hide file tree
Showing 2 changed files with 1,231 additions and 211 deletions.
244 changes: 243 additions & 1 deletion js/src/jit/GenerateAtomicOperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7309,6 +7309,55 @@
"
)

elif
size
=
=
2
:

insns
+
=
fmt_insn
(
"
movw
OFFSET
(
%
[
src
]
)
%
[
scratch
]
"
)

insns
+
=
fmt_insn
(
"
movw
%
[
scratch
]
OFFSET
(
%
[
dst
]
)
"
)

elif
size
=
Expand Down Expand Up @@ -7471,6 +7520,112 @@
"
)

elif
size
=
=
2
:

insns
+
=
fmt_insn
(
"
ldrh
%
w
[
scratch
]
[
%
x
[
src
]
OFFSET
]
"
)

insns
+
=
fmt_insn
(
"
strh
%
w
[
scratch
]
[
%
x
[
dst
]
OFFSET
]
"
)

elif
size
=
=
4
:

insns
+
=
fmt_insn
(
"
ldr
%
w
[
scratch
]
[
%
x
[
src
]
OFFSET
]
"
)

insns
+
=
fmt_insn
(
"
str
%
w
[
scratch
]
[
%
x
[
dst
]
OFFSET
]
"
)

else
:

Expand Down Expand Up @@ -7586,6 +7741,57 @@
"
)

elif
size
=
=
2
:

insns
+
=
fmt_insn
(
"
ldrh
%
[
scratch
]
[
%
[
src
]
#
OFFSET
]
"
)

insns
+
=
fmt_insn
(
"
strh
%
[
scratch
]
[
%
[
dst
]
#
OFFSET
]
"
)

else
:

Expand Down Expand Up @@ -9133,7 +9339,43 @@
gen_copy
(
"
AtomicCopyByteUnsynchronized
AtomicCopy32Unsynchronized
"
"
uint32_t
"
4
1
"
down
"
)

contents
+
=
gen_copy
(
"
AtomicCopy16Unsynchronized
"
"
uint16_t
"
2
1
"
down
"
)

contents
+
=
gen_copy
(
"
AtomicCopy8Unsynchronized
"
"
uint8_t
Expand Down
Loading

0 comments on commit 0455d19

Please sign in to comment.