aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-17 18:16:06 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-17 18:16:06 -0700
commit30a363191c06f40fb988fdaa0ecb35b0c97ea236 (patch)
tree0018cb49f9588d3f0608a6e5fefb6d2090527606
parent7e8bd8bc10fa0d70913c21dd914c70db0bbc2523 (diff)
add asm coercions to ifs for outlining
-rw-r--r--tools/js-optimizer.js14
-rw-r--r--tools/test-js-optimizer-asm-outline1-output.js18
-rw-r--r--tools/test-js-optimizer-asm-outline2-output.js18
3 files changed, 25 insertions, 25 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 9de40d20..63849ac9 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3199,26 +3199,26 @@ function outline(ast) {
// read the control data at the callsite to the outlined function
if (codeInfo.hasReturn) {
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_RETURN_VOID]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_RETURN_VOID]),
[['stat', ['return']]]
));
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_RETURN_INT]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_RETURN_INT]),
[['stat', ['return', makeStackAccess(ASM_INT, asmData.controlDataStackPos)]]]
));
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_RETURN_DOUBLE]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_RETURN_DOUBLE]),
[['stat', ['return', makeStackAccess(ASM_DOUBLE, asmData.controlDataStackPos)]]]
));
}
if (codeInfo.hasBreak) {
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_BREAK]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_BREAK]),
[['stat', ['break']]]
));
if (keys(codeInfo.breaks).length > 0) {
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_BREAK_LABEL]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_BREAK_LABEL]),
[makeSwitch(makeStackAccess(ASM_INT, asmData.controlDataStackPos), keys(codeInfo.breaks).map(function(key) {
var id = codeInfo.breaks[key];
return [['num', id], [['stat', ['break', key]]]];
@@ -3228,12 +3228,12 @@ function outline(ast) {
}
if (codeInfo.hasContinue) {
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_CONTINUE]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_CONTINUE]),
[['stat', ['continue']]]
));
if (keys(codeInfo.continues).length > 0) {
reps.push(makeIf(
- makeComparison(makeStackAccess(ASM_INT, asmData.controlStackPos), '==', ['num', CONTROL_CONTINUE_LABEL]),
+ makeComparison(makeAsmCoercion(makeStackAccess(ASM_INT, asmData.controlStackPos), ASM_INT), '==', ['num', CONTROL_CONTINUE_LABEL]),
[makeSwitch(makeStackAccess(ASM_INT, asmData.controlDataStackPos), keys(codeInfo.continues).map(function(key) {
var id = codeInfo.continues[key];
return [['num', id], [['stat', ['continue', key]]]];
diff --git a/tools/test-js-optimizer-asm-outline1-output.js b/tools/test-js-optimizer-asm-outline1-output.js
index ea447ac1..74d7d1ae 100644
--- a/tools/test-js-optimizer-asm-outline1-output.js
+++ b/tools/test-js-optimizer-asm-outline1-output.js
@@ -36,15 +36,15 @@ function lin3() {
c(5);
lin3$1(sp);
lin3$0(sp);
- if (HEAP32[sp + 0 >> 2] == 5) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 5) {
STACKTOP = sp;
return;
}
- if (HEAP32[sp + 0 >> 2] == 6) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 6) {
STACKTOP = sp;
return HEAP32[sp + 8 >> 2];
}
- if (HEAP32[sp + 0 >> 2] == 7) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 7) {
STACKTOP = sp;
return HEAPF32[sp + 8 >> 2];
}
@@ -63,7 +63,7 @@ function lin4() {
c(4);
lin4$1(sp);
lin4$0(sp);
- if (HEAP32[sp + 0 >> 2] == 1) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 1) {
break;
}
}
@@ -81,7 +81,7 @@ function lin5() {
c(4);
lin5$1(sp);
lin5$0(sp);
- if (HEAP32[sp + 0 >> 2] == 3) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 3) {
continue;
}
}
@@ -102,19 +102,19 @@ function mix() {
c(7);
mix$1(sp);
mix$0(sp);
- if (HEAP32[sp + 0 >> 2] == 1) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 1) {
break;
}
- if (HEAP32[sp + 0 >> 2] == 2) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 2) {
switch (HEAP32[sp + 8 >> 2]) {
case 2:
break main;
}
}
- if (HEAP32[sp + 0 >> 2] == 3) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 3) {
continue;
}
- if (HEAP32[sp + 0 >> 2] == 4) {
+ if ((HEAP32[sp + 0 >> 2] | 0) == 4) {
switch (HEAP32[sp + 8 >> 2]) {
case 3:
continue main;
diff --git a/tools/test-js-optimizer-asm-outline2-output.js b/tools/test-js-optimizer-asm-outline2-output.js
index e8877937..fafb97c6 100644
--- a/tools/test-js-optimizer-asm-outline2-output.js
+++ b/tools/test-js-optimizer-asm-outline2-output.js
@@ -90,19 +90,19 @@ function _free($mem) {
$120 = HEAP32[sp + 184 >> 2] | 0;
$151 = HEAP32[sp + 192 >> 2] | 0;
$164 = HEAP32[sp + 200 >> 2] | 0;
- if (HEAP32[sp + 632 >> 2] == 5) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 5) {
return;
}
- if (HEAP32[sp + 632 >> 2] == 6) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 6) {
return HEAP32[sp + 640 >> 2];
}
- if (HEAP32[sp + 632 >> 2] == 7) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 7) {
return HEAPF32[sp + 640 >> 2];
}
- if (HEAP32[sp + 632 >> 2] == 1) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 1) {
break;
}
- if (HEAP32[sp + 632 >> 2] == 2) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 2) {
switch (HEAP32[sp + 640 >> 2]) {
case 2:
break L621;
@@ -189,16 +189,16 @@ function _free($mem) {
$351 = HEAP32[sp + 400 >> 2] | 0;
$364 = HEAP32[sp + 408 >> 2] | 0;
$psize_1 = HEAP32[sp + 416 >> 2] | 0;
- if (HEAP32[sp + 632 >> 2] == 5) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 5) {
return;
}
- if (HEAP32[sp + 632 >> 2] == 6) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 6) {
return HEAP32[sp + 640 >> 2];
}
- if (HEAP32[sp + 632 >> 2] == 7) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 7) {
return HEAPF32[sp + 640 >> 2];
}
- if (HEAP32[sp + 632 >> 2] == 1) {
+ if ((HEAP32[sp + 632 >> 2] | 0) == 1) {
break;
}
} else {