Bug 136261 - ARM32 iOS: JSC Test math.js fails
Summary: ARM32 iOS: JSC Test math.js fails
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Michael Saboff
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-26 11:38 PDT by Michael Saboff
Modified: 2014-09-05 13:08 PDT (History)
0 users

See Also:


Attachments
Patch (4.01 KB, patch)
2014-09-04 18:32 PDT, Michael Saboff
ggaren: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Saboff 2014-08-26 11:38:20 PDT
All variants of math.js fail the Math.ceil(Number.MIN_VALUE) and Math.floor(-Number.MIN_VALUE) test.  For example:

jsc-layout-tests.yaml/js/script-tests/math.js.layout: --- ../.tests/jsc-layout-tests.yaml/js/math-expected.txt	2014-08-26 09:20:39.000000000 -0700
jsc-layout-tests.yaml/js/script-tests/math.js.layout: +++ ../jsc-layout-tests.yaml/js/script-tests/math.js.layout.out	2014-08-26 09:57:11.000000000 -0700
jsc-layout-tests.yaml/js/script-tests/math.js.layout: @@ -53,7 +53,7 @@
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(-1) is -1
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(1.1) is 2
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(-1.1) is -1
jsc-layout-tests.yaml/js/script-tests/math.js.layout: -PASS Math.ceil(Number.MIN_VALUE) is 1
jsc-layout-tests.yaml/js/script-tests/math.js.layout: +FAIL Math.ceil(Number.MIN_VALUE) should be 1. Was 0.
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(-Number.MIN_VALUE) is -0
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(Number.MAX_VALUE) is Number.MAX_VALUE
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.ceil(-Number.MAX_VALUE) is -Number.MAX_VALUE
jsc-layout-tests.yaml/js/script-tests/math.js.layout: @@ -78,7 +78,7 @@
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(1.1) is 1
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(-1.1) is -2
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(Number.MIN_VALUE) is 0
jsc-layout-tests.yaml/js/script-tests/math.js.layout: -PASS Math.floor(-Number.MIN_VALUE) is -1
jsc-layout-tests.yaml/js/script-tests/math.js.layout: +FAIL Math.floor(-Number.MIN_VALUE) should be -1. Was -0.
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(Number.MAX_VALUE) is Number.MAX_VALUE
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(-Number.MAX_VALUE) is -Number.MAX_VALUE
jsc-layout-tests.yaml/js/script-tests/math.js.layout:  PASS Math.floor(Infinity) is Infinity
Comment 1 Michael Saboff 2014-08-28 15:02:28 PDT
This happens on 32 bit ARM code on iOS, even if that code is executed on an ARM64 device.

Number.MIN_VALUE  is coded as a constant in NumberConstructor.cpp as  5E-324.  The issue seems to be that the ceil() and floor() library routines on iOS return the wrong answer for 5E-324 and -5E-324 respectively.  I verified this with a test program.  I checked to see if the issue was the flush to zero of denormalized numbers in ARM, but the FZ bit of the FPSCR register is 0 (Flush-to-zero disabled).  That bit is cleared in jsc.cpp around line 1100.
Comment 2 Michael Saboff 2014-09-04 18:32:45 PDT
Created attachment 237666 [details]
Patch
Comment 3 Geoffrey Garen 2014-09-05 11:55:34 PDT
Comment on attachment 237666 [details]
Patch

r=me
Comment 4 Michael Saboff 2014-09-05 13:08:19 PDT
Committed r173330: <http://trac.webkit.org/changeset/173330>