The default bug view has changed. See this FAQ.

IonMonkey: x + 0 equals x only when x can't be -0

RESOLVED FIXED

Status

()

Core
JavaScript Engine
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: h4writer, Assigned: h4writer)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

5 years ago
During GVN we fold values. E.g. in the addition we fold the addition to x + 0 to x.
This isn't true if x equals -0. 

testcase:

function test(i) {
    return i * 0 + 0;
}

// Compile double variant
for(var i=0; i<100; i++){
    test(-i);
}

var x = test(-100);
// Prints if x == -0
print((x===0 && (1/x)===-Infinity));

prints true in Ionmonkey, false in interpreter.

Reason:
-0 + 0 = +0 // positive zero
but we remove the addition (as 0 is the identity function of addition)

So the test function becomes:

function test(i){
   return i * 0
}

Which gives negative zero when i < 0
(Assignee)

Comment 1

5 years ago
Another fault in foldsto:

function test(i) {
    return 0 - i;
}

is folded to:

function test(i) {
    return i; // NOTICE THE LACK OF SIGN
}
(Assignee)

Comment 2

5 years ago
Created attachment 606278 [details] [diff] [review]
Patch for both issues

This fixes both issues. I'll add both testcases and commit msg after review.
Attachment #606278 - Flags: review?(dvander)
(Assignee)

Updated

5 years ago
Assignee: general → hv1989

Comment 3

5 years ago
s/substraction/subtraction/
Comment on attachment 606278 [details] [diff] [review]
Patch for both issues

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

Nice catch!
Attachment #606278 - Flags: review?(dvander) → review+
(Assignee)

Comment 5

5 years ago
Created attachment 606517 [details] [diff] [review]
Patch for both issues

Robert's nit addressed, together with commit description and author. Ready for checkin.
Attachment #606278 - Attachment is obsolete: true
(Assignee)

Updated

5 years ago
Attachment #606517 - Flags: review+
(Assignee)

Updated

5 years ago
Keywords: checkin-needed
Whiteboard: checkin on ionmonkey branch
Jan, can you check this in?
(In reply to Ryan VanderMeulen from comment #6)
> Jan, can you check this in?

Sure: http://hg.mozilla.org/projects/ionmonkey/rev/3a4607b336a8
Status: NEW → RESOLVED
Last Resolved: 5 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: checkin on ionmonkey branch
You need to log in before you can comment on or make changes to this bug.