Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6120dec
Part 1: add tests and instParamLookup refactor
hez2010 Apr 15, 2026
007d14f
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 Apr 15, 2026
42d5011
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 Apr 22, 2026
e7acb94
Address review feedbacks
hez2010 Apr 25, 2026
eeb97f8
Update src/coreclr/inc/corinfo.h
hez2010 Apr 25, 2026
7dfc4f3
Use hasTypeArg instead of leaking CORINFO_LOOKUP
hez2010 Apr 25, 2026
c3e08f2
Merge branch 'shared-gvm-devirt/1-tests-instparamlookup' of github.co…
hez2010 Apr 25, 2026
5942cb8
Switch back to needsMethodContext
hez2010 Apr 25, 2026
7c8536e
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
jakobbotsch Apr 28, 2026
44fd8f5
Get rid of needsMethodContext in addGuardedDevirtualizationCandidate
hez2010 Apr 30, 2026
ff34512
Remove a couple of redundant assertions
hez2010 May 4, 2026
12f5e75
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 May 4, 2026
82d01b9
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 May 4, 2026
e48b7b8
Bring back the separate needsMethodContext
hez2010 May 5, 2026
8bacc6d
Extract a tail for impDevirtualizeCall
hez2010 May 7, 2026
40137e8
Wire GDV to the new devirt transform tail
hez2010 May 7, 2026
0918712
jit format
hez2010 May 7, 2026
04f4d98
Oops
hez2010 May 7, 2026
7eb07c2
Rename exactContext to tokenLookupContext
hez2010 May 7, 2026
173e637
More cleanup
hez2010 May 15, 2026
8245929
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 May 15, 2026
df165e6
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 May 18, 2026
81d1b95
Use methInfo.args.hasTypeArg
hez2010 May 18, 2026
fd5bafb
Stop communicating with lookup sentinel value
hez2010 May 18, 2026
0509d1b
Merge remote-tracking branch 'origin/main' into shared-gvm-devirt/1-t…
hez2010 May 19, 2026
1f8c758
Correctly handle method context in GDV
hez2010 May 19, 2026
e7c0082
Move debug print to devirt tail
hez2010 May 19, 2026
48312ee
Address feedbacks
hez2010 May 20, 2026
52fefff
Match the context handling in impImportCall
hez2010 May 20, 2026
c5734a2
Merge remote-tracking branch 'origin/main' into shared-gvm-devirt/1-t…
hez2010 May 20, 2026
4a84096
Unify the inst param handling in devirt tail
hez2010 May 21, 2026
dddfb18
Pass the IL offset
hez2010 May 21, 2026
de5e241
Remove unnecessary guard
hez2010 May 21, 2026
3682fc7
Always pass a valid base method handle
hez2010 May 22, 2026
ef634dc
Merge remote-tracking branch 'origin/main' into shared-gvm-devirt/1-t…
hez2010 May 22, 2026
1ef516f
Remove dead code for now
hez2010 May 23, 2026
aea7a8f
Merge branch 'main' into shared-gvm-devirt/1-tests-instparamlookup
hez2010 May 23, 2026
eaca574
Address a regression
hez2010 May 23, 2026
c5816f4
Experiment for zero-diff
hez2010 May 23, 2026
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
13 changes: 5 additions & 8 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,6 @@ struct CORINFO_CONST_LOOKUP
// IAT_PVALUE --> "addr" stores a pointer to a location which will hold the real handle
// IAT_RELPVALUE --> "addr" stores a relative pointer to a location which will hold the real handle
// IAT_PPVALUE --> "addr" stores a double indirection to a location which will hold the real handle

InfoAccessType accessType;
union
{
Expand Down Expand Up @@ -1585,21 +1584,19 @@ struct CORINFO_DEVIRTUALIZATION_INFO
// [Out] results of resolveVirtualMethod.
// - devirtualizedMethod is set to MethodDesc of devirt'ed method iff we were able to devirtualize.
// invariant is `resolveVirtualMethod(...) == (devirtualizedMethod != nullptr)`.
// - exactContext is set to wrapped CORINFO_CLASS_HANDLE of devirt'ed method table.
// - tokenLookupContext is set to the wrapped context handle to use for token lookups after devirtualization.
// - details on the computation done by the jit host
// - If pResolvedTokenDevirtualizedMethod is not set to NULL and targeting an R2R image
// use it as the parameter to getCallInfo
// - isInstantiatingStub is set to TRUE if the devirtualized method is a generic method instantiating stub
// - needsMethodContext is set TRUE if the devirtualized method may require a method context
// (in which case the method handle and context will be a generic method)
// - instParamLookup contains all the information necessary to pass the instantiation parameter for
// the devirtualized method. A constant lookup with IAT_VALUE with a nullptr handle indicates no instantiation parameter is needed.
//
CORINFO_METHOD_HANDLE devirtualizedMethod;
CORINFO_CONTEXT_HANDLE exactContext;
CORINFO_CONTEXT_HANDLE tokenLookupContext;
CORINFO_DEVIRTUALIZATION_DETAIL detail;
CORINFO_RESOLVED_TOKEN resolvedTokenDevirtualizedMethod;
CORINFO_RESOLVED_TOKEN resolvedTokenDevirtualizedUnboxedMethod;
bool isInstantiatingStub;
bool needsMethodContext;
CORINFO_LOOKUP instParamLookup;
};

