Closed Bug 1688913 Opened 3 years ago Closed 3 years ago

Follow-up changes for bug 1687441

Categories

(Core :: JavaScript Engine: JIT, task, P3)

task

Tracking

()

RESOLVED FIXED
87 Branch
Tracking Status
firefox87 --- fixed

People

(Reporter: jandem, Assigned: jandem)

References

Details

Attachments

(11 files, 1 obsolete file)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

André suggested some performance improvements that are worth addressing.

  • Inline IntPtr constants for LCompare
  • Avoid two MArrayBufferViewLength for .length (Int32) and bounds check (IntPtr) with a separate IntPtrToInt32 guard
  • Related, optimize bounds check hoisting better for trivial i < ta.length case
  • See if we can use redefine for no-op MInt32ToIntPtr
  • move64 optimization: https://bugzilla.mozilla.org/show_bug.cgi?id=1586662
  • Fix AnalyzeLoadUnboxedScalar, although it has no effect with Spectre mitigations on
  • Support IntPtr (for MInt32ToIntPtr) in RangeAnalysis::addRangeAssertions.
  • Propagate range for MNonNegativeIntPtrToInt32.
Summary: Follow-up changes for bug 1686936 → Follow-up changes for bug 1687441
Depends on: 1586662

Change useAnyOrConstant to useAnyOrInt32Constant and use for Compare_UIntPtr.
For IntPtr values, useAnyOrInt32Constant checks a constant is only used for values
in the Int32 range.

Drive-by change: for Compare_Symbol and Compare_Object this allows the RHS to be
a memory operand on non-ARM platforms, instead of requiring a register.

Depends on D103482

Very similar to MIRType::Int32 but use branchPtr instead of branch32 for codegen.

Depends on D103483

This makes GVN and bounds check optimizations work better.

Depends on D103484

Keywords: leave-open
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/02ffbca866a0
part 1 - Support int32 constants for Compare_UIntPtr. r=iain
https://hg.mozilla.org/integration/autoland/rev/ea00bb31867e
part 2 - Use useAny for RHS of pointer-size comparison. r=iain
https://hg.mozilla.org/integration/autoland/rev/5f1f8088956c
part 3 - Support range analysis checks for MIRType::IntPtr nodes. r=iain
https://hg.mozilla.org/integration/autoland/rev/886fe5870eb6
part 4 - Use separate NonNegativeIntPtrToInt32 node for ta.length. r=anba,iain
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/58cbe2d6f575
part 1 - Support int32 constants for Compare_UIntPtr. r=iain
https://hg.mozilla.org/integration/autoland/rev/1facc48a0706
part 2 - Use useAny for RHS of pointer-size comparison. r=iain
https://hg.mozilla.org/integration/autoland/rev/b86a32fff5d5
part 3 - Support range analysis checks for MIRType::IntPtr nodes. r=iain
https://hg.mozilla.org/integration/autoland/rev/90c909eee4b7
part 4 - Use separate NonNegativeIntPtrToInt32 node for ta.length. r=anba,iain

32-bit platforms: alawys use redefine to avoid an unnecessary register move.

64-bit platforms: use redefine for LInt32ToIntPtr when we know input >= 0
(checked in debug builds with LAssertInt32IsIntPtr).

It's easy enough to support memory operands with load32SignExtendToPtr.

Depends on D103754

Flags: needinfo?(jdemooij)
Attachment #9200622 - Attachment description: Bug 1688913 part 5 - Use 'redefine' for Int32 <=> IntPtr conversions when possible. r?anba! → Bug 1688913 part 5 - Optimize Int32 <=> IntPtr conversions a bit more. r?anba!

We're already using defineReuseInput for LNonNegativeIntPtrToInt32 and the next patch
uses it for LInt32ToIntPtr too. This exposed an issue on Try: we can't merge those
virtual registers into a single bundle (allocation) because we can get confused about
the stack slots (for example do an 8-byte write for IntPtr to a 4-byte Int32 slot).

This adds some code to disable the tryMergeReusedRegister optimization in this case.

Attachment #9200622 - Attachment description: Bug 1688913 part 5 - Optimize Int32 <=> IntPtr conversions a bit more. r?anba! → Bug 1688913 part 6 - Optimize Int32 <=> IntPtr conversions a bit more. r?anba!
Attachment #9200623 - Attachment description: Bug 1688913 part 6 - Use useAtStart instead of useRegisterAtStart for LInt32ToIntPtr operand. r?anba! → Bug 1688913 part 7 - Use useAtStart instead of useRegisterAtStart for LInt32ToIntPtr operand. r?anba!

