-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Check full JS output for hello world #12806
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var d = Module; | ||
|
||
var e = new TextDecoder("utf8"); | ||
|
||
function f(a) { | ||
if (!a) return ""; | ||
for (var b = a + NaN, c = a; !(c >= b) && g[c]; ) ++c; | ||
return e.decode(g.subarray(a, c)); | ||
} | ||
|
||
var g, h, k; | ||
|
||
WebAssembly.instantiate(d.wasm, { | ||
a: { | ||
a: function(a) { | ||
console.log(f(a)); | ||
} | ||
} | ||
}).then((function(a) { | ||
a = a.instance.exports; | ||
k = a.e; | ||
h = a.b; | ||
var b = h.buffer; | ||
g = new Uint8Array(b); | ||
a.d(); | ||
k(); | ||
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
var b = Module; | ||
|
||
var c = new TextDecoder("utf8"); | ||
|
||
function e(a) { | ||
if (!a) return ""; | ||
for (var m = a + NaN, d = a; !(d >= m) && f[d]; ) ++d; | ||
return c.decode(f.subarray(a, d)); | ||
} | ||
|
||
var f, g; | ||
|
||
g = new function(a) { | ||
this.buffer = new ArrayBuffer(65536 * a.initial); | ||
}({ | ||
initial: 256, | ||
maximum: 256 | ||
}); | ||
|
||
var h = g.buffer; | ||
|
||
f = new Uint8Array(h); | ||
|
||
var k = { | ||
a: function(a) { | ||
console.log(e(a)); | ||
}, | ||
memory: g | ||
}, l, n = (new function() { | ||
this.exports = function instantiate(t) { | ||
function r(u) { | ||
u.set = function(v, w) { | ||
this[v] = w; | ||
}; | ||
u.get = function(v) { | ||
return this[v]; | ||
}; | ||
return u; | ||
} | ||
function s(x) { | ||
var a = Math.imul; | ||
var b = Math.fround; | ||
var c = Math.abs; | ||
var d = Math.clz32; | ||
var e = Math.min; | ||
var f = Math.max; | ||
var g = Math.floor; | ||
var h = Math.ceil; | ||
var i = Math.trunc; | ||
var j = Math.sqrt; | ||
var k = x.abort; | ||
var l = NaN; | ||
var m = Infinity; | ||
var n = x.a; | ||
function q(a, b) { | ||
a = a | 0; | ||
b = b | 0; | ||
n(1024); | ||
return 0; | ||
} | ||
function p() {} | ||
var o = r([]); | ||
return { | ||
b: o, | ||
c: p, | ||
d: q | ||
}; | ||
} | ||
return s(t); | ||
}(k); | ||
}).exports; | ||
|
||
l = n.d; | ||
|
||
f.set(new Uint8Array(b.mem), 1024); | ||
|
||
n.c(); | ||
|
||
l(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Yikes - This looks like something that could be low hanging to DCE? I wonder why Closure did not clean them.. :/
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.
@alon... What phase would we expect to clean this up? Is it something that closure should be able deal with?
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.
I believe this is inside the wasm2js output. The JS optimizer doesn't normally run on that. We usually don't run a JS minifier on compiled code, as it could be massive. But you can try
--closure 2
which I think does that.An option is to handle this in wasm2js, that is, track what is needed and emit only that. Not sure how easy it would be.
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.
But that about closure compiler itself.. .shouldn't it be able to eliminate these unused variables?
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 would be able to do it., but closure does not run on the wasm2js output - except for
--closure 2
(because, as I said, the compiled code can be massive).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.
Ah I see. Thanks. I wonder if we should be running with
--closure 2
for these minimal codesize tests? @juj?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.
Because it falls down on huge files, I don't think we recommend
--closure 2
. But it would be good to investigate that, as maybe closure has gotten faster/uses less memory now?