Closed
Bug 1272640
Opened 9 years ago
Closed 9 years ago
wasm: Implement {f32,f64}.{trunc,nearest,copysign}
Categories
(Core :: JavaScript Engine: JIT, defect)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
FIXED
mozilla49
Tracking | Status | |
---|---|---|
firefox49 | --- | fixed |
People
(Reporter: bbouvier, Assigned: bbouvier)
References
Details
Attachments
(5 files)
2.90 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
7.95 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
5.14 KB,
patch
|
arai
:
review+
|
Details | Diff | Splinter Review |
8.40 KB,
patch
|
sunfish
:
review+
|
Details | Diff | Splinter Review |
5.72 KB,
patch
|
sunfish
:
review+
|
Details | Diff | Splinter Review |
These should be pretty easy to do:
- for trunc/nearest, we can use math functions, for a start. Then maybe optimize trunc/nearest/floor to use roundss/roundsd with a rounding mode, when it's available for x86. I haven't checked ARM yet.
- for copysign, we can reinterpret the inputs as uint32/uint64, then use a combination of and/or to extract the sign and replace it. Unless there is a corresponding instruction. That's what fdlibm does.
Comment 1•9 years ago
|
||
It would be lovely if these could be exposed in a platform-independent way in MacroAssembler.h from the outset - I'll need them too...
Assignee | ||
Comment 2•9 years ago
|
||
Lars, my current plan is to use math.h functions for trunc/nearest. More precisely, fdlibm functions; so the same mechanism as for floor, etc. could be reused here. Although we could use fdlibm functions for copysign too, the inlining is quite easy: https://github.com/WebAssembly/spec/blob/master/ml-proto/spec/float.ml#L188
Assignee | ||
Comment 3•9 years ago
|
||
Attachment #8754384 -
Flags: review?(arai.unmht)
Assignee | ||
Comment 4•9 years ago
|
||
Meta-patch: updates the patches to apply to fdlibm when doing an update.
Attachment #8754385 -
Flags: review?(arai.unmht)
Assignee | ||
Comment 5•9 years ago
|
||
Actually applies the meta-patches.
Attachment #8754386 -
Flags: review?(arai.unmht)
Assignee | ||
Comment 6•9 years ago
|
||
This implements trunc/nearest in terms of VM calls. We can probably use roundss on recent intel chips, but I'd rather do that in a follow up.
Attachment #8754388 -
Flags: review?(sunfish)
Assignee | ||
Comment 7•9 years ago
|
||
Copysign can be just implemented with bit twiddling.
Attachment #8754389 -
Flags: review?(sunfish)
Assignee | ||
Comment 8•9 years ago
|
||
Comment 9•9 years ago
|
||
Comment on attachment 8754384 [details] [diff] [review]
1.updatesh.importsh.patch
Review of attachment 8754384 [details] [diff] [review]:
-----------------------------------------------------------------
Thank you for the patch :D
::: modules/fdlibm/import.sh
@@ +8,3 @@
> REMOTE_FILENAME=$1
> LOCAL_FILENAME=$2
> + while true; do
shouldn't we abort script when curl fails several times?
::: modules/fdlibm/update.sh
@@ +11,5 @@
> curl -s "${API_BASE_URL}/commits?path=lib/msun/src&per_page=1" \
> | python -c 'import json, sys; print(json.loads(sys.stdin.read())[0]["sha"])'
> }
>
> +mv src/moz.build ./src_moz.build
thank you for following up :)
@@ +17,5 @@
> BEFORE_COMMIT=$(get_commit)
> sh ./import.sh
> COMMIT=$(get_commit)
> if [ ${BEFORE_COMMIT} != ${COMMIT} ]; then
> echo "Latest commit is changed during import. Please run again."
can you move the moz.build back here?
so that `mv src/moz.build ./src_moz.build` won't fail on next run.
Attachment #8754384 -
Flags: review?(arai.unmht) → review+
Updated•9 years ago
|
Attachment #8754385 -
Flags: review?(arai.unmht) → review+
Updated•9 years ago
|
Attachment #8754386 -
Flags: review?(arai.unmht) → review+
Comment 10•9 years ago
|
||
Comment on attachment 8754388 [details] [diff] [review]
4.trunc.nearest.patch
Review of attachment 8754388 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good. There's no test, though we will have good test coverage of these in the spec testsuite. With this patch and the copysign patch, is it enough to enable f32.wast and f64.wast in js/src/jit-test/tests/wasm/spec/list.js ?
Attachment #8754388 -
Flags: review?(sunfish) → review+
Comment 11•9 years ago
|
||
Comment on attachment 8754389 [details] [diff] [review]
5.copysign.patch
Review of attachment 8754389 [details] [diff] [review]:
-----------------------------------------------------------------
Looks good.
Attachment #8754389 -
Flags: review?(sunfish) → review+
Assignee | ||
Comment 12•9 years ago
|
||
And thank you for the review!
(In reply to Tooru Fujisawa [:arai] from comment #9)
> Comment on attachment 8754384 [details] [diff] [review]
> 1.updatesh.importsh.patch
>
> Review of attachment 8754384 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Thank you for the patch :D
>
> ::: modules/fdlibm/import.sh
> @@ +8,3 @@
> > REMOTE_FILENAME=$1
> > LOCAL_FILENAME=$2
> > + while true; do
>
> shouldn't we abort script when curl fails several times?
I've actually had a very flaky connection these days, and curl often resulted in CONNECTION_RESET failures, and that is why I have updated this code. However, curl failing might indicate many other things: e.g. the network can't be reached, or github being down for some reason. I guess the user can still force stop by ctrl+c in this case? Anyways, I don't have strong opinions here and would be okay reverting this chunk.
Assignee | ||
Comment 13•9 years ago
|
||
(In reply to Dan Gohman [:sunfish] from comment #10)
> Comment on attachment 8754388 [details] [diff] [review]
> 4.trunc.nearest.patch
>
> Review of attachment 8754388 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> Looks good. There's no test, though we will have good test coverage of these
> in the spec testsuite. With this patch and the copysign patch, is it enough
> to enable f32.wast and f64.wast in js/src/jit-test/tests/wasm/spec/list.js ?
Thank you for the reviews! Indeed all the testing is done in the spec tests, which are very cautious and tests many more things. Unfortunately, we can't enable the f32/f64 wast tests yet, because of custom NaNs.
Comment 14•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/335c62fd3d98
https://hg.mozilla.org/integration/mozilla-inbound/rev/7ba34f7a79a0
https://hg.mozilla.org/integration/mozilla-inbound/rev/a7d6629e599e
https://hg.mozilla.org/integration/mozilla-inbound/rev/f60ddfa778a9
https://hg.mozilla.org/integration/mozilla-inbound/rev/740a2bf1fa9e
Comment 15•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/335c62fd3d98
https://hg.mozilla.org/mozilla-central/rev/7ba34f7a79a0
https://hg.mozilla.org/mozilla-central/rev/a7d6629e599e
https://hg.mozilla.org/mozilla-central/rev/f60ddfa778a9
https://hg.mozilla.org/mozilla-central/rev/740a2bf1fa9e
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla49
You need to log in
before you can comment on or make changes to this bug.
Description
•