Closed Bug 513865 Opened 16 years ago Closed 16 years ago

nanojit: make LirReader::read() clearer and faster

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: n.nethercote, Assigned: n.nethercote)

Details

(Whiteboard: fixed-in-nanojit, fixed-in-tracemonkey)

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
With LIR_2 gone, LirReader::read() can be reworked to be clearer and faster. Specifically: - Currently the loop never has a skip on the first iteration, but only has skips on the 2nd and subsequent iterations. So I split it into a single switch (which doesn't have to handle skip) followed by a skip-chasing loop. This makes things clearer. - The LIR_start case can be skipped in optimised builds, avoiding one comparison. Doesn't make a noticeable difference to SunSpider, but it can't hurt in the long run. - Added some comments making some invariants clearer. - Removed setpos(), which is dead.
Attachment #397814 - Flags: review?(gal)
Attachment #397814 - Flags: review?(gal) → review+
I wonder whether its worth grouping the calls such that we can mask-match them. Just an idea.
I don't understand -- what do you mean by "mask-match"? It's a shame that calls are variable-length. I wonder if making them fixed length -- unused arguments would just be wasted space -- would be worth it just to avoid this switch.
icall is 16. fcall is 16 | 64 and qcall is 17 | 64. So ((iop &~ (64 | 1)) == 16) should be equivalent. This would need some asserts and explanation in LIRopcode.tbl and blocking of 17 (which is currently unused anyway). Its a bit ugly, but might be fast.
Hmm, I'll believe it's faster when I see the numbers...
Yeah, its only worth taking that ugly hack if it is actually measurably faster.
Whiteboard: fixed-in-tracemonkey
Backed out due to Tinderbox crashes: http://hg.mozilla.org/tracemonkey/rev/0fc46fb6cba1
Whiteboard: fixed-in-tracemonkey
Profiling under 20x-over-compilation (see bug 504258) has shown a very slight slowdown. If bug 515305 is completed that will supersede this anyway.
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Attached patch new patchSplinter Review
Thanks to bug 525437, which removed the special-casing required for calls, this is back on the table. For an optimised build we now just (a) do a table-lookup to get the instruction size, step back that many bytes, and (b) check if we're now on a skip, and if so follow it back to the previous chunk. No switches required!
Attachment #397814 - Attachment is obsolete: true
Attachment #411614 - Flags: review?(edwsmith)
Attachment #411614 - Flags: review?(edwsmith) → review?(gal)
Attachment #411614 - Flags: review?(gal) → review+
tamarin has code that erases instructions by turning them into a LIR_skip, but that could cause read() to see two skips in a row. so, maybe don't want that assert there at least until tamarin's erasure code is changed.
Ed, I'll change the skip test to a while loop that ignores multiple skips in a row.
Whiteboard: fixed-in-nanojit → fixed-in-nanojit, fixed-in-tracemonkey
Status: REOPENED → RESOLVED
Closed: 16 years ago16 years ago
Resolution: --- → FIXED
For the record, this introduced an intermittent bug :( It was fixed in bug 530713.
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: