-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Basic support of asm.js uglification #373
Conversation
|
||
// asm.js: don't mask module-scope names | ||
var asm = this.has_directive("use asm"), | ||
pasm = this.parent_scope ? this.parent_scope.has_directive("use asm") : false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that has_directive
returns the scope where the directive is found (so it looks into the parent scope too), therefore if the directive is specified on the parent then: this.has_directive("use asm") == this.parent_scope.has_directive("use asm");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a closer look: pasm
is set to true
only if the current scope is nested into the asm scope.
So it's false
for top-level asm scope even it has "use asm"
directive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. It's just that it's unclear to me what this whole patch does, can you explain in plain English?
My understanding is that you need to not shadow the name of the function where "use asm" is found, is that all?
Sorry, my fault. Asm.js — is a highly optimizable and restricted subset of JavaScript. For more information take a look into Wikipedia article and latest Asm.js specification. It's in heavy development now and available only in Firefox (>= 22). This patch attempts to add basic support of asm.js handling into your project as UglifyJS2 doesn't know anything about asm.js and when I feed valid asm.js code it produces invalid uglified output (though output remains valid JS code).
There is a number of issues:
Also asm.js have its own validation rules but they are out of the scope of this project since it is for general-purpose JavaScript. My patch is focused on making UglifyJS2 not to produce invalid asm.js code when valid is supplied. |
Rebased |
Up |
It would be really nice if asm.js support was provided out of the box by UglifyJS2. It can be a real stopper for automatic deployment of JS modules via |
Bump |
I am wondering why this ticket is still being open. However given the comments in the patches, I guess we need a separate maintainer for the asm module with someone who knows asm.js better (just take this as a proposal, other ideas are welcome). I am not sure if that's doable and/or its something that @mishoo wants. Comments? |
+1 -- Bump |
Just rebased my old commits with few minor modifications |
bb6cd07
to
fa69efa
Compare
This is probably outdated, so I'm closing this PR. Feel free to re-submit if you think it should be merged. |
A had a problem when trying to uglify asm.js modules in my asmcrypto.js project.
To fix that issue I added basic support: