aboutsummaryrefslogtreecommitdiff
path: root/src/parseTools.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/parseTools.js')
-rw-r--r--src/parseTools.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/parseTools.js b/src/parseTools.js
index 40051e29..85e91f68 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1954,6 +1954,7 @@ function processMathop(item) {
if (item.type[0] === 'i') {
bits = parseInt(item.type.substr(1));
}
+ var bitsBefore = parseInt((item.params[0] ? item.params[0].type : item.type).substr(1)); // remove i to leave the number of bits left after this
var bitsLeft = parseInt(((item.params[1] && item.params[1].ident) ? item.params[1].ident : item.type).substr(1)); // remove i to leave the number of bits left after this operation
function integerizeBignum(value) {
@@ -2235,7 +2236,14 @@ function processMathop(item) {
}
// Note that zext has sign checking, see above. We must guard against -33 in i8 turning into -33 in i32
// then unsigning that i32... which would give something huge.
- case 'zext': case 'fpext': case 'sext': return idents[0];
+ case 'zext': {
+ if (EXPLICIT_ZEXT && bitsBefore == 1 && bitsLeft > 1) {
+ return '(' + originalIdents[0] + '?1:0)'; // explicit bool-to-int conversion, work around v8 issue 2513
+ break;
+ }
+ // otherwise, fall through
+ }
+ case 'fpext': case 'sext': return idents[0];
case 'fptrunc': return idents[0];
case 'select': return idents[0] + ' ? ' + asmEnsureFloat(idents[1], item.type) + ' : ' + asmEnsureFloat(idents[2], item.type);
case 'ptrtoint': case 'inttoptr': {