Closed Bug 640293 Opened 13 years ago Closed 13 years ago

TI+JM: consider optimizing JSOP_NEG for known integers

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jandem, Assigned: jandem)

References

(Blocks 1 open bug)

Details

(Whiteboard: fixed-in-jaegermonkey)

Attachments

(1 file)

Currently we generate a jump to an OOL path and generate an (unused) inline double path. I'll try to add an inline integer path for this and measure perf impact for micro-benchmarks and SS/V8/kraken. I'd also like to test compiling -x as x * -1.

JSOP_NEG with integer arg seems quite common, so we should make it as fast as possible.
Assignee: general → jandemooij
Status: NEW → ASSIGNED
Attached patch PatchSplinter Review
This patch adds an inline integer path for known integers. It also optimizes the is-0 and is-MIN_INT checks to one test instruction (both have 31 lower bits zero). This passes jit-tests and jstests with -m -n -a.

For this micro-benchmark:
--
function f() {
    var a = 0;
    var t0 = new Date;
    for(var i=1; i<10000000; i++) {
        a = -i;
    }
    print(new Date - t0);
    print(a);
}
f();
--
...these numbers:

d8: 52 ms
JM: 62 ms
TM: 27 ms
JM+TI (old): 39 ms
JM+TI (new): 17 ms

I don't think this helps SS/V8/Kraken much but I think it's worth the small amount of extra code, -int seems like a common thing to do. The code is also pretty straight-forward.
Attachment #520020 - Flags: review?(bhackett1024)
Comment on attachment 520020 [details] [diff] [review]
Patch

Nice!
Attachment #520020 - Flags: review?(bhackett1024) → review+
http://hg.mozilla.org/projects/jaegermonkey/rev/ad4909bdd6a7
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Whiteboard: fixed-in-jaegermonkey
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: