Skip to content

The x86 path for UnmanagedCallersOnlyAttribute should be improved. #33582

Closed
@AaronRobinsonMSFT

Description

@AaronRobinsonMSFT

The making public of NativeCallableAttribute UnmanagedCallersOnlyAttribute done in #33005, provided some additional optimizations. However the Windows-x86 path was deemed lower priority so wasn't optimized. There are various locations where the Windows-x86 platform opted out of the optimization.

Examples:

#if defined(TARGET_X86) && defined(TARGET_WINDOWS) && !defined(CROSSGEN_COMPILE)
// Deferring X86 support until a need is observed or
// time permits investigation into all the potential issues.
if (pMD->HasNativeCallableAttribute())
{
pResult->addr = (void*)COMDelegate::ConvertToCallback(pMD);
}
else
{
pResult->addr = (void*)pMD->GetMultiCallableAddrOfCode();
}
#else

#if !defined(TARGET_X86) || !defined(TARGET_WINDOWS)
if (ftn->HasNativeCallableAttribute())
flags.Set(CORJIT_FLAGS::CORJIT_FLAG_REVERSE_PINVOKE);
#endif // !TARGET_X86 || !TARGET_WINDOWS

if (targetArchitecture == TargetArchitecture.X86
&& _compilation.TypeSystemContext.Target.OperatingSystem == TargetOS.Windows)
{
throw new RequiresRuntimeJitException("ReadyToRun: Methods with NativeCallableAttribute not implemented");
}

var targetDetails = _compilation.TypeSystemContext.Target;
if (targetDetails.Architecture == TargetArchitecture.X86
&& targetDetails.OperatingSystem == TargetOS.Windows
&& targetMethod.IsNativeCallable)
{
throw new RequiresRuntimeJitException("ReadyToRun: References to methods with NativeCallableAttribute not implemented");
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions