[mono] AOT-compile methods that use the IL jmp opcode#129708
Open
pavelsavara wants to merge 2 commits into
Open
[mono] AOT-compile methods that use the IL jmp opcode#129708pavelsavara wants to merge 2 commits into
pavelsavara wants to merge 2 commits into
Conversation
The IL `jmp` opcode (CEE_JMP) is compiled to a real tail call (OP_TAILCALL) on the non-llvm_only path, which disables AOT for the whole method (DISABLE_AOT). Under full-AOT (aot-only) the method is then left out of the AOT image, so the first call to it fails at runtime with "Attempting to JIT compile method ... while running in aot-only mode". The llvm_only path already avoids this by emitting `jmp` as a normal call followed by a return. Extend that to AOT compilation: when compiling for AOT, emit the jmp as a call + return instead of a real tail call, so the method can be AOT compiled. This is observably equivalent for jmp (transfer to the target with the current arguments and return its result); it just does not reuse the caller's stack frame. The JIT keeps the real tail call. Fixes the Mono full-AOT failures of the JIT/jit64/localloc/call/call05_large and call05_small tests, which were crashing with ExecutionEngineException under full-AOT because their `jmp` method was excluded from the AOT image.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Mono’s IL CEE_JMP handling during AOT compilation so methods containing jmp are no longer excluded from the AOT image (avoiding aot-only/full-AOT runtime failures due to missing compiled methods).
Changes:
- Treat
CEE_JMPas “call + return” whencfg->compile_aot(in addition to the existingcfg->llvm_onlyhandling), instead of emitting a realOP_TAILCALLthat triggersDISABLE_AOT(cfg). - Ensure the AOT path emits a plain call (non-tailcall) so it remains AOT-able by both LLVM and Mono code generators.
| fsig = mono_method_signature_internal (cmethod); | ||
| int nargs = fsig->param_count + fsig->hasthis; | ||
| if (cfg->llvm_only) { | ||
| if (cfg->llvm_only || cfg->compile_aot) { |
These tests use the IL jmp opcode from a method that also uses localloc; with the AOT compiler now emitting such methods, they pass under Mono full-AOT. Remove the ActiveIssue annotation so CI exercises the fix.
7 tasks
pavelsavara
added a commit
that referenced
this pull request
Jun 22, 2026
Re-link the disabled Mono full-AOT tests from the #129508 tracking issue to the individual PRs that fix them (nullabletypes -> #129702, call05_large/small -> #129708, WPF_3226 -> #129710, b143840 -> #129713, UnitTest_GVM_TypeLoadException -> #129715). The tests stay disabled; Runtime_105619 keeps the #129508 link.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Methods that use the IL
jmpopcode (CEE_JMP) are excluded from the AOT image on Mono and crash at runtime under full-AOT.Root cause
In the
CEE_JMPhandler, the non-llvm_onlypath compilesjmpto a real tail call (OP_TAILCALL) and callsDISABLE_AOT(cfg). Under full-AOT (aot-only) the method is then absent from the AOT image, so the first call to it fails with:(JIT mode is fine — a real tail call works there.)
The
llvm_onlypath already avoids this by emittingjmpas a normal call followed by a return.Fix
Extend the
llvm_onlycall+return handling to AOT compilation (cfg->llvm_only || cfg->compile_aot). For the non-llvm_onlyAOT case the call is emitted as a plain call (tailcall = FALSE), which is AOT-able by both the LLVM and the Mono code generators. This is observably equivalent forjmp— transfer to the target with the current arguments and return its result — it just does not reuse the caller's stack frame. The JIT keeps the real tail call.Validation
Built Mono + LLVM full-AOT on x64 and ran
JIT/jit64/localloc/call/call05_largeandcall05_small(localloc +jmp):ExecutionEngineExceptionunder full-AOT (thejmpmethodfunc0was missing from the image; only a PLT stub was emitted).func0is present in the AOT image.Note
This pull request was prepared with the assistance of GitHub Copilot.