diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-05-07 16:52:27 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-05-07 16:52:27 -0700 |
commit | e5b7fab17eccd032160a50f859b9430819e13929 (patch) | |
tree | 212be7a2e6ab0692345ef0871a2bf78f35e5c708 /tools | |
parent | 0cd8926f0f8b7076e2badcb0c6d03f680b677179 (diff) |
infer untyped variables in js-optimizer.js by origin variable's type if they are just a copy
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eliminator/asm-eliminator-test-output.js | 6 | ||||
-rw-r--r-- | tools/eliminator/asm-eliminator-test.js | 8 | ||||
-rw-r--r-- | tools/js-optimizer.js | 8 |
3 files changed, 20 insertions, 2 deletions
diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index e477c320..4cd9cbaa 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -123,4 +123,10 @@ function switchy() { continue; } } +function confuusion() { + var i = +0, j = +0; + func1(+i); + j = i; + func2(+j); +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index acc07edb..9dc71835 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -156,5 +156,11 @@ function switchy() { continue; } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label"] +function confuusion() { + var i = +0; + func1(+i); + var j = i; // add this var in the middle. should show up with right type later, auto-inferred from i's type + func2(+j); +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion"] diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index b82d23d3..3e57c096 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -1392,7 +1392,13 @@ function normalizeAsm(func) { var name = v[0]; var value = v[1]; if (!(name in data.vars)) { - data.vars[name] = detectAsmCoercion(value); + if (value[0] != 'name') { + data.vars[name] = detectAsmCoercion(value); // detect by coercion + } else { + var origin = value[1]; + assert(origin in data.vars); + data.vars[name] = data.vars[origin]; // detect by origin variable + } } } unVarify(node[1], node); |