aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-23 18:18:40 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-23 18:18:40 -0700
commit4d74114a45901d8b694e1f543b0b8ff6daf10acb (patch)
treeb632a214de53d196f644ebe98e5f2c0d8430ab15
parentb49c89fd54b60b03e437367c30bf92daf4b14d6a (diff)
emit coercion on i64 math call return values
-rw-r--r--src/fastLong.js17
-rw-r--r--src/parseTools.js2
2 files changed, 10 insertions, 9 deletions
diff --git a/src/fastLong.js b/src/fastLong.js
index 95f398db..d1ce5d39 100644
--- a/src/fastLong.js
+++ b/src/fastLong.js
@@ -22,13 +22,13 @@ function ___divdi3($a$0, $a$1, $b$0, $b$1) {
$1$1 = (($a$1 | 0) < 0 ? -1 : 0) >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1;
$2$0 = $b$1 >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1;
$2$1 = (($b$1 | 0) < 0 ? -1 : 0) >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1;
- $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1);
+ $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0;
$4$1 = tempRet0;
- $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1);
+ $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0;
$7$0 = $2$0 ^ $1$0;
$7$1 = $2$1 ^ $1$1;
$8$0 = ___udivmoddi4($4$0, $4$1, $6$0, tempRet0, 0) | 0;
- $10$0 = _i64Subtract($8$0 ^ $7$0, tempRet0 ^ $7$1, $7$0, $7$1);
+ $10$0 = _i64Subtract($8$0 ^ $7$0, tempRet0 ^ $7$1, $7$0, $7$1) | 0;
return (tempRet0 = tempRet0, $10$0) | 0;
}
function ___remdi3($a$0, $a$1, $b$0, $b$1) {
@@ -44,11 +44,11 @@ function ___remdi3($a$0, $a$1, $b$0, $b$1) {
$1$1 = (($a$1 | 0) < 0 ? -1 : 0) >> 31 | (($a$1 | 0) < 0 ? -1 : 0) << 1;
$2$0 = $b$1 >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1;
$2$1 = (($b$1 | 0) < 0 ? -1 : 0) >> 31 | (($b$1 | 0) < 0 ? -1 : 0) << 1;
- $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1);
+ $4$0 = _i64Subtract($1$0 ^ $a$0, $1$1 ^ $a$1, $1$0, $1$1) | 0;
$4$1 = tempRet0;
- $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1);
+ $6$0 = _i64Subtract($2$0 ^ $b$0, $2$1 ^ $b$1, $2$0, $2$1) | 0;
___udivmoddi4($4$0, $4$1, $6$0, tempRet0, $rem);
- $10$0 = _i64Subtract(HEAP32[$rem >> 2] ^ $1$0, HEAP32[$rem + 4 >> 2] ^ $1$1, $1$0, $1$1);
+ $10$0 = _i64Subtract(HEAP32[$rem >> 2] ^ $1$0, HEAP32[$rem + 4 >> 2] ^ $1$1, $1$0, $1$1) | 0;
$10$1 = tempRet0;
STACKTOP = __stackBase__;
return (tempRet0 = $10$1, $10$0) | 0;
@@ -245,7 +245,7 @@ function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) {
} else {
$d_sroa_0_0_insert_insert99$0 = 0 | $b$0 & -1;
$d_sroa_0_0_insert_insert99$1 = $d_sroa_1_4_extract_shift$0 | $b$1 & 0;
- $137$0 = _i64Add($d_sroa_0_0_insert_insert99$0, $d_sroa_0_0_insert_insert99$1, -1, -1);
+ $137$0 = _i64Add($d_sroa_0_0_insert_insert99$0, $d_sroa_0_0_insert_insert99$1, -1, -1) | 0;
$137$1 = tempRet0;
$q_sroa_1_1198 = $q_sroa_1_1_ph;
$q_sroa_0_1199 = $q_sroa_0_1_ph;
@@ -262,7 +262,7 @@ function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) {
$150$1 = tempRet0;
$151$0 = $150$1 >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1;
$152 = $151$0 & 1;
- $154$0 = _i64Subtract($r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1, $151$0 & $d_sroa_0_0_insert_insert99$0, ((($150$1 | 0) < 0 ? -1 : 0) >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1) & $d_sroa_0_0_insert_insert99$1);
+ $154$0 = _i64Subtract($r_sroa_0_0_insert_insert42$0, $r_sroa_0_0_insert_insert42$1, $151$0 & $d_sroa_0_0_insert_insert99$0, ((($150$1 | 0) < 0 ? -1 : 0) >> 31 | (($150$1 | 0) < 0 ? -1 : 0) << 1) & $d_sroa_0_0_insert_insert99$1) | 0;
$r_sroa_0_0_extract_trunc = $154$0;
$r_sroa_1_4_extract_trunc = tempRet0;
$155 = $sr_1202 - 1 | 0;
@@ -296,3 +296,4 @@ function ___udivmoddi4($a$0, $a$1, $b$0, $b$1, $rem) {
return (tempRet0 = $_0$1, $_0$0) | 0;
}
// =======================================================================
+
diff --git a/src/parseTools.js b/src/parseTools.js
index 8347a929..f4ce12d5 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -2000,7 +2000,7 @@ function processMathop(item) {
}
function preciseCall(name) {
Types.preciseI64MathUsed = true;
- return finish([name + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + ')', 'tempRet0']);
+ return finish([asmCoercion(name + '(' + low1 + ',' + high1 + ',' + low2 + ',' + high2 + ')', 'i32'), 'tempRet0']);
}
function i64PreciseLib(type) {
return preciseCall('_i64' + type[0].toUpperCase() + type.substr(1));