Skip to content

Preserve IL for CoreCLR interpreter fallback on Apple mobile#130622

Draft
kotlarmilos with Copilot wants to merge 7 commits into
mainfrom
copilot/clr-ios-track-il-stripping-issues
Draft

Preserve IL for CoreCLR interpreter fallback on Apple mobile#130622
kotlarmilos with Copilot wants to merge 7 commits into
mainfrom
copilot/clr-ios-track-il-stripping-issues

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Apple mobile composite ReadyToRun publishing could strip IL later required by the CoreCLR interpreter when compiled code is rejected or unavailable in a custom load context.

  • Stripping policy

    • Preserve IL for methods with per-method instruction-set support fixups.
    • Retain component IL on Apple mobile targets where interpreter fallback remains possible.
  • Coverage

    • Add focused ReadyToRun coverage for opportunistic instruction sets and Apple mobile publishing.
    • Remove the temporary project-level IL-stripping opt-outs.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/runtime-infrastructure
See info in area-owners.md if you want to be subscribed.

Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot July 13, 2026 14:07
Co-authored-by: kotlarmilos <11523312+kotlarmilos@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot July 13, 2026 14:18
Copilot AI changed the title [WIP] Track IL-stripping issues for CoreCLR on Apple mobile Preserve IL for CoreCLR interpreter fallback on Apple mobile Jul 13, 2026
Copilot AI requested a review from kotlarmilos July 13, 2026 14:19
@kotlarmilos

Copy link
Copy Markdown
Member

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@jkotas

jkotas commented Jul 13, 2026

Copy link
Copy Markdown
Member

Apple mobile composite ReadyToRun publishing could strip IL later required by the CoreCLR interpreter when compiled code is rejected

This sounds like a bug in how we produce the R2R images for use with interpreter. The instruction set should be fixed in this case, and we should never reject the native code. If the actual machine supports more instruction set extensions that the fixed set, we should ignore them.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 19812166-4b05-40cc-9a81-8b80b909e10b
Copilot AI review requested due to automatic review settings July 14, 2026 12:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts composite ReadyToRun IL-stripping behavior so IL is retained when it may be needed at runtime (notably for interpreter fallback scenarios), and tightens instruction-set handling on “fixed instruction set” platforms (Apple mobile / browser), with added ReadyToRun test coverage.

Changes:

  • Removes temporary project-level PublishReadyToRunStripILBodies=false opt-outs from several test projects.
  • Introduces a shared “fixed instruction set platform” classification and uses it to adjust instruction set support encoding and per-method fixup generation.
  • Preserves IL for methods that have per-method instruction-set support fixups, and adds/extends ReadyToRun tests to validate stripping/preservation behavior across target configurations.
Show a summary per file
File Description
src/tests/JIT/Regression/Regression_o_2.csproj Removes a project-level opt-out from ReadyToRun IL stripping.
src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj Removes a project-level opt-out from ReadyToRun IL stripping.
src/libraries/System.Reflection.Metadata/tests/Metadata/Decoding/SignatureDecoderTests.cs Updates test logic to recognize an additional stripped-IL sentinel pattern.
src/libraries/System.IO.Hashing/tests/System.IO.Hashing.Tests.csproj Removes a project-level opt-out from ReadyToRun IL stripping.
src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs Adds a helper to classify fixed-instruction-set target OSes.
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Skips unsupported-ISA-based per-method fixup work on fixed-instruction-set platforms; adjusts fixup support construction accordingly.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs Uses a fixed-instruction-set-aware baseline instruction set support signature; plumbs per-method-fixup method set into component rewriting.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs Collects methods that carry per-method instruction-set support fixups while building the compiled-method definition set.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/CopiedMethodILNode.cs Preserves IL for methods known to have per-method instruction-set support fixups during strip-IL processing.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/RuntimeAsync/StripILBodies.cs Adds a runtime-checked-instruction-set probe method used by strip/preserve IL tests.
src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs Extends strip-IL test coverage and adds an iOS-targeted validation case for fixed-instruction-set behavior.
src/coreclr/tools/aot/crossgen2/Program.cs Centralizes fixed-instruction-set detection and uses it to disable optimistic ISA defaults and Vector optimism accordingly.

Copilot's findings

  • Files reviewed: 12/12 changed files
  • Comments generated: 1

@kotlarmilos

Copy link
Copy Markdown
Member

Apple mobile composite ReadyToRun publishing could strip IL later required by the CoreCLR interpreter when compiled code is rejected

This sounds like a bug in how we produce the R2R images for use with interpreter. The instruction set should be fixed in this case, and we should never reject the native code. If the actual machine supports more instruction set extensions that the fixed set, we should ignore them.

Updated the PR to keep IL stripping enabled on Apple and fix the known fallback paths. Crossgen2 now treats Apple mobile and browser as fixed instruction-set targets, so additional runtime ISA support does not reject valid baseline native code. Non-fixed targets still preserve IL for methods with per-method ISA fixups.

Custom AssemblyLoadContext scenarios retain scoped project opt-outs which would require the assembly-level exclusion mentioned in #130620.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 19812166-4b05-40cc-9a81-8b80b909e10b
Copilot AI review requested due to automatic review settings July 14, 2026 13:29
@kotlarmilos kotlarmilos temporarily deployed to copilot-pat-pool July 14, 2026 13:29 — with GitHub Actions Inactive
@kotlarmilos kotlarmilos temporarily deployed to copilot-pat-pool July 14, 2026 13:30 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 12/12 changed files
  • Comments generated: 3

Comment thread src/coreclr/tools/Common/TypeSystem/Common/TargetDetails.cs
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 14, 2026 13:49
@kotlarmilos kotlarmilos temporarily deployed to copilot-pat-pool July 14, 2026 13:49 — with GitHub Actions Inactive
@kotlarmilos kotlarmilos temporarily deployed to copilot-pat-pool July 14, 2026 13:49 — with GitHub Actions Inactive
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot's findings

  • Files reviewed: 12/12 changed files
  • Comments generated: 1

Comment on lines +50 to +56
/// <summary>
/// Returns <see langword="true"/> for target OSes where the runtime cannot JIT new code, so ISA support is treated as fixed.
/// </summary>
public static bool IsFixedInstructionSetPlatform(TargetOS operatingSystem) =>
operatingSystem is TargetOS.iOS or TargetOS.tvOS
or TargetOS.iOSSimulator or TargetOS.tvOSSimulator
or TargetOS.MacCatalyst or TargetOS.Browser;
@kotlarmilos

Copy link
Copy Markdown
Member

/azp run runtime-extra-platforms

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[clr-ios] Track IL-stripping issues for CoreCLR on Apple mobile

5 participants