Ion pads OSI points with four times as many nops as needed when a nop is four bytes
Categories
(Core :: JavaScript Engine: JIT, defect, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: andrew, Assigned: andrew)
References
Details
Attachments
(1 external file)
CodeGeneratorShared::ensureOsiSpace() works out how many bytes of padding an OSI point needs so that invalidation can patch a near call over it, but its loop emits one nop per byte rather than one per Assembler::NopSize() bytes. On every backend whose nop is four bytes, it pads four times as much as needed. BaselineCompilerCodeGen::ensureDebugModeOSRPointSpace() already steps by Assembler::NopSize(), and x86 and x64, whose nop is one byte, are unaffected.
How much this costs depends on PatchWrite_NearCallSize():
- RISC-V 64 patches in 28 bytes (
li_ptrandjalr), so padding is common: the first OSI point of a function, 16 bytes past its prologue, gets 12 nops rather than 3. In a JetStream 3 run on a SpacemiT K3, stepping byNopSize()removes 85,579 of the 156,684 nops in Ion code, 342 KB or 0.41% of it. - ARM and ARM64 patch in a 4-byte BL, so they pad only when two OSI points share an offset, which happened once in a JetStream 3 run on ARM64.
- MIPS64 and LoongArch64 patch in 24 and 16 bytes, so they pad with up to 24 and 16 nops where 6 and 4 would do. Neither has been measured.
JetStream 3 A/B runs on the K3 and on an Apple M4 show no measurable change in score, cycles or wall time, so this is a code-size fix.
Found with riscvlint.
| Assignee | ||
Comment 1•22 days ago
|
||
CodeGeneratorShared::ensureOsiSpace() works out how many bytes of
padding an OSI point needs but emitted one nop per byte, so every
backend whose nop is four bytes padded four times as much as it needed
to. BaselineCompilerCodeGen::ensureDebugModeOSRPointSpace() already
steps by Assembler::NopSize(), and x86 and x64, whose nop is one byte,
are unchanged.
How much the overpadding costs depends on PatchWrite_NearCallSize(), the
room an OSI point needs for the call invalidation patches in. ARM and
ARM64 patch in a 4-byte BL, so they pad only when two OSI points share
an offset, which happened once in a JetStream 3 run on ARM64. RISC-V 64
patches in 28 bytes (li_ptr and jalr), so padding is common: the first
OSI point of a function, 16 bytes past its prologue, got 12 nops rather
than 3. In a JetStream 3 run on a SpacemiT K3 this removes 85,579 of the
156,684 nops in Ion code, 342 KB or 0.41% of it.
MIPS64 and LoongArch64 patch in 24 and 16 bytes, so they pad with up to
24 and 16 nops where 6 and 4 would do, and should shrink in the same
way. Neither has been measured.
Found with riscvlint.
Updated•22 days ago
|
Updated•21 days ago
|
Comment 2•21 days ago
•
|
||
Bug 1037319 is a duplicate of this. (I could have sworn we just fixed this, but maybe we just talked about it.)
EDIT: Ah, Jan pointed out this conversation.
Updated•18 days ago
|
Updated•4 days ago
|
Description
•