Closed Bug 1986348 Opened 1 year ago Closed 1 year ago

Prefer std functions in fdlibm when precise results are guaranteed

Categories

(Core :: JavaScript Engine, task, P3)

task

Tracking

()

RESOLVED FIXED
145 Branch
Tracking Status
firefox145 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(4 external files)

Use std version for sqrtf, fabs(f), scalb(f), copysign(f), ceil(f), floor(f), trunc(f), nearbyint(f), and rint(f), because they're guaranteed to be precise per https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf, Annex F.

And remove no longer used imports.

Blocks: sm-jits
Severity: -- → N/A
Priority: -- → P3

There are some unfortunate complications on Windows:

  1. Rounding functions on Windows x64 can return the wrong NaN value for some Wasm tests. Probably fixable by adding a wrapper function which handles NaN.
  2. Try-runs on Windows x86 are broken all over the place (tests abort with Windows error code 0xC0000409). There seems to be an issue when the JIT calls into the runtime and the runtime performs a call to std rounding functions. Probably some calling convention or stack alignment issue involving x87 instructions. I don't have a Windows setup right now, so diagnosing and fixing this issue is difficult for me.

Try-run: https://treeherder.mozilla.org/jobs?repo=try&revision=fd508dc771f2f6b1b4e11747a2eb1678c7d5e2fe

Add force_align_arg_pointer to ensure the stack is aligned to 16 bytes on
Windows x86. Without the extra stack alignment, calls from the JITs abort with
error code 0xC0000409.

And for Wasm additionally ensure NaN values are handled consistently across
different platforms. Tests in "jit-test/tests/wasm/spec/spec/f{32,64}.wast.js"
fail without this change. See also [1].

[1] https://webassembly.github.io/spec/core/exec/numerics.html#nan-propagation

QA Whiteboard: [qa-triage-done-c146/b145]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: