Elektrine lite

← Feed

@slava@mathstodon.xyz

Post #3722145

2026-07-10 18:02 UTC

@zwarich@hachyderm.io @joe@f.duriansoftware.com In C# implementations, at what point does monomorphization happen? Do they execute unspecialized code at all? Is there an interpreter for it?

Replies (3)

  • @joe@f.duriansoftware.com 2026-07-10 18:10

    @slava@mathstodon.xyz @zwarich@hachyderm.io in a full-fat JIT implementation, the VM generates monomorphizations on demand. .NET core does a more swift-style thing where specializations are pregenerated for the statically visible uses, and a polymorphic entry point catches the dynamic cases

    Open ##3722144

  • @zwarich@hachyderm.io 2026-07-10 18:12

    @slava@mathstodon.xyz @joe@f.duriansoftware.com The original story was single-tier JIT with monomorphization at runtime. They experimented with AOT solutions for desktop apps, and then at some point they added a tiered JIT along with an interpreter that works more like Swift’s baseline model and uses metadata. I think the current AOT solution is totally different and closer to the JIT compiler.

    Open ##4248954

  • @slava@mathstodon.xyz @zwarich@hachyderm.io @joe@f.duriansoftware.com initially it was a runtime error when we encountered that, later the compilers were taught additional patterns to recognize and generate code, but it get bloated. Some heavy generic code is just too popular and hard to take (Linq) so it ships with an interpreter for those expressions. There have been efforts to use an interpreter as a fallback and avoid the bloat. Not sure if it ever shipped or “educate users” remains the guidance

    Open ##4248957