Repository navigation
Conversation
superpmi, mcs and the collector, counter and simple shims are now C#, published with NativeAOT under the same names, command lines, outputs and locations, so they are drop-in replacements; the native sources are deleted. - SuperPmi.Shared has the method context format and the recording, replay and dumping of the JIT-EE calls. superpmi and the shims reuse crossgen2's JIT interface (CorInfoImpl_generated.cs and its native JitInterfaceWrapper). - The shims call the EE through native forwarders generated by the ThunkGenerator, which capture the EE's exceptions and rethrow them at the boundaries. The native glue is linked in statically. - The output matches native on Linux and Windows x64: replay, mcs, collections and call counts. The win-x86 and linux-arm64 cross builds were checked too. Co-authored-by: Cursor <[email protected]>
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
@jkoritzinsky, @jkotas, @jakobbotsch: the JIT-EE interface layer is shared with crossgen2/ILC; the rest is a C# rewrite that fast-forwards SuperPMI to the point where it no longer depends on the CoreCLR PAL, which is why I started on this during the PAL cleanup. The remaining C++ is about 600 lines of glue that uses only the JIT-EE interface headers. Based on my testing, it's a drop-in replacement: same binaries in the same places, same command lines and outputs, and no CI changes needed. |
|
@dotnet/jit-contrib Thoughts about this rewrite? It sounds good to me, as long as it does not negatively impact team productivity and validations based on superpmi. |
This is something we've thought about doing but never tried. I'd say it is worth serious consideration.
|
| // Dummy change to excercise in CI | ||
|
|
||
| /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
There was a problem hiding this comment.
Remove after pipeline run:
| // Dummy change to excercise in CI | |
| /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
| /*XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX |
|
Thanks @AndyAyersMS.
|
a8c6eec to
cdb024b
Compare
cdb024b to
4db2623
Compare
We should verify if it is handled by TPDiff properly as well because we are thinking to utilize TPDiff for Arm PRs. |
|
I'm not so sure about making superpmi-shim-collector rely on NativeAOT. In bring-up scenarios I would expect that we want to be able to record SuperPMI collections well before we have a working NativeAOT for the target platform. I don't have too many concerns about moving the other tooling and replaying side, however. |
These days, we typically have a working coreclr+nativeaot runtimes ported in one shot, since most of the asm helpers are shared. Besides, we start needing SPMI type of tooling once we have a working stack. NativeAOT went from an optional to a required component on desktop platforms (where we run the spmi host). |
Well, working NativeAOT depends on working JIT. If the JIT is not working my go to dev loop would have me using natively compiled superpmi-shim-collector on the target when isolating the repro. |
AFAIK, (and I think it’s written in the porting docs) new platforms are always cross compiled during the port work, and we use host platform toolchain to emit for the target until the port is completed. At least this is how five platforms were ported in past few years. |
Sure, how superpmi-shim-collector and coreclr are compiled for for the target does not matter much to this workflow. |
I don't think the workflow changes in practice:
|
I do not think bring-ups like LoongArch64 had working crossgen2/ILC until a much later point-in-time. All the focus was on coreclr/corerun and the initial work was around running trivial examples with corerun. It is also the approach pointed at by https://github.com/dotnet/runtime/blob/main/docs/design/coreclr/botr/guide-for-porting.md. I assume most of this PR is LLM-coded? It seems likely that during bring-up an LLM could just create an ad-hoc native version of superpmi-shim-collector if necessary, so in practice this may not even matter. |
|
Yup, at the time LA64 and RV64 were ported, nativeaot and surrounding infra was handwritten. These days we are in a much better situation a) due to more code sharing (e.g. src/native/minipal, src/coreclr/minipal, src/coreclr/runtime etc. are shared layers) and b) LLM can accelerate going from zero to working hello-world app on a new target over a weekend: #128783. |
|
I agree with @am11 that that the historical way of doing new architecture ports is not necessarily the best way of doing new architecture ports going forward. #128783 suggests that NAOT is a better target for initial bring up. Also, I expect that we will eventually get to a place where AOT/R2R compilation is required for the JITed runtime startup. In that world, doing AOT bring up first is going to be the only viable path. |
|
Validated with a scratch JIT that faults (null write / div-by-zero, or
|
Co-authored-by: Cursor <[email protected]>
|
@jakobbotsch, the remaining |
|
/azp runtime-coreclr superpmi-collect-test |
|
Command 'runtime-coreclr' is not supported by Azure Pipelines. Supported commands
See additional documentation. |
|
@am11 This is a massive change, I still need to review and test it more thoroughly. I am doing that as time allows, but there's a lot of stuff coming in. |
|
/azp run runtime-coreclr superpmi-collect-test |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
# Conflicts: # src/coreclr/tools/superpmi/CMakeLists.txt # src/coreclr/tools/superpmi/superpmi-shared/spmiutil.cpp # src/coreclr/tools/superpmi/superpmi-shared/standardpch.h # src/coreclr/tools/superpmi/superpmi/cycletimer.cpp # src/coreclr/tools/superpmi/superpmi/jitdebugger.cpp # src/coreclr/tools/superpmi/superpmi/jithost.cpp # src/coreclr/tools/superpmi/superpmi/parallelsuperpmi.cpp
- Count the calls of superpmi-shim-counter and write the counts natively, so no managed code runs when the shim is unloaded. - Let the counter shim set itself up in its own jitStartup/getJit instead of ForwardingShim.OnStartup. - Get the CPU time of the replay thread through P/Invoke instead of a native helper. - Clarify how RecordingJitInfo keeps the EE's exceptions out of managed frames. - Default the real JIT name to clrjit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
RecordingJitInfo calls the EE, then passes the arguments, the result and the exception code (if the EE threw) to the generated managed recorder, which only records them. This removes OriginalJitInfo, the native forwarders and the pending call. The few extra EE queries are made natively: the "fat" method context data and getArgType's getArgClass are recorded through RecordingJitInfo, and the collection filter and the GC layout length use unrecorded helpers. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| host->freeStringConfigValue(value); | ||
| } | ||
|
|
||
| extern "C" const char* Shim_GetProcessCommandLine() |


superpmi, mcs and the collector, counter and simple shims are now C#, published with NativeAOT under the same names, command lines, outputs and locations, so they are drop-in replacements; the native sources are deleted.