Skip to content

Add a copilot prompt file for JIT-EE interface modifications #115889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented May 22, 2025

Adding new APIs to the JIT-EE interface is time-consuming and is difficult to automate: 15-16 files need to be updated with a complex (de)serialization logic in SPMI. So far, we’ve managed to automate generation for only 7 of those files; the rest still require manual edits. This prompt file (see Prompt Files feature) is designed to help with it. The typical workflow looks like this:

  • Open VSCode Chat Window (in dotnet/runtime repository, root folder)
  • Switch to the Agent mode and Claude Sonnet 4 model (or gpt-4.1, for some reason I've got bad experience with others)
  • Type /add-new-jit-ee-api.prompt (there should be suggestions) and hit enter

image

It is supposed to ask for the signature (e.g. CORINFO_METHOD_HANDLE getHelperHandle(int helperId)) and perform all the modifications (including the gen.sh script).

Alternatively, you can type the signature right away /add-new-jit-ee-api.prompt CORINFO_METHOD_HANDLE getHelperHandle(int helperId)

It managed to successfully generate simple APIs for me (sometimes not from the first try). If it lands, I presume we can improve the prompt to handle more complex cases if it fails on them.

@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label May 22, 2025
@EgorBo
Copy link
Member Author

EgorBo commented May 22, 2025

@stephentoub @mrsharm @dotnet/jit-contrib opinions?

The JIT-VM interface defines the APIs through which the JIT compiler communicates with the runtime (VM).
If the new API signature is not provided, prompt the user for it with `src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt` file as a reference.

For example, assume the following API signature is provided:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the LLM get "assume" wrong at all?

Would a different wording perhaps be better, such as:

The steps to add the new API signature are given below and use the following API signature as an example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this seems better given a few times the LLM got confused and used the example as the actual API it needs to add

@jakobbotsch
Copy link
Member

@stephentoub @mrsharm @dotnet/jit-contrib opinions?

Sounds cool, LGTM 🙂

Comment on lines 13 to 15
[add-new-jit-ee-api.prompt.md](../../.github/prompts/add-new-jit-ee-api.prompt.md) contains a prompt that can be used to add a new JIT-VM API through an agent. Example usage in VSCode:
* Open the Copilot Chat Window
* Type "/add-new-jit-ee-api.prompt" and either hit enter and follow the instructions or provide the API signature directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we retain the old information for environments where no agent mode is available?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should indeed, I just removed the out-of-date stuff, I can update it

@jkotas jkotas added area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels May 22, 2025
Copy link
Contributor

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

Insert the new API definition without removing any existing entries, placing it near similar signatures.

2. Invoke `<repo_root>/src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh` script
(or `<repo_root>/src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh` on Windows) to update auto-generated files.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(or `<repo_root>/src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.sh` on Windows) to update auto-generated files.
(or `<repo_root>/src/coreclr/tools/Common/JitInterface/ThunkGenerator/gen.bat` on Windows) to update auto-generated files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants