Closed Bug 1987227 Opened 1 year ago Closed 1 year ago

Emitting incorrect x64 instruction for cmpb in some cases

Categories

(Core :: JavaScript Engine: JIT, task)

task

Tracking

()

RESOLVED FIXED
144 Branch
Tracking Status
firefox-esr140 --- fixed
firefox144 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

Attachments

(4 files, 4 obsolete files)

With patches for bug 1986983 I got a mysterious jit-test failure on Try, only on Win64 debug builds. I managed to reproduce it locally and I got a time travel debugging trace from WinDbg.

In CodeGenerator::visitStringToLowerCase we use branch8 to check if a char is already lower case:

      masm.branch8(Assembler::NotEqual,
                   BaseIndex(toLowerCaseTable, current, TimesOne), current,
                   &hasUpper);

For certain registers, for example if toLowerCaseTable == rax and current == rdi, we emit a cmp instruction that compares to the wrong register:

cmp    %bh,(%rax,%rdi,1)

Changing oneByteOp to oneByteOp8 in cmpb_rm fixes this:

cmp    %dil,(%rax,%rdi,1)

If the bh register happens to have the same value in it as dil, this resulted in LStringToLowerCase thinking it could just return the input string and we fail the test.

This uses the Zydis disassembler to check the generated code is what we expect.

Attachment #9511787 - Attachment description: WIP: Bug 1987227 - Fix. → Bug 1987227 part 2 - Emit correct instructions for cmp8 with byte registers on x64. r?iain!
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 144 Branch

This uses the Zydis disassembler to check the generated code is what we expect.

Original Revision: https://phabricator.services.mozilla.com/D264054

Attachment #9512230 - Flags: approval-mozilla-esr140?

This uses the Zydis disassembler to check the generated code is what we expect.

Original Revision: https://phabricator.services.mozilla.com/D264054

Attachment #9512231 - Flags: approval-mozilla-esr140?

This uses the Zydis disassembler to check the generated code is what we expect.

Original Revision: https://phabricator.services.mozilla.com/D264054

Attachment #9512232 - Flags: approval-mozilla-esr140?
Attachment #9512230 - Attachment is obsolete: true
Attachment #9512230 - Flags: approval-mozilla-esr140?
Attachment #9512231 - Attachment is obsolete: true
Attachment #9512231 - Flags: approval-mozilla-esr140?
Attachment #9512232 - Attachment is obsolete: true
Attachment #9512232 - Flags: approval-mozilla-esr140?

This uses the Zydis disassembler to check the generated code is what we expect.

Original Revision: https://phabricator.services.mozilla.com/D264054

Attachment #9512234 - Flags: approval-mozilla-esr140?
Attachment #9512234 - Attachment is obsolete: true
Attachment #9512234 - Flags: approval-mozilla-esr140?

This uses the Zydis disassembler to check the generated code is what we expect.

Original Revision: https://phabricator.services.mozilla.com/D264054

Attachment #9512236 - Flags: approval-mozilla-esr140?

Use oneByteOp8 to emit the REX prefix for byte registers if needed. This fixes an
issue with our code for LStringToLowerCase for certain register combinations/values.

With patches for bug 1986983 this was caught by jit-tests on Win64-debug builds.

Original Revision: https://phabricator.services.mozilla.com/D263972

Attachment #9512237 - Flags: approval-mozilla-esr140?
QA Whiteboard: [qa-triage-done-c145/b144]

:jandem, the uplift request patches are missing the Uplift Request form?
https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift#Submit_the_Uplift_Request_Form

Flags: needinfo?(jdemooij)

firefox-esr140 Uplift Approval Request

  • User impact if declined: Broken websites.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing:
  • Risk associated with taking this patch: low
  • Explanation of risk level: Self-contained fix for x64 platforms to generate the right instruction.
  • String changes made/needed: N/A
  • Is Android affected?: no

(In reply to Donal Meehan [:dmeehan] from comment #11)

:jandem, the uplift request patches are missing the Uplift Request form?
https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift#Submit_the_Uplift_Request_Form

Huh weird, when I went to "Uplift Assessment" for part 2 now it still had the answers I entered last time so I just submitted that again. I'm not sure what went wrong the first time. Is this okay now?

Flags: needinfo?(jdemooij) → needinfo?(dmeehan)

(In reply to Jan de Mooij [:jandem] from comment #13)

(In reply to Donal Meehan [:dmeehan] from comment #11)

:jandem, the uplift request patches are missing the Uplift Request form?
https://wiki.mozilla.org/Release_Management/Requesting_an_Uplift#Submit_the_Uplift_Request_Form

Huh weird, when I went to "Uplift Assessment" for part 2 now it still had the answers I entered last time so I just submitted that again. I'm not sure what went wrong the first time. Is this okay now?

Thanks, it looks ok now

Flags: needinfo?(dmeehan)
Attachment #9512237 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
Attachment #9512236 - Flags: approval-mozilla-esr140? → approval-mozilla-esr140+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: