Skip to content

Conversation

@davidwrighton
Copy link
Member

Allow use of the transient pointer concept from ECMA 335 using a "bashing" approach where the StackType is adjusted to I as needed. This is done at the same points that the JIT does this bashing. See I.12.3.2.1

Allow the convert opcode to operate on StackTypeByRef and StackTypeO as if they were of StackTypeI.

In combination with @janvorli's PR to implement JMP this should fix much of Directed_3 and IL_Conformance

Copilot AI review requested due to automatic review settings October 28, 2025 20:06
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 28, 2025
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 pull request implements support for transient pointers as defined in ECMA-335 section I.12.3.2.1 within the CoreCLR interpreter. The changes introduce a new stack type StackTypeTransientPointer to track when a byref pointer is "transient" (e.g., from ldloca operations), allowing more accurate type tracking and proper handling during operations like arithmetic, conversions, and comparisons.

Key changes:

  • Added StackTypeTransientPointer enum value and infrastructure for tracking transient pointer state
  • Encapsulated direct access to the type field in StackInfo behind a GetStackType() accessor
  • Added methods to manage transient pointer state (SetAsTransientPointer, IsTransientPointer, BashStackTypeToI_ForTransientPointerUse, BashStackTypeToIForConvert)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/interpreter/compiler.h Adds StackTypeTransientPointer enum value, makes StackInfo::type private with accessor methods, and adds transient pointer management methods
src/coreclr/interpreter/compiler.cpp Updates all direct accesses to .type field to use GetStackType(), adds transient pointer handling logic in arithmetic/conversion operations, marks ldloca results as transient pointers
Comments suppressed due to low confidence (1)

src/coreclr/interpreter/compiler.cpp:1818

  • The EmitConv function creates a new StackInfo with placement new, which always sets the internal type field directly via the constructor, bypassing transient pointer tracking. If a transient pointer undergoes conversion, its transient state will be lost after EmitConv. This could cause incorrect behavior when a transient pointer is converted and then needs to be treated as a regular byref or integer. Consider preserving transient pointer state where appropriate, or ensuring that BashStackTypeToIForConvert is called before conversions that should clear this state.
    new (sp) StackInfo(type, NULL, var);

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

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant