Skip to content
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

Non-PGO calli/delegate call transformation #109679

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
10 changes: 9 additions & 1 deletion src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2326,7 +2326,7 @@ class ICorStaticInfo
CORINFO_CLASS_HANDLE cls
) = 0;

// Returns the assembly name of the class "cls", or nullptr if there is none.
// Returns the assembly name of the class "cls", or nullptr if there is none.
virtual const char* getClassAssemblyName (
CORINFO_CLASS_HANDLE cls
) = 0;
Expand Down Expand Up @@ -2611,6 +2611,14 @@ class ICorStaticInfo
CorInfoClassId classId
) = 0;

// returns the method the delegate object calls
virtual CORINFO_METHOD_HANDLE getMethodFromDelegate (
CORINFO_CLASS_HANDLE calledCls,
CORINFO_OBJECT_HANDLE delObj,
CORINFO_CLASS_HANDLE* methodCls,
CORINFO_CLASS_HANDLE* targetCls
) = 0;

// "System.Int32" ==> CORINFO_TYPE_INT..
virtual CorInfoType getTypeForPrimitiveValueClass(
CORINFO_CLASS_HANDLE cls
Expand Down
6 changes: 6 additions & 0 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,12 @@ void classMustBeLoadedBeforeCodeIsRun(
CORINFO_CLASS_HANDLE getBuiltinClass(
CorInfoClassId classId) override;

CORINFO_METHOD_HANDLE getMethodFromDelegate(
CORINFO_CLASS_HANDLE calledCls,
CORINFO_OBJECT_HANDLE delegateObj,
CORINFO_CLASS_HANDLE* methodCls,
CORINFO_CLASS_HANDLE* targetCls) override;

CorInfoType getTypeForPrimitiveValueClass(
CORINFO_CLASS_HANDLE cls) override;

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 @@ -43,11 +43,11 @@ typedef const GUID *LPCGUID;
#define GUID_DEFINED
#endif // !GUID_DEFINED

constexpr GUID JITEEVersionIdentifier = { /* 9014d652-5dc7-4edf-9285-6644d0898fb5 */
0x9014d652,
0x5dc7,
0x4edf,
{0x92, 0x85, 0x66, 0x44, 0xd0, 0x89, 0x8f, 0xb5}
constexpr GUID JITEEVersionIdentifier = { /* b96e2e14-6e3c-48a2-aa20-650d9dcb6673 */
0xb96e2e14,
0x6e3c,
0x48a2,
{0xaa, 0x20, 0x65, 0x0d, 0x9d, 0xcb, 0x66, 0x73}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
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 @@ -81,6 +81,7 @@ DEF_CLR_API(getReadyToRunDelegateCtorHelper)
DEF_CLR_API(initClass)
DEF_CLR_API(classMustBeLoadedBeforeCodeIsRun)
DEF_CLR_API(getBuiltinClass)
DEF_CLR_API(getMethodFromDelegate)
DEF_CLR_API(getTypeForPrimitiveValueClass)
DEF_CLR_API(getTypeForPrimitiveNumericClass)
DEF_CLR_API(canCast)
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,18 @@ CORINFO_CLASS_HANDLE WrapICorJitInfo::getBuiltinClass(
return temp;
}

CORINFO_METHOD_HANDLE WrapICorJitInfo::getMethodFromDelegate(
CORINFO_CLASS_HANDLE calledCls,
CORINFO_OBJECT_HANDLE delegateObj,
CORINFO_CLASS_HANDLE* methodCls,
CORINFO_CLASS_HANDLE* targetCls)
{
API_ENTER(getMethodFromDelegate);
CORINFO_METHOD_HANDLE temp = wrapHnd->getMethodFromDelegate(calledCls, delegateObj, methodCls, targetCls);
API_LEAVE(getMethodFromDelegate);
return temp;
}

CorInfoType WrapICorJitInfo::getTypeForPrimitiveValueClass(
CORINFO_CLASS_HANDLE cls)
{
Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3920,7 +3920,7 @@ class Compiler

// false: we can add new tracked variables.
// true: We cannot add new 'tracked' variable
bool lvaTrackedFixed = false;
bool lvaTrackedFixed = false;

unsigned lvaCount; // total number of locals, which includes function arguments,
// special arguments, IL local variables, and JIT temporary variables
Expand Down Expand Up @@ -4560,6 +4560,7 @@ class Compiler
void impPopArgsForUnmanagedCall(GenTreeCall* call, CORINFO_SIG_INFO* sig, GenTree** swiftErrorNode);
void impPopArgsForSwiftCall(GenTreeCall* call, CORINFO_SIG_INFO* sig, GenTree** swiftErrorNode);
void impRetypeUnmanagedCallArgs(GenTreeCall* call);
bool impCanSubstituteSig(CORINFO_SIG_INFO* sourceSig, CORINFO_SIG_INFO* targetSig);

#ifdef SWIFT_SUPPORT
void impAppendSwiftErrorStore(GenTree* const swiftErrorNode);
Expand Down Expand Up @@ -6879,15 +6880,15 @@ class Compiler
unsigned acdCount = 0;

// Get the index to use as part of the AddCodeDsc key for sharing throw blocks
unsigned bbThrowIndex(BasicBlock* blk, AcdKeyDesignator* dsg);
unsigned bbThrowIndex(BasicBlock* blk, AcdKeyDesignator* dsg);

struct AddCodeDscKey
{
public:
AddCodeDscKey(): acdKind(SCK_NONE), acdData(0) {}
AddCodeDscKey(SpecialCodeKind kind, BasicBlock* block, Compiler* comp);
AddCodeDscKey(AddCodeDsc* add);

static bool Equals(const AddCodeDscKey& x, const AddCodeDscKey& y)
{
return (x.acdData == y.acdData) && (x.acdKind == y.acdKind);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12067,7 +12067,7 @@ void Compiler::gtDispConst(GenTree* tree)
}
else if (tree->IsIconHandle(GTF_ICON_OBJ_HDL))
{
eePrintObjectDescription(" ", (CORINFO_OBJECT_HANDLE)tree->AsIntCon()->gtIconVal);
eePrintObjectDescription(" ", tree->AsIntCon()->GetFrozenObject());
}
else
{
Expand Down Expand Up @@ -19073,7 +19073,7 @@ CORINFO_CLASS_HANDLE Compiler::gtGetClassHandle(GenTree* tree, bool* pIsExact, b
{
if (obj->IsIconHandle(GTF_ICON_OBJ_HDL))
{
objClass = info.compCompHnd->getObjectType((CORINFO_OBJECT_HANDLE)obj->AsIntCon()->IconValue());
objClass = info.compCompHnd->getObjectType(obj->AsIntCon()->GetFrozenObject());
if (objClass != NO_CLASS_HANDLE)
{
// if we managed to get a class handle it's definitely not null
Expand Down
14 changes: 14 additions & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -3288,6 +3288,20 @@ struct GenTreeIntCon : public GenTreeIntConCommon
{
}
#endif

CORINFO_OBJECT_HANDLE GetFrozenObject()
{
assert(IsIconHandle(GTF_ICON_OBJ_HDL));
return (CORINFO_OBJECT_HANDLE)IconValue();
}

CORINFO_FIELD_HANDLE GetStaticFieldHandle()
{
assert(IsIconHandle(GTF_ICON_STATIC_BOX_PTR) || IsIconHandle(GTF_ICON_CONST_PTR) ||
IsIconHandle(GTF_ICON_STATIC_HDL));
assert(gtFieldSeq != nullptr);
return gtFieldSeq->GetFieldHandle();
}
};

/* gtLngCon -- long constant (GT_CNS_LNG) */
Expand Down
Loading
Loading