Closed Bug 1639896 Opened 5 years ago Closed 5 years ago

[MIPS] Support unaligned reads by baseline-interpreter

Categories

(Core :: JavaScript Engine, defect, P5)

defect

Tracking

()

RESOLVED FIXED
mozilla79
Tracking Status
firefox-esr78 --- fixed
firefox79 --- fixed

People

(Reporter: tcampbell, Assigned: zhaojiazhong-hf)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

The BaselineInterpreter makes unaligned access to bytecode data. For platforms that care about this (MIPS?) we can add a couple extra MacroAssembler methods to unaligned loads and call them for https://searchfox.org/mozilla-central/rev/a40ef31fc9af34a99ceda6d65cdc4573d52b83d2/js/src/jit/BaselineCodeGen.cpp#368-389

For almost all platforms, it would just be a wrapper of normal masm. For MIPS, we can use the special MIPS rotation instructions for 24/32-bit loads. For unaligned 16-bit loads, we would just load the two bytes.

(This is a P5 issue and will not be fixed without someone volunteering :)

Bug 1065894 already added load16UnalignedSignExtend, load16UnalignedZeroExtend, load32Unaligned, and load64Unaligned to the MacroAssembler (https://phabricator.services.mozilla.com/D74621). Jan mentioned in the review that BaselineCodeGen could switch to use those methods. (The methods themselves aren't currently implemented for MIPS, though.)

Hi, I'm from Loongson Technology, and we are trying to maintain firefox on mips64el platform. I may submit a patch to fix this issue after some time, but we don't have 32-bit products, so I can't guarantee it works on mips32.

That would be great.

Generally when I test MIPS I use our simulator build on amd64 host. These builds use host machine for the C++ code, but run the JITs to target MIPS instruction set. When SpiderMonkey tries to execute the JIT code, it uses a simulator. This is far from perfect (eg. the canonical NaN stuff could not be tested), but it makes it simpler for people without hardware access.

Example moz-config I use for mips32:

ac_add_options --enable-application=js

ac_add_options --enable-debug
ac_add_options --enable-optimize

# Specify 32-bit target to use a 32-bit simulator. This still runs on 64-bit linux host
ac_add_options --target=i686-pc-linux
ac_add_options --enable-simulator=mips32

See https://firefox-source-docs.mozilla.org/js/build.html for the workflow the team currently uses to build with mach

Attachment #9154873 - Attachment description: Bug 1639896 - [MIPS] Add unaligned load and store functions to the assemblers. → Bug 1639896 - [WIP] [MIPS] Add unaligned load and store functions to the assemblers.
Assignee: nobody → zhaojiazhong-hf
Attachment #9154873 - Attachment description: Bug 1639896 - [WIP] [MIPS] Add unaligned load and store functions to the assemblers. → Bug 1639896 - [MIPS] Add unaligned load and store functions to the assemblers. r=tcampbell
Status: NEW → ASSIGNED
Pushed by ncsoregi@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7b24bbc87f56 [MIPS] Add unaligned load and store functions to the assemblers. r=tcampbell
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Regressions: 1680262

Comment on attachment 9154873 [details]
Bug 1639896 - [MIPS] Add unaligned load and store functions to the assemblers. r=tcampbell

ESR Uplift Approval Request

  • If this is not a sec:{high,crit} bug, please state case for ESR consideration: Some web sites like twitter crashed on mips64 platform due to this bug.
  • User impact if declined: js or browser will crash if the program needs unaligned memory access in baseline jit.
  • Fix Landed on Version: firefox79
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): It only affects mips platform.
  • String or UUID changes made by this patch:
Attachment #9154873 - Flags: approval-mozilla-esr78?

This has no impact on non-MIPS builds and has been on central for a while anyways. Uplift to ESR seems quite reasonable to me.

Comment on attachment 9154873 [details]
Bug 1639896 - [MIPS] Add unaligned load and store functions to the assemblers. r=tcampbell

MIPS-only. Approved for 78.6esr.

Attachment #9154873 - Flags: approval-mozilla-esr78? → approval-mozilla-esr78+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: