Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harmony 2.8.0 #1509

Merged
merged 53 commits into from
Feb 28, 2017
Merged

Harmony 2.8.0 #1509

merged 53 commits into from
Feb 28, 2017

Conversation

alexlamsl
Copy link
Collaborator

Tests aren't passing at the moment, as this is just a "straight-forward" merge of source files.

(#1508 was created against the wrong branch. Sorry about that.)

Anat Dagan and others added 30 commits February 10, 2017 14:13
…that it is not a reserved word. This should apply to propsmangle as well.
…fiers

verify that property names after mangle are legal
remove extraneous call to AST_SymbolRef.reference()

closes mishoo#1443
happens when inner function:
- just below top level
- not referenced
- `unused` is disabled

closes mishoo#1445
move out of unsafe, guard corner case with screw_id8 instead

closes mishoo#1446
- assign statement does not count towards variable usage by default
- only works with assignments on the same scope level as declaration
- can be disabled with `unused` set to "keep_assign"
- `toplevel` to drop unused top-level variables and/or functions
- `top_retain` to whitelist top-level exceptions

closes mishoo#1450
fixes
- [a].join() => "" + a
- ["a", , "b"].join() => "a,,b"
- ["a", null, "b"].join() => "a,,b"
- ["a", undefined, "b"].join() => "a,,b"

improvements
- ["a", "b"].join(null) => "anullb"
- ["a", "b"].join(undefined) => "a,b"
- [a + "b", c].join("") => a + "b" + c

closes mishoo#1453
- `do{...}while(false)` => `{...}`
- clean up `AST_While` logic

closes mishoo#1452
N = 2:
  a;
  b;
  c;
  d;
was:
  a, b;
  c;
  d;
now:
  a, b;
  c, d;

fixes mishoo#1455
closes mishoo#1457
shuffle associative operations to minimise parentheses and aid other uglification efforts

closes mishoo#1454
- remove extra tree scanning phase for `negate_iife`
- `negate_iife` now only deals with the narrowest form, i.e. IIFE sitting directly under `AST_SimpleStatement`
- `booleans`, `conditionals` etc. will now take care the rest via more accurate accounting
- `a(); void b();` => `a(); b();`

fixes mishoo#1288
closes mishoo#1451
previously test cases with the same name would be skipped except for the last one

`test/run-test.js` will now report duplicated names as errors

closes mishoo#1461
- utilise in_use_ids instead of unreferenced()
- drop_unused now up-to-date for subsequent passes

closes mishoo#1476
- update modified flag between compress() passes
- support IIFE arguments
- fix corner case with multiple definitions

closes mishoo#1473
fix invalid boolean conversion now exposed in `make_node_from_constant()`

closes mishoo#1477
- support arrays, objects & AST_Node
- support `"a.b":1` on both cli & API
- emit warning if variable is modified
- override top-level variables

fixes mishoo#1416
closes mishoo#1198
closes mishoo#1469
- `test/benchmark.js` measures performance
- `test/jetstream.js` verifies correctness
- configurable mangle/compress/output options

closes mishoo#1479
reduce whitespaces from if-else statements

fixes mishoo#1482
closes mishoo#1483
- `Array.prototype.slice` => `[].slice`

closes mishoo#1491
- never exceed specified limit
- otherwise warning is shown
- enabled only for final output

closes mishoo#1496
- only drops side-effect-free arguments
- drop side-effect-free parts with discarded value from `AST_Seq` & `AST_SimpleStatement`

closes mishoo#1494
A function call or IIFE with an immediately preceding comment
containing `@__PURE__` or `#__PURE__` is deemed to be a
side-effect-free pure function call and can potentially be
dropped.

Depends on `side_effects` option.

`[#@]__PURE__` hint will be removed from comment when pure
call is dropped.

fixes mishoo#1261
closes mishoo#1448
- fix corner cases in `const` optimisation
- deprecate `/*@const*/`

fixes mishoo#1497
closes mishoo#1498
@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

master:

$ echo 'var a = /*#__PURE__*/(function(){return 1})();' | bin/uglifyjs -c
var a=function(){return 1}();

#1509 including patch:

$ echo 'var a = /*#__PURE__*/(function(){return 1})();' | bin/uglifyjs -c
WARN: Dropping __PURE__ call [-:1,21]
var a=function(){return 1}();

Ideas?

@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

The real question is why didn't master also report the false positive?

@alexlamsl
Copy link
Collaborator Author

@kzc I did the commit all on my mobile phone, so I'm afraid I can't debug any further atm.

Let's me get back to you in a couple of hours when I'm back at my desk.

@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

On master has_pure_annotation() is not called for:

$ echo 'var a = /*#__PURE__*/(function(){return 1})();' | bin/uglifyjs -c --comments=all
var a=/*#__PURE__*/function(){return 1}();

whereas this harmony PR does call it:

$ echo 'var a = /*#__PURE__*/(function(){return 1})();' | bin/uglifyjs -c --comments=all 
WARN: Dropping __PURE__ call [-:1,21]
var a=/* */function(){return 1}();

so your original concern about false positive warnings was well founded.

I know this is a cop out, but we can drop the warning altogether on both master and harmony. The output is still correct on harmony. It just appears that this harmony PR indirectly calls has_pure_annotation() for whatever reason - thus triggering the false positive warning, while master does not.

Edit:

Note: in spite of the #__PURE__ comment being dropped in the false positive warning case, AST_Call.pure would still be set to true, so the compress code will function correctly.

@alexlamsl
Copy link
Collaborator Author

@kzc sounds like a reasonable workaround. I'll give it some more thoughts while getting stuck on the metro.

@alexlamsl
Copy link
Collaborator Author

The one thing that made me feel uneasy is the indiscriminate elimination of @__PURE__ in the comments, regardless of whether the IIFE is dropped.

I can cleanly report the warning within drop_side_effect_free(), so one plan of attack is to convert existing sites which checks for has_side_effects() for the purpose of wholesome elimination to use the aforementioned method. Now I wish I can get home sooner!

alexlamsl and others added 3 commits February 28, 2017 02:25
- consolidate `side-effects` optimisations
- improve string `+` optimisation
- enhance literal & `conditionals` optimisations
@alexlamsl
Copy link
Collaborator Author

@kzc a0eaff7 corresponds to #1510 (comment)

@alexlamsl
Copy link
Collaborator Author

#1493 now exposes a bug with AST_ObjectProperty.key.start.pos on harmony

update exception messages
@alexlamsl
Copy link
Collaborator Author

The only other test failure left is to do with -source-map-inline giving slightly different content

master

{
  "version":3,
  "sources":[
    "test/input/issue-1323/sample.js"
  ],
  "names":[
    "bar",
    "foo"
  ],
  "mappings":"AAAA,GAAIA,KAAO,WACP,QAASC,KAAKD,KACV,MAAOA,KAGX,MAAOC"
}

This PR

{
  "version":3,
  "sources":[
    "test/input/issue-1323/sample.js"
  ],
  "names":[
    "bar",
    "foo"
  ],
  "mappings":"AAAA,GAAIA,KAAM,WACN,QAASC,KAAKD,KACV,MAAOA,KAGX,MAAOC"
}

@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

#1493 now exposes a bug with AST_ObjectProperty.key.start.pos on harmony

That's minor. Can the test simply be if(0)'d out on the harmony branch with a comment?

@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

Regarding the ---source-map-inline failure, has the output changed due to compress improvements and/or differences?

@kzc
Copy link
Contributor

kzc commented Feb 27, 2017

@alexlamsl Looks like you've made really good progress. The remaining test failures are related to wrong start/end positions of AST_Nodes it appears. I guess there were harmony parser changes that inadvertently dropped this info.

@alexlamsl
Copy link
Collaborator Author

Ah, so it was broken before, but b7bb706 then broke the test output instead of fixing the parser.

Restoring sourceMappingURL to the same as master and the test now passes.

not sure if `start.pos` is correct, but oh well
@alexlamsl
Copy link
Collaborator Author

All tests passed now 💯

@alexlamsl
Copy link
Collaborator Author

@avdg @kzc PTAL

@alexlamsl alexlamsl changed the title [WIP] Harmony 2.8.0 Harmony 2.8.0 Feb 28, 2017
@kzc
Copy link
Contributor

kzc commented Feb 28, 2017

@alexlamsl Congrats on the 2.8.0 releases.

@kzc
Copy link
Contributor

kzc commented Feb 28, 2017

I assumed this PR was merged already. :-)

Looks good to merge with a harmony-v2.8.0 tag.

@alexlamsl alexlamsl merged commit 514fc68 into mishoo:harmony Feb 28, 2017
@alexlamsl alexlamsl deleted the harmony-2.8.0 branch February 28, 2017 15:14
@avdg
Copy link
Contributor

avdg commented Mar 2, 2017

Too much to review on my side, sorry :P

@alexlamsl
Copy link
Collaborator Author

@avdg no worries ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants