Closed Bug 538583 Opened 15 years ago Closed 15 years ago

JIT should emit LIR_j instead of LIR_jtbl if the latter only has one target

Categories

(Tamarin Graveyard :: Baseline JIT (CodegenLIR), enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Future

People

(Reporter: edwsmith, Assigned: stejohns)

Details

(Whiteboard: PACMAN)

Attachments

(1 file)

simple example comes from try/catch/finally: function f() { try { } catch (e) { } finally { } } Generates a suboptimal sequence for OP_lookupswitch: 120: jf ult2 -> B66 121: jtbl ld8 [ B48 ] <--- this could be LIR_j -> B48 122: B66: Also note the whole sequence could be replaced with a single branch and fall-through case, if the JIT notices that the default switch target is immediately next: 120: jt ult2 -> B48 <-- invert the sense of the branch 121: B66: <-- only needed if other branches still land here
Target Milestone: --- → Future
OP_lookupswitch already does this for count == 0.
exactly. count==1 should generate a range check and a jump instead of a range check and a 1-entry jtbl.
Whiteboard: PACMAN
Assignee: nobody → wmaddox
Assignee: wmaddox → nobody
Attached patch PatchSplinter Review
OP_lookupswitch the only user of LIR_jtbl, so the easy fix is there. (Might be interesting to unroll switches of 2 or 3 too and see if that is faster...)
Assignee: nobody → stejohns
Attachment #477633 - Flags: review?(edwsmith)
Comment on attachment 477633 [details] [diff] [review] Patch Looks pretty simple, and if tests pass then its probably fine. But i'm also fighting a massive head cold so my judgement is cloudy. Asking Bill for a second look. As for unrolling jtbl into individual branches, that should be a backend-specific codegen decision, not in LIR (but still worth a try, its probably a win for low sized tables).
Attachment #477633 - Flags: review?(wmaddox)
Attachment #477633 - Flags: review?(edwsmith)
Attachment #477633 - Flags: review+
(In reply to comment #4) > Looks pretty simple, and if tests pass then its probably fine. But i'm also > fighting a massive head cold so my judgement is cloudy. Asking Bill for a > second look. Passes all tests (and it is being exercised, I checked). Doesn't move the needle noticeably in the perf tests I tried, but is arguably better code.
Comment on attachment 477633 [details] [diff] [review] Patch R+ Looks good to me.
Attachment #477633 - Flags: review?(wmaddox) → review+
pushed to TR as 5251:3381faf0c552
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: