Skip to main content

Module jit

Module jit 

Source
Expand description

CoreCLR JIT helpers — resolve precode indirections and call JIT’d methods.

CoreCLR compiles methods lazily. Before a method is JIT’d, calls go through a precode stub that triggers compilation and then patches itself to jump directly to the native code. The two common precode forms on x86-64 are:

  • ff 25 <disp32> — indirect jump through a pointer slot
  • e9 <disp32> — relative jump to the JIT’d body

resolve_jit follows one level of indirection so you get the actual native address, and patch_precode_target rewrites the indirect-jump slot to redirect a method. Both decode the instruction with iced-x86 rather than matching raw opcode bytes.

With tiered compilation a not-yet-promoted method’s precode points at a CallCountingStub (a call counter) rather than the body; resolve_jit_body sees through that stub to the method’s current native code.

call_native and call_native_float are small trampolines that call a native function pointer with up to 6 integer arguments, used by script runtimes to invoke managed methods generically.

Enums§

JitError
Errors returned by JIT helpers.

Functions§

call_native⚠x86-64
Call a native function pointer with up to 6 integer/pointer arguments.
call_native_f32x4⚠x86-64
Like call_native, but for methods returning a small struct of floats (up to 4 × f32) via xmm0+xmm1 on x86-64 SysV ABI.
call_native_float⚠x86-64
Like call_native, but for methods returning a float (xmm0 on x86-64). Supports up to 3 integer arguments.
patch_precode_target⚠x86-64
Rewrite an indirect-jump precode’s target pointer to redirect the method.
peek_bytes⚠
Read count bytes starting at addr as a hex string, capped at 64.
resolve_jit⚠x86-64
Follow one level of CoreCLR precode indirection.
resolve_jit_body⚠x86-64
Like resolve_jit, but additionally sees through a CoreCLR tiered- compilation CallCountingStub to the method’s current native body. Use this to get real code to hook; use resolve_jit for the raw one-level precode target.