Skip to content
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

Cleanup unused JIT stubs in vm #111237

Merged
merged 16 commits into from
Jan 12, 2025
Merged

Cleanup unused JIT stubs in vm #111237

merged 16 commits into from
Jan 12, 2025

Conversation

huoyaoyuan
Copy link
Member

The JIT_TailCall helpers are only used on Windows x86. Removing all stub definitions on other platforms.
GetCONTEXTFromRedirectedStubStackFrame(DISPATCH_CONTEXT) is only used on Windows.

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 9, 2025
# <NOTE>
#
# </NOTE>
LEAF_ENTRY JIT_ProfilerEnterLeaveTailcallStub, _TEXT
Copy link
Member Author

Choose a reason for hiding this comment

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

UNIX_AMD64 was the only platform not implementing this in ASM.
What's the requirement for this method? Can it be implemented in C for all platforms?

Copy link
Member

Choose a reason for hiding this comment

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

This method has custom calling convention - it has to preserve more register than the default calling convention is guaranteed to preserve. It cannot be implemented in C in general.

I think we just got lucky on UNIX_AMD64 or this profiling scenario is not tested on Unix Amd64.

@@ -89,9 +89,9 @@ EXTERN_C LPVOID STDCALL COMPlusEndCatch(LPVOID ebp, DWORD ebx, DWORD edi, DWORD
// RedirectedHandledJITCaseForXXX_Stub's.
//
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(CONTEXT * pContext);
#ifdef FEATURE_EH_FUNCLETS
#if defined(FEATURE_EH_FUNCLETS) && !defined(TARGET_UNIX)
Copy link
Member Author

Choose a reason for hiding this comment

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

Would it be possible to port Windows x86 to new EH in the future?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, it is something we have in our backlog

Copy link
Member

Choose a reason for hiding this comment

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

I think it is better to delete this since there is no implementation.

This method has to more to do with low-level implementation of EH and thread suspension than funclets. If I am reading the code correctly, this method is only called from FixRedirectContextHandler that is only used on Windows x64. It can be probably deleted everywhere else as well.

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 can be probably deleted everywhere else as well.

I do plan to delete it on UNIX. Including in this PR should be fine.
For Windows x86, leaving a stub may be useful for future implementation. Deleting it should also be fine because there should be more missing definitions for new EH on Windows x86.

Copy link
Member

Choose a reason for hiding this comment

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

I do not think it will be needed for new EH on Windows x86

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 seems that GetFrameFromRedirectedStubStackFrame and more related code are not used for UNIX.
Before including more, I'd like to confirm that would we ever want them on UNIX?

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 seems that FEF comes from initial coreclr commit, and there's intend to eliminate it. Making sure I'm in the right direction.

Copy link
Member

Choose a reason for hiding this comment

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

DISPATCHER_CONTEXT is a Windows SEH specific type. We try to stay away from building more Windows emulators for Unix, so I do not think that it will be ever needed on Unix.

I would leave FEF alone. I am not sure whether it is a good idea to try to eliminate it.

Copy link
Member Author

Choose a reason for hiding this comment

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

FEF is still used in stack overflow handler. DISPATCHER_CONTEXT is also used by a bit more components. I think it's better to keep the scope of this PR.

@@ -5891,7 +5891,7 @@ void FixupDispatcherContext(DISPATCHER_CONTEXT* pDispatcherContext, CONTEXT* pCo

pDispatcherContext->ControlPc = (UINT_PTR) GetIP(pDispatcherContext->ContextRecord);

#if defined(TARGET_ARM) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
#if defined(TARGET_ARM64)
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It would be nice to change the ifdef around this method to #ifdef TARGET_WINDOWS to match the rest

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thanks!

@jkotas jkotas merged commit 9bef28b into dotnet:main Jan 12, 2025
109 checks passed
@huoyaoyuan huoyaoyuan deleted the jit-tailcall branch January 12, 2025 04:29
grendello added a commit to grendello/runtime that referenced this pull request Jan 13, 2025
* main:
  JIT: Model GT_RETURN kills with contained operand (dotnet#111230)
  Update dependencies from https://github.com/dotnet/runtime-assets build 20250110.2 (dotnet#111290)
  [NativeAOT/ARM64] Generate frames compatible with Apple compact unwinding (dotnet#107766)
  Cleanup unused JIT stubs in vm (dotnet#111237)
  Ensure that Shuffle is marked as HW_Flag_CanBenefitFromConstantProp (dotnet#111303)
  Fix CMP0173 policy warning with cmake 3.31 (dotnet#110522)
  [RISC-V] Fix HostActivation.Tests unknown-rid (dotnet#110687)
  Fix accidentally duplicated global-build-step.yml in runtime-official.yml (dotnet#111302)
  JIT: run extra SPMI queries for arrays (dotnet#111293)
  Split the Runtime Shared Framework project and combine legs in the official build (dotnet#111136)
  Do not ignore `MemoryMarshal.TryWrite` result (dotnet#108661)
  Update dependencies from https://github.com/dotnet/emsdk build 20250109.1 (dotnet#111263)
  Clean up in Number.Formatting.cs (dotnet#110955)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants