asm-js / validator

A reference validator for asm.js.
Apache License 2.0
1.78k stars 148 forks source link

Call-site coercions. #70

Closed cscott closed 10 years ago

cscott commented 11 years ago

This is discussed in https://bugzilla.mozilla.org/show_bug.cgi?id=883175 and https://bugzilla.mozilla.org/show_bug.cgi?id=854061 (comments 26 and 29). The current (final?) version of the rules proposal is in comment 7 and 15 on bug 883175.

Call sites to local and foreign functions must appear in one of the following grammatical forms: +f() => f returns doublish f()|0 => f returns intish f(); => f returns void

cscott commented 11 years ago

Oh, and this also removes the 'unknown' type from the spec.

cscott commented 11 years ago

Updated the issue description to match the latest proposal from bug 883175 (comment 7 and 15).

cscott commented 11 years ago

Latest proposal also allows f(), ... => f returns void. (ie, void functions can appear as left operand to the comma operator). See https://bugzilla.mozilla.org/show_bug.cgi?id=883175#c26

kripken commented 11 years ago

Without that last one, could have been quite painful...

jruderman commented 11 years ago

Does this mean changing Math.abs(signed) to return signed instead of unsigned?

cscott commented 11 years ago

The result of Math.abs(-2147483648) is indeed unsigned, not signed. The callsite grammar requires us to coerce the result back to signed using Math.abs(-2147483648)|0 (yielding a negative result), but that seems like an orthogonal issue (unless you're proposing that f()>>>0 be added to the set of valid call site expressions).

sunfishcode commented 10 years ago

The unknown type was removed and several other changes were added in 7881fbe325fbfbeed1caf5d1d48b8c5f121ead2d.

Math.abs' return type in asm.js is signed, since unsigned return types are not supported in general. The document at asmjs.org/spec/latest has this update, though it's not yet in the github repository.

sunfishcode commented 10 years ago

Looking at the actual latest github repository, the update is indeed present.