Repository navigation
Conversation
…e helpers Object stack allocation skipped all array allocations in ReadyToRun code because CORINFO_HELP_READYTORUN_NEWARR_1 has no type argument for the stack allocation expansion. ReadyToRun code that allocates through the explicit-type newarr helpers (for example on WebAssembly, where crossgen2 does not use the compact ReadyToRun helpers) passes the type handle as an argument, so it can use the same path as JIT-compiled code. Only classify the explicit-type newarr helpers as array candidates and drop the blanket ReadyToRun bail-out. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8c63b295-3bbc-4eae-ac3b-012e284ba542
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
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.
Object stack allocation skips every array allocation in ReadyToRun code because
CORINFO_HELP_READYTORUN_NEWARR_1has no type argument for the stack allocation expansion. Some R2R code allocates arrays through the explicit-type newarr helpers instead (CORINFO_HELP_NEWARR_1_DIRECT(type, length), as in JIT-compiled code). That happens on WebAssembly, where crossgen2 does not use the compact R2R helpers. Those allocations take the same path as JIT-compiled code, so there is no reason to exclude them.This change:
CORINFO_HELP_READYTORUN_NEWARR_1unlisted;MorphAllocObjNodeHelperArr, which only the explicit-type helpers can now reach, and the now-unusedm_isR2R.This is the explicit-type-helper subset of #116651. Unlike #116651, it doesn't embed a class handle, so it doesn't depend on #116808. When #116651 lands, it supersedes this change.
Validation
SuperPMI asmdiffs (Checked). No asm diffs on osx-arm64 (all collections) or on linux-x64 libraries.crossgen2. Some R2R contexts replay with missing data, for example 43 of 286,981 on linux-x64 libraries.crossgen2. These are shared-generic (
__Canon) array allocations that now query the array layout,GetChildType, before being rejected.To see what those contexts compile to, I crossgen'd 9 framework assemblies for linux-x64 with matched base and diff JITs and JitDisasm: CoreLib, System.Linq, System.Linq.Parallel, System.Collections, System.Collections.Concurrent, System.Collections.Immutable, System.Text.Json, System.Private.Xml, and System.Text.RegularExpressions. Both JITs produced zero stack-allocated arrays, so native R2R codegen does not change.
JIT tests.
src/tests/build.sh -Test JIT/opt/JIT.opt.csproj arm64 checked, then the merged runner:RunCrossGen2=1: 428/428 passed.Wasm (browser, CoreCLR R2R, node).
JIT/opt/ObjectStackAllocation/ObjectStackAllocationTestshad its xunit attributes stripped and ran as an app, because browser CoreCLR runtime tests don't run it ([browser][coreCLR] Track disabled OOP runtime tests pending browser support #131321).AllocateArrayWithNonGCElements,AllocateArrayWithGCElements,AllocateArrayT<int>,AllocateArrayT<string>,SpanCaptureArray1/2,SpanCaptureArrayT<int>,SpanCaptureArrayT<string>, andStructReferredObjects.new int[4]that doesn't escape, ×1e7: 194 ms → 27.3 ms. For comparison, native arm64 R2R is 32 ms and Tier1 is 9.4 ms. Other kernels and the framework size are unchanged.Test exclusions. I checked whether this change lets any disabled test be re-enabled. It doesn't:
ObjectStackAllocationTestssets<CrossGenTest>false</CrossGenTest>(Crossgen outerloop regression: JIT/opt/ObjectStackAllocation/ObjectStackAllocationTests/ObjectStackAllocationTests.cmd #109314). Native R2R allocates arrays withCORINFO_HELP_READYTORUN_NEWARR_1, which this change still skips, so that exclusion still applies.CLRTestTargetUnsupportedfor browser CoreCLR ([browser][coreCLR] Track disabled OOP runtime tests pending browser support #131321). Browser CoreCLR runtime tests run on the interpreter, not R2R, so that still applies.OutOfProcessTesttreats WASI as unsupported), so it reports as passed without executing. This holds in the composite R2R lane too.Related: #116651, #116808, #109314, #134428 (write barriers for stores into stack-allocated reference arrays).
Note
This PR description was drafted with GitHub Copilot.