-
Notifications
You must be signed in to change notification settings - Fork 2.7k
new JitEE interface method: expandRawHandleIntrinsic #12071
Conversation
src/jit/importer.cpp
Outdated
@@ -6675,6 +6703,12 @@ var_types Compiler::impImportCall(OPCODE opcode, | |||
call = impIntrinsic(newobjThis, clsHnd, methHnd, sig, pResolvedToken->token, readonlyCall, | |||
(canTailCall && (tailCall != 0)), &intrinsicID); | |||
|
|||
if (compInlineResult->IsFailure()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because now we call impLookupToTree inside impIntrinsic, that can set the Failure if it is compIsForInlining() and we need a runtime lookup.
I didn't notice any order in these files (and code convention too), so I just added my method right after the last added resolveVirtualMethod. |
src/jit/importer.cpp
Outdated
{ | ||
assert(IsTargetAbi(CORINFO_CORERT_ABI)); // Only CoreRT supports it. | ||
CORINFO_RESOLVED_TOKEN resolvedToken; | ||
resolvedToken.hMethod = method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MichalStrehovsky Is it necessary to set hMethod here? It is usually an output argument for resolvedToken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can null it out. We can fetch that from token/tokenScope (and in fact, we need do it from the token anyway if the method is canonical (and it pretty much always will be canonical)).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, done.
PTAL @dotnet/jit-contrib, @MichalStrehovsky. @jkotas. |
@@ -2111,13 +2121,6 @@ class ICorStaticInfo | |||
BOOL *pfIsOpenDelegate /* is the delegate open */ | |||
) = 0; | |||
|
|||
// Determines whether the delegate creation obeys security transparency rules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you are on it you can also delete getAddrModuleDomainID
... I have noticed earlier today that it is also unused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, done.
LGTM |
I think I do not understand the purpose of jit\ICorJitInfo_API_names.h, @AndyAyersMS do you know that? Why is not resolveVirtualMethod there? |
src/jit/importer.cpp
Outdated
{ | ||
assert(IsTargetAbi(CORINFO_CORERT_ABI)); // Only CoreRT supports it. | ||
CORINFO_RESOLVED_TOKEN resolvedToken; | ||
resolvedToken.hMethod = method; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can null it out. We can fetch that from token/tokenScope (and in fact, we need do it from the token anyway if the method is canonical (and it pretty much always will be canonical)).
src/jit/importer.cpp
Outdated
if (eeTypePtrOfNode == nullptr) | ||
return nullptr; | ||
|
||
unsigned eeSlot = lvaGrabTemp(true DEBUGARG("eeTypePtrOf")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could you remove the references to EETypePtrOf
?
While the original motivation for this is to allow having a EETypePtr EETypePtrOf<T>()
method that intrinsically expands to "raw value of the TypeHandle of T", I'm already thinking of using this for IntPtr DefaultConstructorOf<T>()
that expands to "pointer to the default constructor of type T" (to be used in the implementation of Activator.CreateInstance<T>
). The API surface is general purpose to allow adding other interesting cases without requiring RyuJIT to learn about them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, is rawPointer an appropriate name?
src/jit/importer.cpp
Outdated
impAssignTempGen(eeSlot, eeTypePtrOfNode, clsHnd, (unsigned)CHECK_SPILL_NONE); | ||
GenTreePtr lclVar = gtNewLclvNode(eeSlot, TYP_I_IMPL); | ||
GenTreePtr lclVarAddr = gtNewOperNode(GT_ADDR, TYP_I_IMPL, lclVar); | ||
var_types resultType = JITtype2varType(sig->retType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to add some kind of assert that the return type of the method is interchangeable with TYP_I_IMPL? (either an IntPtr, or a pointer-sized struct that is ideally not a GC pointer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure about a GC pointer check.
I added noway_assert that the return tree has the same size as TYP_I_IMPL.
and the additional assert. It should be noway_assert, because CoreRT doesn't use this intrinsic in the debug mode.
@dotnet-bot test Windows_NT arm64 Checked pri1r2r |
fot the future usages.
@dotnet-bot test Windows_NT arm64 Checked pri1r2r |
@dotnet-bot test Windows_NT Checked pri1r2r |
Please port these changes to the desktop and build at least x86/x64/arm64 checked/release there before merging this (to ensure there are no desktop-specific build problems that will ensue when this is mirrored). |
src/jit/importer.cpp
Outdated
case CORINFO_INTRINSIC_GetRawHandle: | ||
{ | ||
assert(IsTargetAbi(CORINFO_CORERT_ABI)); // Only CoreRT supports it. | ||
CORINFO_RESOLVED_TOKEN resolvedToken; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should be a noway_assert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -189,17 +189,6 @@ BOOL WrapICorJitInfo::isCompatibleDelegate( | |||
return temp; | |||
} | |||
|
|||
BOOL WrapICorJitInfo::isDelegateCreationAllowed( | |||
CORINFO_CLASS_HANDLE delegateHnd, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you add a new case for expandRawHandleIntrinsic() in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -20,7 +20,6 @@ DEF_CLR_API(getUnmanagedCallConv) | |||
DEF_CLR_API(pInvokeMarshalingRequired) | |||
DEF_CLR_API(satisfiesMethodConstraints) | |||
DEF_CLR_API(isCompatibleDelegate) | |||
DEF_CLR_API(isDelegateCreationAllowed) | |||
DEF_CLR_API(isInstantiationOfVerifiedGeneric) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't you add a new case for expandRawHandleIntrinsic() in this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure, I asked @AndyAyersMS in the message above why there is no resolveVirtualMethod there. Looks like we do not test code under MEASURE_CLRAPI_CALLS 1.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was created by Peter Kukol to measure JIT-EE interface overhead. It's probably reasonable to keep it working as close as possible, even if we don't actively build with it regularly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I fixed that for both methods. I checked that it is possible to build VM with this flag on.
When this is merged, please be prepared to immediately do a desktop SuperPMI recollection. |
add resolveVirtualMethod and expandRawHandleIntrinsic there.
Done for checked, it is in progress for release. |
CoreRT side of dotnet/coreclr#12071. I also took this as an opportunity to clean up how we use `runtimeLookupArgs` - we now consistently fill it out instead of trying to figure out what to put there based on the token and ready to run helper ID.
It is implemented only in CoreRT and used in importer.
Delete isDelegateCreationAllowed because it is unused and I was waiting for a JitEEinterface change
to delete it.