Closed Bug 2089860 Opened 22 days ago Closed 17 days ago

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)

defect

Tracking

()

RESOLVED FIXED
162 Branch
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_ptr and jalr), 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 by NopSize() 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.

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.

Assignee: nobody → andrew
Status: NEW → ASSIGNED
Severity: -- → S3
Priority: -- → P2

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.

Attachment #9675448 - Attachment description: Bug 2089860 - Pad an OSI point with one nop per NopSize() bytes. r?jandem → Bug 2089860 - Pad OSI points with nops the way Baseline pads debug mode OSR points. r?jandem
Duplicate of this bug: 1037319
Status: ASSIGNED → RESOLVED
Closed: 17 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
QA Whiteboard: [qa-triage-done-c163/b162]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: