Skip to content

JIT: Preserve receiver side effects in constrained GetType calls - #133806

Open
EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:fix-constrained-gettype-side-effects
Open

JIT: Preserve receiver side effects in constrained GetType calls#133806
EgorBo wants to merge 1 commit into
dotnet:mainfrom
EgorBo:fix-constrained-gettype-side-effects

Conversation

@EgorBo

@EgorBo EgorBo commented Sep 12, 2026

Copy link
Copy Markdown
Member

Fixes #133715.

The constrained Object.GetType() expansion discarded the receiver tree when replacing boxing with direct type construction, losing bounds checks and other side effects. Preserve receiver evaluation and the null check that boxing would perform, while retaining the boxing optimization.

Preserve receiver evaluation and the null check that boxing would perform when expanding constrained GetType calls. Add a source-only regression covering bounds checks, null arrays, and null byrefs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d1ad7889-9252-4fe8-a399-88e91f2652be
Copilot AI lite review requested due to automatic review settings September 12, 2026 21:52
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 12, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

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.

🟢 Approval recommended

No unresolved blocking issues were identified.

Pull request overview

Fixes a JIT bug where constrained GetType() optimization discarded receiver side effects and required checks.

Changes:

  • Preserves receiver evaluation, bounds checks, and null checks.
  • Adds regression coverage for int and Guid.
File summaries
File Description
src/tests/JIT/Regression_ro_2/Runtime_133715.cs Adds regression tests for valid, bounds-error, and null cases.
src/coreclr/jit/importercalls.cpp Preserves receiver side effects during constrained GetType() expansion.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT: (bug) constrained GetType() expansion drops the receiver's bounds/null check

2 participants