-
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
Leverage coalescing operators. NFC #20531
Conversation
Sigh, does that failure mean it would require Node.js update too? I'm guessing that's less likely? |
This is awesome! Can you update Normally/historically when I make this kind of change I like to land the change the bumps to browser versions and updates |
Old versions of node (just like old browser versions) should be supported via transpilation, no? |
Probably. I'm not entirely sure what this |
That makes sense, probably helps with ignoring revisions too. I'm happy to split out if the PR is looking acceptable otherwise, but first would probably need to figure out this failure. |
I'm not even sure why I'm doing this. I don't need it for my work, but this kind of large-scale refactorings is somewhat addicting 😅 |
...huh, those are some weird "bulk memory support is not enabled" failures. Especially given that it's couple of standalone tests that are failing - those that don't depend on JS. |
Just noticed the version, that's very old Node indeed. Why does that job use it instead of the one from emsdk which I believe is newer? |
c6c31a0
to
07a0a8f
Compare
Extracted in #20549. Interesting that I can observe some failures even on that innocently-looking change. |
c9ca59a
to
123905a
Compare
@sbc100 Given that other PRs were merged, why is test-node-compat still breaking on |
In my PR where I tried to do something like this I ended up doing #19772
You can test this locally be setting NODE_JS_TEST to v10.19.0. I have the following in my
Then I just uncomment the NODE_JS_TEST that I want to test with. |
Oh wow, I never saw that PR, sorry for stepping on your toes with this one. Yeah, using feature matrix for this makes sense. I could probably also include BCD syntax data in my automatic feature detection PR too. |
No worries! I half forgot about it myself.. I have so many stale PRs I loose track.
|
Did you mean to write something after that quote? |
So close... but I'm not sure what's causing it yet. That test shouldn't go via transpiling, so that's not the cause, but the only other change is usage of |
Doesn't solve the issue, but this construction in the test looks odd btw: Lines 9274 to 9275 in 5137bfc
self.assertFalse('my ' + attribute in code, 'Attribute `%s` could not be DCEd' % attribute) |
5137bfc
to
b62683d
Compare
Probably historical reasons. And using f-strings would be even better. |
Testing a bit further and comparing diffs with That's pretty unfortunate and I don't see where to go from here, other than maybe reporting issue to them. |
I don't quite understand the reason that |
settings.MIN_FIREFOX_VERSION < 79 or | ||
settings.MIN_CHROME_VERSION < 85 or | ||
settings.MIN_SAFARI_VERSION < 140000 or | ||
settings.MIN_NODE_VERSION < 160000 or |
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.
Maybe you can land this change on its own / separately?
Yeah looks like at least some of the changes cause Closure to retain variables that would be previously DCEd. Looking at the diff, those are huge chunks of SDL, WebGL and HTML5 API bindings that were previously removed. But there's nothing special about changes to those libraries in particular... |
Another offtopic, but you landed that PR with automatic CI retries on failure, right? Do you know why those flaky tests are still failing then? |
There are two mechanisms for re-trying... tests marked a However because browser tests are just generally more flakey we have a second mechanism that retries all browser tests then they fail. However, I believe the most of the failures we are seeing in the browser test suite today involve the browser crashing or otherwise becoming unresponsive.. which then results in all subsequest browser tests failing with "[no http server activity]". I don't believe any amount of re-trying will help in this case. I think we need to somehow restart the browser when this happens, but we don't currently have a mechanism for this. CC @kripken |
Slowly went through reverting bunch of files at a time and narrowed issue down to changes in just two files
Now I'm going to try and identify what exactly is "rooting" those functions and prevents them from being DCEd. |
Huh, that's... not at all the kind of changes I expected to be problematic. diff --git a/src/library_browser.js b/src/library_browser.js
index 67accc101..6e5904b1a 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -736,7 +736,7 @@ var LibraryBrowser = {
{{{ runtimeKeepalivePush() }}}
var _suffix = UTF8ToString(suffix);
- Browser.asyncPrepareDataCounter ||= 0;
+ if (!Browser.asyncPrepareDataCounter) Browser.asyncPrepareDataCounter = 0;
var name = 'prepare_data_' + (Browser.asyncPrepareDataCounter++) + '.' + _suffix;
var cname = stringToNewUTF8(name);
FS.createPreloadedFile(
diff --git a/src/library_webgl.js b/src/library_webgl.js
index b4cde3c73..6c26b45fc 100644
--- a/src/library_webgl.js
+++ b/src/library_webgl.js
@@ -231,7 +231,9 @@ for (/**@suppress{duplicate}*/var i = 0; i < {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
// cleared the stored error by a call to glGetError().
recordError: function recordError(errorCode) {
#if GL_TRACK_ERRORS
- GL.lastError ||= errorCode;
+ if (!GL.lastError) {
+ GL.lastError = errorCode;
+ }
#endif
},
// Get a new ID for a texture/buffer/etc., while keeping the table dense and Reverting just those 2 changes is enough to make test pass. This feels almost random :/ |
I little worrying.. but this change lgtm still |
Hm are you sure, despite the bloat it potentially adds? |
Should I remove the test then or? |
To be clear those changes break closure's ability to DCE other unrelated stuff? WTF! |
I think you should just revert those parts of the change. |
Somewhat related stuff (e.g. that
FWIW even without them manual verification shows that the output JS is still much larger than before this PR. It's just that it passes the specific checks in the test. |
Trying with Closure, it seems it treats those operators somewhat differently when using globals. Standalone sample: globalThis.foo = () => {
if (!GL.lastError) {
GL.lastError = errorCode;
}
};
globalThis.bar = () => {
GL.lastError ||= errorCode;
} Pretty-printed output after advanced opts: globalThis.h = function() {
GL.lastError || (GL.lastError = errorCode);
};
globalThis.g = function() {
var a;
(a = GL).lastError || (a.lastError = errorCode);
}; I think Closure is "worried" that the globals might happen to be getters on the global object, in which case they might have side effects, so they need to be stored in a separate variable first to ensure they're accessed only once when using If this assumption is correct, it would explain why the issue occurs only when accessing properties on our own I wonder if there's some way to annotate those variables as safe to access for Closure. |
This makes me wonder if we need more code size tests to catch this kind of thing.. perhaps one that does How about landing the just the functional part of this change first without that actual mass usage of the new operators? (Or perhaps just one usage). Then the large scale change can follow once we figure out the closure stuff? |
That's what the failing test does at the moment. Although maybe a size test for
Main functional part has already landed in #20549, the only remaining functional bit is transpilation versions but it's pretty tiny. I first want to see if it's possible to either annotate those few vars somehow or just revert those files in particular for now. I tried adding |
Note that this bumps minimum Chrome & Firefox versions, as well as JS version from ES2020 to ES2021. I believe this is not blocked on emscripten-core#11984 as it doesn't require Closure to emit runtime helpers. This is mostly automated with ast-grep, bunch of custom rules, and a few manual fixups. Best viewed with "ignore whitespace changes" (https://github.com/emscripten-core/emscripten/pull/20531/files) due to indentation changes and due to first commit being emscripten-core#20530. Care was taken to ensure that false-y conditions still use `||` where it might matter and only null-ish conditions use `??`.
b62683d
to
cd192bb
Compare
Ok I applied just the simple fix to those methods. Idk what to do about Closure issue in general, but since you're okay with it and the increased size of INCLUDE_FULL_LIBRARY is not covered by tests, I suppose it should be fine. |
Note that this bumps minimum engine versions that can avoid transpilation.
I believe this is not blocked on #11984 as it doesn't require Closure to emit runtime helpers.
This is mostly automated with ast-grep, bunch of custom rules, and a few manual fixups. Best viewed with "ignore whitespace changes" (https://github.com/emscripten-core/emscripten/pull/20531/files) due to indentation changes and due to first commit being #20530.
Care was taken to ensure that false-y conditions still use
||
where it might matter and only null-ish conditions use??
.