Closed Bug 758376 Opened 12 years ago Closed 12 years ago

IonMonkey: Differential Testing: Getting 0 vs. NaN with/without ion

Categories

(Core :: JavaScript Engine, defect)

Other Branch
x86_64
Linux
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 792234

People

(Reporter: decoder, Assigned: dvander)

References

Details

(Keywords: regression, testcase, Whiteboard: [ion:p1:fx18])

Attachments

(1 file)

The following testcase shows different behavior with options --ion -n -m --ion-eager vs. --no-ion on ionmonkey revision c05b873dad48:


function spectralnorm(n) {
  var i, u=[], v=[], w=[], vv=0, vBv=0;
  for (i=0; i<n; ++i) {
    vv  += v[i]*v[i];
  }
  return Math.sqrt(vBv/vv);
}
var actual = '';
for (var i = 6; i <= 48; i *= 2) {
  actual += spectralnorm(i) + ',';
}
print(actual);


$ debug64/js --ion -n -m --ion-eager test.js
NaN,0,0,0,

$ debug64/js --no-ion test.js
NaN,NaN,NaN,NaN,
Assignee: general → dvander
Status: NEW → ASSIGNED
Attached patch fixSplinter Review
Subtle bug in MDiv folding, if lhs or rhs are constant 0, the other side may be NaN, so this patch just restricts that folding to integer specialization.
Attachment #627426 - Flags: review?(kvijayan)
Comment on attachment 627426 [details] [diff] [review]
fix

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

::: js/src/ion/MIR.cpp
@@ +687,4 @@
>  
>      // 0 / x -> 0
>      // x / 1 -> x
> +    if (specialization_ == MIRType_Int32 && (IsConstant(lhs(), 0) || IsConstant(rhs(), 1)))

This can be slightly expanded to:

if ((specialization_ == MIRType_Int32 && IsConstant(lhs(), 0)) || IsConstant(rhs(), 1))

As in the rhs() == 1 case, NaN / 1 == Nan == lhs() holds even without the Int32 check.
Attachment #627426 - Flags: review?(kvijayan) → review+
Missed something:

I don't think the lhs() == 0 case should be included at all, as

0 / I == 0

doesn't hold for all int32 Is, specifically for I=0, as 0/0 == NaN.
Whiteboard: [ion:p1:fx18]
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: