aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-11 19:14:28 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-11 19:14:28 -0800
commit8a4fdd5adc853ff0332daca63268349c02910dd8 (patch)
tree755904cb3c682dbca47b1143a23df8a3672d8b97
parent9edafa0105fb440e9128d02a192fe375910bba63 (diff)
correct sign when casting int to double in asm
-rw-r--r--src/parseTools.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 43319859..8d6115b8 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1014,11 +1014,18 @@ function asmInitializer(type, impl) {
}
}
-function asmCoercion(value, type) {
+function asmCoercion(value, type, signedness) {
if (!ASM_JS) return value;
if (type == 'void') {
return value;
} else if (type in Runtime.FLOAT_TYPES) {
+ if (signedness) {
+ if (signedness == 'u') {
+ value = '(' + value + ')>>>0';
+ } else {
+ value = '(' + value + ')|0';
+ }
+ }
return '(+(' + value + '))';
} else {
return '((' + value + ')|0)';
@@ -2081,7 +2088,7 @@ function processMathop(item) {
case 'fdiv': return getFastValue(idents[0], '/', idents[1], item.type);
case 'fmul': return getFastValue(idents[0], '*', idents[1], item.type);
case 'frem': return getFastValue(idents[0], '%', idents[1], item.type);
- case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double');
+ case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double', op[0]);
case 'fptoui': case 'fptosi': return makeRounding(idents[0], bitsLeft, op === 'fptosi', true);
// TODO: We sometimes generate false instead of 0, etc., in the *cmps. It seemed slightly faster before, but worth rechecking