Closed Bug 2041580 Opened 5 months ago Closed 5 months ago

Clean-up riscv64 branch methods

Categories

(Core :: JavaScript Engine: JIT, task)

task

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(17 external files)

The riscv64 branch methods contain a lot of unused code. Removing the unused code allows to simplify the implementation at lot.

After part 1, BranchAndLinkShortHelper is only called from BranchAndLinkShort.

Just moves the code, so that related methods are placed next to each other.

The functions are only called from Branch(AndLink)Long, so let's inline
them there.

After part 5, BranchShortCheck is only called from BranchShort, so inline
it into its caller.

Again inline a function which has only a single caller.

CalculateOffset is also always called with offset = 0.

Handle the same register case early instead of in each case block to avoid
code repetition.

The single argument isNear requires a bound Label, whereas the two
argument isNear handles nullptr and unbound Label. Combine both
methods into a single method which requires a bound Label. (Until isNear
is removed completely in part 16.)

Also remove the unused is_near_branch method.

Because it only delegates to branchOffsetHelper.

Inline in preparation for part 16.

Make ma_branch the internal branch method, which is only called from ma_b
and jump. This should make it easier to reason about the code. Also make
JumpKind a required parameter instead of implicitly defaulting it to
ShortJump. (Also pay attention that ma_b defaults to LongJump!).

Both methods are only called from BranchAndLink.

This part finishes the code restructuring for branch methods. The next part will
only remove more unused functions and move more related functions next to each
other.

The new code structure for branch methods:

  1. The five argument ma_branch method calls either the two or five argument
    Branch method.
  2. The Branch methods call UseShortBranch to determine if short or long
    branches must be emitted.
  3. BranchShort resp. BranchLong emit the actual branch instructions.
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/0d76151e88a0 https://hg.mozilla.org/integration/autoland/rev/14269ff3b9cd Part 1: Remove unused BranchAndLinkShort with int32_t argument. r=iain https://github.com/mozilla-firefox/firefox/commit/050415d7a6c2 https://hg.mozilla.org/integration/autoland/rev/3102abb08908 Part 2: Inline BranchAndLinkShortHelper into caller. r=iain https://github.com/mozilla-firefox/firefox/commit/2a7d860cd30d https://hg.mozilla.org/integration/autoland/rev/bbf768f7a6ed Part 3: Move BranchAndLink(Short) nearer to other branch methods. r=iain https://github.com/mozilla-firefox/firefox/commit/ef6b8e248877 https://hg.mozilla.org/integration/autoland/rev/8417ad26d175 Part 4: Inline GenPCRelativeJump(AndLink). r=iain https://github.com/mozilla-firefox/firefox/commit/e91ec9b2d84b https://hg.mozilla.org/integration/autoland/rev/c28db72ab1e4 Part 5: Remove unused BranchShort with offset parameter. r=iain https://github.com/mozilla-firefox/firefox/commit/6abcf60748c8 https://hg.mozilla.org/integration/autoland/rev/56469cc16c79 Part 6: Inline BranchShortCheck and BRANCH_ARGS_CHECK. r=iain https://github.com/mozilla-firefox/firefox/commit/e5641959f723 https://hg.mozilla.org/integration/autoland/rev/1bd95dfdc6e9 Part 7: Inline two-argument BranchShortHelper into caller. r=iain https://github.com/mozilla-firefox/firefox/commit/0934cb39e435 https://hg.mozilla.org/integration/autoland/rev/4ec6fe6d7c30 Part 8: Inline five-argument BranchShortHelper into caller. r=iain https://github.com/mozilla-firefox/firefox/commit/a37ded879d11 https://hg.mozilla.org/integration/autoland/rev/605af5af91a9 Part 9: Remove always zero argument from GetOffset. r=iain https://github.com/mozilla-firefox/firefox/commit/981708049043 https://hg.mozilla.org/integration/autoland/rev/a30fce27ffb6 Part 10: Simplify BranchShort. r=iain https://github.com/mozilla-firefox/firefox/commit/19ca09e6f475 https://hg.mozilla.org/integration/autoland/rev/f1b0c9b5af88 Part 11: Use a single isNear method. r=iain https://github.com/mozilla-firefox/firefox/commit/e6463ad4a9da https://hg.mozilla.org/integration/autoland/rev/db23d15f7a18 Part 12: Move GetOffset to header. r=iain https://github.com/mozilla-firefox/firefox/commit/01f163f4a5d4 https://hg.mozilla.org/integration/autoland/rev/123e2a70b48f Part 13: Inline CalculateOffset. r=iain https://github.com/mozilla-firefox/firefox/commit/5c39e2985b45 https://hg.mozilla.org/integration/autoland/rev/8be82b45fa8a Part 14: Make ma_branch the internal branch method. r=iain https://github.com/mozilla-firefox/firefox/commit/2fb6dd97c674 https://hg.mozilla.org/integration/autoland/rev/1ecdb86d1c1c Part 15: Inline BranchAndLinkShort and BranchAndLinkLong. r=iain https://github.com/mozilla-firefox/firefox/commit/416a99afbf78 https://hg.mozilla.org/integration/autoland/rev/043769adfbb8 Part 16: Split conditional and unconditional branches. r=iain https://github.com/mozilla-firefox/firefox/commit/18cc75d56c92 https://hg.mozilla.org/integration/autoland/rev/182818addff6 Part 17: Remove unused ma_b methods and move branch methods next to each other. r=iain
QA Whiteboard: [qa-triage-done-c154/b153]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: