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

fix output of imported AST #2771

Merged
merged 1 commit into from
Jan 11, 2018
Merged

fix output of imported AST #2771

merged 1 commit into from
Jan 11, 2018

Conversation

alexlamsl
Copy link
Collaborator

@alexlamsl alexlamsl commented Jan 11, 2018

Discovered by test/mozilla-ast.js

For ease of review: https://github.com/mishoo/UglifyJS2/pull/2771/files?w=1

@alexlamsl
Copy link
Collaborator Author

(OT) Woah AppVeyor...:exclamation:

[00:22:25]   1) spidermonkey export/import sanity test should produce a functional build when using --self with spidermonkey:
[00:22:25]      Uncaught Command failed: "C:\Program Files (x86)\nodejs\node.exe" bin/uglifyjs --self -cm --wrap SpiderUglify -o spidermonkey | "C:\Program Files (x86)\nodejs\node.exe" bin/uglifyjs -p spidermonkey -cm
[00:22:25] events.js:141
[00:22:25]       throw er; // Unhandled 'error' event
[00:22:25]       ^
[00:22:25] 
[00:22:25] Error: write UNKNOWN
[00:22:25]     at exports._errnoException (util.js:907:11)
[00:22:25]     at Socket._writeGeneric (net.js:702:26)
[00:22:25]     at Socket._write (net.js:721:8)
[00:22:25]     at doWrite (_stream_writable.js:301:12)
[00:22:25]     at writeOrBuffer (_stream_writable.js:287:5)
[00:22:25]     at Socket.Writable.write (_stream_writable.js:215:11)
[00:22:25]     at Socket.write (net.js:648:40)
[00:22:25]     at print (C:\projects\uglifyjs2\bin\uglifyjs:398:20)
[00:22:25]     at run (C:\projects\uglifyjs2\bin\uglifyjs:242:9)
[00:22:25]     at Object.<anonymous> (C:\projects\uglifyjs2\bin\uglifyjs:149:5)
[00:22:25] ERROR: Unexpected end of input
[00:22:25]     at Object.parse (native)
[00:22:25]     at C:\projects\uglifyjs2\bin\uglifyjs:188:36
[00:22:25]     at Array.reduce (native)
[00:22:25]     at convert_ast (C:\projects\uglifyjs2\bin\uglifyjs:168:66)
[00:22:25]     at run (C:\projects\uglifyjs2\bin\uglifyjs:187:25)
[00:22:25]     at Socket.<anonymous> (C:\projects\uglifyjs2\bin\uglifyjs:162:9)
[00:22:25]     at emitNone (events.js:72:20)
[00:22:25]     at Socket.emit (events.js:166:7)
[00:22:25]     at endReadableNT (_stream_readable.js:923:12)
[00:22:25]     at nextTickCallbackWith2Args (node.js:511:9)
[00:22:25] 
[00:22:25]   Error: Command failed: "C:\Program Files (x86)\nodejs\node.exe" bin/uglifyjs --self -cm --wrap SpiderUglify -o spidermonkey | "C:\Program Files (x86)\nodejs\node.exe" bin/uglifyjs -p spidermonkey -cm
[00:22:25]   events.js:141
[00:22:25]   
[00:22:25]         throw er; // Unhandled 'error' event
[00:22:25]   
[00:22:25]         ^
[00:22:25]   
[00:22:25]   
[00:22:25]   
[00:22:25]   Error: write UNKNOWN
[00:22:25]   
[00:22:25]       at exports._errnoException (util.js:907:11)
[00:22:25]   
[00:22:25]       at Socket._writeGeneric (net.js:702:26)
[00:22:25]   
[00:22:25]       at Socket._write (net.js:721:8)
[00:22:25]   
[00:22:25]       at doWrite (_stream_writable.js:301:12)
[00:22:25]   
[00:22:25]       at writeOrBuffer (_stream_writable.js:287:5)
[00:22:25]   
[00:22:25]       at Socket.Writable.write (_stream_writable.js:215:11)
[00:22:25]   
[00:22:25]       at Socket.write (net.js:648:40)
[00:22:25]   
[00:22:25]       at print (C:\projects\uglifyjs2\bin\uglifyjs:398:20)
[00:22:25]   
[00:22:25]       at run (C:\projects\uglifyjs2\bin\uglifyjs:242:9)
[00:22:25]   
[00:22:25]       at Object.<anonymous> (C:\projects\uglifyjs2\bin\uglifyjs:149:5)
[00:22:25]   
[00:22:25]   ERROR: Unexpected end of input
[00:22:25]       at Object.parse (native)
[00:22:25]       at bin\uglifyjs:188:36
[00:22:25]       at Array.reduce (native)
[00:22:25]       at convert_ast (bin\uglifyjs:168:66)
[00:22:25]       at run (bin\uglifyjs:187:25)
[00:22:25]       at Socket.<anonymous> (bin\uglifyjs:162:9)
[00:22:25]       at endReadableNT (_stream_readable.js:923:12)
[00:22:25]   
[00:22:25]       at ChildProcess.exithandler (child_process.js:200:12)
[00:22:25]       at maybeClose (internal/child_process.js:862:16)
[00:22:25]       at Process.ChildProcess._handle.onexit (internal/child_process.js:222:5)
[00:22:25] 
[00:22:25] 
[00:22:25] 
[00:22:25] npm ERR! Test failed.  See above for more details.
[00:22:25] Command exited with code 1

@alexlamsl
Copy link
Collaborator Author

... and this one is on GitHub:

[00:00:00] Build started
[00:00:00] git clone -q --branch=master https://github.com/mishoo/UglifyJS2.git C:\projects\uglifyjs2
[00:00:03] git checkout -qf b757450cd8e6c5f9fc766673a4ef9f32060703d7
[00:00:03] The build phase is set to "MSBuild" mode (default), but no Visual Studio project or solution files were found in the root directory. If you are not building Visual Studio project switch build mode to "Script" and provide your custom build command.

@alexlamsl
Copy link
Collaborator Author

alexlamsl commented Jan 11, 2018

Meanwhile, Travis CI timed-out on Node.js 0.10

3883 uglifyjs Octane2/base.js -mc keep_fargs=false,passes=3,pure_getters,unsafe,unsafe_comps,unsafe_math,unsafe_proto -b beautify=false,webkit --timings
3884 - parse: 0.232s
3885 - rename: 0.074s
3886 - compress: 1.548s
3887 - scope: 0.006s
3888 - mangle: 0.123s
3889 - properties: 0.000s
3890 - output: 0.063s
3891 - total: 2.046s
3892
3893
3894
3895 The job exceeded the maximum time limit for jobs, and has been terminated.

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

#2771 (comment) - related to removal of setBlocking on stdout/stderr in #2741?

@alexlamsl
Copy link
Collaborator Author

#2771 (comment) - related to removal of setBlocking on stdout/stderr in #2741?

If that's the case I'd expect it to fail more regularly - full log for that job:
https://ci.appveyor.com/api/buildjobs/qu9u7884q6h71xtr/log

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

acorn@5 added support for ESTree Directives.

But it appears to be backwards compatible and uglify handles the ESTree round trip...

$ echo '"use strict"; function f(){ "use strict"; "use asm"; }' | bin/uglifyjs -p acorn -o spidermonkey | bin/uglifyjs -p spidermonkey -b
"use strict";

function f() {
    "use strict";
    "use asm";
}
$ echo '"use strict"; function f(){ "use strict"; "use asm"; }' | node_modules/.bin/acorn | bin/uglifyjs -p spidermonkey -b
"use strict";

function f() {
    "use strict";
    "use asm";
}

@alexlamsl
Copy link
Collaborator Author

Just to confirm - it only presents an issue if somebody sends us an ESTree to parse that contains that new node type?

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

If that's the case I'd expect it to fail more regularly

The node stdout/stderr buffer bug is timing/load dependent. If downstream process can keep up with 64K buffering on Linux all appears well.

@alexlamsl
Copy link
Collaborator Author

The node stdout/stderr buffer bug is timing/load dependent. If downstream process can keep up with 64K buffering on Linux all appears well.

Understood - I'm assuming there will be more instances of failure. So far I've only seen it once from AppVeyor (Windows) and none from Travis CI (Linux), but I shall keep an eye out.

@alexlamsl
Copy link
Collaborator Author

IIRC mandreel.js from test/jetstream.js pretty large, so should also help to trigger any stream-related bugs.

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

Just to confirm - it only presents an issue if somebody sends us an ESTree to parse that contains that new node type?

#2771 (comment) tested new ESTree input.

I suppose uglify could emit the new ESTree directive property in AST_Node.to_mozilla_ast without ill effects. Or we could just leave it as is until someone inquires about it.

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

So far I've only seen it once from AppVeyor (Windows) and none from Travis CI (Linux),

I didn't realize the failure was only seen on Windows. That node subsystem is completely different than the UNIX implementation - and still is blocking as far as I know.

@alexlamsl
Copy link
Collaborator Author

Sorry for missing that second example which feeds directly from acorn - though it does not seem to generate said new node type:

$ echo '"use strict"; function f(){ "use strict"; "use asm"; }' | acorn
{
  "type": "Program",
  "start": 0,
  "end": 57,
  "body": [
    {
      "type": "ExpressionStatement",
      "start": 0,
      "end": 13,
      "expression": {
        "type": "Literal",
        "start": 0,
        "end": 12,
        "value": "use strict",
        "raw": "'use strict'"
      },
      "directive": "use strict"
    },
    {
      "type": "FunctionDeclaration",
      "start": 14,
      "end": 54,
      "id": {
        "type": "Identifier",
        "start": 23,
        "end": 24,
        "name": "f"
      },
      "generator": false,
      "expression": false,
      "params": [],
      "body": {
        "type": "BlockStatement",
        "start": 26,
        "end": 54,
        "body": [
          {
            "type": "ExpressionStatement",
            "start": 28,
            "end": 41,
            "expression": {
              "type": "Literal",
              "start": 28,
              "end": 40,
              "value": "use strict",
              "raw": "'use strict'"
            },
            "directive": "use strict"
          },
          {
            "type": "ExpressionStatement",
            "start": 42,
            "end": 52,
            "expression": {
              "type": "Literal",
              "start": 42,
              "end": 51,
              "value": "use asm",
              "raw": "'use asm'"
            },
            "directive": "use asm"
          }
        ]
      }
    }
  ],
  "sourceType": "script"
}

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

It's there - see last line:

          {
            "type": "ExpressionStatement",
            "start": 28,
            "end": 41,
            "expression": {
              "type": "Literal",
              "start": 28,
              "end": 40,
              "value": "use strict",
              "raw": "'use strict'"
            },
            "directive": "use strict"
          },

It's redundant as far as uglify parsing is concerned - it is handled via different means.

@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

Just to be clear, only this line was added for each of the "use strict" and "use asm" directives:

            "directive": "use strict"

@alexlamsl
Copy link
Collaborator Author

I see - thanks for the clarification 👍

@alexlamsl alexlamsl merged commit 6a696d0 into mishoo:master Jan 11, 2018
@alexlamsl alexlamsl deleted the mozilla-ast branch January 11, 2018 17:05
@kzc
Copy link
Contributor

kzc commented Jan 11, 2018

Uglify would be more robust if it continued to ignore the new directive property in AST_Node.from_mozilla_ast. Although it could be emitted in AST_Directive.to_mozilla_ast.

@alexlamsl
Copy link
Collaborator Author

I'll leave that to whoever uses ESTree - there's also work to be done on uglify-es on that front 👻

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.

2 participants