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

Remove unused GETFIELD/SETFIELD helpers #105023

Merged
merged 11 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
36 changes: 1 addition & 35 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,23 +145,13 @@ The first 4 options are mutually exclusive
also CORINFO_FLG_STATIC_IN_HEAP).


This last field can modify any of the cases above except CORINFO_FLG_HELPER
This last field can modify any of the cases above

CORINFO_FLG_STATIC_IN_HEAP This is currently only used for static fields of value classes. If the field has
this set then after computing what would normally be the field, what you actually get is a object pointer
(that must be reported to the GC) to a boxed version of the value. Thus the actual field address is computed
by addr = (*addr+sizeof(OBJECTREF))

Instance fields

* CORINFO_FLG_HELPER This is used if the class is MarshalByRef, which means that the object might be a
proxy to the real object in some other appdomain or process. If the field has this set, then the JIT
must call getFieldHelper and call the returned helper with the object ref. If the helper returned is
helpers that are for structures the args are as follows

* CORINFO_HELP_GETFIELDSTRUCT - args are: retBuff, object, fieldDesc
* CORINFO_HELP_SETFIELDSTRUCT - args are object fieldDesc value

The other GET helpers take an object fieldDesc and return the value The other SET helpers take an object
fieldDesc and value

Expand Down Expand Up @@ -499,28 +489,8 @@ enum CorInfoHelpFunc
CORINFO_HELP_ASSIGN_BYREF,
CORINFO_HELP_BULK_WRITEBARRIER,


/* Accessing fields */

// For COM object support (using COM get/set routines to update object)
// and EnC and cross-context support
CORINFO_HELP_GETFIELD8,
CORINFO_HELP_SETFIELD8,
CORINFO_HELP_GETFIELD16,
CORINFO_HELP_SETFIELD16,
CORINFO_HELP_GETFIELD32,
CORINFO_HELP_SETFIELD32,
CORINFO_HELP_GETFIELD64,
CORINFO_HELP_SETFIELD64,
CORINFO_HELP_GETFIELDOBJ,
CORINFO_HELP_SETFIELDOBJ,
CORINFO_HELP_GETFIELDSTRUCT,
CORINFO_HELP_SETFIELDSTRUCT,
CORINFO_HELP_GETFIELDFLOAT,
CORINFO_HELP_SETFIELDFLOAT,
CORINFO_HELP_GETFIELDDOUBLE,
CORINFO_HELP_SETFIELDDOUBLE,

CORINFO_HELP_GETFIELDADDR,
CORINFO_HELP_GETSTATICFIELDADDR,
CORINFO_HELP_GETSTATICFIELDADDR_TLS, // Helper for PE TLS fields
Expand Down Expand Up @@ -2246,10 +2216,6 @@ class ICorStaticInfo
CORINFO_METHOD_HANDLE method
) = 0;

virtual CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl(
CORINFO_METHOD_HANDLE method
) = 0;

// Returns the global cookie for the /GS unsafe buffer checks
// The cookie might be a constant value (JIT), or a handle to memory location (Ngen)
virtual void getGSCookie(
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/inc/icorjitinfoimpl_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ bool satisfiesMethodConstraints(
void methodMustBeLoadedBeforeCodeIsRun(
CORINFO_METHOD_HANDLE method) override;

CORINFO_METHOD_HANDLE mapMethodDeclToMethodImpl(
CORINFO_METHOD_HANDLE method) override;

void getGSCookie(
GSCookie* pCookieVal,
GSCookie** ppCookieVal) 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 = { /* e6c7a441-8d3c-4135-abc2-bc4dd7c6a4d7 */
0xe6c7a441,
0x8d3c,
0x4135,
{0xab, 0xc2, 0xbc, 0x4d, 0xd7, 0xc6, 0xa4, 0xd7}
constexpr GUID JITEEVersionIdentifier = { /* 64fe30fb-0a27-4b1d-b89e-306e552ac848 */
0x64fe30fb,
0x0a27,
0x4b1d,
{0xb8, 0x9e, 0x30, 0x6e, 0x55, 0x2a, 0xc8, 0x48}
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
16 changes: 0 additions & 16 deletions src/coreclr/inc/jithelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@
DYNAMICJITHELPER(CORINFO_HELP_BULK_WRITEBARRIER, NULL, CORINFO_HELP_SIG_REG_ONLY)

// Accessing fields
JITHELPER(CORINFO_HELP_GETFIELD8, JIT_GetField8,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELD8, JIT_SetField8,CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_GETFIELD16, JIT_GetField16,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELD16, JIT_SetField16,CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_GETFIELD32, JIT_GetField32,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELD32, JIT_SetField32,CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_GETFIELD64, JIT_GetField64,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELD64, JIT_SetField64,CORINFO_HELP_SIG_8_STACK)
JITHELPER(CORINFO_HELP_GETFIELDOBJ, JIT_GetFieldObj,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELDOBJ, JIT_SetFieldObj,CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_GETFIELDSTRUCT, JIT_GetFieldStruct,CORINFO_HELP_SIG_8_STACK)
JITHELPER(CORINFO_HELP_SETFIELDSTRUCT, JIT_SetFieldStruct,CORINFO_HELP_SIG_8_STACK)
JITHELPER(CORINFO_HELP_GETFIELDFLOAT, JIT_GetFieldFloat,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELDFLOAT, JIT_SetFieldFloat,CORINFO_HELP_SIG_4_STACK)
JITHELPER(CORINFO_HELP_GETFIELDDOUBLE, JIT_GetFieldDouble,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_SETFIELDDOUBLE, JIT_SetFieldDouble,CORINFO_HELP_SIG_8_STACK)

JITHELPER(CORINFO_HELP_GETFIELDADDR, JIT_GetFieldAddr,CORINFO_HELP_SIG_REG_ONLY)
JITHELPER(CORINFO_HELP_GETSTATICFIELDADDR, JIT_GetStaticFieldAddr,CORINFO_HELP_SIG_REG_ONLY)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/ICorJitInfo_names_generated.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ DEF_CLR_API(getUnmanagedCallConv)
DEF_CLR_API(pInvokeMarshalingRequired)
DEF_CLR_API(satisfiesMethodConstraints)
DEF_CLR_API(methodMustBeLoadedBeforeCodeIsRun)
DEF_CLR_API(mapMethodDeclToMethodImpl)
DEF_CLR_API(getGSCookie)
DEF_CLR_API(setPatchpointInfo)
DEF_CLR_API(getOSRInfo)
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/jit/ICorJitInfo_wrapper_generated.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,6 @@ void WrapICorJitInfo::methodMustBeLoadedBeforeCodeIsRun(
API_LEAVE(methodMustBeLoadedBeforeCodeIsRun);
}

CORINFO_METHOD_HANDLE WrapICorJitInfo::mapMethodDeclToMethodImpl(
CORINFO_METHOD_HANDLE method)
{
API_ENTER(mapMethodDeclToMethodImpl);
CORINFO_METHOD_HANDLE temp = wrapHnd->mapMethodDeclToMethodImpl(method);
API_LEAVE(mapMethodDeclToMethodImpl);
return temp;
}

void WrapICorJitInfo::getGSCookie(
GSCookie* pCookieVal,
GSCookie** ppCookieVal)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2002,7 +2002,6 @@ void Compiler::compInit(ArenaAllocator* pAlloc,
// check that HelperCallProperties are initialized

assert(s_helperCallProperties.IsPure(CORINFO_HELP_GET_GCSTATIC_BASE));
assert(!s_helperCallProperties.IsPure(CORINFO_HELP_GETFIELDOBJ)); // quick sanity check

// We start with the flow graph in tree-order
fgOrder = FGOrderTree;
Expand Down
96 changes: 4 additions & 92 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1485,11 +1485,6 @@ CallArg* CallArgs::GetThisArg()
// convention it is passed in x8 (see `CallArgs::GetCustomRegister` for the
// exact conditions).
//
// Some jit helpers may have "out buffers" that are _not_ classified as the
// ret buffer. These are normal arguments that function similarly to ret
// buffers, but they do not have the special ABI treatment of ret buffers.
// See `GenTreeCall::TreatAsShouldHaveRetBufArg` for more details.
//
CallArg* CallArgs::GetRetBufferArg()
{
if (!HasRetBuffer())
Expand Down Expand Up @@ -2402,56 +2397,6 @@ int GenTreeCall::GetNonStandardAddedArgCount(Compiler* compiler) const
return 0;
}

//-------------------------------------------------------------------------
// TreatAsShouldHaveRetBufArg:
//
// Return Value:
// Returns true if we treat the call as if it has a retBuf argument
// This method may actually have a retBuf argument
// or it could be a JIT helper that we are still transforming during
// the importer phase.
//
// Notes:
// On ARM64 marking the method with the GTF_CALL_M_RETBUFFARG flag
// will make HasRetBufArg() return true, but will also force the
// use of register x8 to pass the RetBuf argument.
//
// These two Jit Helpers that we handle here by returning true
// aren't actually defined to return a struct, so they don't expect
// their RetBuf to be passed in x8, instead they expect it in x0.
//
bool GenTreeCall::TreatAsShouldHaveRetBufArg() const
{
if (ShouldHaveRetBufArg())
{
return true;
}

// If we see a Jit helper call that returns a TYP_STRUCT we may
// transform it as if it has a Return Buffer Argument
//
if (IsHelperCall() && (gtReturnType == TYP_STRUCT))
{
// There are two helpers that return structs through an argument,
// ignoring the ABI, but where we want to handle them during import as
// if they have return buffers:
// - CORINFO_HELP_GETFIELDSTRUCT
// - CORINFO_HELP_UNBOX_NULLABLE
//
// Other TYP_STRUCT returning helpers follow the ABI normally and
// should return true for `ShouldHaveRetBufArg` if they need a retbuf
// arg, so when we get here, those cases never need retbufs. They
// include:
// - CORINFO_HELP_PINVOKE_CALLI
// - CORINFO_HELP_DISPATCH_INDIRECT_CALL
//
CorInfoHelpFunc helpFunc = Compiler::eeGetHelperNum(gtCallMethHnd);

return (helpFunc == CORINFO_HELP_GETFIELDSTRUCT) || (helpFunc == CORINFO_HELP_UNBOX_NULLABLE);
}
return false;
}

//-------------------------------------------------------------------------
// IsHelperCall: Determine if this GT_CALL node is a specific helper call.
//
Expand Down Expand Up @@ -16548,14 +16493,7 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr,
if (access & CORINFO_ACCESS_SET)
{
assert(value != nullptr);
// helper needs pointer to struct, not struct itself
if (pFieldInfo->helper == CORINFO_HELP_SETFIELDSTRUCT)
{
// TODO-Bug?: verify if flags matter here
GenTreeFlags indirFlags = GTF_EMPTY;
value = impGetNodeAddr(value, CHECK_SPILL_ALL, &indirFlags);
}
else if (lclTyp == TYP_DOUBLE && value->TypeGet() == TYP_FLOAT)
if ((lclTyp == TYP_DOUBLE) && (value->TypeGet() == TYP_FLOAT))
{
value = gtNewCastNode(TYP_DOUBLE, value, false, TYP_DOUBLE);
}
Expand All @@ -16570,22 +16508,9 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr,
else if (access & CORINFO_ACCESS_GET)
{
helperType = lclTyp;

// The calling convention for the helper does not take into
// account optimization of primitive structs.
if ((pFieldInfo->helper == CORINFO_HELP_GETFIELDSTRUCT) && !varTypeIsStruct(lclTyp))
{
helperType = TYP_STRUCT;
}
}
}

if (pFieldInfo->helper == CORINFO_HELP_GETFIELDSTRUCT || pFieldInfo->helper == CORINFO_HELP_SETFIELDSTRUCT)
{
assert(pFieldInfo->structType != nullptr);
args[nArgs++] = gtNewIconEmbClsHndNode(pFieldInfo->structType);
}

GenTree* fieldHnd = impTokenToHandle(pResolvedToken);
if (fieldHnd == nullptr)
{ // compDonotInline()
Expand Down Expand Up @@ -16622,23 +16547,10 @@ GenTree* Compiler::gtNewRefCOMfield(GenTree* objPtr,

if (pFieldInfo->fieldAccessor == CORINFO_FIELD_INSTANCE_HELPER)
{
if (access & CORINFO_ACCESS_GET)
if (((access & CORINFO_ACCESS_GET) != 0) && varTypeIsSmall(lclTyp))
{
if (pFieldInfo->helper == CORINFO_HELP_GETFIELDSTRUCT)
{
if (!varTypeIsStruct(lclTyp))
{
// get the result as primitive type
GenTreeFlags indirFlags = GTF_EMPTY;
result = impGetNodeAddr(result, CHECK_SPILL_ALL, &indirFlags);
result = gtNewIndir(lclTyp, result, indirFlags);
}
}
else if (varTypeIsSmall(lclTyp))
{
// The helper does not extend the small return types.
result = gtNewCastNode(genActualType(lclTyp), result, false, lclTyp);
}
// The helper does not extend the small return types.
result = gtNewCastNode(genActualType(lclTyp), result, false, lclTyp);
}
}
else if ((access & CORINFO_ACCESS_ADDRESS) == 0) // OK, now do the indirection
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -5305,8 +5305,6 @@ struct GenTreeCall final : public GenTree
return (gtCallMoreFlags & GTF_CALL_M_RETBUFFARG) != 0;
}

bool TreatAsShouldHaveRetBufArg() const;

//-----------------------------------------------------------------------------------------
// HasMultiRegRetVal: whether the call node returns its value in multiple return registers.
//
Expand All @@ -5330,7 +5328,7 @@ struct GenTreeCall final : public GenTree
}
#endif

if (!varTypeIsStruct(gtType) || TreatAsShouldHaveRetBufArg())
if (!varTypeIsStruct(gtType) || ShouldHaveRetBufArg())
{
return false;
}
Expand Down
Loading
Loading