With the old Linear Scan register allocator, the list of Value stack slots in
safepoints was used on 32-bit platforms too: the allocator tried hard to spill
Value type and payload slots to adjacent stack slots so that we could trace them
as a single Value. If this failed, the type and payload halves were encoded
separately as "nunbox parts".

With the backtracking allocator we now always use the "nunbox parts" encoding on
32-bit. The Value slots in the safepoints are only used on 64-bit platforms
(addValueSlot is only called on 64-bit). This patch makes this more explicit by
either using "value slots" (64-bit) or "nunbox slots" (32-bit).

The old register allocator allocated 8 bytes for nunbox type or payload. It was
then able to use the same 8-byte slot for spilling the other half and could add
this Value-slot to safepoints as a single unit.

The backtracking allocator, however, doesn't have this optimization so allocating
8 bytes for nunbox type/payload is a waste: we only ever use 4 bytes.

This simplifies the next patch.

Depends on D104363

Attachment #9201383 - Attachment description: Bug 1688913 part 5 - Don't share bundles for MUST_REUSE_INPUT definitions if they don't match. r?iain! → Bug 1688913 part 7 - Don't share bundles for MUST_REUSE_INPUT definitions if they don't match. r?iain!
Attachment #9200622 - Attachment description: Bug 1688913 part 6 - Optimize Int32 <=> IntPtr conversions a bit more. r?anba! → Bug 1688913 part 8 - Optimize Int32 <=> IntPtr conversions a bit more. r?anba!
Attachment #9200623 - Attachment description: Bug 1688913 part 7 - Use useAtStart instead of useRegisterAtStart for LInt32ToIntPtr operand. r?anba! → Bug 1688913 part 9 - Use useAtStart instead of useRegisterAtStart for LInt32ToIntPtr operand. r?anba!

This isn't observable because offsetAdjustment is always 0 (AnalyzeLoadUnboxedScalar
doesn't know about the Int32 to IntPtr conversion).

Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/74776ac44456
part 5 - Clean up safepoint code now that Value slots are only used on 64-bit. r=iain
https://hg.mozilla.org/integration/autoland/rev/de63db33c09c
part 6 - Use 4 bytes instead of 8 bytes for nunbox half stack slots. r=iain
https://hg.mozilla.org/integration/autoland/rev/4ef58cf45f1f
part 7 - Don't share bundles for MUST_REUSE_INPUT definitions if they don't match. r=iain
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aa08364eea3a
part 8 - Optimize Int32 <=> IntPtr conversions a bit more. r=anba
https://hg.mozilla.org/integration/autoland/rev/b072991bff68
part 9 - Use useAtStart instead of useRegisterAtStart for LInt32ToIntPtr operand. r=anba
Attachment #9201738 - Attachment is obsolete: true

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

  • Fix AnalyzeLoadUnboxedScalar, although it has no effect with Spectre mitigations on

I'm not sure what to do with this one: I have a patch to make this work on a local test case, but the optimization doesn't kick in on any jit-tests or Octane (tested by adding a MOZ_CRASH()) with --spectre-mitigations=off.

As suggested, we can just propagate the range from the input.

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

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

  • Fix AnalyzeLoadUnboxedScalar, although it has no effect with Spectre mitigations on

I'm not sure what to do with this one: I have a patch to make this work on a local test case, but the optimization doesn't kick in on any jit-tests or Octane (tested by adding a MOZ_CRASH()) with --spectre-mitigations=off.

Filed bug 1691919 for this. Other than that, everything in comment 0 has now been addressed.

Attachment #9202283 - Attachment description: Bug 1688913 part 10 - Propagate input range for MNonNegativeIntPtrToInt32. r?anba! → Bug 1688913 part 10 - Improve ranges of MNonNegativeIntPtrToInt32 and MArrayLength. r?anba,nbp

This is consistent with the shell flag that was renamed to --large-arraybuffers

Attachment #9202283 - Attachment description: Bug 1688913 part 10 - Improve ranges of MNonNegativeIntPtrToInt32 and MArrayLength. r?anba,nbp → Bug 1688913 part 10 - Improve ranges of MNonNegativeIntPtrToInt32 and similar instructions. r?anba!,nbp!
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/aab887fbb0e9
part 11 - Rename jit-test/tests/large-buffers directory to jit-test/tests/large-arraybuffers. r=lth DONTBUILD
Keywords: leave-open
Pushed by jdemooij@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8f89f1881b93
part 10 - Improve ranges of MNonNegativeIntPtrToInt32 and similar instructions. r=anba,nbp
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 87 Branch
Regressions: 1830107
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: