aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/js-optimizer.js2
-rw-r--r--tools/test-js-optimizer-asm-outline1-output.js39
-rw-r--r--tools/test-js-optimizer-asm-outline1.js26
3 files changed, 66 insertions, 1 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 7989f1f4..49bc5d12 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3105,7 +3105,6 @@ function outline(ast) {
// Generate new function
if (codeInfo.hasReturn || codeInfo.hasBreak || codeInfo.hasContinue) {
// we need to capture all control flow using a top-level labeled one-time loop in the outlined function
- code = [['label', 'OL', ['do', ['num', 0], ['block', code]]]];
var breakCapturers = 0;
var continueCapturers = 0;
traverse(code, function(node, type) {
@@ -3158,6 +3157,7 @@ function outline(ast) {
continueCapturers--;
}
});
+ code = [['label', 'OL', ['do', ['num', 0], ['block', code]]]]; // do this after processing, to not confuse breakCapturers etc.
// read the control data at the callsite to the outlined function
if (codeInfo.hasReturn) {
reps.push(makeIf(
diff --git a/tools/test-js-optimizer-asm-outline1-output.js b/tools/test-js-optimizer-asm-outline1-output.js
index 0949865a..b89402c6 100644
--- a/tools/test-js-optimizer-asm-outline1-output.js
+++ b/tools/test-js-optimizer-asm-outline1-output.js
@@ -37,6 +37,20 @@ function lin3() {
}
return 20;
}
+function lin4() {
+ while (1) {
+ c(1);
+ c(2);
+ c(3);
+ c(4);
+ lin4$1(sp);
+ lin4$0(sp);
+ if (HEAP32[sp + 0 >> 2] == 1) {
+ break;
+ }
+ }
+ return 20;
+}
function lin$0(sp) {
sp = sp | 0;
c(13);
@@ -105,4 +119,29 @@ function lin3$1(sp) {
c(12);
c(13);
}
+function lin4$0(sp) {
+ sp = sp | 0;
+ OL : do {
+ c(13);
+ c(14);
+ c(15);
+ c(16);
+ c(17);
+ c(18);
+ c(19);
+ c(20);
+ HEAP32[sp + 0 >> 2] = 1, break OL;
+ } while (0);
+}
+function lin4$1(sp) {
+ sp = sp | 0;
+ c(5);
+ c(6);
+ c(7);
+ c(8);
+ c(9);
+ c(10);
+ c(11);
+ c(12);
+}
diff --git a/tools/test-js-optimizer-asm-outline1.js b/tools/test-js-optimizer-asm-outline1.js
index 9d41b727..b8c1b28f 100644
--- a/tools/test-js-optimizer-asm-outline1.js
+++ b/tools/test-js-optimizer-asm-outline1.js
@@ -70,5 +70,31 @@ function lin3() {
}
return 20;
}
+function lin4() {
+ while (1) {
+ c(1);
+ c(2);
+ c(3);
+ c(4);
+ c(5);
+ c(6);
+ c(7);
+ c(8);
+ c(9);
+ c(10);
+ c(11);
+ c(12);
+ c(13);
+ c(14);
+ c(15);
+ c(16);
+ c(17);
+ c(18);
+ c(19);
+ c(20);
+ break;
+ }
+ return 20;
+}
// EMSCRIPTEN_GENERATED_FUNCTIONS
// EXTRA_INFO: { "sizeToOutline": 30 }