Repository navigation
[registrar] Specialize inherited generic exports. Fixes #14899 - #27302
rolfbjarne wants to merge 4 commits into
Conversation
Add the opt-in specialize-generic-registrations optimization. Emit closed forwarding methods before registration and trimming so all static registrars can use their existing non-generic callback paths instead of resolving an inherited generic export on each native invocation. Preserve virtual dispatch, closed parameter and return types, and effective property/protocol marshalling attributes. Use shared generic helpers for inaccessible exports, and leave reloadable assemblies unchanged. Wire both assembly preparation and direct ILLink processing, document the code-size tradeoff, and cover the generated metadata and callbacks with regression tests. Fixes #14899 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Build and run a trimmed macOS app with generic registration specialization enabled, both with assembly preparation and with direct ILLink processing. Confirm that closed forwarding methods survive trimming and that native calls preserve virtual hash overrides, closed generic parameter/return conversion, and private exported methods. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Check that all optimizations bring inherited generic exports within 20% of a non-generic baseline, while ordinary native static registration remains slower. Use warmed-up, alternating samples and their median to limit timing noise. Skip optimized-mode checks for reloadable assemblies. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Read pre-trim attributes from the prepared assemblies so postprocessing can recover generated exports. Reuse the registrar and register new forwarders directly to avoid duplicate diagnostics, then filter trimmed APIs before rewriting native class handles. Let deeper subclasses inherit specialized entry points instead of generating them again. Strengthen the existing dispatch tests to cover stripped attributes, native static registration and virtual calls through inherited forwarders, and lengthen performance samples. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
🚀 [CI Build #05766da] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 217 tests passed 🎉 Tests counts✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download Linux Build VerificationPipeline on Agent |
Add the
specialize-generic-registrationsoptimization for non-genericNSObjectsubclasses that inherit exported methods from generic base classes. It adds forwarding methods to these subclasses so the static registrar can generate dedicated native entry points. Objective-C calls then no longer look up the generic method each time.The optimization preserves virtual dispatch and marshalling attributes. It is off by default because it adds code, but
--optimize=allenables it. Reloadable assemblies in Hot Reload-compatible builds are left unchanged.Add tests for assembly preparation, trimming, and Objective-C dispatch. A monotouch performance test compares calls to inherited generic exports with a non-generic baseline, with and without all optimizations enabled.
Fixes #14899
🤖 Pull request created by Copilot