Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7d27090
Initial
jakobbotsch Oct 4, 2025
6743534
Fix build, make tests run
jakobbotsch Oct 4, 2025
0f8cd9c
Tailored continuation layouts
jakobbotsch Oct 4, 2025
a642f42
Update type
jakobbotsch Oct 4, 2025
03a640d
Fix bug
jakobbotsch Oct 4, 2025
a99ce96
Fix some bugs
jakobbotsch Oct 4, 2025
fa1820a
Run thunk generator
jakobbotsch Oct 4, 2025
e4a75f1
Create a manager in the LoaderAllocator to hold map and create types
jakobbotsch Oct 6, 2025
82995d5
Use SPC for continuation's module
jakobbotsch Oct 6, 2025
38bdf11
Remove unnecessary continuation allocation
jakobbotsch Oct 6, 2025
97de35e
Fix some bugs
jakobbotsch Oct 6, 2025
fb296e3
Fix type GC info, add debug name, remove comments
jakobbotsch Oct 7, 2025
a3e223f
Refactor building of obj refs bitmap into helper class
jakobbotsch Oct 7, 2025
71b47b0
Properly allocate space for KeepAlive object
jakobbotsch Oct 7, 2025
7df6464
Merge branch 'main' of github.com:dotnet/runtime into tailored-contin…
jakobbotsch Oct 7, 2025
badee7d
Fix bitmap building for implicit byrefs
jakobbotsch Oct 7, 2025
56c403a
Run jit-format, remove copilot comment
jakobbotsch Oct 7, 2025
ca7ef69
Move Continuation MT into a static
jakobbotsch Oct 8, 2025
9d6d275
Remove added newline
jakobbotsch Oct 8, 2025
04cd9f4
Undo another change
jakobbotsch Oct 8, 2025
2c30029
Undo name change
jakobbotsch Oct 8, 2025
21ab2fc
Add a cache for created layout types
jakobbotsch Oct 8, 2025
a45427b
Fix a bug
jakobbotsch Oct 8, 2025
37fd434
Fix another bug
jakobbotsch Oct 8, 2025
15f205a
Fix debug counting
jakobbotsch Oct 8, 2025
d48bcd5
Merge branch 'main' of github.com:dotnet/runtime into tailored-contin…
jakobbotsch Oct 10, 2025
8a6564e
Fix MethodTable::ValidateWithPossibleAV for new types
jakobbotsch Oct 10, 2025
a92ca94
Add assert in `GetModule()`, make `GetType()` return `typeof(Continua…
jakobbotsch Oct 10, 2025
4d99c5b
Minor cleanups
jakobbotsch Oct 14, 2025
cd4fbd5
Throw `NotSupportedException` for Object.GetType() called on continua…
jakobbotsch Oct 14, 2025
3bde22a
Update src/coreclr/System.Private.CoreLib/src/System/Runtime/Compiler…
jakobbotsch Oct 14, 2025
c1d737f
Merge branch 'main' of github.com:dotnet/runtime into tailored-contin…
jakobbotsch Oct 14, 2025
11033f6
Handle large alignment requirements
jakobbotsch Oct 14, 2025
83bcde7
Fix after merge
jakobbotsch Oct 14, 2025
b6ad42e
Allocate singleton subclassed continuation with a corresponding `EECl…
jakobbotsch Oct 14, 2025
5e4fb40
Enable runtime async by default for testing
jakobbotsch Oct 14, 2025
a21a7a8
Fix bug
jakobbotsch Oct 15, 2025
84b205c
Run jit-format
jakobbotsch Oct 15, 2025
7b5f8a7
Give continuations names, fire profiler/ETW events
jakobbotsch Oct 15, 2025
df38ceb
Get Continuation class name from EE
jakobbotsch Oct 15, 2025
91158a1
Fire duplicate TypeLoadEnd events instead of no matching pair
jakobbotsch Oct 15, 2025
98917c0
Fix non Windows build
jakobbotsch Oct 15, 2025
ec99d53
Fix OFFSETOF__CORINFO_Continuation__data for 32 bit
jakobbotsch Oct 16, 2025
9b3eea9
Remove CORINFO_CONTINUATION_DATA_OFFSETS; implement SuperPMI support
jakobbotsch Oct 16, 2025
21698ea
Sort all object refs to be first
jakobbotsch Oct 16, 2025
69f8eb6
Pass keep alive offset as an argument to complex allocation helpers
jakobbotsch Oct 16, 2025
f5bb499
Remove managed MethodTable.IsContinuation
jakobbotsch Oct 16, 2025
ee717bd
Address feedback
jakobbotsch Oct 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/prompts/add-new-jit-ee-api.prompt.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
---
mode: 'agent'
tools: ['githubRepo', 'codebase', 'terminalLastCommand']
tools: ['fetch', 'codebase', 'runCommands', 'usages', 'search', 'think']
description: 'Add a new API to the JIT-VM (aka JIT-EE) interface in the codebase.'
---

#### 1 — Goal

Implement **one** new JIT-VM (also known as JIT-EE) API and all supporting glue.
Implement **one** new JIT-VM (also known as JIT-EE) API and all supporting glue.
The JIT-VM interface defines the APIs through which the JIT compiler communicates with the runtime (VM).

#### 2 — Prerequisites for the model

* You have full repo access
* You may run scripts (e.g., `.sh` or `.bat`)
* You may run scripts (e.g., `.sh` or `.bat`)
* Ask **clarifying questions** before the first code change if anything (signature, types, platform constraints) is unclear.

#### 3 — Required user inputs

Ask the user for a C-like signature of the new API if it's not provided.
Ask the user for a C-like signature of the new API if it's not provided.
Suggest `<repo_root>/src/coreclr/tools/Common/JitInterface/ThunkGenerator/ThunkInput.txt` file as a reference. Example:

```
Expand Down Expand Up @@ -83,8 +83,8 @@ Use the correct directory for the script to run.
+}
```

6. Now implement the most complex part - SuperPMI. SuperPMI acts as a (de)serializer for JIT-VM queries in order
to then replay them without the actual VM to speed up jit-diffs and other scenarios. All parameters and return
6. Now implement the most complex part - SuperPMI. SuperPMI acts as a (de)serializer for JIT-VM queries in order
to then replay them without the actual VM to speed up jit-diffs and other scenarios. All parameters and return
values recorded/restored using special primitve types and helpers. We need to update the following files:

* `<repo_root>/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h`:
Expand All @@ -96,7 +96,7 @@ Go through each of them one by one.

* `<repo_root>/src/coreclr/tools/superpmi/superpmi-shared/agnostic.h`:
Define two `Agnostic_*` types for input arguments and another one for output parameters (return value, output arguments).
Do not create them if one of the generics ones can be re-used such as `DLD`, `DD`, `DLDL`, etc. Use `DWORD*`
Do not create them if one of the generics ones can be re-used such as `DLD`, `DD`, `DLDL`, etc. Use `DWORD*`
like types for integers. Inspect the whole file to see how other APIs are defined.

* `<repo_root>/src/coreclr/tools/superpmi/superpmi-shared/lwmlist.h`:
Expand Down Expand Up @@ -126,7 +126,7 @@ Now add a new element to `enum mcPackets` enum in the same file. Example:
```

* `<repo_root>/src/coreclr/tools/superpmi/superpmi-shared/methodcontext.cpp`:
Add the implementation of the 3 methods to `methodcontext.cpp` at the end of it.
Add the implementation of the 3 methods to `methodcontext.cpp` at the end of it.
Consider other similar methods in the file for reference. Do not change implementations of other methods in the file. Example:

```diff
Expand Down

Large diffs are not rendered by default.

