aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/parseTools.js10
-rw-r--r--src/settings.js2
2 files changed, 11 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': {
diff --git a/src/settings.js b/src/settings.js
index 26b649e0..e8e13668 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -327,6 +327,8 @@ var ASM_JS = 0; // If 1, generate code in asm.js format. XXX This is highly expe
// try this yet.
var USE_MATH_IMUL = 0; // If 1, use Math.imul when useful
+var EXPLICIT_ZEXT = 0; // If 1, generate an explicit conversion of zext i1 to i32, using ?:
+
var NECESSARY_BLOCKADDRS = []; // List of (function, block) for all block addresses that are taken.
// Compiler debugging options