-
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
Allow certain ES6 constructs in internal JS code #15763
Conversation
let
, const
and =>
(arrow functions) in internal JS coded743ca4
to
adc04c2
Compare
99827f4
to
0346d1c
Compare
fda7f44
to
e3ec290
Compare
2518eee
to
3213444
Compare
I ran into this issue when working on #15763. We have code interally that converts `=-1` to `=0x7FFFFFFF` for the MIN_XX_VERSION settings. However, this was then being interpreted interally as a string. When read from JS there is no differenence but from python code the value of this setting would appear as the string "0x7FFFFFFF" and not the number 0x7FFFFFFF.
I ran into this issue when working on #15763. We have code interally that converts `=-1` to `=0x7FFFFFFF` for the MIN_XX_VERSION settings. However, this was then being interpreted interally as a string. When read from JS there is no differenence but from python code the value of this setting would appear as the string "0x7FFFFFFF" and not the number 0x7FFFFFFF.
I ran into this issue when working on #15763. We have code interally that converts `=-1` to `=0x7FFFFFFF` for the MIN_XX_VERSION settings. However, this was then being interpreted interally as a string. When read from JS there is no differenence but from python code the value of this setting would appear as the string "0x7FFFFFFF" and not the number 0x7FFFFFFF.
3213444
to
af6ba01
Compare
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 had some comments about using closure here (speed etc.), but I don't see them here. Was that in another PR? Is this the right one to discuss closure in?
I ran into this issue when working on #15763. We have code interally that converts `=-1` to `=0x7FFFFFFF` for the MIN_XX_VERSION settings. However, this was then being interpreted interally as a string. When read from JS there is no differenence but from python code the value of this setting would appear as the string "0x7FFFFFFF" and not the number 0x7FFFFFFF.
af6ba01
to
1a9d0b5
Compare
Your question about performace was in the followup PR: #15764 (review), but this is the right issue in which to discuss since this is PR which will start enabling it by default for those that target older browsers. I will do some measurements. |
I measured the performance of emcc with Without measured the performance of using emcc as linker in 3 modes. The base case of
So, in general I think is safe to say that transpiling is less have have the cost of full closure. These are also the absolute worse case.. its hard to imagine real project using |
I ran the same test without INCLUDE_FULL_LIBRARY to get results for a more typical JS output size (125k):
So I think we have some evidence that supporting older browsers will slow down the links by between 2 and 3 times. |
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.
Thanks for the measurements! Very useful info.
I think an extra ~1 second during link is acceptable if supporting legacy browsers is a rare case, since we get significant benefits in return thanks to this (smaller code size in general).
I wish we had good data for how rare this is in practice among our users. Hard to get a representative sample, of course, so I don't have any good ideas here. But hopefully not many support legacy browsers in practice, and this is off by default. Also these requirements are higher than the requirements for wasm, in fact, so this would only just affect wasm2js users. Btw, do you know how many of our tests would get slower here? I think almost none, since we hardly test LEGACY_VM_SUPPORT
or MIN_*_VERSION
.
lgtm aside from tests.
1a9d0b5
to
9aa4ade
Compare
Added more testing including |
08645c4
to
08dbd6b
Compare
I investigated the transpiration of let and const and arrow functions and they looks like they to the obvious and minimal thing. |
cff7c8d
to
fe16954
Compare
With this change we allow these features by default. If a user explicitly opts into older browser support we trigger the running of closure compiler with `--language_out ES5 --compilation_level WHITESPACE_ONLY`. For most users this will be a code size win, but otherwise a no-op. For users who need older browser support they will now have their output run though closure by default. If they want to take a care of the transpilaion process themselves rather than have emscripten to it auto-magically they can run with `--closure=0`. When we auto-magically run closure to do transpilation we generate a warning. This warning can be suppressed by add `--closure=1` to explicitly opt in, or `--closure=0` to explicitly opt out. This change in does not actually include any usage of these features and so don't include the code size benefits. Those will be part of followup PRs. Fixes: #11984
fe16954
to
bc31c66
Compare
…15771) I ran into this issue when working on emscripten-core#15763. We have code interally that converts `=-1` to `=0x7FFFFFFF` for the MIN_XX_VERSION settings. However, this was then being interpreted interally as a string. When read from JS there is no differenence but from python code the value of this setting would appear as the string "0x7FFFFFFF" and not the number 0x7FFFFFFF.
With this change we allow these features by default. If a user explicitly opts into older browser support we trigger the running of closure compiler with `--language_out ES5 --compilation_level WHITESPACE_ONLY`. For most users this will be a code size win, but otherwise a no-op. For users who need older browser support they will now have their output run though closure by default. If they want to take a care of the transpilation process themselves rather than have emscripten to it auto-magically they can run with `--closure=0`. When we auto-magically run closure to do transpilation we generate a warning. This warning can be suppressed by add `--closure=1` to explicitly opt in, or `--closure=0` to explicitly opt out. This change in does not actually include any usage of these features and so don't include the code size benefits. Those will be part of followup PRs. Fixes: emscripten-core#11984
Now that ES6 features are permitted in emscripten JS library code (see emscripten-core#15763) we can take advantage of some of them to reduce size of our output JS. This is just an initial test of using ES6 features. See: emscripten-core#11984
With this change we allow these features by default. If a user
explicitly opts into older browser support we trigger the running
of closure compiler with
--language_out ES5 --compilation_level WHITESPACE_ONLY
.For most users this will be a code size win, but otherwise a no-op.
For users who need older browser support they will now have their
output run though closure by default. If they want to take a care
of the transpilaion process themselves rather than have emscripten
to it auto-magically they can run with
--closure=0
.When we auto-magically run closure to do transpilation we generate
a warning. This warning can be suppressed by add
--closure=1
toexplicitly opt in, or
--closure=0
to explicitly opt out.This change in does not actually include any usage of these features
and so don't include the code size benefits. Those will be part of
followup PRs: #15764 #15765 #15758
Fixes: #11984