asm-js / validator

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

Math.round not supported #84

Closed sbalko closed 9 years ago

sbalko commented 10 years ago

I noticed that Math.round is not currently supported by the asm.js specification (or its implementation in Firefox, for that matter).

While I am not sure if there is any particular reason for this, I would love to have it included. Emscripten uses Math.round to implement standard library functions such as rint and others. As Math.round is not currently asm.js compliant, this lets Ionmonkey break out from asm.js mode for every Math.round call, with accompanying performance penalties (also see here: https://groups.google.com/forum/m/?fromgroups#!topic/emscripten-discuss/Cgdd3RUsLME)

Any chance to have Math.round added?

Soeren

sunfishcode commented 10 years ago

This sounds reasonable to me. Math.round's behavior of always rounding ties upward is unfortunate, but given that it's what JS has, we might as well make it available in asm.js.

kripken commented 10 years ago

cc @andhow @dherman

sunfishcode commented 9 years ago

The general way forward is to implement math functions in C code which can be compiled to asm.js by Emscripten. This now includes rint and many others, so there's no longer a major need for Math.round in asm.js. With that, and its non-standard rounding behavior, it doesn't look like it'll make sense.