Closed Bug 562857 Opened 15 years ago Closed 15 years ago

TM: use LIR_d2i instead of js_DoubleToInt32() when possible

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-tracemonkey)

Attachments

(1 file)

Attached patch patchSplinter Review
In makeNumberInt32(), we convert a double to an int, then convert the int back to a double and compare it against the first double; if not equal, we exit. In other words, we exit if the double wasn't integral. We sometimes use js_DoubleToInt32() for the double-to-int conversion, but that's overkill, we can instead use the LIR_d2i instruction. LIR_d2i uses platform rounding rules for inexact cases, but it gives the same results as js_DoubleToInt32() for integral cases, which are the ones that will avoid side-exits. (At least, that's my understanding; the main part of reviewing this patch should be confirming that this is true.) This improves instruction counts on a few SS benchmarks (i386): 3d-morph: total 74,361,061 67,229,750 1.106x better on-trace 26,384,213 25,520,222 1.034x better 3d-raytrace: total 141,205,085 138,777,675 1.017x better on-trace 26,154,743 25,661,153 1.019x better access-fannkuch: total 241,803,476 227,917,250 1.061x better on-trace 117,430,228 113,871,377 1.031x better string-validate-input: total 83,040,900 82,153,955 1.011x better on-trace 8,045,440 7,853,415 1.024x better ------- all: total 2,522,688,742 2,498,272,094 1.010x better on-trace 627,236,604 622,128,042 1.008x better And one V8 benchmark: v8-crypto: total 2,592,495,616 2,519,708,387 1.029x better on-trace 1,488,287,032 1,472,364,445 1.011x better Timewise, fannkuch is about 3--5% faster, 3d-morph is 1--10%, others have smaller improvements. (I timed on 32-bit and 64-bit, hence the big variations.) V8 timing differences were below noise level.
Attachment #442598 - Flags: review?(gal)
Comment on attachment 442598 [details] [diff] [review] patch I think splitting that up and then using separate entry points instead of the boolean flag would be nicer. Up to you. Nice work. I did the work for F2I a while but never got around to actually wire it up. This could be used for other stuff too (BoxDouble i.e.).
Attachment #442598 - Flags: review?(gal) → review+
(In reply to comment #1) > This could be used for other stuff too (BoxDouble i.e.). I discussed this with Andreas on IRC and I think the conclusion was that it can't be used for BoxDouble, that the use done in the patch is the only suitable one.
Whiteboard: fixed-in-tracemonkey
Status: ASSIGNED → 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

Created:
Updated:
Size: