diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-02-06 16:35:51 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-02-06 16:35:51 -0800 |
commit | 91b6da47ba6aedfc34974cd8d9f7fe8f0074a4cd (patch) | |
tree | 5687948ab502692349c60975e992530b6cbde968 | |
parent | c34404474ee6aa9d1c3f368792057729837812f3 (diff) |
limit eliminator to variables with a single use, to avoid exponential growth of replacements
-rw-r--r-- | tools/eliminator/eliminator-test-output.js | 5 | ||||
-rw-r--r-- | tools/eliminator/eliminator-test.js | 4 | ||||
-rw-r--r-- | tools/eliminator/eliminator.coffee | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index 876340de..d914a5da 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -76,9 +76,8 @@ function strtok_part(b, j, f) { } } function py() { - var $7 = HEAP[HEAP[__PyThreadState_Current] + 12] + 1; - var $8 = HEAP[__PyThreadState_Current] + 12; - HEAP[$8] = $7; + var $8 = HEAP[HEAP[__PyThreadState_Current] + 12] + 1 + 12; + HEAP[$8] = 99; } function otherPy() { var $4 = HEAP[__PyThreadState_Current]; diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index 4928134a..35bed0bb 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -88,8 +88,8 @@ function py() { var $4 = HEAP[__PyThreadState_Current]; var $5 = $4 + 12; var $7 = HEAP[$5] + 1; - var $8 = $4 + 12; - HEAP[$8] = $7; + var $8 = $7 + 12; + HEAP[$8] = 99; } function otherPy() { var $4 = HEAP[__PyThreadState_Current]; diff --git a/tools/eliminator/eliminator.coffee b/tools/eliminator/eliminator.coffee index 5b8ac43f..b78a5a7e 100644 --- a/tools/eliminator/eliminator.coffee +++ b/tools/eliminator/eliminator.coffee @@ -27,7 +27,9 @@ isGenerated = (ident) -> ident in generatedFunctions # Maximum number of uses to consider a variable not worth eliminating. -MAX_USES = 3 +# The risk with using > 1 is that a variable used by another can have +# a chain that leads to exponential uses +MAX_USES = 1 # The UglifyJs code generator settings to use. GEN_OPTIONS = |