aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-07-20 21:15:29 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-20 21:15:29 -0700
commit94c3b3ce73670e928a7613228ac9049aa709ff9a (patch)
treee1264203aab930934a6dc58b84fe42a6671a2db5 /tools/js-optimizer.js
parenta5bb34ba04e1d17a59fda20f6a7e82c64f6ed6cc (diff)
allow sp to be modified in outlined code, by changing the model to where outlined code returns sp (which also parallels that we sent it as the single parameter)
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 810edd46..eec384a4 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -3144,7 +3144,7 @@ function outline(ast) {
reps.push(['stat', ['assign', true, ['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], ['name', v]]]);
}
});
- reps.push(['stat', ['call', ['name', newIdent], [['name', 'sp']]]]);
+ reps.push(['stat', ['assign', true, ['name', 'sp'], makeAsmCoercion(['call', ['name', newIdent], [['name', 'sp']]], ASM_INT)]]);
for (var v in codeInfo.writes) {
if (!(v in owned)) {
reps.push(['stat', ['assign', true, ['name', v], makeAsmCoercion(['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], getAsmType(v, asmData))]]);
@@ -3278,6 +3278,8 @@ function outline(ast) {
code.push(['stat', ['assign', true, ['sub', ['name', getAsmType(v, asmData) == ASM_INT ? 'HEAP32' : 'HEAPF32'], ['binary', '>>', ['binary', '+', ['name', 'sp'], ['num', asmData.stackPos[v]]], ['num', '2']]], ['name', v]]]);
}
}
+ // add final return of sp. the model is that we send sp as the single param, and get it back out
+ code.push(['stat', ['return', makeAsmCoercion(['name', 'sp'], ASM_INT)]]);
// finalize
var newFunc = ['defun', newIdent, ['sp'], code];
var newAsmData = { params: { sp: ASM_INT }, vars: {} };
@@ -3285,8 +3287,7 @@ function outline(ast) {
if (v != 'sp') newAsmData.vars[v] = getAsmType(v, asmData);
}
for (var v in codeInfo.writes) {
- assert(v != 'sp');
- newAsmData.vars[v] = getAsmType(v, asmData);
+ if (v != 'sp') newAsmData.vars[v] = getAsmType(v, asmData);
}
denormalizeAsm(newFunc, newAsmData);
for (var v in owned) {