Skip to content
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

Bump swc #8029

Merged
merged 28 commits into from May 17, 2022
Merged

Bump swc #8029

merged 28 commits into from May 17, 2022

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented Apr 29, 2022

Closes #7911

@mischnic mischnic marked this pull request as ready for review April 30, 2022 09:25
@devongovett
Copy link
Member

Can the unresolved_mark be used to solve issues like #7911?

@mischnic
Copy link
Member Author

mischnic commented May 6, 2022

Can the unresolved_mark be used to solve issues like #7911?

I just had the exact same thing happen with __filename not being renamed by hoist. In that case the problem was 2ad46b5, but this doesn't solve that issue, maybe we can get swc to add global_mark for that variable (I imagine this is what's happening)

Though I'm not actually sure if that commit was correct or just made things worse...

@mischnic
Copy link
Member Author

mischnic commented May 7, 2022

So it turns out that global_mark is only supposed to be set for user-defined global variables. That explains why #7911 is broken.
Unfortunately the only valid check for whether a variable is top-level is by checking in the visitor whether it's in a function/block/...

Copy link
Member

@devongovett devongovett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this ready or is the first checkbox in the description still pending?

@mischnic
Copy link
Member Author

mischnic commented May 9, 2022

This whole global_mark/global_syntax situation is still not fully resolved (which is also the problem for #7911). Maybe I can add some hacks to make it work for now

@mischnic
Copy link
Member Author

mischnic commented May 9, 2022

This should now be correct (and fix that one issue), but it introduces one extra collect_decls for everything and additionally when scope hoisting a fold with chain!(hygiene(),resolver(unresolved_mark, global_mark, config.is_type_script)) plus another collect_decls call.

So we'll want to benchmark if this makes a difference. If it's too slow, we could alternatively create a custom visitor that collects all top level variables into a set and then check against that instead of has_mark(global_mark) in hoist.

@mischnic
Copy link
Member Author

Last blocker for the tests: swc-project/swc#4608

@mischnic
Copy link
Member Author

So we'll want to benchmark if this makes a difference. If it's too slow, we could alternatively create a custom visitor that collects all top level variables

Build ak-editor is equally fast

@parcel-benchmark
Copy link

parcel-benchmark commented May 11, 2022

Benchmark Results

Kitchen Sink 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

React HackerNews ✅

Timings

Description Time Difference
Cold 10.59s -781.00ms 🚀
Cached 528.00ms -2.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.js 486.35kb +25.00b ⚠️ 5.54s -470.00ms 🚀
dist/PermalinkedComment.46b19af5.js 4.21kb +0.00b 5.54s -471.00ms 🚀
dist/UserProfile.f8cd7884.js 1.57kb +0.00b 5.54s -470.00ms 🚀
dist/NotFound.960ab92b.js 429.00b +0.00b 5.54s -471.00ms 🚀
dist/logo.c5bb83f1.png 246.00b +0.00b 5.48s -475.00ms 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.js 486.35kb +25.00b ⚠️ 5.63s -196.00ms

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.91m -29.00ms
Cached 2.94s -75.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.494dca73.js 3.33mb -751.00b 🚀 37.46s +215.00ms
dist/index.8d3be486.js 1.27mb +1.02kb ⚠️ 1.44m -779.00ms
dist/card.8ef3bfa3.js 366.77kb -30.00b 🚀 1.44m -774.00ms
dist/ConfigPanelFieldsLoader.6adc99a5.js 288.22kb -24.00b 🚀 41.28s +117.00ms
dist/EmojiPickerComponent.347f8762.js 187.30kb -10.00b 🚀 37.48s +197.00ms
dist/mobile-upload.a62de28d.js 68.25kb -31.00b 🚀 37.46s +214.00ms
dist/esm.c7dc1640.js 61.96kb +0.00b 47.35s -39.72s 🚀
dist/ElementBrowser.1c600f9b.js 57.31kb -21.00b 🚀 42.62s +74.00ms
dist/dropzone.ca6653ff.js 13.83kb -11.00b 🚀 47.35s +527.00ms
dist/pdfRenderer.9d4c17f1.js 12.17kb +1.00b ⚠️ 47.35s +527.00ms
dist/workerHasher.e50d242f.js 1.72kb +0.00b 47.35s -39.72s 🚀
dist/16.1969624f.js 1.08kb +0.00b 42.62s -4.20s 🚀
dist/16.069344b7.js 905.00b +0.00b 42.62s -4.20s 🚀
dist/simpleHasher.46d6f2e5.js 742.00b +0.00b 47.35s -39.72s 🚀
dist/index.html 240.00b +0.00b 37.48s -49.63s 🚀

Cached Bundles

Bundle Size Difference Time Difference
dist/index.32f08f28.js 3.33mb -751.00b 🚀 37.15s -458.00ms
dist/index.ad6d475a.js 1.27mb +1.02kb ⚠️ 1.46m +1.58s
dist/card.8ef3bfa3.js 366.77kb -30.00b 🚀 1.46m +1.58s
dist/ConfigPanelFieldsLoader.6adc99a5.js 288.22kb -24.00b 🚀 40.91s -616.00ms
dist/EmojiPickerComponent.347f8762.js 187.30kb -10.00b 🚀 37.19s -456.00ms
dist/mobile-upload.a62de28d.js 68.25kb -31.00b 🚀 37.15s -458.00ms
dist/esm.c7dc1640.js 61.96kb +0.00b 46.90s -39.02s 🚀
dist/ElementBrowser.1c600f9b.js 57.31kb -21.00b 🚀 42.26s -587.00ms
dist/dropzone.ca6653ff.js 13.83kb -11.00b 🚀 46.91s +19.00ms
dist/pdfRenderer.9d4c17f1.js 12.17kb +1.00b ⚠️ 46.90s +18.00ms
dist/workerHasher.e50d242f.js 1.72kb +0.00b 46.90s -39.02s 🚀
dist/16.1969624f.js 1.08kb +0.00b 42.26s -4.62s 🚀
dist/index.html 240.00b +0.00b 40.91s -45.05s 🚀

Three.js ✅

Timings

Description Time Difference
Cold 7.86s +136.00ms
Cached 345.00ms +18.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/Three.js 580.03kb +13.00b ⚠️ 5.59s +86.00ms

Cached Bundles

Bundle Size Difference Time Difference
dist/Three.js 580.03kb +13.00b ⚠️ 5.89s +217.00ms

Click here to view a detailed benchmark overview.

@mischnic mischnic requested a review from devongovett May 11, 2022 20:46
hygiene(),
resolver(unresolved_mark, global_mark, false)
));
(collect_decls(&module), module)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if the node replacements pass doesn't run we do this twice in a row? Also, are there more cases where these extra passes can be skipped (e.g. if no preset-env)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made our replacement passes use the "incorrect" global syntax context directly (which is what will be the case after the resolver reruns anyway). So now it's only needed for preset_env.

collect_decls has to always be rerun here because of line 3:

              // Flush (JsWord, SyntaxContexts) into unique names and reresolve to
              // set global_mark for all nodes, even generated ones.
              // - This changes the syntax context ids and therefore invalidates decls

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I guess the real question is why the first one exists before the node replacements pass, or why the node pass runs after preset-env rather than before?

@devongovett
Copy link
Member

I guess some tests are failing now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Symbol.toStringTag
3 participants