diff options
-rw-r--r-- | tools/js-optimizer.js | 9 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-relocate-output.js | 8 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-relocate.js | 10 |
3 files changed, 14 insertions, 13 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 0e3a21f3..2c0a2b88 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2742,8 +2742,9 @@ function relocate(ast) { assert(asm); // we also assume we are normalized var replacements = extraInfo.replacements; - var fBase = extraInfo.fBase; + var fBases = extraInfo.fBases; var hBase = extraInfo.hBase; + var m; traverse(ast, function(node, type) { switch(type) { @@ -2755,10 +2756,10 @@ function relocate(ast) { case 'binary': { if (node[1] == '+' && node[2][0] == 'name') { var base = null; - if (node[2][1] == 'F_BASE') { - base = fBase; - } else if (node[2][1] == 'H_BASE') { + if (node[2][1] == 'H_BASE') { base = hBase; + } else if (m = /^F_BASE_(\w+)$/.exec(node[2][1])) { + base = fBases[m[1]]; } if (base !== null) { var other = node[3]; diff --git a/tools/test-js-optimizer-asm-relocate-output.js b/tools/test-js-optimizer-asm-relocate-output.js index 6a197e81..2f999c6e 100644 --- a/tools/test-js-optimizer-asm-relocate-output.js +++ b/tools/test-js-optimizer-asm-relocate-output.js @@ -1,9 +1,9 @@ function leaveMeAlone(c) {} function fixed(a, b) {} function a(x, y) { - fixed(34, 12); - fixed(34 | 0, 12 | 0); - leaveMeAlone(10 + x, 33 + y); - leaveMeAlone(10 + x | 0, 33 + y | 0); + fixed(34, 4); + fixed(34 | 0, 102 | 0); + leaveMeAlone(2 + x, 33 + y); + leaveMeAlone(20 + x | 0, 33 + y | 0); } diff --git a/tools/test-js-optimizer-asm-relocate.js b/tools/test-js-optimizer-asm-relocate.js index a45bc2f0..cf823205 100644 --- a/tools/test-js-optimizer-asm-relocate.js +++ b/tools/test-js-optimizer-asm-relocate.js @@ -3,10 +3,10 @@ function leaveMeAlone(c) { function replaceMe(a, b) { } function a(x, y) { - replaceMe(H_BASE + 1, F_BASE + 2); - replaceMe(H_BASE + 1 | 0, F_BASE + 2 | 0); - leaveMeAlone(F_BASE + x, H_BASE + y); - leaveMeAlone(F_BASE + x | 0, H_BASE + y | 0); + replaceMe(H_BASE + 1, F_BASE_vii + 2); + replaceMe(H_BASE + 1 | 0, F_BASE_vi + 2 | 0); + leaveMeAlone(F_BASE_vii + x, H_BASE + y); + leaveMeAlone(F_BASE_v + x | 0, H_BASE + y | 0); } // EMSCRIPTEN_GENERATED_FUNCTIONS -// EXTRA_INFO: { "replacements": { "replaceMe": "fixed" }, "hBase": 33, "fBase": 10 } +// EXTRA_INFO: { "replacements": { "replaceMe": "fixed" }, "hBase": 33, "fBases": { "vii": 2, "vi": 100, "v": 20 } } |