runtime icon indicating copy to clipboard operation
runtime copied to clipboard

CoreCLR Interpreter

Open BrzVlad opened this issue 1 year ago • 6 comments

This issue tracks required work and progress for the porting of the mono interpreter to CoreCLR. The end goal of this issue is to be able to run entire test suites in full interpreter mode (without any JIT/AOT) on desktop platforms (ex. arm64 linux). This issue will be updated on the fly as the implementation progresses.

M1 - basic compilation and interpreting support of a simple method

  • [x] interp wire-in https://github.com/dotnet/runtime/pull/112202 https://github.com/dotnet/runtime/pull/112369
  • [x] interp executor in libcoreclr https://github.com/dotnet/runtime/pull/112369
  • [x] interpreter runtime test https://github.com/dotnet/runtime/pull/112369

M2 - stress tests involving object manipulation

  • [x] constant loads and unchecked binops https://github.com/dotnet/runtime/pull/113292
  • [x] ldlocal/ldarg https://github.com/dotnet/runtime/pull/113292
  • [x] static direct calls https://github.com/dotnet/runtime/pull/113292
  • [x] full var offset allocator https://github.com/dotnet/runtime/pull/113292
  • [x] basic block formation and implementation of branch opcodes https://github.com/dotnet/runtime/pull/113292
  • [x] newobj creation https://github.com/dotnet/runtime/pull/114049
  • [x] field access opcodes https://github.com/dotnet/runtime/pull/114049
  • [x] indirect load/store opcodes https://github.com/dotnet/runtime/pull/114049
  • [x] precise GC scanning https://github.com/dotnet/runtime/pull/114469
  • [x] GC safepoints https://github.com/dotnet/runtime/pull/115567
  • [x] conversion opcodes https://github.com/dotnet/runtime/pull/113292
  • [x] valuetypes (locals, fields, ctor) https://github.com/dotnet/runtime/pull/114049
  • [x] basic generics working https://github.com/dotnet/runtime/pull/116357 and https://github.com/dotnet/runtime/issues/116395
  • [x] static fields https://github.com/dotnet/runtime/pull/114049

M3 - EH and interpreter calls

  • [x] basic non exceptional path for try/finally/leave #116046
  • [x] exception throw support and resume to correct handler clause #116046
  • [x] implement invocation of finally/filter clauses from EH #116046
  • [x] null checks and ovf opcodes - #116046
  • [x] interp virtual call support https://github.com/dotnet/runtime/pull/114529
  • [x] interp interface call support https://github.com/dotnet/runtime/pull/114529
  • [x] direct calls to non-interp code #115375

M4 - mixing with compiled code

  • [x] figure out separation between interp/jit/R2R code for testing purposes #116769
  • [x] calli and ldftn with interpreter target method #116449
  • [x] calli and ldftn with jitted target method #116449
  • [x] delegate creation and invocation with interpreter target method #116449
  • [x] other delegate scenarios, passing it between interp/jit with either interpreted or jitted target method #116449

M5 - pinvoke support, full interpreter support for Hello World

  • [x] implement pinvoke support https://github.com/dotnet/runtime/pull/115393
  • [x] implement reverse pinvoke support https://github.com/dotnet/runtime/pull/119133
  • [x] bugfixes and feature support for Console.WriteLine("Hello World") in full interpreter mode

M6 - IL opcodes for CoreCLR startup ordered by number of occurrences:

  • [x] array support https://github.com/dotnet/runtime/pull/115553
    • [x] ldlen
    • [x] newarr
    • [x] stelem
    • [x] ldelem
  • [x] array ref support https://github.com/dotnet/runtime/pull/116384
    • [x] ldelema
    • [x] ldelem.ref
    • [x] stelem.ref
    • [x] get
    • [x] set
  • [x] ldtoken https://github.com/dotnet/runtime/pull/115723
  • [x] isinst #116046
  • [x] castclass
  • [x] box, unbox https://github.com/dotnet/runtime/pull/115549
  • [x] sizeof https://github.com/dotnet/runtime/pull/115745
  • [x] ldobj, stobj https://github.com/dotnet/runtime/pull/115900
  • [x] cpobj https://github.com/dotnet/runtime/pull/119025
  • [x] localloc https://github.com/dotnet/runtime/pull/114860
  • [x] floating point conversion opcodes #116356
  • [x] mkrefany, refanyval, refanytype https://github.com/dotnet/runtime/pull/118753
  • [x] cpblk https://github.com/dotnet/runtime/pull/118404
  • [x] initblk https://github.com/dotnet/runtime/pull/119025
  • [x] ckfinite
  • [x] jmp https://github.com/dotnet/runtime/pull/121130
  • [x] constrained calls #116702
  • [x] volatile prefix and memory barriers
  • [x] tailcall prefix
  • [x] interpreter->interpreter tailcalls
  • [x] interpreter->native tailcalls
  • [x] native->interpreter tailcalls
  • [x] readonly prefix
  • [x] bugfixes and feature support for test suites
    • [x] ldc.r8 with double.MinValue return NaN https://github.com/dotnet/runtime/pull/116115

Nice to have refactorings/improvements that are out of scope of this project:

  • Remove the usage of StackType, we could rely exclusively on the InterpType instead
  • Optimize reimportation. Use a graph clique approach similar to RyuJIT, rather than naive retries.

BrzVlad avatar Feb 04 '25 22:02 BrzVlad

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

great work!

kidsang avatar Apr 22 '25 03:04 kidsang

A discrete ckfinite op is absent from the list (for conformance: src/tests/JIT/IL_Conformance/Old/Base/ckfinite.ilproj). Implementation-wise, it's basically: https://godbolt.org/z/vxMYrvb8d.

am11 avatar Apr 28 '25 15:04 am11

great work! are there examples available now? can we try them out?

shumtn avatar Nov 03 '25 02:11 shumtn

@BrzVlad, @janvorli, is it still in progress / is the checklist up-to-date?

am11 avatar Mar 03 '26 18:03 am11

The work is complete, this issue should be closed.

janvorli avatar Mar 03 '26 19:03 janvorli