55 changes: 32 additions & 23 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1698,29 +1698,34 @@ struct CORINFO_EE_INFO
CORINFO_OS osType;
};

// Keep in sync with ContinuationFlags enum in BCL sources
enum CorInfoContinuationFlags
{
// Whether or not the continuation expects the result to be boxed and
// placed in the GCData array at index 0. Not set if the callee is void.
CORINFO_CONTINUATION_RESULT_IN_GCDATA = 1,
// If this bit is set the continuation resumes inside a try block and thus
// if an exception is being propagated, needs to be resumed. The exception
// should be placed at index 0 or 1 depending on whether the continuation
// also expects a result.
CORINFO_CONTINUATION_NEEDS_EXCEPTION = 2,
// If this bit is set the continuation has the IL offset that inspired the
// OSR method saved in the beginning of 'Data', or -1 if the continuation
// belongs to a tier 0 method.
CORINFO_CONTINUATION_OSR_IL_OFFSET_IN_DATA = 4,
// Note: the following 'Has' members determine the members present at
// the beginning of the continuation's data chunk. Each field is
// pointer sized when present, apart from the result that has variable
// size.

// Whether or not the continuation starts with an OSR IL offset.
CORINFO_CONTINUATION_HAS_OSR_ILOFFSET = 1,
// If this bit is set the continuation resumes inside a try block and
// thus if an exception is being propagated, needs to be resumed.
CORINFO_CONTINUATION_HAS_EXCEPTION = 2,
// If this bit is set the continuation has space for a continuation
// context.
CORINFO_CONTINUATION_HAS_CONTINUATION_CONTEXT = 4,
// If this bit is set the continuation has space to store a result
// returned by the callee.
CORINFO_CONTINUATION_HAS_RESULT = 8,
// If this bit is set the continuation should continue on the thread
// pool.
CORINFO_CONTINUATION_CONTINUE_ON_THREAD_POOL = 8,
// If this bit is set the continuation has a SynchronizationContext
// that we should continue on.
CORINFO_CONTINUATION_CONTINUE_ON_CAPTURED_SYNCHRONIZATION_CONTEXT = 16,
// If this bit is set the continuation has a TaskScheduler
// that we should continue on.
CORINFO_CONTINUATION_CONTINUE_ON_CAPTURED_TASK_SCHEDULER = 32,
CORINFO_CONTINUATION_CONTINUE_ON_THREAD_POOL = 16,
// If this bit is set the continuation context is a
// SynchronizationContext that we should continue on.
CORINFO_CONTINUATION_CONTINUE_ON_CAPTURED_SYNCHRONIZATION_CONTEXT = 32,
// If this bit is set the continuation context is a TaskScheduler that
// we should continue on.
CORINFO_CONTINUATION_CONTINUE_ON_CAPTURED_TASK_SCHEDULER = 64,
};

struct CORINFO_ASYNC_INFO
Expand All @@ -1735,10 +1740,6 @@ struct CORINFO_ASYNC_INFO
CORINFO_FIELD_HANDLE continuationStateFldHnd;
// 'Flags' field
CORINFO_FIELD_HANDLE continuationFlagsFldHnd;
// 'Data' field
CORINFO_FIELD_HANDLE continuationDataFldHnd;
// 'GCData' field
CORINFO_FIELD_HANDLE continuationGCDataFldHnd;
// Whether or not the continuation needs to be allocated through the
// helper that also takes a method handle
bool continuationsNeedMethodHandle;
Copy link
Member

Choose a reason for hiding this comment

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

bool continuationsNeedMethodHandle is no longer needed and it can be deleted. The continuation type is attached to the collectible loader allocator now. It will prevent the loader allocator from unloading and we do not need to keep it alive explicitly.

(The shared generic handling done on the JIT side right before continuationsNeedMethodHandle is checked is still needed.)

Expand Down Expand Up @@ -1960,6 +1961,8 @@ struct CORINFO_FPSTRUCT_LOWERING
#define OFFSETOF__CORINFO_Span__reference 0
#define OFFSETOF__CORINFO_Span__length TARGET_POINTER_SIZE

#define OFFSETOF__CORINFO_Continuation__data (SIZEOF__CORINFO_Object + TARGET_POINTER_SIZE /* Next */ + TARGET_POINTER_SIZE /* Resume */ + 8 /* Flags + State */)


/* data to optimize delegate construction */
struct DelegateCtorArgs
Expand Down Expand Up @@ -3342,6 +3345,12 @@ class ICorDynamicInfo : public ICorStaticInfo

virtual CORINFO_METHOD_HANDLE getAsyncResumptionStub() = 0;

virtual CORINFO_CLASS_HANDLE getContinuationType(
size_t dataSize,
bool* objRefs,
size_t objRefsSize
) = 0;

// Optionally, convert calli to regular method call. This is for PInvoke argument marshalling.
virtual bool convertPInvokeCalliToCall(
CORINFO_RESOLVED_TOKEN * pResolvedToken,
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_TypedReferenceMT, ::g_TypedReferenceM
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pWeakReferenceClass, ::g_pWeakReferenceClass)
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pWeakReferenceOfTClass, ::g_pWeakReferenceOfTClass)

DEFINE_DACVAR_VOLATILE(UNKNOWN_POINTER_TYPE, dac__g_pContinuationClassIfSubTypeCreated, ::g_pContinuationClassIfSubTypeCreated)

#ifdef FEATURE_COMINTEROP
DEFINE_DACVAR(UNKNOWN_POINTER_TYPE, dac__g_pBaseCOMObject, ::g_pBaseCOMObject)
#endif
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ bool getTailCallHelpers(
CORINFO_GET_TAILCALL_HELPERS_FLAGS flags,
CORINFO_TAILCALL_HELPERS* pResult) override;

CORINFO_CLASS_HANDLE getContinuationType(
size_t dataSize,
bool* objRefs,
size_t objRefsSize) override;

CORINFO_METHOD_HANDLE getAsyncResumptionStub() override;

bool convertPInvokeCalliToCall(
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* 3d2bdd20-eced-4a07-b9fb-227ce7f55fcd */
0x3d2bdd20,
0xeced,
0x4a07,
{0xb9, 0xfb, 0x22, 0x7c, 0xe7, 0xf5, 0x5f, 0xcd}
constexpr GUID JITEEVersionIdentifier = { /* 68e93e9d-dd28-49ca-9ebc-a01a54532bb3 */
0x68e93e9d,
0xdd28,
0x49ca,
{0x9e, 0xbc, 0xa0, 0x1a, 0x54, 0x53, 0x2b, 0xb3}
};

#endif // JIT_EE_VERSIONING_GUID_H
1 change: 1 addition & 0 deletions src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ DEF_CLR_API(getFieldThreadLocalStoreID)
DEF_CLR_API(GetDelegateCtor)
DEF_CLR_API(MethodCompileComplete)
DEF_CLR_API(getTailCallHelpers)
DEF_CLR_API(getContinuationType)
DEF_CLR_API(getAsyncResumptionStub)
DEF_CLR_API(convertPInvokeCalliToCall)
DEF_CLR_API(notifyInstructionSetUsage)
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,17 @@ bool WrapICorJitInfo::getTailCallHelpers(
return temp;
}

CORINFO_CLASS_HANDLE WrapICorJitInfo::getContinuationType(
size_t dataSize,
bool* objRefs,
size_t objRefsSize)
{
API_ENTER(getContinuationType);
CORINFO_CLASS_HANDLE temp = wrapHnd->getContinuationType(dataSize, objRefs, objRefsSize);
API_LEAVE(getContinuationType);
return temp;
}

CORINFO_METHOD_HANDLE WrapICorJitInfo::getAsyncResumptionStub()
{
API_ENTER(getAsyncResumptionStub);
Expand Down
Loading
Loading