IonMonkey: constant fold arithm operations with double output that fits in int32

RESOLVED FIXED in mozilla25

Status

()

RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: h4writer, Assigned: h4writer)

Tracking

unspecified
mozilla25
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
Noticed this on kraken-stanford-crypto-ccm. EvaluateConstantOperands uses setNumber what will try to put the value in int32 if possible. Now if the output result needs to be in double, we won't constant fold, since the types don't match. But we can just transform the int32 result to double without precision loss.
(Assignee)

Comment 1

5 years ago
Created attachment 776659 [details] [diff] [review]
Patch
Assignee: general → hv1989
Attachment #776659 - Flags: review?(jdemooij)
Comment on attachment 776659 [details] [diff] [review]
Patch

Review of attachment 776659 [details] [diff] [review]:
-----------------------------------------------------------------

Nice find!

::: js/src/ion/MIR.cpp
@@ +123,5 @@
>      }
>  
> +    // setNumber eagerly transforms a number to int32.
> +    // Transform back to double, if the output type is double.
> +    if (ins->type() == MIRType_Double && MIRTypeFromValue(ret) == MIRType_Int32)

You can use ret.isInt32() instead of MIRTypeFromValue(ret) == MIRType_Int32.
Attachment #776659 - Flags: review?(jdemooij) → review+
(Assignee)

Comment 3

5 years ago
Created attachment 778565 [details] [diff] [review]
Patch
Attachment #776659 - Attachment is obsolete: true
(Assignee)

Updated

5 years ago
Keywords: checkin-needed

Comment 5

5 years ago
https://hg.mozilla.org/mozilla-central/rev/7c5c7d816fbb
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
You need to log in before you can comment on or make changes to this bug.