Repository navigation
[JSC] Walk star-export graph once when building a module namespace - #63795
Conversation
|
EWS run on previous version of this PR (hash ddaae59) Details |
macOS Safer C++ Build #98164 (ddaae59)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
iOS Safer C++ Build #16516 (ddaae59)❌ Found 1 failing file with 1 issue. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
ddaae59 to
93faec5
Compare
|
EWS run on previous version of this PR (hash 93faec5) Details |
|
Thank you for your work on upstreaming this! |
| ASSERT(cyclic->status() != CyclicModuleRecord::Status::New && cyclic->status() != CyclicModuleRecord::Status::Unlinked); | ||
| #endif | ||
|
|
||
| // http://www.ecma-international.org/ecma-262/6.0/#sec-getmodulenamespace |
There was a problem hiding this comment.
Let's replace with newer URL https://tc39.es/ecma262/#sec-getmodulenamespace
93faec5 to
e21ac44
Compare
|
EWS run on current version of this PR (hash e21ac44) Details |
https://bugs.webkit.org/show_bug.cgi?id=313549 Reviewed by Yusuke Suzuki. GetModuleNamespace [1] currently runs GetExportedNames followed by a ResolveExport call per name. resolveExportImpl walks the star-export graph independently for each name, so building a namespace for a deep barrel module costs O(names * star-edges). Walk the graph once instead, recording each name's unique Local / Namespace binding. A name with exactly one such binding across the whole star-reachable graph is provably Resolved regardless of resolveSet [2] (resolveSet only turns paths into null, and merge(Resolved, null) = Resolved). Names with an Indirect entry, or with two or more distinct bindings, fall back to resolveExport(). The root module's own export entries shadow star-reachable bindings (ResolveExport returns at step 4-6 before consulting star), so a star-side conflict for a name the root already provides never goes to the slow path. Add Resolution::isSameBinding() and reuse it in mergeToCurrentTop. In a local microbenchmark importing a barrel of 9000 exported names through ~1500 star edges, namespace creation drops from 331 ms to 19 ms (~17x). For modules without `export *` the walk visits only the root, so behavior and cost are unchanged. [1]: https://tc39.es/ecma262/#sec-getmodulenamespace [2]: https://tc39.es/ecma262/#sec-resolveexport Tests: JSTests/modules/namespace-single-walk.js JSTests/modules/namespace-single-walk/conflict-only.js JSTests/modules/namespace-single-walk/cycle-a.js JSTests/modules/namespace-single-walk/cycle-b.js JSTests/modules/namespace-single-walk/leaf-a.js JSTests/modules/namespace-single-walk/leaf-b.js JSTests/modules/namespace-single-walk/mid-left.js JSTests/modules/namespace-single-walk/mid-right.js JSTests/modules/namespace-single-walk/root.js * JSTests/modules/namespace-single-walk.js: Added. * JSTests/modules/namespace-single-walk/conflict-only.js: Added. * JSTests/modules/namespace-single-walk/cycle-a.js: Added. * JSTests/modules/namespace-single-walk/cycle-b.js: Added. * JSTests/modules/namespace-single-walk/leaf-a.js: Added. * JSTests/modules/namespace-single-walk/leaf-b.js: Added. * JSTests/modules/namespace-single-walk/mid-left.js: Added. * JSTests/modules/namespace-single-walk/mid-right.js: Added. * JSTests/modules/namespace-single-walk/root.js: Added. * Source/JavaScriptCore/runtime/AbstractModuleRecord.cpp: (JSC::AbstractModuleRecord::resolveExportImpl): (JSC::AbstractModuleRecord::getModuleNamespace): (JSC::getExportedNames): Deleted. * Source/JavaScriptCore/runtime/AbstractModuleRecord.h: (JSC::AbstractModuleRecord::Resolution::isSameBinding const): Canonical link: https://commits.webkit.org/312370@main
e21ac44 to
66c577c
Compare
|
Committed 312370@main (66c577c): https://commits.webkit.org/312370@main Reviewed commits have been landed. Closing PR #63795 and removing active labels. |
…rop our RtlDllShutdownInProgress decl e9072ad adds pas_process_is_shutting_down() (RtlDllShutdownInProgress via GetProcAddress) and uses it in TLC destructor + WTF::Thread::didExit. Subsumes our direct RtlDllShutdownInProgress guard; dropped the decl + ntdll pragma from pas_thread.h. AbstractModuleRecord: upstream landed the same single-pass star-export walk (Sosuke WebKit#63795); replaced our equivalent with the canonical version, keeping our shouldPreventExtensions parameter and BUN m_isTypeScript guard. Kept: is_exiting flag, pas_thread_suspender plumbing, asymmetric decommit_allocator_range (is_symmetric=false).
🛠 wpe
66c577c
e21ac44