Skip to content

Commit

Permalink
Start marking generic virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
hez2010 committed Feb 16, 2025
1 parent 8a79637 commit 114d3c4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10082,6 +10082,10 @@ JITDBGAPI void __cdecl cTreeFlags(Compiler* comp, GenTree* tree)
{
chars += printf("[CALL_VIRT_STUB]");
}
if (tree->AsCall()->IsVirtualGeneric())
{
chars += printf("[CALL_VIRT_GENERIC]");
}
if (tree->gtFlags & GTF_CALL_NULLCHECK)
{
chars += printf("[CALL_NULLCHECK]");
Expand Down
7 changes: 6 additions & 1 deletion src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,8 @@ enum GenTreeFlags : unsigned int
GTF_CALL_VIRT_KIND_MASK = 0x30000000, // GT_CALL -- mask of the below call kinds
GTF_CALL_NONVIRT = 0x00000000, // GT_CALL -- a non virtual call
GTF_CALL_VIRT_STUB = 0x10000000, // GT_CALL -- a stub-dispatch virtual call
GTF_CALL_VIRT_VTABLE = 0x20000000, // GT_CALL -- a vtable-based virtual call
GTF_CALL_VIRT_VTABLE = 0x20000000, // GT_CALL -- a vtable-based virtual call
GTF_CALL_VIRT_GENERIC = 0x30000000, // GT_CALL -- a generic virtual call

GTF_CALL_NULLCHECK = 0x08000000, // GT_CALL -- must check instance pointer for null
GTF_CALL_POP_ARGS = 0x04000000, // GT_CALL -- caller pop arguments?
Expand Down Expand Up @@ -5331,6 +5332,10 @@ struct GenTreeCall final : public GenTree
{
return (gtFlags & GTF_CALL_VIRT_KIND_MASK) == GTF_CALL_VIRT_VTABLE;
}
bool IsVirtualGeneric() const
{
return (gtFlags & GTF_CALL_VIRT_KIND_MASK) == GTF_CALL_VIRT_GENERIC;
}
bool IsInlineCandidate() const
{
return (gtFlags & GTF_CALL_INLINE_CANDIDATE) != 0;
Expand Down
13 changes: 8 additions & 5 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,14 @@ var_types Compiler::impImportCall(OPCODE opcode,
call->AsCall()->gtCallAddr = fptr;
call->gtFlags |= GTF_EXCEPT | (fptr->gtFlags & GTF_GLOB_EFFECT);

if ((sig->sigInst.methInstCount != 0) && IsTargetAbi(CORINFO_NATIVEAOT_ABI))
if (sig->sigInst.methInstCount != 0)
{
// NativeAOT generic virtual method: need to handle potential fat function pointers
addFatPointerCandidate(call->AsCall());
call->gtFlags |= GTF_CALL_VIRT_GENERIC;
if (IsTargetAbi(CORINFO_NATIVEAOT_ABI))
{
// NativeAOT generic virtual method: need to handle potential fat function pointers
addFatPointerCandidate(call->AsCall());
}
}
#ifdef FEATURE_READYTORUN
if (opts.IsReadyToRun())
Expand Down Expand Up @@ -8348,8 +8352,7 @@ void Compiler::impDevirtualizeCall(GenTreeCall* call,
JITDUMP(" %s; can devirtualize\n", note);

// Make the updates.
call->gtFlags &= ~GTF_CALL_VIRT_VTABLE;
call->gtFlags &= ~GTF_CALL_VIRT_STUB;
call->gtFlags &= ~GTF_CALL_VIRT_KIND_MASK;
call->gtCallMethHnd = derivedMethod;
call->gtCallType = CT_USER_FUNC;
call->gtControlExpr = nullptr;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2852,6 +2852,7 @@ GenTree* Lowering::LowerCall(GenTree* node)
}
break;

case GTF_CALL_VIRT_GENERIC:
case GTF_CALL_NONVIRT:
if (call->IsUnmanaged())
{
Expand Down

0 comments on commit 114d3c4

Please sign in to comment.