Skip to content

[clr-interp] Fix CEE_ISINST to push object reference instead of InterpTypeI#121207

Merged
janvorli merged 1 commit intodotnet:mainfrom
kotlarmilos:bugfix/clr-interp-isinst
Oct 30, 2025
Merged

[clr-interp] Fix CEE_ISINST to push object reference instead of InterpTypeI#121207
janvorli merged 1 commit intodotnet:mainfrom
kotlarmilos:bugfix/clr-interp-isinst

Conversation

@kotlarmilos
Copy link
Member

Description

According to ECMA, CEE_ISINST must push an object reference onto stack, but it currently pushes InterpTypeI, which propagates an invalid IR stack type.

In the example below, by IL_0022 the stind.ref takes an i8 instead of object reference, triggering OBJECTREF validation failure.

Interpreter compile method Microsoft.Maui.Controls.Platform.GesturePlatformManager:TryGetTapGestureRecognizer(Microsoft.Maui.Controls.IGestureRecognizer,byref)

Create IL Vars:
alloc arg var 0 to offset 0
alloc arg var 1 to offset 8
alloc arg var 2 to offset 16

Create clause Vars:
BB1 (IL_0000):
Chaining BB0 -> BB1
IL_0000 ldarg.2   , sp 0,   
IL_0001 ldarg.1   , sp 1, MP
IL_0002 isinst    , sp 2, O 
IL_0007 dup       , sp 2, I8
IL_0008 brtrue.s  , sp 3, I8
BB3 (IL_000a):
Chaining BB1 -> BB3
IL_000a pop       , sp 2, I8
IL_000b ldarg.1   , sp 1, MP
IL_000c isinst    , sp 2, O 
IL_0011 dup       , sp 2, I8
IL_0012 brtrue.s  , sp 3, I8
BB5 (IL_0014):
Chaining BB3 -> BB5
IL_0014 pop       , sp 2, I8
IL_0015 ldnull    , sp 1, MP
IL_0016 br.s      , sp 2, O 
BB4 (IL_0018):
Chaining BB5 -> BB4
IL_0018 call      , sp 2, I8
BB6 (IL_001d):
Chaining BB4 -> BB6
IL_001d isinst    , sp 2, O 
BB2 (IL_0022):
Chaining BB6 -> BB2
IL_0022 stind.ref , sp 2, I8
IL_0023 ldarg.2   , sp 0,   
IL_0024 ldind.ref , sp 1, MP
IL_0025 ldnull    , sp 1, O 
IL_0026 cgt.un    , sp 2, O 
IL_0028 ret     

Copilot AI review requested due to automatic review settings October 30, 2025 15:50
@kotlarmilos kotlarmilos self-assigned this Oct 30, 2025
@kotlarmilos kotlarmilos added this to the 11.0.0 milestone Oct 30, 2025
@dotnet-policy-service
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a comment

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 removes trailing whitespace throughout the compiler.cpp file and fixes a bug in the handling of the ISINST and CASTCLASS IL opcodes.

  • Removes trailing whitespace from multiple lines for code cleanliness
  • Fixes incorrect type selection for ISINST opcode by always using InterpTypeO instead of conditionally choosing between InterpTypeO and InterpTypeI

Copy link
Member

@janvorli janvorli left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@janvorli
Copy link
Member

/ba-g Windows arm64 in CI is down

@janvorli janvorli merged commit a927415 into dotnet:main Oct 30, 2025
100 of 105 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Nov 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants