Repository navigation
[browser][CoreCLR] Guard Wasm ReadyToRun interface and delegate calls from profile data - #138615
Open
pavelsavara wants to merge 1 commit into
Open
pavelsavara wants to merge 1 commit into
pavelsavara wants to merge 1 commit into
Conversation
Wasm ReadyToRun imports non-generic interface calls through ldvirtftn. Mark them with GTF_CALL_M_R2R_INTERFACE_LDVIRTFTN so class profiles in a .mibc can drive guarded devirtualization, and keep the ldvirtftn lookup on the fallback path only. For delegate calls, crossgen2 now implements getFunctionFixedEntryPoint on Wasm, where a delegate holds the target's portable entry point, so method profiles can guard and inline delegate targets. Filter profile types and delegate targets to those the compilation can reference, so a speculative guard cannot make an otherwise compilable Wasm method fall back. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Let Wasm ReadyToRun code use class and delegate profiles from a
.mibcfor guarded devirtualization. This works with any profile, without the new instrumentation in #137502.GTF_CALL_M_R2R_INTERFACE_LDVIRTFTNflag makes them eligible forpickGDVandconsiderGuardedDevirtualization.SplitCallgains afallbackUseparameter, so the ldvirtftn lookup, which can throw, runs only on the fallback path.getFunctionFixedEntryPointfor Wasm, andimpTransformDevirtualizedCalluses it for delegate guards. The target is restricted to methodsCanReferenceDelegateProfileTargetcan name.Exact-type devirtualization of these interface calls is unchanged in the default configuration: the control expression is
CORINFO_HELP_VIRTUAL_FUNC_PTR, soIsGenericVirtualalready made them candidates. The call keepsGTF_CALL_NULLCHECK, so a devirtualized call still throws on a nullthis.Stack
Layer 4 of the Browser ReadyToRun PGO stack; #137502 is the integration PR on top.
Validation
The new tests use hand-written MIBC profiles and do not need the producer side:
ReadyToRunGuardsVirtualAndInterfaceReceiversFromProfileReadyToRunGuardsDelegateTargetsFromProfileCastProfileDoesNotRequireUnreferencedTypes.\build.cmd -subset clr.alljits -c Debug.\build.cmd -os browser -subset clr.crossarchtools -c Debug /p:RuntimeFlavor=CoreCLR.\dotnet.cmd build src\coreclr\tools\aot\ILCompiler.ReadyToRun.Tests\ILCompiler.ReadyToRun.Tests.csproj -c Debug /p:TargetOS=browser /p:TargetArchitecture=wasm /p:RuntimeFlavor=CoreCLR '/t:Build;Test'Note
This PR description was drafted with GitHub Copilot.