Stream: wasm

Topic: list of trapping instructions?


view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 17:50):

specifically, looking for which numeric instructions can trap. the spec makes figuring this out way harder than I feel it should be :pensive:

I know some of the float<-->int conversions can trap, but can't find the set of them all listed in one place

view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 17:59):

I guess all the truncating conversions?

view this post on Zulip Alex Crichton (Mar 09 2022 at 17:59):

IIRC yeah it's like i32.trunc_f32 or those

view this post on Zulip Alex Crichton (Mar 09 2022 at 17:59):

The trunc_sat_* things explicitly don't trap though

view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 18:01):

right

view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 18:03):

do you know if there are anything in the simd instructions that trap other than loads and stores?

view this post on Zulip Alex Crichton (Mar 09 2022 at 18:03):

I don't believe so, let me double-check

view this post on Zulip Alex Crichton (Mar 09 2022 at 18:04):

ok no I don't think so but fuzzing will probably confirm that one way or another

view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 18:04):

ah there are a bunch more truncating conversions there

view this post on Zulip fitzgen (he/him) (Mar 09 2022 at 18:08):

but they all seem to use the saturating logic, okay

view this post on Zulip Conrad Watt (Mar 31 2022 at 22:01):

of the SIMD instructions, (only) the binops seem to be spec'd to allow the possiblity of trapping

which suggests that at least one of them traps, although it's hard to work out which one(s) from the spec

(or the spec might just be written defensively because there's a feeling that binops might be particularly likely to trap in future?)

view this post on Zulip Chris Fallin (Mar 31 2022 at 22:06):

I don't recall any of the SIMD lowerings having a trap but I could be wrong... @Andrew Brown might be able to say for sure?

view this post on Zulip Andrew Brown (Mar 31 2022 at 22:38):

I was going to say the conversion instructions but they aren't binop (and don't really trap either); looking again at the spec I think you may be right that that is a defensive move

view this post on Zulip Dan Gohman (Mar 31 2022 at 22:40):

The SIMD load/store instructions can trap.

view this post on Zulip Dan Gohman (Mar 31 2022 at 22:41):

But otherwise yes, there was a concerted effort to minimize trapping in the SIMD proposal.

view this post on Zulip Dan Gohman (Mar 31 2022 at 22:44):

There was a moment I like to call "the great divide coincidence": it would be really awkward if we had to make divide non-trapping, because what else should it do, but then it turns out that a lot of SIMD units don't have integer divide anyway, so we could just leave it out of the spec altogether.

view this post on Zulip Chris Fallin (Mar 31 2022 at 22:46):

huh, that is indeed convenient


Last updated: Dec 23 2024 at 12:05 UTC