Closed Bug 1225024 Opened 6 years ago Closed 6 years ago

Math.log10 is sloppy on 32bit build on Mac OS X 10.7

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox45 --- fixed

People

(Reporter: arai, Assigned: arai)

References

Details

Attachments

(1 file)

derived from bug 1155473 comment #14 to #19.

on 32bit build of js shell and browser on Mac OS X 10.7.x,
Math.log10(0.01) returns -1.9999999999999996 (bfffffff fffffffe) and ecma_6/Math/log10-approx.js fails on 32bit ARM-simulator shell jstests (bug 1155473 comment #14)

>  ## ecma_6/Math/log10-approx.js: rc = 3, run time = 0.144168
>  ecma_6/Math/shell.js:7:19 Error: got -1.9999999999999996, expected a number near -2 (relative error: 2)
>  Stack:
>    fail@ecma_6/Math/shell.js:7:19
>    assertNear@ecma_6/Math/shell.js:69:1
>    @ecma_6/Math/log10-approx.js:6:1
>  TEST-UNEXPECTED-FAIL | ecma_6/Math/log10-approx.js | (args: "")

It's reproducible on following environment:
  * Mac build slave (bld-lion-r5-*)
  * Mac OS X 10.7.5, core-2 duo, first model MacBook Air, early 2008 (thanks to lth)

It's not reproducible on following environment (they're not 10.7, so I think it's a bug in 10.7):
  * OSX 10.10.5, Core i5, iMac Late 2013
  * OSX 10.11,   Code 2 duo, iMac Mid 2007
in case there's no simple way to fix the log10 implementation and this accuracy issue is not so critical, incremented tolerance from 1 to 2.
if we can land this, we can add osx arm to treeherder.
Attachment #8687853 - Flags: review?(jdemooij)
Comment on attachment 8687853 [details] [diff] [review]
Allow sloppy tolerance in ecma_6/Math/log10-approx.js.

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

Forwarding to jorendorff, I'm not sure about the precision required by the spec.
Attachment #8687853 - Flags: review?(jdemooij) → review?(jorendorff)
> I'm not sure about the precision required by the spec.

The ES 2015 spec requires nothing here.  You could literally return any number you felt like for positive finite values other than 1 and be spec-compliant.

The informative text has two things to say (in section 20.2.2):

  The general intent is that an implementer should be able to use the same mathematical
  library for ECMAScript on a given hardware platform that is available to C programmers
  on that platform.

and

  Although the choice of algorithms is left to the implementation, it is recommended
  (but not specified by this standard) that implementations use the approximation
  algorithms for IEEE 754-2008 arithmetic contained in fdlibm

Now in our case, log10 is implemented via a direct call to the log10 function provided by the C standard library on the compilation platform.  Which is precisely what that first non-normative bit of text is talking about.
Comment on attachment 8687853 [details] [diff] [review]
Allow sloppy tolerance in ecma_6/Math/log10-approx.js.

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

Yeah, it's OK to loosen this up so the tests pass.

Sigh. I would love to just switch to fdlibm for all platforms, but it's so far from being a priority...
Attachment #8687853 - Flags: review?(jorendorff) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/86f7c45c29716cd326643a30a9e48915e0e694cc
Bug 1225024 - Allow sloppy tolerance in ecma_6/Math/log10-approx.js. r=jorendorff
Thank you for reviewing :D
I'll look into fdlibm
Assignee: nobody → arai.unmht
https://hg.mozilla.org/mozilla-central/rev/86f7c45c2971
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
See Also: → 933257
You need to log in before you can comment on or make changes to this bug.