diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-02 15:22:32 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:05 -0700 |
commit | 5beb8daae49c7ef9232a658c3158ebe0d565489c (patch) | |
tree | 00debc119ca0b81720df0680c40493f1f03d08f7 /tools | |
parent | aebf1a7ba53cc744fe69f209126aea37b4eca1c7 (diff) |
do not relocate function pointers when no need to (no such table in parent)
Diffstat (limited to 'tools')
-rw-r--r-- | tools/js-optimizer.js | 3 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-relocate-output.js | 2 | ||||
-rw-r--r-- | tools/test-js-optimizer-asm-relocate.js | 2 |
3 files changed, 4 insertions, 3 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 2c0a2b88..1de06e4c 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -2759,10 +2759,11 @@ function relocate(ast) { if (node[2][1] == 'H_BASE') { base = hBase; } else if (m = /^F_BASE_(\w+)$/.exec(node[2][1])) { - base = fBases[m[1]]; + base = fBases[m[1]] || 0; // 0 if the parent has no function table for this, but the child does. so no relocation needed } if (base !== null) { var other = node[3]; + if (base === 0) return other; if (other[0] == 'num') { other[1] += base; return other; diff --git a/tools/test-js-optimizer-asm-relocate-output.js b/tools/test-js-optimizer-asm-relocate-output.js index 2f999c6e..2f8294c5 100644 --- a/tools/test-js-optimizer-asm-relocate-output.js +++ b/tools/test-js-optimizer-asm-relocate-output.js @@ -4,6 +4,6 @@ function a(x, y) { fixed(34, 4); fixed(34 | 0, 102 | 0); leaveMeAlone(2 + x, 33 + y); - leaveMeAlone(20 + x | 0, 33 + y | 0); + leaveMeAlone(x | 0, 33 + y | 0); } diff --git a/tools/test-js-optimizer-asm-relocate.js b/tools/test-js-optimizer-asm-relocate.js index cf823205..5402c9f6 100644 --- a/tools/test-js-optimizer-asm-relocate.js +++ b/tools/test-js-optimizer-asm-relocate.js @@ -6,7 +6,7 @@ function a(x, y) { 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); + leaveMeAlone(F_BASE_vUNKNOWN + x | 0, H_BASE + y | 0); } // EMSCRIPTEN_GENERATED_FUNCTIONS // EXTRA_INFO: { "replacements": { "replaceMe": "fixed" }, "hBase": 33, "fBases": { "vii": 2, "vi": 100, "v": 20 } } |