Skip to content

Implement CORINFO_FIELD_INTRINSIC_ZERO and _ISLITTLEENDIAN #116853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

janvorli
Copy link
Member

These has shown up on the runtime startup path

These has shown up on the runtime startup path
@janvorli janvorli added this to the 10.0.0 milestone Jun 20, 2025
@janvorli janvorli requested a review from kotlarmilos June 20, 2025 11:23
@janvorli janvorli self-assigned this Jun 20, 2025
@Copilot Copilot AI review requested due to automatic review settings June 20, 2025 11:23
@janvorli janvorli requested review from BrzVlad and kg as code owners June 20, 2025 11:23
Copy link
Contributor

@Copilot 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 implements two new CORINFO field intrinsics to support runtime startup behavior. Key updates include:

  • Adding a switch-case in EmitStaticFieldAccess for CORINFO_FIELD_INTRINSIC_ZERO, which pushes a null reference.
  • Adding logic for CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN to push a constant reflecting the system’s endianness.

Comment on lines +2922 to +2924
m_pLastNewIns->data[0] = 0;
#else
m_pLastNewIns->data[0] = 1;
Copy link
Preview

Copilot AI Jun 20, 2025

Choose a reason for hiding this comment

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

Consider defining named constants for the literal endianness flag values (e.g., ZERO_VALUE and ONE_VALUE) to improve clarity in the code block handling CORINFO_FIELD_INTRINSIC_ISLITTLEENDIAN.

Suggested change
m_pLastNewIns->data[0] = 0;
#else
m_pLastNewIns->data[0] = 1;
m_pLastNewIns->data[0] = BIG_ENDIAN_FLAG;
#else
m_pLastNewIns->data[0] = LITTLE_ENDIAN_FLAG;

Copilot uses AI. Check for mistakes.

Copy link
Contributor

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

#else
m_pLastNewIns->data[0] = 1;
#endif
PushInterpType(InterpTypeI1, NULL);
Copy link
Member

Choose a reason for hiding this comment

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

Should it be extended to InterpTypeI4 on the eval stack even though it is a bool?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is actually one thing I am not sure about, maybe @BrzVlad could provide a guidance here.

Copy link
Member

Choose a reason for hiding this comment

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

We only support pushing I4,I8,R4,R8 or VT on the stack. When pushing on the stack from IL locals/args we will sign extend. In this particular example, whether you push InterpTypeI1 or InterpTypeI4, you will still end up pushing an I4 var so there is not really a difference in practice. Overall I suggest pushing the I4 explicitly. In the future we will probably get rid of the StackType* so we will have to push the actual type anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you, I'll change it that way then.

EmitStind(interpFieldType, pFieldInfo->structType, 0, true);
switch (pFieldInfo->fieldAccessor)
{
case CORINFO_FIELD_INTRINSIC_ZERO:
Copy link
Member

Choose a reason for hiding this comment

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

CORINFO_FIELD_INTRINSIC_EMPTY_STRING is handled in EmitStaticFieldAddress.

Should it be all together?

Copy link
Member

Choose a reason for hiding this comment

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

My judgment call was that static field values and addresses should be separate things, so that's why I split it originally. I'm not opposed to unifying them into one function, but 'EmitStaticFieldAddress' is followed by a ldind, so that gets awkward if you want to generate a literal zero.

Copy link
Member Author

Choose a reason for hiding this comment

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

It was actually me who put the CORINFO_FIELD_INTRINSIC_EMPTY_STRING in the EmitStaticFieldAddress. I guess I might have done it in an unnecessary complicated manner by getting the address and then emiting the indirection opcode.

Copy link
Member Author

Choose a reason for hiding this comment

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

But I have thought the indirection was necessary.

Copy link
Member

Choose a reason for hiding this comment

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

The extra indirection for CORINFO_FIELD_INTRINSIC_EMPTY_STRING looks suspect to me. emptyStringLiteral returns the string object (for IAT_VALUE). There should not be any indirection required.

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

Successfully merging this pull request may close these issues.

5 participants