-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Google Closure Compiler Java update #5720
Google Closure Compiler Java update #5720
Conversation
…solve some issues with newer version
…e JavaScript code inside
Fixes to externs (added File API externs).
… but don't cause everything to fail)
…ulted in corrupted JS build). More externs fixes.
Fix for `EmterpreterAsync` usage appearing in builds without `EmterpreterAsync` definition. Suppress `FUNCTION_TABLE` undefined variable. Fix for `getterReturnType` and `setterArgumentType` used while undefined (probably copy-paste typo, replaced with `rawFieldType`).
Some changes are fixes for multiple actual issues reported by Closure Compiler that are difficult to discover otherwise, like copy-paste typo here: 9b32d3e#diff-8f35bc569987bab9a3691d986d90e75fR223 |
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.
Overall this looks good, thanks! Mostly minor stuff and questions below.
emscripten.py
Outdated
@@ -1495,7 +1495,7 @@ def create_asm_start_pre(asm_setup, the_global, sending, metadata, settings): | |||
module_library = module_get.format(access=access_quote('asmLibraryArg'), val=sending) | |||
|
|||
asm_function_top = ('// EMSCRIPTEN_START_ASM\n' | |||
'var asm = (function(global, env, buffer) {') | |||
'var asm = (/** @suppress {uselessCode} */function(global, env, buffer) {') |
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.
please add a space after the */
(so it's not right on top of the function
keyword)
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.
Fixed
@@ -10,7 +10,6 @@ function intArrayFromString(stringy, dontAddNull, length) { | |||
} | |||
|
|||
// Temporarily duplicating function pending Python preprocessor support | |||
var ASSERTIONS; |
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.
Is this because we start to unconditionally print var ASSERTIONS
later down in this PR?
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.
Yes. Under some circumstances ASSERTIONS
was defined twice and Closure Compiler complained. So I've made sure it is always defined exactly once. Closure Compiler can remove it from source code later if not used at all.
@@ -2186,14 +2187,14 @@ var LibraryEmbind = { | |||
var humanName = classType.name + '.' + fieldName; | |||
var desc = { | |||
get: function() { | |||
throwUnboundTypeError('Cannot access ' + humanName + ' due to unbound types', [getterReturnType, setterArgumentType]); | |||
throwUnboundTypeError('Cannot access ' + humanName + ' due to unbound types', [rawFieldType]); |
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.
this looks like an actual change, not just fixing a closure warning? i'm not familiar enough with the embind code to know if it's valid or not, but was this intentional?
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.
Closure Compiler complained about undefined variables and I've made a change that seems appropriate (I'm not familiar with this part of the code base either). Looks like a copy-paste from few pages of code above before this place.
The lines were introduced in 1f6b09d by @chadaustin, could you confirm this is a correct fix? Anyway, this is not a main code path, so doesn't seem that critical.
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.
also cc @AlexPerrot
It might make sense to split this off into another embind-focused PR (but let's see what they say first, maybe not)
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.
This change looks fine to me. I'm a little bit surprised that this made it in there in the first place (since we had linters at the time) but who knows. :)
@@ -220,7 +221,7 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { | |||
return new Uint8Array(xhr.response); | |||
#if SUPPORT_BASE64_EMBEDDING | |||
} catch (err) { | |||
var data = tryParseAsDataURI(f); | |||
var data = tryParseAsDataURI(url); |
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.
this looks correct, but it suggests we don't have a test for this code path. @buu700, can you please look into that?
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.
Oops, sorry about the typo there. As far as the code path, it looks like to test this we would need to be combining SINGLE_FILE and/or mem init mode 0 with a Worker, and the only SINGLE_FILE-related browser test we have now is to make sure it still works without a native atob
implementation.
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.
Ahh, I just spent way too long trying to figure out what code path was hitting this. It looks like there isn't actually a code path that hits this line; the test @nazar-pc fixed must've been from Closure Compiler doing some static analysis on the output.
If that's the case, the test that failed for him is probably already the best test we're gonna get without refactoring and writing a bunch of unit tests (and/or incrementally adding more static analysis from Closure/TypeScript/Flow).
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.
Yes, Closure Compiler was complaining about the variable being undefined
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.
Got it, thanks.
tools/js-optimizer.js
Outdated
@@ -5730,12 +5730,13 @@ function safeHeap(ast) { | |||
traverseGeneratedFunctions(ast, function(func) { | |||
if (func[1] in SAFE_HEAP_FUNCS) return null; | |||
traverseGenerated(func, function(node, type) { | |||
var heap, prt; |
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.
prt => ptr
does closure even run on this file? that would surprise me but maybe I forgot something.
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.
Sorry, fixed.
I don't think closure runs here, but variables were defined twice in the same scope, so I though it is an appropriate change as I was fixing similar things in other places.
Thanks, looks good aside from the embind stuff that we are waiting to hear about. |
Great, thanks everyone. |
FYI: Seems this breaks compilation of binaryen.js: https://travis-ci.org/AssemblyScript/binaryen.js/builds/299063033#L4549
|
@dcodeIO, well, this will require a bit more externs, I'll debug it today and provide PR either for Emscripten or Binaryen. Modern Closure Compiler is much stricter to such kinds of stuff. |
This broke Closure compiler from running in Emsdk on Windows, with error
|
As agreed in #5464 this is a part of #5464 without immediate transition to JavaScript version of Closure Compiler.
This should be a smaller diff to review.
Essentially this PR updates Google Closure Compiler to latest version and introduces necessary tweaks both to externs and to source code so that Closure Compiler doesn't complain too much in advanced mode.
After merging this PR #5464 will be rebased and reduced to just Java -> JavaScript version transition.
Probably obsoletes #5109
Enables #5185 (
ECMASCRIPT5
needs to be changed toECMASCRIPT6
for this, which is trivial)UPD: Use this link to review changes ignoring whitespaces: https://github.com/kripken/emscripten/pull/5720/files?w=1