Skip to content

Instantly share code, notes, and snippets.

@kant2002
Created December 20, 2021 12:29
Show Gist options
  • Save kant2002/4af8e087de367a55d82d2e62e4917cab to your computer and use it in GitHub Desktop.
Save kant2002/4af8e087de367a55d82d2e62e4917cab to your computer and use it in GitHub Desktop.
Jit in C# discussion

MS: Michal Strehovlky AK: Andrii Kurdiumov

MS: yeah well there's still some things that can only be done in C/C++ and cannot be done in C#

AK: I understand that life not all rosy. but when I see how you bend C# to your wishes, I think a lot of can be done.

I trying to build standalone Jit without relying on infrastructure too much to be able mix a bit of C#, but so far it's hard.

MS: You want to call into C# from JIT? NativeAOT compiled C#, or actual managed code running in CoreCLR?

AK: I want to explore untouchable area, like "writing JIT in C#". Or alternatively, how to faster tests Jit changes.

I was tired testing during ARM, so I thought that it was good idea to try compile/test jit somehow separatedly. but seems to be it is bolted to whole repo.

MS: Hehe, "JIT in C#" is on my list too

Well, JIT is compiled into a standalone DLL that you can load from anywhere else

If you want to add more stuff to it, you can just ask CMake to build a static library for you (instead of a dynamic library) and bolt on the stuff afterward before you make a DLL out of it

But I don't know what exactly you're after

AK:

just ask CMake that's what I cannot understand how to do. but I did not specifically look for that. That maybe fine for me

MS: when JIT does add_library_clr in CMakeLists, replace SHARED with STATIC. might be enough to get a LIB if that helps

AK: When you think about "Jit in C#" are you plan to use low-level C# which is mimiking C, or do you plan to rely on GC too ?

MS: No, with GC. But when I say "JIT", I mean more like a codegen backend for ILCompiler. Not in a true JIT sense. It wouldn't be behind the JitInterface

AK: That’s seems to be much easier

MS: Yep. I'm not too interested in building something that the CoreCLR VM can talk to. It might be interesting to do that one too, but I don't think CoreCLR would be ready to accept a GC at that point. So one would have to build it with NativeAOT and then it's the problem of having two GCs in the same process

AK: In order to CoreCLR to accept something like that it should be much better in something without obvious drawback.

I understand that most likely this is far in the future.

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