//----------------------------------------------------------------------------
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 = { /* 5635ae9d-ffa5-4336-b027-a383971e3918 */
0x5635ae9d,
0xffa5,
0x4336,
{0xb0, 0x27, 0xa3, 0x83, 0x97, 0x1e, 0x39, 0x18}
constexpr GUID JITEEVersionIdentifier = { /* fc5f63e7-921b-4091-b920-8df8d7b872c1 */
0xfc5f63e7,
0x921b,
0x4091,
{0xb9, 0x20, 0x8d, 0xf8, 0xd7, 0xb8, 0x72, 0xc1}
};

#endif // JIT_EE_VERSIONING_GUID_H
62 changes: 44 additions & 18 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4959,6 +4959,34 @@ class Compiler
bool isExplicitTailCall,
IL_OFFSET ilOffset = BAD_IL_OFFSET);

// Information needed to turn a resolved devirtualization target into a direct call.
struct DevirtualizedCallInfo
{
CORINFO_CONTEXT_HANDLE tokenLookupContext; // The class context or method context
CORINFO_RESOLVED_TOKEN* pResolvedToken; // Resolved token for the target method, used by R2R.
CORINFO_RESOLVED_TOKEN* pUnboxedResolvedToken; // Resolved token for the unboxed entry, used by R2R.
CORINFO_LOOKUP* pInstParamLookup; // All the information needed for the instantiation parameter lookup.
bool objIsNonNull; // True if the receiver is known non-null.
bool hadImplicitNullCheck; // True if the original call's null check was implicit.
bool isDelegateCall; // True when transforming a delegate invoke into a direct call.
bool isExplicitTailCall; // True for explicit tail calls.
bool objClassIsExact; // True if the receiver type is exact.
bool objClassIsFinal; // True if the receiver type is final.
IL_OFFSET ilOffset; // IL offset of the original call.
};

void impTransformDevirtualizedCall(GenTreeCall* call,
CORINFO_METHOD_HANDLE* method,
unsigned* methodFlags,
DevirtualizedCallInfo* dcInfo,
BasicBlock* block,
CORINFO_CONTEXT_HANDLE* contextHandle,
CORINFO_CONTEXT_HANDLE* exactContextHandle
#if defined(DEBUG)
, CORINFO_METHOD_HANDLE baseMethod
#endif // defined(DEBUG)
);

bool impConsiderCallProbe(GenTreeCall* call, IL_OFFSET ilOffset);

enum class GDVProbeType
Expand Down Expand Up @@ -7102,13 +7130,11 @@ class Compiler
GenTree* fgCreateCallDispatcherAndGetResult(GenTreeCall* origCall,
CORINFO_METHOD_HANDLE callTargetStubHnd,
CORINFO_METHOD_HANDLE dispatcherHnd);
GenTree* getLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_LOOKUP* pLookup,
GenTreeFlags handleFlags,
void* compileTimeHandle);
GenTree* getRuntimeLookupTree(CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_LOOKUP* pLookup,
void* compileTimeHandle);
GenTree* getLookupTree(CORINFO_LOOKUP* pLookup,
GenTreeFlags handleFlags,
void* compileTimeHandle);
GenTree* getRuntimeLookupTree(CORINFO_LOOKUP* pLookup,
void* compileTimeHandle);
GenTree* getVirtMethodPointerTree(GenTree* thisPtr,
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_CALL_INFO* pCallInfo);
Expand Down Expand Up @@ -8002,17 +8028,17 @@ class Compiler

bool isCompatibleMethodGDV(GenTreeCall* call, CORINFO_METHOD_HANDLE gdvTarget);

void addGuardedDevirtualizationCandidate(GenTreeCall* call,
CORINFO_METHOD_HANDLE methodHandle,
CORINFO_CLASS_HANDLE classHandle,
CORINFO_CONTEXT_HANDLE contextHandle,
unsigned methodAttr,
unsigned classAttr,
unsigned likelihood,
bool arrayInterface,
bool instantiatingStub,
CORINFO_METHOD_HANDLE originalMethodHandle,
CORINFO_CONTEXT_HANDLE originalContextHandle);
void addGuardedDevirtualizationCandidate(GenTreeCall* call,
CORINFO_METHOD_HANDLE methodHandle,
CORINFO_CLASS_HANDLE classHandle,
CORINFO_CONTEXT_HANDLE contextHandle,
unsigned methodAttr,
unsigned classAttr,
unsigned likelihood,
const CORINFO_LOOKUP* instParamLookup,
CORINFO_METHOD_HANDLE originalMethodHandle,
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_RESOLVED_TOKEN* pUnboxedResolvedToken);

int getGDVMaxTypeChecks()
{
Expand Down
Loading
Loading