dotnet / dotnet/runtime

WASM JIT: profiler ELT (enter/leave/tailcall) hooks are not implemented

Open
#130,953 6 comments 0 reactions 1 assignee Claimed by @AndyAyersMS View on GitHub
arch-wasm area-CodeGen-coreclr
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

## Summary

The experimental WASM JIT (`clrjit_universal_wasm`) does not implement profiler ELT (enter/leave/tailcall) hook codegen. Today this is asymmetric and inconsistent:

- **Enter** hook: the `genProfilingEnterCallback` call in `genFnProlog` is fully compiled out for WASM (`codegencommon.cpp`, `#if !TARGET_WASM`), so WASM never emits the enter hook.
- **Leave / tailcall** hooks: `genReturn` (`codegencommon.cpp:7438`) and `genJmpPlaceArgs` (`codegencommon.cpp:7949`) still call `genProfilingLeaveCallback` whenever `compIsProfilerHookNeeded()`, and the WASM implementation is a bare `NYI_WASM("genProfilingLeaveCallback")` (`codegenwasm.cpp`).

So when the runtime requests ELT profiling, a WASM method emits a leave hook with no matching enter hook and asserts.

## Scope

This issue tracks implementing real profiler ELT hook codegen for WASM: emitting the enter/leave/tailcall helper calls (`CORINFO_HELP_PROF_FCN_ENTER` / `_LEAVE` / `_TAILCALL`) with the appropriate WASM calling sequence and frame/argument setup.

An interim change makes the leave/tailcall path a no-op on WASM (matching the already-skipped enter side) so WASM is internally consistent — no ELT hooks emitted — instead of emitting half of them and asserting. That unblocks measurement but does **not** provide working profiler ELT on WASM; this issue tracks the real implementation.

## Impact

In an SPMI replay of the WASM altjit over `libraries_tests_no_tiered_compilation` + `coreclr_tests`, the leave-callback stub accounts for ~1,522 asserting contexts.

> [!NOTE]
> This issue was authored with the assistance of GitHub Copilot.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.