aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-29 09:43:53 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:19 -0800
commit9c983423f5dabf81cf4cb552e0211b8938ed3c54 (patch)
tree00aeba3f662fdf13fc3d29dcb6ac86f563539124 /src
parentd618e974df0f4cffe955da1cd3d9657ef91fc481 (diff)
explicit asm.js float-to-int conversion
Diffstat (limited to 'src')
-rw-r--r--src/parseTools.js4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 4e1833ae..0a86abc1 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1623,6 +1623,10 @@ function makeSignOp(value, type, op, force, ignore) {
function makeRounding(value, bits, signed, floatConversion) {
// TODO: handle roundings of i64s
assert(bits);
+ if (ASM_JS && floatConversion && bits <= 32) {
+ return '(~~(' + value + '))'; // explicit float-to-int conversion
+ }
+
// C rounds to 0 (-5.5 to -5, +5.5 to 5), while JS has no direct way to do that.
if (bits <= 32 && signed) return '((' + value + ')&-1)'; // This is fast and even correct, for all cases. Note that it is the same
// as |0, but &-1 hints to the js optimizer that this is a rounding correction