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

Removal of Helper Method Frames (HMF) #110767

Closed
31 tasks
AaronRobinsonMSFT opened this issue Dec 17, 2024 · 9 comments
Closed
31 tasks

Removal of Helper Method Frames (HMF) #110767

AaronRobinsonMSFT opened this issue Dec 17, 2024 · 9 comments

Comments

@AaronRobinsonMSFT
Copy link
Member

AaronRobinsonMSFT commented Dec 17, 2024

Background

Over the past several releases, there has been a slow, but intentional, effort to move more runtime code from C++ into C#. A consequence of this effort has meant the removal of Helper Method Frames (HMF). Removal of HMFs simplifies the runtime for efforts like cDAC, reduces opportunities for GC holes, and in some cases can result in improved performance when the JIT can see more of the code that is can optimize.

Prior work

Below is a list of various PRs that can be referenced that demonstrate that effort across multiple authors and releases.

#70000, #70055, #71873, #87166, #95038, #96926, #97590, #100116, #101353, #106793, #107058, #107218, #107648, #108167, #109135, #109996, #110064, #110211, #110377, #110481, #110627, #110766

Remaining work

List of JIT helpers that need the removal of explicit HMFs:

  • JIT_GetFieldAddr_Framed
  • JIT_New
  • JIT_NewMaybeFrozen
  • FramedAllocateString
  • JIT_StrCns
  • JIT_NewArr1
  • JIT_NewArr1MaybeFrozen
  • JIT_NewMDArr
  • JIT_Box
  • JIT_GetRuntimeFieldStub
  • JIT_GetRuntimeMethodStub
  • JIT_GetRuntimeType_Framed
  • JIT_MonEnter_Helper
  • JIT_MonTryEnter_Helper
  • JIT_MonExit_Helper
  • JIT_MonExit_Signal
  • IL_Throw
  • IL_Rethrow
  • JIT_ThrowMethodAccessException
  • JIT_ThrowFieldAccessException
  • JIT_ThrowClassAccessException
  • JIT_UserBreakpoint
  • JIT_PollGC_Framed
  • JIT_PInvokeEndRarePath
  • JIT_RareDisableHelper/JIT_RareDisableHelperWorker
  • JIT_StressGC
  • JIT_Patchpoint_Framed
  • JIT_PartialCompilationPatchpoint

List of JIT helpers with implicit HMFs through a use of FCThrow.

The following clean-up can occur after all the above is complete:

Copy link
Contributor

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

@huoyaoyuan
Copy link
Member

Also #95695

@AaronRobinsonMSFT
Copy link
Member Author

Also #95695

Thanks, I added it. I wasn't trying to be exhaustive. Wanted to provide a bunch of examples people could reference.

@AaronRobinsonMSFT
Copy link
Member Author

@am11
Copy link
Member

am11 commented Dec 17, 2024

JIT_MonEnter_Helper

The way @VSadov consolidated lock primitives with NativeAOT, if we continue on that path, maybe it is possible to share the entire implementation with AOT (which has this HCall written in C#).

JIT_Patchpoint_Framed

There is also a related JIT_Patchpoint HCall, which ends up using VirtualUnwindToFirstManagedCallFrame, not sure if there is a better structured way to tackle it without the libunwind dependency but would be nice to switch to one if it exists.

@huoyaoyuan
Copy link
Member

Also #95695

Thanks, I added it. I wasn't trying to be exhaustive. Wanted to provide a bunch of examples people could reference.

It was tracking issue instead of PR. There is also more context about HMF.

@AaronRobinsonMSFT
Copy link
Member Author

Also #95695

Thanks, I added it. I wasn't trying to be exhaustive. Wanted to provide a bunch of examples people could reference.

It was tracking issue instead of PR. There is also more context about HMF.

Ah, I see now. Hmmm. @jkotas Should I close this one?

@am11
Copy link
Member

am11 commented Dec 17, 2024

Removal of HMF has come a long way:

Release FCThrow HELPER_METHOD_FRAME
v5.0.0 187 353
v6.0.0 179 326
v7.0.0 164 298
v8.0.0 158 308
v9.0.0 97 152
main (+ #110766 and #109087) 0 37

@AaronRobinsonMSFT
Copy link
Member Author

Closing this one in lieu of #95695.

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

No branches or pull requests

4 participants