Alex Lam S.L
3c74047368
implement compress option reduce_funcs ( #2466 )
...
- inline single-use function declarations as expressions when permissible
- depend on `reduce_vars`
- enabled by default
- disable for speed critical code
fixes #2464
2017-11-11 05:59:35 +08:00
Alex Lam S.L
94525d859f
fix object literal tracing in reduce_vars ( #2461 )
2017-11-10 05:47:10 +08:00
Alex Lam S.L
1127a2caf3
fix multiple nested function substitutions ( #2458 )
...
fixes #2449
2017-11-09 23:30:00 +08:00
Alex Lam S.L
4c0b0177b6
preserve function identity in reduce_vars ( #2451 )
...
fixes #2450
2017-11-08 03:28:46 +08:00
alexlamsl
e11cec1ab8
Merge branch 'master' into harmony
2017-11-07 04:30:40 +08:00
Alex Lam S.L
bbedbf4ea0
handle circular function reference gracefully ( #2446 )
...
fixes #2442
2017-11-07 02:37:23 +08:00
Alex Lam S.L
2cfb5aa7da
account for eval & with in reduce_vars ( #2441 )
...
fixes #2440
2017-11-06 16:10:57 +08:00
Alex Lam S.L
6c45101870
consolidate & enhance unused ( #2439 )
...
- defer declaration removal in `collapse_vars`
- account for `AST_SymbolFunarg` in deduplication
- private accounting for `collapse_vars`
- avoid issues with identity reference due to deep cloning
fixes #2437
2017-11-06 14:25:10 +08:00
alexlamsl
352a7de204
update tests
2017-11-05 16:48:00 +08:00
alexlamsl
df9c8dfd72
Merge branch 'master' into harmony-v3.1.7
2017-11-05 15:47:40 +08:00
Alex Lam S.L
5b4b07e9a7
extend function inlining safety checks ( #2430 )
2017-11-05 06:18:45 +08:00
Alex Lam S.L
a8aa28a7a6
consolidate single-use function reduction ( #2427 )
...
fixes #2423
2017-11-05 04:27:01 +08:00
Alex Lam S.L
c8b6f4733d
reduce this within functions ( #2421 )
...
- only replace same-scope usages
- augment `test/ufuzz.js` to test for `this`
fixes #2420
2017-11-04 00:31:37 +08:00
alexlamsl
086cb33163
Merge branch 'master' into harmony-v3.1.6
2017-10-29 13:23:39 +08:00
Alex Lam S.L
8428326ea1
enhance properties ( #2412 )
...
- trim array items only if `side_effects`
- extend to non-identifier properties
2017-10-29 04:11:26 +08:00
Alex Lam S.L
6371e2ee63
consistently reduce const safe literals ( #2411 )
...
fixes #2406
2017-10-28 11:36:44 +08:00
Alex Lam S.L
74ae16f9f8
fix unsafe reduce_vars on arrays & objects ( #2397 )
2017-10-24 22:10:36 +08:00
Alex Lam S.L
86ea38a259
enhance unsafe evaluate of arrays & objects ( #2394 )
2017-10-24 02:58:30 +08:00
Alex Lam S.L
24aa07855b
safer properties transform ( #2391 )
...
`{ a: x, b: y }.a` => `[ x, y ][0]`
- `x` cannot be function containing `this`
`[ x, y, z ][1]` => `(x, z, y)`
- only if `z` is side-effect-free
2017-10-22 20:10:13 +08:00
Alex Lam S.L
011123223b
fix unsafe escape analysis in reduce_vars ( #2387 )
2017-10-22 03:23:31 +08:00
alexlamsl
9f1c72ae28
update test
...
Sub-optimal result due to block scope.
2017-10-22 00:38:16 +08:00
alexlamsl
c60fa67827
Merge branch 'master' into harmony-v3.1.5
2017-10-22 00:35:00 +08:00
Alex Lam S.L
c927cea632
unsafe fix-ups for #2351 ( #2379 )
2017-10-21 04:08:26 +08:00
alexlamsl
d8ee2de95c
adjust tests for #2351
2017-10-16 13:24:50 +08:00
alexlamsl
58a5608b66
Merge branch 'master' into harmony-v3.1.4
2017-10-16 12:32:50 +08:00
Alex Lam S.L
eba0f93bc0
more tests for #2351 ( #2357 )
2017-10-12 02:58:25 +08:00
Alex Lam S.L
b810e2f8da
perform reduce_vars on safe literals ( #2351 )
...
- constant expression
- single reference
- same scope
- not across loop body
2017-10-09 12:25:06 +08:00
alexlamsl
744032755d
add tests for #2336 & #2337
2017-10-01 13:20:17 +08:00
alexlamsl
4fac8076b8
Merge branch 'master' into harmony-v3.1.3
2017-10-01 12:42:40 +08:00
Alex Lam S.L
dd71639264
enhance reduce_vars for AST_Accessor ( #2339 )
...
fixes #2336
2017-10-01 03:01:50 +08:00
alexlamsl
a556dd2dcb
Merge branch 'master' into harmony-v3.0.24
2017-07-08 13:12:54 +08:00
Alex Lam S.L
1ac25fc032
improve compress granularity through typeofs ( #2201 )
...
fixes #2198
2017-07-05 19:20:33 +08:00
alexlamsl
11afa816e3
Merge branch 'master' into harmony-v3.0.20
2017-06-25 16:43:44 +08:00
Alex Lam S.L
3d5bc08185
fix reduce_vars on this ( #2145 )
...
fixes #2140
2017-06-23 04:44:57 +08:00
alexlamsl
8af362ed57
Merge branch 'master' into harmony-v3.0.16
2017-06-14 17:09:30 +08:00
Alex Lam S.L
68138f2281
fix reduce_vars on AST_Arrow ( #2091 )
...
fixes #2090
2017-06-14 16:40:37 +08:00
Alex Lam S.L
3493a182b2
implement function inlining ( #2053 )
...
- empty body
- single `AST_Return`
- single `AST_SimpleStatement`
- avoid `/*#__PURE__*/`
Miscellaneous
- enhance single-use function substitution
fixes #281
2017-06-06 05:49:53 +08:00
Alex Lam S.L
540220b91b
fix AST_Function scope invariance ( #2052 )
...
improve function name hack in `run_code()`
2017-06-04 19:27:43 +08:00
alexlamsl
cd6e849555
Revert "remove support for const ( #1910 )"
...
This reverts commit c391576d52 .
2017-05-15 18:38:16 +08:00
Alex Lam S.L
3ca902258c
fix bugs with getter/setter ( #1926 )
...
- `reduce_vars`
- `side_effects`
- property access for object
- `AST_SymbolAccessor` as key names
enhance `test/ufuzz.js`
- add object getter & setter
- property assignment to setter
- avoid infinite recursion in setter
- fix & adjust assignment operators
- 50% `=`
- 25% `+=`
- 2.5% each for the rest
- avoid "Invalid array length"
- fix `console.log()`
- bypass getter
- curb recursive reference
- deprecate `-E`, always report runtime errors
2017-05-14 02:10:34 +08:00
Alex Lam S.L
c391576d52
remove support for const ( #1910 )
...
As this is not part of ES5.
2017-05-12 14:57:41 +08:00
Alex Lam S.L
ac73c5d421
avoid arguments and eval in reduce_vars ( #1924 )
...
fixes #1922
2017-05-12 12:34:55 +08:00
Alex Lam S.L
98cf95e5b5
fix test for #1865 ( #1873 )
2017-05-07 02:56:02 +08:00
Alex Lam S.L
2c7ee956fd
fix unsafe on evaluate of reduce_vars ( #1870 )
...
Determine if variables with non-constant values can escape and be modified.
fixes #1865
2017-05-06 23:18:55 +08:00
Alex Lam S.L
2cb55b2ad0
enforce toplevel on other compress options ( #1855 )
...
Respect "funcs" and "vars" properly.
fixes #1850
2017-04-30 22:52:36 +08:00
Alex Lam S.L
f05d4f7af3
improve unused ( #1832 )
...
- extract leading value with side-effects out of `var` statement
- reduce scanning of `AST_Definitions` from 3 passes to just once
2017-04-20 13:06:14 +08:00
Alex Lam S.L
5d9f1da3ab
support safe reassignments in reduce_vars ( #1823 )
...
`var a=1;a=2;x(a)` => `x(2)`
fix pre-existing issues
- reference counting on assignment
- walking of anonymous functions
- chained assignment
2017-04-18 13:38:42 +08:00
Alex Lam S.L
d1aa09c5c7
fix reduce_vars on conditionals ( #1822 )
2017-04-18 01:44:23 +08:00
Alex Lam S.L
6d5f341999
fix reduce_vars on boolean binary expressions ( #1819 )
...
Side effects of `&&` and `||` have not mattered until #1814 , which takes assignment expressions into account.
2017-04-17 17:24:29 +08:00
Alex Lam S.L
4ffb6fce76
compress duplicated variable definitions ( #1817 )
...
These are surprisingly common, as people reuse the same variable name within loops or switch branches.
2017-04-17 17:11:29 +08:00