Closed Bug 1370208 Opened 8 years ago Closed 8 years ago

Inline Boolean when called as a function

Categories

(Core :: JavaScript Engine: JIT, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla55
Tracking Status
firefox55 --- fixed

People

(Reporter: anba, Assigned: anba)

Details

Attachments

(1 file, 1 obsolete file)

I saw this in a Speedometer/React profile and it should be easy enough to inline in MCallOptimize using IonBuilder::convertToBoolean(...).
(In reply to André Bargull from comment #0) > I saw this in a Speedometer/React profile and it should be easy enough to > inline in MCallOptimize using IonBuilder::convertToBoolean(...). Can you provide more information, with ideally a micro benchmark which highlight the issue?
var q = 0; var inputs = [true, false, 0, 1, "", "awd", null, {}]; var t = Date.now(); for (var i = 0; i < 10000000; ++i) { if (Boolean(inputs[i & 0x7])) q++; } print(Date.now() - t, q); Would improve from 125ms to ~30ms (same number as V8, which also optimizes calls to the Boolean constructor -> https://github.com/v8/v8/blob/a234136074366a8ab8d1c703bad1949ec5a1f033/src/compiler/js-call-reducer.cc#L67-L81). FWIW in Speedometer, this React function seems to cause most Boolean calls: https://github.com/facebook/react/blob/0.14-stable/src/renderers/shared/reconciler/ReactCompositeComponent.js#L689
Attached patch bug1370208.patch (obsolete) — Splinter Review
The patch used for comment #2. Do you think this makes sense to optimize?
Attachment #8874444 - Flags: feedback?(nicolas.b.pierron)
Comment on attachment 8874444 [details] [diff] [review] bug1370208.patch Review of attachment 8874444 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jit/MCallOptimize.cpp @@ +904,5 @@ > > IonBuilder::InliningResult > +IonBuilder::inlineBoolean(CallInfo& callInfo) > +{ > + if (callInfo.argc() != 1 || callInfo.constructing()) { nit/follow-up: It seems that the 0 argument case, or more than one case should be easy to implement as well. http://searchfox.org/mozilla-central/source/js/src/jsbool.cpp#116
Attachment #8874444 - Flags: feedback?(nicolas.b.pierron) → review+
Attached patch bug1370208.patchSplinter Review
Relaxed arguments check to allow only number of arguments per comment #4. Carrying r+.
Attachment #8874444 - Attachment is obsolete: true
Attachment #8874744 - Flags: review+
Pushed by cbook@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/f302f3481aaa Inline Boolean constructor when called as a function. r=nbp
Keywords: checkin-needed
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: