From 74a25be685ded88bd964d5def38b161e417f9575 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 21:20:51 -0700 Subject: [PATCH 1/8] Rename NDirect -> PInvoke --- docs/design/coreclr/botr/guide-for-porting.md | 2 +- docs/design/coreclr/botr/method-descriptor.md | 12 +- docs/design/datacontracts/PrecodeStubs.md | 2 +- .../design/datacontracts/RuntimeTypeSystem.md | 2 +- .../src/System/StubHelpers.cs | 4 +- .../debug/daccess/dacdbiimplstackwalk.cpp | 4 +- src/coreclr/debug/di/shimstackwalk.cpp | 2 +- src/coreclr/debug/ee/frameinfo.cpp | 2 +- .../debug/runtimeinfo/datadescriptor.inc | 2 +- src/coreclr/jit/importercalls.cpp | 2 +- src/coreclr/vm/amd64/AsmHelpers.asm | 14 +- src/coreclr/vm/amd64/PInvokeStubs.asm | 4 +- src/coreclr/vm/amd64/asmconstants.h | 6 +- src/coreclr/vm/amd64/pinvokestubs.S | 4 +- src/coreclr/vm/amd64/unixasmhelpers.S | 12 +- src/coreclr/vm/arm/asmconstants.h | 4 +- src/coreclr/vm/arm/asmhelpers.S | 8 +- src/coreclr/vm/arm/pinvokestubs.S | 2 +- src/coreclr/vm/arm64/PInvokeStubs.asm | 2 +- src/coreclr/vm/arm64/asmconstants.h | 4 +- src/coreclr/vm/arm64/asmhelpers.S | 8 +- src/coreclr/vm/arm64/asmhelpers.asm | 8 +- src/coreclr/vm/arm64/pinvokestubs.S | 2 +- src/coreclr/vm/array.cpp | 2 +- src/coreclr/vm/binder.cpp | 6 +- src/coreclr/vm/ceeload.cpp | 10 +- src/coreclr/vm/ceeload.h | 8 +- src/coreclr/vm/ceeload.inl | 8 +- src/coreclr/vm/class.cpp | 2 +- src/coreclr/vm/class.h | 2 +- src/coreclr/vm/classcompat.cpp | 4 +- src/coreclr/vm/clrtocomcall.cpp | 6 +- src/coreclr/vm/comdelegate.cpp | 6 +- src/coreclr/vm/common.h | 2 +- src/coreclr/vm/comtoclrcall.cpp | 4 +- src/coreclr/vm/dispatchinfo.cpp | 2 +- src/coreclr/vm/dispparammarshaler.cpp | 6 +- src/coreclr/vm/dllimport.cpp | 302 +++++++++--------- src/coreclr/vm/dllimport.h | 32 +- src/coreclr/vm/dllimportcallback.cpp | 2 +- src/coreclr/vm/dllimportcallback.h | 2 +- src/coreclr/vm/exceptionhandling.cpp | 4 +- src/coreclr/vm/frames.h | 4 +- src/coreclr/vm/i386/asmconstants.h | 2 +- src/coreclr/vm/i386/asmhelpers.S | 12 +- src/coreclr/vm/i386/asmhelpers.asm | 14 +- src/coreclr/vm/i386/cgenx86.cpp | 6 +- src/coreclr/vm/ilmarshalers.cpp | 62 ++-- src/coreclr/vm/ilmarshalers.h | 102 +++--- src/coreclr/vm/ilstubcache.h | 6 +- src/coreclr/vm/interoplibinterface.h | 2 +- src/coreclr/vm/interoplibinterface_shared.cpp | 2 +- src/coreclr/vm/jitinterface.cpp | 40 +-- src/coreclr/vm/jitinterface.h | 2 +- src/coreclr/vm/loongarch64/asmconstants.h | 4 +- src/coreclr/vm/loongarch64/asmhelpers.S | 8 +- src/coreclr/vm/loongarch64/pinvokestubs.S | 2 +- src/coreclr/vm/marshalnative.cpp | 4 +- src/coreclr/vm/method.cpp | 66 ++-- src/coreclr/vm/method.hpp | 66 ++-- src/coreclr/vm/method.inl | 2 +- src/coreclr/vm/methodtablebuilder.cpp | 22 +- src/coreclr/vm/methodtablebuilder.h | 4 +- src/coreclr/vm/mlinfo.cpp | 16 +- src/coreclr/vm/mlinfo.h | 12 +- src/coreclr/vm/nativelibrary.cpp | 10 +- src/coreclr/vm/nativelibrary.h | 2 +- src/coreclr/vm/olevariant.cpp | 8 +- src/coreclr/vm/precode.cpp | 10 +- src/coreclr/vm/precode.h | 24 +- src/coreclr/vm/prestub.cpp | 4 +- src/coreclr/vm/proftoeeinterfaceimpl.cpp | 2 +- src/coreclr/vm/readytoruninfo.cpp | 6 +- src/coreclr/vm/riscv64/asmconstants.h | 4 +- src/coreclr/vm/riscv64/asmhelpers.S | 8 +- src/coreclr/vm/riscv64/pinvokestubs.S | 2 +- src/coreclr/vm/stackingallocator.cpp | 2 +- src/coreclr/vm/stackwalk.cpp | 2 +- src/coreclr/vm/stubgen.cpp | 2 +- src/coreclr/vm/stublink.h | 2 +- src/coreclr/vm/stubmgr.cpp | 20 +- src/coreclr/vm/threads.h | 2 +- src/coreclr/vm/threadsuspend.cpp | 2 +- src/coreclr/vm/wasm/helpers.cpp | 4 +- .../src/Resources/Strings.resx | 2 +- .../Contracts/PrecodeStubs_Common.cs | 2 +- .../MethodDescOptionalSlots.cs | 2 +- 87 files changed, 552 insertions(+), 552 deletions(-) diff --git a/docs/design/coreclr/botr/guide-for-porting.md b/docs/design/coreclr/botr/guide-for-porting.md index 500d95394266a0..7cb7fdd905bfe4 100644 --- a/docs/design/coreclr/botr/guide-for-porting.md +++ b/docs/design/coreclr/botr/guide-for-porting.md @@ -340,7 +340,7 @@ Here is an annotated list of the stubs implemented for Unix on Arm64. calls. Necessary for all applications as this is how the main method is called. - 2. `NDirectImportThunk` – Needed to support saving off a set of arguments to + 2. `PInvokeImportThunk` – Needed to support saving off a set of arguments to a p/invoke so that the runtime can find the actual target. Also uses one of the secret arguments (Used by all p/invoke methods) diff --git a/docs/design/coreclr/botr/method-descriptor.md b/docs/design/coreclr/botr/method-descriptor.md index d3d304b91744b1..7adb72f5192a55 100644 --- a/docs/design/coreclr/botr/method-descriptor.md +++ b/docs/design/coreclr/botr/method-descriptor.md @@ -44,7 +44,7 @@ Used for less common IL methods that have generic instantiation or that do not h Internal methods implemented in unmanaged code. These are [methods marked with MethodImplAttribute(MethodImplOptions.InternalCall) attribute](corelib.md), delegate constructors and tlbimp constructors. -**NDirect** +**PInvoke** P/Invoke methods. These are methods marked with DllImport attribute. @@ -270,14 +270,14 @@ ThisPtrRetBufPrecode looks like this: jmp entrypoint dw pMethodDesc -**NDirectImportPrecode** +**PInvokeImportPrecode** -NDirectImportPrecode is used for lazy binding of unmanaged P/Invoke targets. This precode is for convenience and to reduce amount of platform specific plumbing. +PInvokeImportPrecode is used for lazy binding of unmanaged P/Invoke targets. This precode is for convenience and to reduce amount of platform specific plumbing. -Each NDirectMethodDesc has NDirectImportPrecode in addition to the regular precode. +Each PInvokeMethodDesc has PInvokeImportPrecode in addition to the regular precode. -NDirectImportPrecode looks like this on x86: +PInvokeImportPrecode looks like this on x86: mov eax,pMethodDesc mov eax,eax // dummy instruction that marks the type of the precode - jmp NDirectImportThunk // loads P/Invoke target for pMethodDesc lazily + jmp PInvokeImportThunk // loads P/Invoke target for pMethodDesc lazily diff --git a/docs/design/datacontracts/PrecodeStubs.md b/docs/design/datacontracts/PrecodeStubs.md index 0dc4f8e1fc74c5..b336b433ac2e13 100644 --- a/docs/design/datacontracts/PrecodeStubs.md +++ b/docs/design/datacontracts/PrecodeStubs.md @@ -194,7 +194,7 @@ After the initial precode type is determined, for stub precodes a refined precod internal enum KnownPrecodeType { Stub = 1, - PInvokeImport, // also known as NDirectImport in the runtime + PInvokeImport, Fixup, ThisPtrRetBuf, UMEntry, diff --git a/docs/design/datacontracts/RuntimeTypeSystem.md b/docs/design/datacontracts/RuntimeTypeSystem.md index 77980940d829ee..54a542056108a4 100644 --- a/docs/design/datacontracts/RuntimeTypeSystem.md +++ b/docs/design/datacontracts/RuntimeTypeSystem.md @@ -1083,7 +1083,7 @@ Checking if a method has a native code slot and getting its address { MethodClassification.IL => /*size of MethodDesc*/, MethodClassification.FCall => /* size of FCallMethodDesc */ - MethodClassification.PInvoke => /* size of NDirectMethodDesc */ + MethodClassification.PInvoke => /* size of PInvokeMethodDesc */ MethodClassification.EEImpl => /* size of EEImplMethodDesc */ MethodClassification.Array => /* size of ArrayMethodDesc */ MethodClassification.Instantiated => /* size of InstantiatedMethodDesc */ diff --git a/src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs b/src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs index b3b624050ebd46..61e71adcff477a 100644 --- a/src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs +++ b/src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs @@ -944,7 +944,7 @@ private unsafe IntPtr ConvertArrayToNative(object pManagedHome, int dwFlags) } default: - throw new ArgumentException(SR.Arg_NDirectBadObject); + throw new ArgumentException(SR.Arg_PInvokeBadObject); } // marshal the object as C-style array (UnmanagedType.LPArray) @@ -1151,7 +1151,7 @@ internal IntPtr ConvertToNative(object pManagedHome, int dwFlags) else { // this type is not supported for AsAny marshaling - throw new ArgumentException(SR.Arg_NDirectBadObject); + throw new ArgumentException(SR.Arg_PInvokeBadObject); } } diff --git a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp index eb5464275d0dc2..dc13cf59a7f006 100644 --- a/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp +++ b/src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp @@ -474,7 +474,7 @@ ULONG32 DacDbiInterfaceImpl::GetCountOfInternalFrames(VMPTR_Thread vmThread) { // Skip new exception handling helpers InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); - PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; + PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) { @@ -527,7 +527,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread { // Skip new exception handling helpers InlinedCallFrame *pInlinedCallFrame = dac_cast(pFrame); - PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; + PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) { diff --git a/src/coreclr/debug/di/shimstackwalk.cpp b/src/coreclr/debug/di/shimstackwalk.cpp index 64ea5d7ad7d918..d3385d2cc40ceb 100644 --- a/src/coreclr/debug/di/shimstackwalk.cpp +++ b/src/coreclr/debug/di/shimstackwalk.cpp @@ -1202,7 +1202,7 @@ BOOL ShimStackWalk::CheckInternalFrame(ICorDebugFrame * pNextStackFrame, // Special handling for the case where a managed method contains a M2U internal frame. // Normally only IL stubs contain M2U internal frames, but we may have inlined pinvoke calls in // optimized code. In that case, we would have an InlinedCallFrame in a normal managed method on x86. - // On WIN64, we would have a normal NDirectMethodFrame* in a normal managed method. + // On WIN64, we would have a normal PInvokeMethodFrame* in a normal managed method. if (pStackWalkInfo->m_internalFrameType == STUBFRAME_M2U) { // create a temporary ICDStackWalk diff --git a/src/coreclr/debug/ee/frameinfo.cpp b/src/coreclr/debug/ee/frameinfo.cpp index 7060087ac24afc..c313c648f27cc9 100644 --- a/src/coreclr/debug/ee/frameinfo.cpp +++ b/src/coreclr/debug/ee/frameinfo.cpp @@ -1503,7 +1503,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data) (pPrevFrame->GetFrameType() == Frame::TYPE_EXIT) && !HasExitRuntime(pPrevFrame, d, NULL) ) { - // This is for the inlined NDirectMethodFrameGeneric case. We have not exit the runtime yet, so the current + // This is for the inlined PInvokeMethodFrameGeneric case. We have not exit the runtime yet, so the current // frame should still be regarded as the leaf frame. d->info.fIsLeaf = true; } diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.inc b/src/coreclr/debug/runtimeinfo/datadescriptor.inc index f28496e5c9b7d3..954879decec9b0 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.inc +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.inc @@ -511,7 +511,7 @@ CDAC_TYPE_SIZE(sizeof(FCallMethodDesc)) CDAC_TYPE_END(FCallMethodDesc) CDAC_TYPE_BEGIN(PInvokeMethodDesc) -CDAC_TYPE_SIZE(sizeof(NDirectMethodDesc)) +CDAC_TYPE_SIZE(sizeof(PInvokeMethodDesc)) CDAC_TYPE_END(PInvokeMethodDesc) CDAC_TYPE_BEGIN(EEImplMethodDesc) diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index a7ccd9ebdf0850..acabb634d46349 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -618,7 +618,7 @@ var_types Compiler::impImportCall(OPCODE opcode, * to the arg list next after we pop them */ } - //--------------------------- Inline NDirect ------------------------------ + //--------------------------- Inline PInvoke ------------------------------ // If this is a call to a PInvoke method, we may be able to inline the invocation frame. // impCheckForPInvokeCall(call->AsCall(), methHnd, sig, mflags, compCurBB); diff --git a/src/coreclr/vm/amd64/AsmHelpers.asm b/src/coreclr/vm/amd64/AsmHelpers.asm index c8f0d98a065396..ee580ba7ec2583 100644 --- a/src/coreclr/vm/amd64/AsmHelpers.asm +++ b/src/coreclr/vm/amd64/AsmHelpers.asm @@ -6,7 +6,7 @@ include asmconstants.inc Thread_GetInterpThreadContext TEXTEQU -extern NDirectImportWorker:proc +extern PInvokeImportWorker:proc extern ThePreStub:proc extern ProfileEnter:proc extern ProfileLeave:proc @@ -23,15 +23,15 @@ extern g_TrapReturningThreads:DWORD ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; -;; NDirectImportThunk +;; PInvokeImportThunk ;; ;; In addition to being called by the EE, this function can be called ;; directly from code generated by JIT64 for CRT optimized direct ;; P/Invoke calls. If it is modified, the JIT64 compiler's code ;; generation will need to altered accordingly. ;; -; EXTERN_C VOID __stdcall NDirectImportThunk(); -NESTED_ENTRY NDirectImportThunk, _TEXT +; EXTERN_C VOID __stdcall PInvokeImportThunk(); +NESTED_ENTRY PInvokeImportThunk, _TEXT ; ; Allocate space for XMM parameter registers and callee scratch area. @@ -55,10 +55,10 @@ NESTED_ENTRY NDirectImportThunk, _TEXT END_PROLOGUE ; - ; Call NDirectImportWorker w/ the NDirectMethodDesc* + ; Call PInvokeImportWorker w/ the PInvokeMethodDesc* ; mov rcx, METHODDESC_REGISTER - call NDirectImportWorker + call PInvokeImportWorker ; ; Restore parameter registers @@ -79,7 +79,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT add rsp, 68h TAILJMP_RAX -NESTED_END NDirectImportThunk, _TEXT +NESTED_END PInvokeImportThunk, _TEXT ;------------------------------------------------ diff --git a/src/coreclr/vm/amd64/PInvokeStubs.asm b/src/coreclr/vm/amd64/PInvokeStubs.asm index a18ed56b752d3c..9913dbd3c53f5b 100644 --- a/src/coreclr/vm/amd64/PInvokeStubs.asm +++ b/src/coreclr/vm/amd64/PInvokeStubs.asm @@ -23,7 +23,7 @@ LEAF_ENTRY GenericPInvokeCalliHelper, _TEXT ; ; check for existing IL stub ; - mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pNDirectILStub] + mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pPInvokeILStub] test rax, rax jz GenericPInvokeCalliGenILStub @@ -85,7 +85,7 @@ LEAF_ENTRY VarargPInvokeStubHelper, _TEXT ; ; check for existing IL stub ; - mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pNDirectILStub] + mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pPInvokeILStub] test rax, rax jz VarargPInvokeGenILStub diff --git a/src/coreclr/vm/amd64/asmconstants.h b/src/coreclr/vm/amd64/asmconstants.h index 96bb2f26d96239..1880ecbafdd340 100644 --- a/src/coreclr/vm/amd64/asmconstants.h +++ b/src/coreclr/vm/amd64/asmconstants.h @@ -248,9 +248,9 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pNonGCStatics ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pGCStatics == offsetof(DynamicStaticsInfo, m_pGCStatics)); -#define OFFSETOF__VASigCookie__pNDirectILStub 0x8 -ASMCONSTANTS_C_ASSERT(OFFSETOF__VASigCookie__pNDirectILStub - == offsetof(VASigCookie, pNDirectILStub)); +#define OFFSETOF__VASigCookie__pPInvokeILStub 0x8 +ASMCONSTANTS_C_ASSERT(OFFSETOF__VASigCookie__pPInvokeILStub + == offsetof(VASigCookie, pPInvokeILStub)); #if defined(UNIX_AMD64_ABI) && !defined(HOST_WINDOWS) // Expression is too complicated, is currently: diff --git a/src/coreclr/vm/amd64/pinvokestubs.S b/src/coreclr/vm/amd64/pinvokestubs.S index 3d33a63d8a0862..49bc602afee105 100644 --- a/src/coreclr/vm/amd64/pinvokestubs.S +++ b/src/coreclr/vm/amd64/pinvokestubs.S @@ -19,7 +19,7 @@ LEAF_ENTRY GenericPInvokeCalliHelper, _TEXT // // check for existing IL stub // - mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pNDirectILStub] + mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pPInvokeILStub] test rax, rax jz C_FUNC(GenericPInvokeCalliGenILStub) @@ -81,7 +81,7 @@ LEAF_ENTRY VarargPInvokeStubHelper, _TEXT // // check for existing IL stub // - mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pNDirectILStub] + mov rax, [PINVOKE_CALLI_SIGTOKEN_REGISTER + OFFSETOF__VASigCookie__pPInvokeILStub] test rax, rax jz C_FUNC(VarargPInvokeGenILStub) diff --git a/src/coreclr/vm/amd64/unixasmhelpers.S b/src/coreclr/vm/amd64/unixasmhelpers.S index cc864816bf03c8..a3491cb2affeaf 100644 --- a/src/coreclr/vm/amd64/unixasmhelpers.S +++ b/src/coreclr/vm/amd64/unixasmhelpers.S @@ -7,15 +7,15 @@ ////////////////////////////////////////////////////////////////////////// // -// NDirectImportThunk +// PInvokeImportThunk // // In addition to being called by the EE, this function can be called // directly from code generated by JIT64 for CRT optimized direct // P/Invoke calls. If it is modified, the JIT64 compiler's code // generation will need to altered accordingly. // -// EXTERN_C VOID __stdcall NDirectImportThunk()// -NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler +// EXTERN_C VOID __stdcall PInvokeImportThunk()// +NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler // // Save integer parameter registers. @@ -36,10 +36,10 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler END_PROLOGUE // - // Call NDirectImportWorker w/ the NDirectMethodDesc* + // Call PInvokeImportWorker w/ the PInvokeMethodDesc* // mov rdi, METHODDESC_REGISTER - call C_FUNC(NDirectImportWorker) + call C_FUNC(PInvokeImportWorker) mov r10, rax RESTORE_FLOAT_ARGUMENT_REGISTERS 0 @@ -58,7 +58,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler jmp r10 -NESTED_END NDirectImportThunk, _TEXT +NESTED_END PInvokeImportThunk, _TEXT //------------------------------------------------ // JIT_RareDisableHelper diff --git a/src/coreclr/vm/arm/asmconstants.h b/src/coreclr/vm/arm/asmconstants.h index c19a2efbd8a68a..0f4840be10697a 100644 --- a/src/coreclr/vm/arm/asmconstants.h +++ b/src/coreclr/vm/arm/asmconstants.h @@ -123,8 +123,8 @@ ASMCONSTANTS_C_ASSERT(ASM__VTABLE_SLOTS_PER_CHUNK == VTABLE_SLOTS_PER_CHUNK) #define ASM__VTABLE_SLOTS_PER_CHUNK_LOG2 3 ASMCONSTANTS_C_ASSERT(ASM__VTABLE_SLOTS_PER_CHUNK_LOG2 == VTABLE_SLOTS_PER_CHUNK_LOG2) -#define VASigCookie__pNDirectILStub 0x4 -ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) +#define VASigCookie__pPInvokeILStub 0x4 +ASMCONSTANTS_C_ASSERT(VASigCookie__pPInvokeILStub == offsetof(VASigCookie, pPInvokeILStub)) #define CONTEXT_Pc 0x040 ASMCONSTANTS_C_ASSERT(CONTEXT_Pc == offsetof(T_CONTEXT,Pc)) diff --git a/src/coreclr/vm/arm/asmhelpers.S b/src/coreclr/vm/arm/asmhelpers.S index 231ea2fb156a69..a929e8121d73da 100644 --- a/src/coreclr/vm/arm/asmhelpers.S +++ b/src/coreclr/vm/arm/asmhelpers.S @@ -188,7 +188,7 @@ ThePreStubPatchLabel: // ------------------------------------------------------------------ // The call in ndirect import precode points to this function. - NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler + NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_PUSH "{r0-r4,r7,r8,lr}" // Spill general argument registers, return address and PROLOG_STACK_SAVE_OFFSET r7, #20 @@ -198,17 +198,17 @@ ThePreStubPatchLabel: CHECK_STACK_ALIGNMENT mov r0, r12 - bl C_FUNC(NDirectImportWorker) + bl C_FUNC(PInvokeImportWorker) mov r12, r0 EPILOG_VPOP {d0-d7} EPILOG_POP "{r0-r4,r7,r8,lr}" - // If we got back from NDirectImportWorker, the MD has been successfully + // If we got back from PInvokeImportWorker, the MD has been successfully // linked. Proceed to execute the original DLL call. bx r12 - NESTED_END NDirectImportThunk, _TEXT + NESTED_END PInvokeImportThunk, _TEXT // ------------------------------------------------------------------ // void ResolveWorkerAsmStub(r0, r1, r2, r3, r4:IndirectionCellAndFlags, r12:DispatchToken) diff --git a/src/coreclr/vm/arm/pinvokestubs.S b/src/coreclr/vm/arm/pinvokestubs.S index b18d20f7d0c768..b102ae12d793e4 100644 --- a/src/coreclr/vm/arm/pinvokestubs.S +++ b/src/coreclr/vm/arm/pinvokestubs.S @@ -24,7 +24,7 @@ PROLOG_PUSH {\VASigCookieReg} // get the stub - ldr \VASigCookieReg, [\VASigCookieReg,#VASigCookie__pNDirectILStub] + ldr \VASigCookieReg, [\VASigCookieReg,#VASigCookie__pPInvokeILStub] // if null goto stub generation cbz \VASigCookieReg, \__PInvokeStubFuncName\()Label diff --git a/src/coreclr/vm/arm64/PInvokeStubs.asm b/src/coreclr/vm/arm64/PInvokeStubs.asm index 05e21ae22d16e4..180dca18de7f69 100644 --- a/src/coreclr/vm/arm64/PInvokeStubs.asm +++ b/src/coreclr/vm/arm64/PInvokeStubs.asm @@ -44,7 +44,7 @@ __PInvokeStubWorkerName SETS "$FuncPrefix":CC:"StubWorker" NESTED_ENTRY $__PInvokeStubFuncName ; get the stub - ldr x9, [$VASigCookieReg, #VASigCookie__pNDirectILStub] + ldr x9, [$VASigCookieReg, #VASigCookie__pPInvokeILStub] ; if null goto stub generation cbz x9, %0 diff --git a/src/coreclr/vm/arm64/asmconstants.h b/src/coreclr/vm/arm64/asmconstants.h index e8d32ab3b76dc9..b5b9de92ff4847 100644 --- a/src/coreclr/vm/arm64/asmconstants.h +++ b/src/coreclr/vm/arm64/asmconstants.h @@ -88,8 +88,8 @@ ASMCONSTANTS_C_ASSERT(CallDescrData__pTarget == offsetof(CallDescrD ASMCONSTANTS_C_ASSERT(CallDescrData__pRetBuffArg == offsetof(CallDescrData, pRetBuffArg)) ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrData, returnValue)) -#define VASigCookie__pNDirectILStub 0x8 -ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) +#define VASigCookie__pPInvokeILStub 0x8 +ASMCONSTANTS_C_ASSERT(VASigCookie__pPInvokeILStub == offsetof(VASigCookie, pPInvokeILStub)) #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index 5a00639e6afbb4..b37ad6186019ba 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -32,14 +32,14 @@ LEAF_END GetDataCacheZeroIDReg, _TEXT // ------------------------------------------------------------------ // The call in ndirect import precode points to this function. -NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler +NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -224 SAVE_ARGUMENT_REGISTERS sp, 16 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 96 mov x0, x12 - bl C_FUNC(NDirectImportWorker) + bl C_FUNC(PInvokeImportWorker) mov x12, x0 // pop the stack and restore original register state @@ -47,11 +47,11 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler RESTORE_ARGUMENT_REGISTERS sp, 16 EPILOG_RESTORE_REG_PAIR_INDEXED fp, lr, 224 - // If we got back from NDirectImportWorker, the MD has been successfully + // If we got back from PInvokeImportWorker, the MD has been successfully // linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG x12 -NESTED_END NDirectImportThunk, _TEXT +NESTED_END PInvokeImportThunk, _TEXT // ------------------------------------------------------------------ diff --git a/src/coreclr/vm/arm64/asmhelpers.asm b/src/coreclr/vm/arm64/asmhelpers.asm index f5de9e3488c7c4..95551bf24d95b3 100644 --- a/src/coreclr/vm/arm64/asmhelpers.asm +++ b/src/coreclr/vm/arm64/asmhelpers.asm @@ -7,7 +7,7 @@ IMPORT ExternalMethodFixupWorker IMPORT PreStubWorker - IMPORT NDirectImportWorker + IMPORT PInvokeImportWorker #ifdef FEATURE_VIRTUAL_STUB_DISPATCH IMPORT VSD_ResolveWorker #endif @@ -97,14 +97,14 @@ ; ------------------------------------------------------------------ ; The call in ndirect import precode points to this function. - NESTED_ENTRY NDirectImportThunk + NESTED_ENTRY PInvokeImportThunk PROLOG_SAVE_REG_PAIR fp, lr, #-224! SAVE_ARGUMENT_REGISTERS sp, 16 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 96 mov x0, x12 - bl NDirectImportWorker + bl PInvokeImportWorker mov x12, x0 ; pop the stack and restore original register state @@ -112,7 +112,7 @@ RESTORE_ARGUMENT_REGISTERS sp, 16 EPILOG_RESTORE_REG_PAIR fp, lr, #224! - ; If we got back from NDirectImportWorker, the MD has been successfully + ; If we got back from PInvokeImportWorker, the MD has been successfully ; linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG x12 diff --git a/src/coreclr/vm/arm64/pinvokestubs.S b/src/coreclr/vm/arm64/pinvokestubs.S index 84bb08bac1463a..de2a23cf06cb31 100644 --- a/src/coreclr/vm/arm64/pinvokestubs.S +++ b/src/coreclr/vm/arm64/pinvokestubs.S @@ -21,7 +21,7 @@ NESTED_ENTRY \__PInvokeStubFuncName, _TEXT, NoHandler // get the stub - ldr x9, [\VASigCookieReg, #VASigCookie__pNDirectILStub] + ldr x9, [\VASigCookieReg, #VASigCookie__pPInvokeILStub] // if null goto stub generation cbz x9, LOCAL_LABEL(\__PInvokeStubFuncName\()_0) diff --git a/src/coreclr/vm/array.cpp b/src/coreclr/vm/array.cpp index 5906f112756b44..ff13abd9422e96 100644 --- a/src/coreclr/vm/array.cpp +++ b/src/coreclr/vm/array.cpp @@ -900,7 +900,7 @@ Stub *GenerateArrayOpStub(ArrayMethodDesc* pMD) static const ILStubTypes stubTypes[3] = { ILSTUB_ARRAYOP_GET, ILSTUB_ARRAYOP_SET, ILSTUB_ARRAYOP_ADDRESS }; _ASSERTE(pMD->GetArrayFuncIndex() <= ARRAY_SIZE(stubTypes)); - NDirectStubFlags arrayOpStubFlag = (NDirectStubFlags)stubTypes[pMD->GetArrayFuncIndex()]; + PInvokeStubFlags arrayOpStubFlag = (PInvokeStubFlags)stubTypes[pMD->GetArrayFuncIndex()]; MethodDesc * pStubMD = ILStubCache::CreateAndLinkNewILStubMethodDesc(pMD->GetLoaderAllocator(), pMD->GetMethodTable(), diff --git a/src/coreclr/vm/binder.cpp b/src/coreclr/vm/binder.cpp index b3ca67e5f24afd..6572465f15d621 100644 --- a/src/coreclr/vm/binder.cpp +++ b/src/coreclr/vm/binder.cpp @@ -1170,10 +1170,10 @@ void CoreLibBinder::CheckExtended() } } else - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { - NDirectMethodDesc* pNMD = (NDirectMethodDesc*)pMD; - NDirect::PopulateNDirectMethodDesc(pNMD); + PInvokeMethodDesc* pNMD = (PInvokeMethodDesc*)pMD; + PInvoke::PopulatePInvokeMethodDesc(pNMD); if (pNMD->IsQCall() && QCallResolveDllImport(pNMD->GetEntrypointName()) == nullptr) { diff --git a/src/coreclr/vm/ceeload.cpp b/src/coreclr/vm/ceeload.cpp index 8494f72d27e8ec..29ea5a358fd2cd 100644 --- a/src/coreclr/vm/ceeload.cpp +++ b/src/coreclr/vm/ceeload.cpp @@ -3355,11 +3355,11 @@ void Module::FixupVTables() iCurMethod++; #ifdef _DEBUG - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { LOG((LF_INTEROP, LL_INFO10, "[0x%lx] <-- PINV thunk for \"%s\" (target = 0x%lx)\n", (size_t)&(pPointers[iMethod]), pMD->m_pszDebugMethodName, - (size_t)(((NDirectMethodDesc*)pMD)->GetNDirectTarget()))); + (size_t)(((PInvokeMethodDesc*)pMD)->GetPInvokeTarget()))); } #endif // _DEBUG @@ -3619,7 +3619,7 @@ void Module::RunEagerFixupsUnlocked() //----------------------------------------------------------------------------- -BOOL Module::FixupNativeEntry(READYTORUN_IMPORT_SECTION* pSection, SIZE_T fixupIndex, SIZE_T* fixupCell, BOOL mayUsePrecompiledNDirectMethods) +BOOL Module::FixupNativeEntry(READYTORUN_IMPORT_SECTION* pSection, SIZE_T fixupIndex, SIZE_T* fixupCell, BOOL mayUsePrecompiledPInvokeMethods) { CONTRACTL { @@ -3635,7 +3635,7 @@ BOOL Module::FixupNativeEntry(READYTORUN_IMPORT_SECTION* pSection, SIZE_T fixupI { PTR_DWORD pSignatures = dac_cast(GetReadyToRunImage()->GetRvaData(pSection->Signatures)); - if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell, mayUsePrecompiledNDirectMethods)) + if (!LoadDynamicInfoEntry(this, pSignatures[fixupIndex], fixupCell, mayUsePrecompiledPInvokeMethods)) return FALSE; _ASSERTE(*fixupCell != 0); @@ -4348,7 +4348,7 @@ VASigCookie *Module::GetVASigCookieWorker(Module* pDefiningModule, Module* pLoad // Now, fill in the new cookie (assuming we had enough memory to create one.) pCookie->pModule = pDefiningModule; - pCookie->pNDirectILStub = 0; + pCookie->pPInvokeILStub = 0; pCookie->sizeOfArgs = sizeOfArgs; pCookie->signature = vaSignature; pCookie->pLoaderModule = pLoaderModule; diff --git a/src/coreclr/vm/ceeload.h b/src/coreclr/vm/ceeload.h index 32c1f1f04fcd50..98853750cd44a9 100644 --- a/src/coreclr/vm/ceeload.h +++ b/src/coreclr/vm/ceeload.h @@ -344,7 +344,7 @@ struct VASigCookie // The JIT wants knows that the size of the arguments comes first // so please keep this field first unsigned sizeOfArgs; // size of argument list - Volatile pNDirectILStub; // will be use if target is NDirect (tag == 0) + Volatile pPInvokeILStub; // will be use if target is PInvoke (tag == 0) PTR_Module pModule; PTR_Module pLoaderModule; Signature signature; @@ -1462,17 +1462,17 @@ class Module : public ModuleBase IMDInternalImport *GetNativeAssemblyImport(BOOL loadAllowed = TRUE); IMDInternalImport *GetNativeAssemblyImportIfLoaded(); - BOOL FixupNativeEntry(READYTORUN_IMPORT_SECTION * pSection, SIZE_T fixupIndex, SIZE_T *fixup, BOOL mayUsePrecompiledNDirectMethods = TRUE); + BOOL FixupNativeEntry(READYTORUN_IMPORT_SECTION * pSection, SIZE_T fixupIndex, SIZE_T *fixup, BOOL mayUsePrecompiledPInvokeMethods = TRUE); //this split exists to support new CLR Dump functionality in DAC. The //template removes any indirections. - BOOL FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledNDirectMethods = TRUE); + BOOL FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledPInvokeMethods = TRUE); template BOOL FixupDelayListAux(TADDR pFixupList, Ptr pThis, FixupNativeEntryCallback pfnCB, PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections, - PEDecoder * pNativeImage, BOOL mayUsePrecompiledNDirectMethods = TRUE); + PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods = TRUE); void RunEagerFixups(); void RunEagerFixupsUnlocked(); diff --git a/src/coreclr/vm/ceeload.inl b/src/coreclr/vm/ceeload.inl index 06a5001c23b22b..2067de38088fd9 100644 --- a/src/coreclr/vm/ceeload.inl +++ b/src/coreclr/vm/ceeload.inl @@ -338,21 +338,21 @@ inline mdAssemblyRef Module::FindAssemblyRef(Assembly *targetAssembly) #include "nibblestream.h" -FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledNDirectMethods) +FORCEINLINE BOOL Module::FixupDelayList(TADDR pFixupList, BOOL mayUsePrecompiledPInvokeMethods) { WRAPPER_NO_CONTRACT; COUNT_T nImportSections; PTR_READYTORUN_IMPORT_SECTION pImportSections = GetImportSections(&nImportSections); - return FixupDelayListAux(pFixupList, this, &Module::FixupNativeEntry, pImportSections, nImportSections, GetReadyToRunImage(), mayUsePrecompiledNDirectMethods); + return FixupDelayListAux(pFixupList, this, &Module::FixupNativeEntry, pImportSections, nImportSections, GetReadyToRunImage(), mayUsePrecompiledPInvokeMethods); } template BOOL Module::FixupDelayListAux(TADDR pFixupList, Ptr pThis, FixupNativeEntryCallback pfnCB, PTR_READYTORUN_IMPORT_SECTION pImportSections, COUNT_T nImportSections, - PEDecoder * pNativeImage, BOOL mayUsePrecompiledNDirectMethods) + PEDecoder * pNativeImage, BOOL mayUsePrecompiledPInvokeMethods) { CONTRACTL { @@ -442,7 +442,7 @@ BOOL Module::FixupDelayListAux(TADDR pFixupList, { CONSISTENCY_CHECK(fixupIndex * sizeof(TADDR) < cbData); - if (!(pThis->*pfnCB)(pImportSection, fixupIndex, dac_cast(pData + fixupIndex * sizeof(TADDR)), mayUsePrecompiledNDirectMethods)) + if (!(pThis->*pfnCB)(pImportSection, fixupIndex, dac_cast(pData + fixupIndex * sizeof(TADDR)), mayUsePrecompiledPInvokeMethods)) return FALSE; int delta = reader.ReadEncodedU32(); diff --git a/src/coreclr/vm/class.cpp b/src/coreclr/vm/class.cpp index 018c7711f71caf..5a3576b4bf4498 100644 --- a/src/coreclr/vm/class.cpp +++ b/src/coreclr/vm/class.cpp @@ -731,7 +731,7 @@ HRESULT EEClass::AddMethodDesc( dwImplFlags, dwMemberAttrs, TRUE, // fEnC - 0, // RVA - non-zero only for NDirect + 0, // RVA - non-zero only for PInvoke pImport, NULL, Signature(), diff --git a/src/coreclr/vm/class.h b/src/coreclr/vm/class.h index 0ee57a801ad5bd..64c5b59746eb25 100644 --- a/src/coreclr/vm/class.h +++ b/src/coreclr/vm/class.h @@ -2047,7 +2047,7 @@ inline PCODE GetPreStubEntryPoint() PCODE TheUMThunkPreStub(); -PCODE TheVarargNDirectStub(BOOL hasRetBuffArg); +PCODE TheVarargPInvokeStub(BOOL hasRetBuffArg); diff --git a/src/coreclr/vm/classcompat.cpp b/src/coreclr/vm/classcompat.cpp index 4f022ec115ec3d..82be81e0130308 100644 --- a/src/coreclr/vm/classcompat.cpp +++ b/src/coreclr/vm/classcompat.cpp @@ -2663,7 +2663,7 @@ VOID MethodTableBuilder::EnumerateClassMethods() if (IsReallyMdPinvokeImpl(dwMemberAttrs) || IsMiInternalCall(dwImplFlags)) { - hr = NDirect::HasNAT_LAttribute(pMDInternalImport, tok, dwMemberAttrs); + hr = PInvoke::HasNAT_LAttribute(pMDInternalImport, tok, dwMemberAttrs); // There was a problem querying for the attribute if (FAILED(hr)) @@ -2698,7 +2698,7 @@ VOID MethodTableBuilder::EnumerateClassMethods() else Classification = mcPInvoke; } - // The NAT_L attribute is present, marking this method as NDirect + // The NAT_L attribute is present, marking this method as PInvoke else { CONSISTENCY_CHECK(hr == S_OK); diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index c9e2ca3290cdd9..ced3bda43099bc 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -35,7 +35,7 @@ // dllimport.cpp void CreateCLRToDispatchCOMStub( MethodDesc * pMD, - DWORD dwStubFlags // NDirectStubFlags + DWORD dwStubFlags // PInvokeStubFlags ); @@ -108,7 +108,7 @@ CLRToCOMCallInfo *CLRToCOMCall::PopulateCLRToCOMCallMethodDesc(MethodDesc* pMD, return pComInfo; // - // Compute NDirectStubFlags + // Compute PInvokeStubFlags // DWORD dwStubFlags = NDIRECTSTUB_FL_COM; @@ -154,7 +154,7 @@ MethodDesc* CLRToCOMCall::GetILStubMethodDesc(MethodDesc* pMD, DWORD dwStubFlags // Get the call signature information StubSigDesc sigDesc(pMD); - return NDirect::CreateCLRToNativeILStub( + return PInvoke::CreateCLRToNativeILStub( &sigDesc, (CorNativeLinkType)0, (CorNativeLinkFlags)0, diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index d9ff94baaabe42..f11387d569b18f 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -1543,7 +1543,7 @@ PCODE COMDelegate::GetStubForILStub(EEImplMethodDesc* pDelegateMD, MethodDesc** dwStubFlags |= NDIRECTSTUB_FL_DELEGATE; - RETURN NDirect::GetStubForILStub(pDelegateMD, ppStubMD, dwStubFlags); + RETURN PInvoke::GetStubForILStub(pDelegateMD, ppStubMD, dwStubFlags); } @@ -1558,7 +1558,7 @@ MethodDesc* COMDelegate::GetILStubMethodDesc(EEImplMethodDesc* pDelegateMD, DWOR dwStubFlags |= NDIRECTSTUB_FL_DELEGATE; PInvokeStaticSigInfo sigInfo(pDelegateMD); - return NDirect::CreateCLRToNativeILStub(&sigInfo, dwStubFlags, pDelegateMD); + return PInvoke::CreateCLRToNativeILStub(&sigInfo, dwStubFlags, pDelegateMD); } extern "C" void QCALLTYPE Delegate_InitializeVirtualCallStub(QCall::ObjectHandleOnStack d, PCODE method) @@ -2034,7 +2034,7 @@ void COMDelegate::ThrowIfInvalidUnmanagedCallersOnlyUsage(MethodDesc* pMD) // Arguments - Scenarios involving UnmanagedCallersOnly are handled during the jit. bool unmanagedCallersOnlyRequiresMarshalling = false; - if (NDirect::MarshalingRequired(pMD, NULL, NULL, NULL, unmanagedCallersOnlyRequiresMarshalling)) + if (PInvoke::MarshalingRequired(pMD, NULL, NULL, NULL, unmanagedCallersOnlyRequiresMarshalling)) EX_THROW(EEResourceException, (kInvalidProgramException, W("InvalidProgram_NonBlittableTypes"))); } diff --git a/src/coreclr/vm/common.h b/src/coreclr/vm/common.h index ce10f52fcb3455..858f6523bb7f05 100644 --- a/src/coreclr/vm/common.h +++ b/src/coreclr/vm/common.h @@ -142,7 +142,7 @@ typedef DPTR(class MethodImpl) PTR_MethodImpl; typedef DPTR(class MethodTable) PTR_MethodTable; typedef DPTR(class CoreLibBinder) PTR_CoreLibBinder; typedef VPTR(class Module) PTR_Module; -typedef DPTR(class NDirectMethodDesc) PTR_NDirectMethodDesc; +typedef DPTR(class PInvokeMethodDesc) PTR_PInvokeMethodDesc; typedef DPTR(class Thread) PTR_Thread; typedef DPTR(class Object) PTR_Object; typedef DPTR(PTR_Object) PTR_PTR_Object; diff --git a/src/coreclr/vm/comtoclrcall.cpp b/src/coreclr/vm/comtoclrcall.cpp index bd77809701cded..45e2c0554aba0f 100644 --- a/src/coreclr/vm/comtoclrcall.cpp +++ b/src/coreclr/vm/comtoclrcall.cpp @@ -1305,7 +1305,7 @@ MethodDesc* ComCall::GetILStubMethodDesc(MethodDesc *pCallMD, DWORD dwStubFlags) // Get the call signature information StubSigDesc sigDesc(pCallMD); - return NDirect::CreateCLRToNativeILStub(&sigDesc, + return PInvoke::CreateCLRToNativeILStub(&sigDesc, (CorNativeLinkType)0, (CorNativeLinkFlags)0, CallConv::GetDefaultUnmanagedCallingConvention(), @@ -1332,7 +1332,7 @@ MethodDesc* ComCall::GetILStubMethodDesc(FieldDesc *pFD, DWORD dwStubFlags) // Get the field signature information pFD->GetSig(&pSig, &cSig); - return NDirect::CreateFieldAccessILStub(pSig, + return PInvoke::CreateFieldAccessILStub(pSig, cSig, pFD->GetModule(), pFD->GetMemberDef(), diff --git a/src/coreclr/vm/dispatchinfo.cpp b/src/coreclr/vm/dispatchinfo.cpp index 6967b196927371..57043fc89d9922 100644 --- a/src/coreclr/vm/dispatchinfo.cpp +++ b/src/coreclr/vm/dispatchinfo.cpp @@ -2340,7 +2340,7 @@ void DispatchInfo::MarshalParamManagedToNativeRef(DispatchMemberInfo *pMemberInf if (ElementVt == VT_RECORD && pElementMT->IsBlittable()) { GCX_PREEMP(); - pStructMarshalStubAddress = NDirect::GetEntryPointForStructMarshalStub(pElementMT); + pStructMarshalStubAddress = PInvoke::GetEntryPointForStructMarshalStub(pElementMT); } GCPROTECT_END(); diff --git a/src/coreclr/vm/dispparammarshaler.cpp b/src/coreclr/vm/dispparammarshaler.cpp index 5ec105ce4de85b..b54030f814debe 100644 --- a/src/coreclr/vm/dispparammarshaler.cpp +++ b/src/coreclr/vm/dispparammarshaler.cpp @@ -250,7 +250,7 @@ void DispParamArrayMarshaler::MarshalNativeToManaged(VARIANT *pSrcVar, OBJECTREF if (vt == VT_RECORD && !pElemMT->IsBlittable()) { GCX_PREEMP(); - pStructMarshalStubAddress = NDirect::GetEntryPointForStructMarshalStub(pElemMT); + pStructMarshalStubAddress = PInvoke::GetEntryPointForStructMarshalStub(pElemMT); } // Create an array from the SAFEARRAY. @@ -296,7 +296,7 @@ void DispParamArrayMarshaler::MarshalManagedToNative(OBJECTREF *pSrcObj, VARIANT if (vt == VT_RECORD && !pElemMT->IsBlittable()) { GCX_PREEMP(); - pStructMarshalStubAddress = NDirect::GetEntryPointForStructMarshalStub(pElemMT); + pStructMarshalStubAddress = PInvoke::GetEntryPointForStructMarshalStub(pElemMT); } GCPROTECT_END(); @@ -407,7 +407,7 @@ void DispParamRecordMarshaler::MarshalNativeToManaged(VARIANT *pSrcVar, OBJECTRE { GCX_PREEMP(); - pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pRecordMT); + pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pRecordMT); } MarshalStructViaILStub(pStructMarshalStub, BoxedValueClass->GetData(), pvRecord, StructMarshalStubs::MarshalOperation::Unmarshal); diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 05a5c538e59e4f..71cd376a9fcd28 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -493,7 +493,7 @@ class ILStubState : public StubState { STANDARD_VM_CONTRACT; - m_slIL.DoNDirect(m_slIL.GetDispatchCodeStream(), m_dwStubFlags, pStubMD); + m_slIL.DoPInvoke(m_slIL.GetDispatchCodeStream(), m_dwStubFlags, pStubMD); } virtual void EmitExceptionHandler(LocalDesc* pNativeReturnType, LocalDesc* pManagedReturnType, @@ -893,7 +893,7 @@ class ILStubState : public StubState #ifdef LOGGING LOG((LF_STUBS, LL_INFO1000, "---------------------------------------------------------------------\n")); - LOG((LF_STUBS, LL_INFO1000, "NDirect IL stub dump: %s::%s\n", pStubMD->m_pszDebugClassName, pStubMD->m_pszDebugMethodName)); + LOG((LF_STUBS, LL_INFO1000, "PInvoke IL stub dump: %s::%s\n", pStubMD->m_pszDebugClassName, pStubMD->m_pszDebugMethodName)); if (LoggingEnabled() && LoggingOn(LF_STUBS, LL_INFO1000)) { CQuickBytes qbManaged; @@ -1237,7 +1237,7 @@ class ILStubState : public StubState protected: CQuickBytes m_qbNativeFnSigBuffer; - NDirectStubLinker m_slIL; + PInvokeStubLinker m_slIL; BOOL m_fSetLastError; DWORD m_dwStubFlags; }; @@ -1434,10 +1434,10 @@ class PInvoke_ILStubState : public ILStubState static BOOL HasCheckForPendingException(MethodDesc* pTargetMD) { - if (pTargetMD == NULL || !pTargetMD->IsNDirect()) + if (pTargetMD == NULL || !pTargetMD->IsPInvoke()) return FALSE; - auto pNMD = (NDirectMethodDesc*)pTargetMD; + auto pNMD = (PInvokeMethodDesc*)pTargetMD; if (!Interop::ShouldCheckForPendingException(pNMD)) return FALSE; @@ -1581,7 +1581,7 @@ class COMToCLRFieldAccess_ILStubState : public COMToCLR_ILStubState }; #endif // FEATURE_COMINTEROP -ILStubLinkerFlags GetILStubLinkerFlagsForNDirectStubFlags(NDirectStubFlags flags) +ILStubLinkerFlags GetILStubLinkerFlagsForPInvokeStubFlags(PInvokeStubFlags flags) { DWORD result = ILSTUB_LINKER_FLAG_NONE; if (!SF_IsCOMStub(flags)) @@ -1607,14 +1607,14 @@ ILStubLinkerFlags GetILStubLinkerFlagsForNDirectStubFlags(NDirectStubFlags flags return (ILStubLinkerFlags)result; } -NDirectStubLinker::NDirectStubLinker( +PInvokeStubLinker::PInvokeStubLinker( DWORD dwStubFlags, Module* pModule, const Signature &signature, SigTypeContext *pTypeContext, MethodDesc* pTargetMD, int iLCIDParamIdx) - : ILStubLinker(pModule, signature, pTypeContext, pTargetMD, GetILStubLinkerFlagsForNDirectStubFlags((NDirectStubFlags)dwStubFlags)), + : ILStubLinker(pModule, signature, pTypeContext, pTargetMD, GetILStubLinkerFlagsForPInvokeStubFlags((PInvokeStubFlags)dwStubFlags)), m_pCleanupFinallyBeginLabel(NULL), m_pCleanupFinallyEndLabel(NULL), m_pSkipExceptionCleanupLabel(NULL), @@ -1660,7 +1660,7 @@ NDirectStubLinker::NDirectStubLinker( #endif // FEATURE_COMINTEROP } -void NDirectStubLinker::SetCallingConvention(CorInfoCallConvExtension unmngCallConv, BOOL fIsVarArg) +void PInvokeStubLinker::SetCallingConvention(CorInfoCallConvExtension unmngCallConv, BOOL fIsVarArg) { LIMITED_METHOD_CONTRACT; @@ -1678,7 +1678,7 @@ void NDirectStubLinker::SetCallingConvention(CorInfoCallConvExtension unmngCallC } } -void NDirectStubLinker::EmitSetArgMarshalIndex(ILCodeStream* pcsEmit, UINT uArgIdx) +void PInvokeStubLinker::EmitSetArgMarshalIndex(ILCodeStream* pcsEmit, UINT uArgIdx) { WRAPPER_NO_CONTRACT; @@ -1708,7 +1708,7 @@ void NDirectStubLinker::EmitSetArgMarshalIndex(ILCodeStream* pcsEmit, UINT uArgI pcsEmit->EmitSTLOC(m_dwArgMarshalIndexLocalNum); } -void NDirectStubLinker::EmitCheckForArgCleanup(ILCodeStream* pcsEmit, UINT uArgIdx, ArgCleanupBranchKind branchKind, ILCodeLabel* pSkipCleanupLabel) +void PInvokeStubLinker::EmitCheckForArgCleanup(ILCodeStream* pcsEmit, UINT uArgIdx, ArgCleanupBranchKind branchKind, ILCodeLabel* pSkipCleanupLabel) { STANDARD_VM_CONTRACT; @@ -1739,55 +1739,55 @@ void NDirectStubLinker::EmitCheckForArgCleanup(ILCodeStream* pcsEmit, UINT uArgI } } -int NDirectStubLinker::GetLCIDParamIdx() +int PInvokeStubLinker::GetLCIDParamIdx() { LIMITED_METHOD_CONTRACT; return m_iLCIDParamIdx; } -ILCodeStream* NDirectStubLinker::GetSetupCodeStream() +ILCodeStream* PInvokeStubLinker::GetSetupCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsSetup; } -ILCodeStream* NDirectStubLinker::GetMarshalCodeStream() +ILCodeStream* PInvokeStubLinker::GetMarshalCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsMarshal; } -ILCodeStream* NDirectStubLinker::GetUnmarshalCodeStream() +ILCodeStream* PInvokeStubLinker::GetUnmarshalCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsUnmarshal; } -ILCodeStream* NDirectStubLinker::GetReturnUnmarshalCodeStream() +ILCodeStream* PInvokeStubLinker::GetReturnUnmarshalCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsRetUnmarshal; } -ILCodeStream* NDirectStubLinker::GetDispatchCodeStream() +ILCodeStream* PInvokeStubLinker::GetDispatchCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsDispatch; } -ILCodeStream* NDirectStubLinker::GetCleanupCodeStream() +ILCodeStream* PInvokeStubLinker::GetCleanupCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsCleanup; } -ILCodeStream* NDirectStubLinker::GetExceptionCleanupCodeStream() +ILCodeStream* PInvokeStubLinker::GetExceptionCleanupCodeStream() { LIMITED_METHOD_CONTRACT; return m_pcsExceptionCleanup; } -void NDirectStubLinker::SetInteropParamExceptionInfo(UINT resID, UINT paramIdx) +void PInvokeStubLinker::SetInteropParamExceptionInfo(UINT resID, UINT paramIdx) { LIMITED_METHOD_CONTRACT; @@ -1801,14 +1801,14 @@ void NDirectStubLinker::SetInteropParamExceptionInfo(UINT resID, UINT paramIdx) m_ErrorParamIdx = paramIdx; } -bool NDirectStubLinker::HasInteropParamExceptionInfo() +bool PInvokeStubLinker::HasInteropParamExceptionInfo() { LIMITED_METHOD_CONTRACT; return !(((DWORD)-1 == m_ErrorResID) && ((DWORD)-1 == m_ErrorParamIdx)); } -void NDirectStubLinker::GenerateInteropParamException(ILCodeStream* pcsEmit) +void PInvokeStubLinker::GenerateInteropParamException(ILCodeStream* pcsEmit) { STANDARD_VM_CONTRACT; @@ -1821,20 +1821,20 @@ void NDirectStubLinker::GenerateInteropParamException(ILCodeStream* pcsEmit) } #ifdef FEATURE_COMINTEROP -DWORD NDirectStubLinker::GetTargetInterfacePointerLocalNum() +DWORD PInvokeStubLinker::GetTargetInterfacePointerLocalNum() { LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK(m_dwTargetInterfacePointerLocalNum != (DWORD)-1); return m_dwTargetInterfacePointerLocalNum; } -DWORD NDirectStubLinker::GetTargetEntryPointLocalNum() +DWORD PInvokeStubLinker::GetTargetEntryPointLocalNum() { LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK(m_dwTargetEntryPointLocalNum != (DWORD)-1); return m_dwTargetEntryPointLocalNum; } -void NDirectStubLinker::EmitLoadRCWThis(ILCodeStream *pcsEmit, DWORD dwStubFlags) +void PInvokeStubLinker::EmitLoadRCWThis(ILCodeStream *pcsEmit, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -1842,34 +1842,34 @@ void NDirectStubLinker::EmitLoadRCWThis(ILCodeStream *pcsEmit, DWORD dwStubFlags } #endif // FEATURE_COMINTEROP -DWORD NDirectStubLinker::GetCleanupWorkListLocalNum() +DWORD PInvokeStubLinker::GetCleanupWorkListLocalNum() { LIMITED_METHOD_CONTRACT; CONSISTENCY_CHECK(m_dwCleanupWorkListLocalNum != (DWORD)-1); return m_dwCleanupWorkListLocalNum; } -DWORD NDirectStubLinker::GetReturnValueLocalNum() +DWORD PInvokeStubLinker::GetReturnValueLocalNum() { LIMITED_METHOD_CONTRACT; return m_dwRetValLocalNum; } -BOOL NDirectStubLinker::IsCleanupNeeded() +BOOL PInvokeStubLinker::IsCleanupNeeded() { LIMITED_METHOD_CONTRACT; return (m_fHasCleanupCode || IsCleanupWorkListSetup()); } -BOOL NDirectStubLinker::IsExceptionCleanupNeeded() +BOOL PInvokeStubLinker::IsExceptionCleanupNeeded() { LIMITED_METHOD_CONTRACT; return m_fHasExceptionCleanupCode; } -void NDirectStubLinker::InitCleanupCode() +void PInvokeStubLinker::InitCleanupCode() { CONTRACTL { @@ -1882,7 +1882,7 @@ void NDirectStubLinker::InitCleanupCode() m_pcsExceptionCleanup->EmitLabel(m_pCleanupFinallyBeginLabel); } -void NDirectStubLinker::InitExceptionCleanupCode() +void PInvokeStubLinker::InitExceptionCleanupCode() { CONTRACTL { @@ -1898,7 +1898,7 @@ void NDirectStubLinker::InitExceptionCleanupCode() EmitCheckForArgCleanup(m_pcsExceptionCleanup, CLEANUP_INDEX_ALL_DONE, BranchIfMarshaled, m_pSkipExceptionCleanupLabel); } -void NDirectStubLinker::SetCleanupNeeded() +void PInvokeStubLinker::SetCleanupNeeded() { WRAPPER_NO_CONTRACT; @@ -1909,7 +1909,7 @@ void NDirectStubLinker::SetCleanupNeeded() } } -void NDirectStubLinker::SetExceptionCleanupNeeded() +void PInvokeStubLinker::SetExceptionCleanupNeeded() { WRAPPER_NO_CONTRACT; @@ -1920,7 +1920,7 @@ void NDirectStubLinker::SetExceptionCleanupNeeded() } } -void NDirectStubLinker::NeedsCleanupList() +void PInvokeStubLinker::NeedsCleanupList() { STANDARD_VM_CONTRACT; @@ -1936,7 +1936,7 @@ void NDirectStubLinker::NeedsCleanupList() } -BOOL NDirectStubLinker::IsCleanupWorkListSetup () +BOOL PInvokeStubLinker::IsCleanupWorkListSetup () { LIMITED_METHOD_CONTRACT; @@ -1944,7 +1944,7 @@ BOOL NDirectStubLinker::IsCleanupWorkListSetup () } -void NDirectStubLinker::LoadCleanupWorkList(ILCodeStream* pcsEmit) +void PInvokeStubLinker::LoadCleanupWorkList(ILCodeStream* pcsEmit) { STANDARD_VM_CONTRACT; @@ -1960,7 +1960,7 @@ void NDirectStubLinker::LoadCleanupWorkList(ILCodeStream* pcsEmit) } -void NDirectStubLinker::Begin(DWORD dwStubFlags) +void PInvokeStubLinker::Begin(DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -1985,7 +1985,7 @@ void NDirectStubLinker::Begin(DWORD dwStubFlags) m_pcsMarshal->EmitLabel(m_pCleanupTryBeginLabel); } -void NDirectStubLinker::End(DWORD dwStubFlags) +void PInvokeStubLinker::End(DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -2084,7 +2084,7 @@ void NDirectStubLinker::End(DWORD dwStubFlags) } } -void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, MethodDesc * pStubMD) +void PInvokeStubLinker::DoPInvoke(ILCodeStream *pcsEmit, DWORD dwStubFlags, MethodDesc * pStubMD) { STANDARD_VM_CONTRACT; @@ -2123,7 +2123,7 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth { EmitLoadStubContext(pcsEmit, dwStubFlags); - pcsEmit->EmitLDC(offsetof(NDirectMethodDesc, ndirect.m_pNDirectTarget)); + pcsEmit->EmitLDC(offsetof(PInvokeMethodDesc, ndirect.m_pPInvokeTarget)); pcsEmit->EmitADD(); pcsEmit->EmitLDIND_I(); } @@ -2174,7 +2174,7 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth pcsEmit->EmitCALLI(TOKEN_ILSTUB_TARGET_SIG, 0, m_iTargetStackDelta); } -void NDirectStubLinker::EmitLogNativeArgument(ILCodeStream* pslILEmit, DWORD dwPinnedLocal) +void PInvokeStubLinker::EmitLogNativeArgument(ILCodeStream* pslILEmit, DWORD dwPinnedLocal) { STANDARD_VM_CONTRACT; @@ -2195,7 +2195,7 @@ void NDirectStubLinker::EmitLogNativeArgument(ILCodeStream* pslILEmit, DWORD dwP } #ifndef DACCESS_COMPILE -void NDirectStubLinker::GetCleanupFinallyOffsets(ILStubEHClause * pClause) +void PInvokeStubLinker::GetCleanupFinallyOffsets(ILStubEHClause * pClause) { CONTRACTL { @@ -2219,7 +2219,7 @@ void NDirectStubLinker::GetCleanupFinallyOffsets(ILStubEHClause * pClause) } #endif // DACCESS_COMPILE -void NDirectStubLinker::ClearCode() +void PInvokeStubLinker::ClearCode() { WRAPPER_NO_CONTRACT; ILStubLinker::ClearCode(); @@ -2231,7 +2231,7 @@ void NDirectStubLinker::ClearCode() } #ifdef PROFILING_SUPPORTED -DWORD NDirectStubLinker::EmitProfilerBeginTransitionCallback(ILCodeStream* pcsEmit, DWORD dwStubFlags) +DWORD PInvokeStubLinker::EmitProfilerBeginTransitionCallback(ILCodeStream* pcsEmit, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -2261,7 +2261,7 @@ DWORD NDirectStubLinker::EmitProfilerBeginTransitionCallback(ILCodeStream* pcsEm return dwMethodDescLocalNum; } -void NDirectStubLinker::EmitProfilerEndTransitionCallback(ILCodeStream* pcsEmit, DWORD dwStubFlags, DWORD dwMethodDescLocalNum) +void PInvokeStubLinker::EmitProfilerEndTransitionCallback(ILCodeStream* pcsEmit, DWORD dwStubFlags, DWORD dwMethodDescLocalNum) { STANDARD_VM_CONTRACT; @@ -2272,7 +2272,7 @@ void NDirectStubLinker::EmitProfilerEndTransitionCallback(ILCodeStream* pcsEmit, #endif // PROFILING_SUPPPORTED #ifdef VERIFY_HEAP -void NDirectStubLinker::EmitValidateLocal(ILCodeStream* pcsEmit, DWORD dwLocalNum, bool fIsByref, DWORD dwStubFlags) +void PInvokeStubLinker::EmitValidateLocal(ILCodeStream* pcsEmit, DWORD dwLocalNum, bool fIsByref, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -2305,7 +2305,7 @@ void NDirectStubLinker::EmitValidateLocal(ILCodeStream* pcsEmit, DWORD dwLocalNu } } -void NDirectStubLinker::EmitObjectValidation(ILCodeStream* pcsEmit, DWORD dwStubFlags) +void PInvokeStubLinker::EmitObjectValidation(ILCodeStream* pcsEmit, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -2341,7 +2341,7 @@ void NDirectStubLinker::EmitObjectValidation(ILCodeStream* pcsEmit, DWORD dwStub #endif // VERIFY_HEAP // Loads the 'secret argument' passed to the stub. -void NDirectStubLinker::EmitLoadStubContext(ILCodeStream* pcsEmit, DWORD dwStubFlags) +void PInvokeStubLinker::EmitLoadStubContext(ILCodeStream* pcsEmit, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -2986,7 +2986,7 @@ namespace { STANDARD_VM_CHECK; PRECONDITION(pMD != NULL); - PRECONDITION(pMD->IsNDirect()); + PRECONDITION(pMD->IsPInvoke()); PRECONDITION(callConv != NULL); } CONTRACTL_END; @@ -3043,13 +3043,13 @@ namespace } } -void NDirect::GetCallingConvention_IgnoreErrors(_In_ MethodDesc* pMD, _Out_opt_ CorInfoCallConvExtension* callConv, _Out_opt_ bool* suppressGCTransition) +void PInvoke::GetCallingConvention_IgnoreErrors(_In_ MethodDesc* pMD, _Out_opt_ CorInfoCallConvExtension* callConv, _Out_opt_ bool* suppressGCTransition) { CONTRACTL { STANDARD_VM_CHECK; PRECONDITION(pMD != NULL); - PRECONDITION(pMD->IsNDirect()); + PRECONDITION(pMD->IsPInvoke()); PRECONDITION(callConv != NULL || suppressGCTransition != NULL); } CONTRACTL_END; @@ -3143,7 +3143,7 @@ void NDirect::GetCallingConvention_IgnoreErrors(_In_ MethodDesc* pMD, _Out_opt_ // FAILED = unknown because something failed. //--------------------------------------------------------- /*static*/ -HRESULT NDirect::HasNAT_LAttribute(IMDInternalImport *pInternalImport, mdToken token, DWORD dwMemberAttrs) +HRESULT PInvoke::HasNAT_LAttribute(IMDInternalImport *pInternalImport, mdToken token, DWORD dwMemberAttrs) { CONTRACTL { @@ -3172,7 +3172,7 @@ HRESULT NDirect::HasNAT_LAttribute(IMDInternalImport *pInternalImport, mdToken t // Either MD or signature & module must be given. /*static*/ -BOOL NDirect::MarshalingRequired( +BOOL PInvoke::MarshalingRequired( _In_opt_ MethodDesc* pMD, _In_opt_ SigPointer sigPointer, _In_opt_ Module* pModule, @@ -3187,7 +3187,7 @@ BOOL NDirect::MarshalingRequired( CONTRACTL_END; // As a by-product, when returning FALSE we will also set the native stack size to the MD if it's - // an NDirectMethodDesc. This number is needed to link the P/Invoke (it determines the @n entry + // an PInvokeMethodDesc. This number is needed to link the P/Invoke (it determines the @n entry // point name suffix and affects alignment thunk generation on the Mac). If this method returns // TRUE, the stack size will be set when building the marshaling IL stub. DWORD dwStackSize = 0; @@ -3196,14 +3196,14 @@ BOOL NDirect::MarshalingRequired( if (pMD != NULL) { // HRESULT swapping is handled by stub - if (pMD->IsNDirect() || pMD->IsCLRToCOMCall()) + if (pMD->IsPInvoke() || pMD->IsCLRToCOMCall()) { if (!IsMiPreserveSig(pMD->GetImplAttrs())) return TRUE; } PInvokeStaticSigInfo sigInfo; - if (!pMD->IsNDirect()) + if (!pMD->IsPInvoke()) { new (&sigInfo) PInvokeStaticSigInfo(pMD); } @@ -3219,8 +3219,8 @@ BOOL NDirect::MarshalingRequired( if (unmanagedCallersOnlyRequiresMarshalling && pMD->HasUnmanagedCallersOnlyAttribute()) return TRUE; - NDirectMethodDesc* pNMD = (NDirectMethodDesc*)pMD; - InitializeSigInfoAndPopulateNDirectMethodDesc(pNMD, &sigInfo); + PInvokeMethodDesc* pNMD = (PInvokeMethodDesc*)pMD; + InitializeSigInfoAndPopulatePInvokeMethodDesc(pNMD, &sigInfo); // Pending exceptions are handled by stub if (Interop::ShouldCheckForPendingException(pNMD)) @@ -3414,9 +3414,9 @@ BOOL NDirect::MarshalingRequired( // do not set the stack size for varargs - the number is call site specific if (pMD != NULL && !pMD->IsVarArg()) { - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { - ((NDirectMethodDesc *)pMD)->SetStackArgumentSize(static_cast(dwStackSize), callConv); + ((PInvokeMethodDesc *)pMD)->SetStackArgumentSize(static_cast(dwStackSize), callConv); } #ifdef FEATURE_COMINTEROP else if (pMD->IsCLRToCOMCall()) @@ -3430,7 +3430,7 @@ BOOL NDirect::MarshalingRequired( return FALSE; } -// factorization of CreateNDirectStubWorker +// factorization of CreatePInvokeStubWorker static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, mdParamDef* params, CorNativeLinkType nlType, @@ -3567,7 +3567,7 @@ static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, // Note that this function may now throw if it fails to create // a stub. //--------------------------------------------------------- -static void CreateNDirectStubWorker(StubState* pss, +static void CreatePInvokeStubWorker(StubState* pss, StubSigDesc* pSigDesc, CorNativeLinkType nlType, CorNativeLinkFlags nlFlags, @@ -3931,18 +3931,18 @@ static void CreateStructStub(ILStubState* pss, namespace { - class NDirectStubParameters + class PInvokeStubParameters { public: - NDirectStubParameters(Signature sig, + PInvokeStubParameters(Signature sig, SigTypeContext* pTypeContext, Module* pModule, Module* pLoaderModule, CorNativeLinkType nlType, CorNativeLinkFlags nlFlags, CorInfoCallConvExtension unmgdCallConv, - DWORD dwStubFlags, // NDirectStubFlags + DWORD dwStubFlags, // PInvokeStubFlags int nParamTokens, mdParamDef* pParamTokenArray, int iLCIDArg, @@ -3978,14 +3978,14 @@ namespace MethodTable* m_pMT; }; - class NDirectStubHashBlob : public ILStubHashBlobBase + class PInvokeStubHashBlob : public ILStubHashBlobBase { public: Module* m_pModule; MethodTable* m_pMT; WORD m_unmgdCallConv; - BYTE m_nlType; // C_ASSERTS are in NDirect::CreateHashBlob + BYTE m_nlType; // C_ASSERTS are in PInvoke::CreateHashBlob BYTE m_nlFlags; DWORD m_StubFlags; @@ -4007,11 +4007,11 @@ namespace PCCOR_SIGNATURE pvNativeType; }; - ILStubHashBlob* CreateHashBlob(NDirectStubParameters* pParams) + ILStubHashBlob* CreateHashBlob(PInvokeStubParameters* pParams) { STANDARD_VM_CONTRACT; - NDirectStubHashBlob* pBlob; + PInvokeStubHashBlob* pBlob; IMDInternalImport* pInternalImport = pParams->m_pModule->GetMDImport(); @@ -4056,7 +4056,7 @@ namespace // // Build hash blob for IL stub sharing // - S_SIZE_T cbSizeOfBlob = S_SIZE_T(offsetof(NDirectStubHashBlob, m_rgbSigAndParamData)) + + S_SIZE_T cbSizeOfBlob = S_SIZE_T(offsetof(PInvokeStubHashBlob, m_rgbSigAndParamData)) + S_SIZE_T(sizeof(ULONG)) * S_SIZE_T(pParams->m_nParamTokens) + // Parameter attributes S_SIZE_T(sizeof(DWORD)) * S_SIZE_T(pParams->m_nParamTokens) + // Native type blob size S_SIZE_T(cbNativeTypeTotal) + // Native type blob data @@ -4072,7 +4072,7 @@ namespace NewArrayHolder pBytes = new BYTE[cbSizeOfBlob.Value()]; // zero out the hash bytes to ensure all bit fields are deterministically set ZeroMemory(pBytes, cbSizeOfBlob.Value()); - pBlob = (NDirectStubHashBlob*)(BYTE*)pBytes; + pBlob = (PInvokeStubHashBlob*)(BYTE*)pBytes; pBlob->m_pModule = NULL; @@ -4131,7 +4131,7 @@ namespace return (ILStubHashBlob*)pBlob; } - ILStubCache* GetILStubCache(NDirectStubParameters* pParams) + ILStubCache* GetILStubCache(PInvokeStubParameters* pParams) { CONTRACTL { @@ -4148,7 +4148,7 @@ namespace MethodDesc* GetStubMethodDesc( MethodDesc *pTargetMD, - NDirectStubParameters* pParams, + PInvokeStubParameters* pParams, ILStubHashBlob* pHashParams, AllocMemTracker* pamTracker, bool& bILStubCreator, @@ -4185,7 +4185,7 @@ namespace RETURN pMD; } - void RemoveILStubCacheEntry(NDirectStubParameters* pParams, ILStubHashBlob* pHashParams) + void RemoveILStubCacheEntry(PInvokeStubParameters* pParams, ILStubHashBlob* pHashParams) { CONTRACTL { @@ -4205,7 +4205,7 @@ namespace pCache->DeleteEntry(pHashParams); } - void AddMethodDescChunkWithLockTaken(NDirectStubParameters* pParams, MethodDesc *pMD) + void AddMethodDescChunkWithLockTaken(PInvokeStubParameters* pParams, MethodDesc *pMD) { CONTRACTL { @@ -4224,12 +4224,12 @@ namespace } // -// Additional factorization of CreateNDirectStub. This hoists all the metadata accesses -// into one location so that we can leave CreateNDirectStubWorker to just generate the -// IL. This allows us to cache a stub based on the inputs to CreateNDirectStubWorker +// Additional factorization of CreatePInvokeStub. This hoists all the metadata accesses +// into one location so that we can leave CreatePInvokeStubWorker to just generate the +// IL. This allows us to cache a stub based on the inputs to CreatePInvokeStubWorker // instead of having to generate the IL first before doing the caching. // -static void CreateNDirectStubAccessMetadata( +static void CreatePInvokeStubAccessMetadata( StubSigDesc* pSigDesc, // IN CorInfoCallConvExtension unmgdCallConv, // IN DWORD* pdwStubFlags, // IN/OUT @@ -4341,8 +4341,8 @@ static void CreateNDirectStubAccessMetadata( namespace { - void PopulateNDirectMethodDescImpl( - _Inout_ NDirectMethodDesc* pNMD, + void PopulatePInvokeMethodDescImpl( + _Inout_ PInvokeMethodDesc* pNMD, _In_ const PInvokeStaticSigInfo& sigInfo, _In_opt_z_ LPCUTF8 libName, _In_opt_z_ LPCUTF8 entryPointName) @@ -4356,26 +4356,26 @@ namespace WORD ndirectflags = 0; if (pNMD->MethodDesc::IsVarArg()) - ndirectflags |= NDirectMethodDesc::kVarArgs; + ndirectflags |= PInvokeMethodDesc::kVarArgs; if (sigInfo.GetCharSet() == nltAnsi) - ndirectflags |= NDirectMethodDesc::kNativeAnsi; + ndirectflags |= PInvokeMethodDesc::kNativeAnsi; CorNativeLinkFlags linkflags = sigInfo.GetLinkFlags(); if (linkflags & nlfLastError) - ndirectflags |= NDirectMethodDesc::kLastError; + ndirectflags |= PInvokeMethodDesc::kLastError; if (linkflags & nlfNoMangle) - ndirectflags |= NDirectMethodDesc::kNativeNoMangle; + ndirectflags |= PInvokeMethodDesc::kNativeNoMangle; CorInfoCallConvExtension callConv = sigInfo.GetCallConv(); if (callConv == CorInfoCallConvExtension::Stdcall) - ndirectflags |= NDirectMethodDesc::kStdCall; + ndirectflags |= PInvokeMethodDesc::kStdCall; if (callConv == CorInfoCallConvExtension::Thiscall) - ndirectflags |= NDirectMethodDesc::kThisCall; + ndirectflags |= PInvokeMethodDesc::kThisCall; if (pNMD->GetLoaderModule()->IsSystem() && (strcmp(libName, "QCall") == 0)) { - ndirectflags |= NDirectMethodDesc::kIsQCall; + ndirectflags |= PInvokeMethodDesc::kIsQCall; } else { @@ -4385,11 +4385,11 @@ namespace pNMD->ndirect.m_pszEntrypointName = entryPointName; // Do not publish incomplete prestub flags or you will introduce a race condition. - pNMD->InterlockedSetNDirectFlags(ndirectflags | NDirectMethodDesc::kNDirectPopulated); + pNMD->InterlockedSetPInvokeFlags(ndirectflags | PInvokeMethodDesc::kPInvokePopulated); } } -void NDirect::PopulateNDirectMethodDesc(_Inout_ NDirectMethodDesc* pNMD) +void PInvoke::PopulatePInvokeMethodDesc(_Inout_ PInvokeMethodDesc* pNMD) { CONTRACTL { @@ -4406,10 +4406,10 @@ void NDirect::PopulateNDirectMethodDesc(_Inout_ NDirectMethodDesc* pNMD) LPCUTF8 szLibName = NULL, szEntryPointName = NULL; PInvokeStaticSigInfo sigInfo(pNMD, &szLibName, &szEntryPointName); - PopulateNDirectMethodDescImpl(pNMD, sigInfo, szLibName, szEntryPointName); + PopulatePInvokeMethodDescImpl(pNMD, sigInfo, szLibName, szEntryPointName); } -void NDirect::InitializeSigInfoAndPopulateNDirectMethodDesc(_Inout_ NDirectMethodDesc* pNMD, _Inout_ PInvokeStaticSigInfo* pSigInfo) +void PInvoke::InitializeSigInfoAndPopulatePInvokeMethodDesc(_Inout_ PInvokeMethodDesc* pNMD, _Inout_ PInvokeStaticSigInfo* pSigInfo) { CONTRACTL { @@ -4428,7 +4428,7 @@ void NDirect::InitializeSigInfoAndPopulateNDirectMethodDesc(_Inout_ NDirectMetho if (pNMD->IsPopulated()) return; - PopulateNDirectMethodDescImpl(pNMD, *pSigInfo, szLibName, szEntryPointName); + PopulatePInvokeMethodDescImpl(pNMD, *pSigInfo, szLibName, szEntryPointName); } #ifdef FEATURE_COMINTEROP @@ -4716,14 +4716,14 @@ namespace //======================================================================= // ILStubCreatorHelper // The class is used as a helper class in CreateInteropILStub. It mainly - // puts two methods NDirect::GetStubMethodDesc and NDirect::RemoveILStubCacheEntry + // puts two methods PInvoke::GetStubMethodDesc and PInvoke::RemoveILStubCacheEntry // into a holder. See CreateInteropILStub for more information //======================================================================= class ILStubCreatorHelper { public: ILStubCreatorHelper(MethodDesc *pTargetMD, - NDirectStubParameters* pParams + PInvokeStubParameters* pParams ) : m_pTargetMD(pTargetMD), m_pParams(pParams), @@ -4794,7 +4794,7 @@ namespace private: MethodDesc* m_pTargetMD; - NDirectStubParameters* m_pParams; + PInvokeStubParameters* m_pParams; NewArrayHolder m_pHashParams; AllocMemTracker* m_pAmTracker; MethodDesc* m_pStubMD; @@ -4861,7 +4861,7 @@ namespace #endif // FEATURE_COMINTEROP // Otherwise, fall back to generating IL stub on-the-fly - NDirectStubParameters params(pSigDesc->m_sig, + PInvokeStubParameters params(pSigDesc->m_sig, &pSigDesc->m_typeContext, pModule, pLoaderModule, @@ -5014,7 +5014,7 @@ namespace BOOL fSigIsStatic = !(callConvInfo & IMAGE_CEE_CS_CALLCONV_HASTHIS); - // CreateNDirectStubWorker will throw an exception for these cases. + // CreatePInvokeStubWorker will throw an exception for these cases. BOOL fCanHaveThis = SF_IsDelegateStub(dwStubFlags) || SF_IsCOMStub(dwStubFlags); if (fSigIsStatic || fCanHaveThis) @@ -5039,7 +5039,7 @@ namespace { // For generic calli, we only support blittable types if (SF_IsCALLIStub(dwStubFlags) - && NDirect::MarshalingRequired(NULL, pStubMD->GetSigPointer(), pSigDesc->m_pModule, &pSigDesc->m_typeContext)) + && PInvoke::MarshalingRequired(NULL, pStubMD->GetSigPointer(), pSigDesc->m_pModule, &pSigDesc->m_typeContext)) { COMPlusThrow(kMarshalDirectiveException, IDS_EE_BADMARSHAL_GENERICS_RESTRICTION); } @@ -5050,7 +5050,7 @@ namespace } } - CreateNDirectStubWorker(pss, + CreatePInvokeStubWorker(pss, pSigDesc, nlType, nlFlags, @@ -5115,9 +5115,9 @@ namespace // (we don't set it for varargs - the number is call site specific) WORD cbStackArgSize = pStubMD->AsDynamicMethodDesc()->GetNativeStackArgSize(); - if (pTargetMD->IsNDirect()) + if (pTargetMD->IsPInvoke()) { - NDirectMethodDesc *pTargetNMD = (NDirectMethodDesc *)pTargetMD; + PInvokeMethodDesc *pTargetNMD = (PInvokeMethodDesc *)pTargetMD; pTargetNMD->SetStackArgumentSize(cbStackArgSize, CallConv::GetDefaultUnmanagedCallingConvention()); } @@ -5142,12 +5142,12 @@ namespace } } -MethodDesc* NDirect::CreateCLRToNativeILStub( +MethodDesc* PInvoke::CreateCLRToNativeILStub( StubSigDesc* pSigDesc, CorNativeLinkType nlType, CorNativeLinkFlags nlFlags, CorInfoCallConvExtension unmgdCallConv, - DWORD dwStubFlags) // NDirectStubFlags + DWORD dwStubFlags) // PInvokeStubFlags { CONTRACT(MethodDesc*) { @@ -5163,7 +5163,7 @@ MethodDesc* NDirect::CreateCLRToNativeILStub( int numParamTokens = 0; mdParamDef* pParamTokenArray = NULL; - CreateNDirectStubAccessMetadata(pSigDesc, + CreatePInvokeStubAccessMetadata(pSigDesc, unmgdCallConv, &dwStubFlags, &iLCIDArg, @@ -5211,12 +5211,12 @@ MethodDesc* NDirect::CreateCLRToNativeILStub( } #ifdef FEATURE_COMINTEROP -MethodDesc* NDirect::CreateFieldAccessILStub( +MethodDesc* PInvoke::CreateFieldAccessILStub( PCCOR_SIGNATURE szMetaSig, DWORD cbMetaSigSize, Module* pModule, mdFieldDef fd, - DWORD dwStubFlags, // NDirectStubFlags + DWORD dwStubFlags, // PInvokeStubFlags FieldDesc* pFD) { CONTRACT(MethodDesc*) @@ -5286,7 +5286,7 @@ MethodDesc* NDirect::CreateFieldAccessILStub( #ifndef DACCESS_COMPILE -MethodDesc* NDirect::CreateStructMarshalILStub(MethodTable* pMT) +MethodDesc* PInvoke::CreateStructMarshalILStub(MethodTable* pMT) { CONTRACT(MethodDesc*) { @@ -5404,7 +5404,7 @@ MethodDesc* NDirect::CreateStructMarshalILStub(MethodTable* pMT) RETURN pStubMD; } -PCODE NDirect::GetEntryPointForStructMarshalStub(MethodTable* pMT) +PCODE PInvoke::GetEntryPointForStructMarshalStub(MethodTable* pMT) { LIMITED_METHOD_CONTRACT; @@ -5417,7 +5417,7 @@ PCODE NDirect::GetEntryPointForStructMarshalStub(MethodTable* pMT) #endif // DACCESS_COMPILE -MethodDesc* NDirect::CreateCLRToNativeILStub(PInvokeStaticSigInfo* pSigInfo, +MethodDesc* PInvoke::CreateCLRToNativeILStub(PInvokeStaticSigInfo* pSigInfo, DWORD dwStubFlags, MethodDesc* pMD) { @@ -5439,7 +5439,7 @@ MethodDesc* NDirect::CreateCLRToNativeILStub(PInvokeStaticSigInfo* pSigInfo, namespace { - MethodDesc* GetILStubMethodDesc(NDirectMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo, DWORD dwStubFlags) + MethodDesc* GetILStubMethodDesc(PInvokeMethodDesc* pNMD, PInvokeStaticSigInfo* pSigInfo, DWORD dwStubFlags) { CONTRACTL { @@ -5452,7 +5452,7 @@ namespace if (!pNMD->IsVarArgs() || SF_IsForNumParamBytes(dwStubFlags)) { - pStubMD = NDirect::CreateCLRToNativeILStub( + pStubMD = PInvoke::CreateCLRToNativeILStub( pSigInfo, dwStubFlags & ~NDIRECTSTUB_FL_FOR_NUMPARAMBYTES, pNMD); @@ -5461,7 +5461,7 @@ namespace return pStubMD; } - LPVOID NDirectGetEntryPoint(NDirectMethodDesc *pMD, NATIVE_LIBRARY_HANDLE hMod) + LPVOID PInvokeGetEntryPoint(PInvokeMethodDesc *pMD, NATIVE_LIBRARY_HANDLE hMod) { // GetProcAddress cannot be called while preemptive GC is disabled. // It requires the OS to take the loader lock. @@ -5479,7 +5479,7 @@ namespace //--------------------------------------------------------- // Loads the DLL and finds the procaddress for an N/Direct call. //--------------------------------------------------------- - VOID NDirectLink(NDirectMethodDesc *pMD) + VOID PInvokeLink(PInvokeMethodDesc *pMD) { CONTRACTL { @@ -5501,7 +5501,7 @@ namespace ("%s::%s is not registered using DllImportEntry macro in qcallentrypoints.cpp", pMD->m_pszDebugClassName, pMD->m_pszDebugMethodName)); #endif - pMD->SetNDirectTarget(pvTarget); + pMD->SetPInvokeTarget(pvTarget); return; } @@ -5512,7 +5512,7 @@ namespace LPVOID pvTarget = (LPVOID)PInvokeOverride::GetMethodImpl(pMD->GetLibNameRaw(), pMD->GetEntrypointName()); if (pvTarget != NULL) { - pMD->SetNDirectTarget(pvTarget); + pMD->SetPInvokeTarget(pvTarget); return; } } @@ -5521,10 +5521,10 @@ namespace _ASSERTE(hmod != NULL); BOOL fSuccess = FALSE; - LPVOID pvTarget = NDirectGetEntryPoint(pMD, hmod); + LPVOID pvTarget = PInvokeGetEntryPoint(pMD, hmod); if (pvTarget) { - pMD->SetNDirectTarget(pvTarget); + pMD->SetPInvokeTarget(pvTarget); fSuccess = TRUE; } @@ -5547,7 +5547,7 @@ namespace } } -PCODE NDirect::GetStubForILStub(MethodDesc* pManagedMD, MethodDesc** ppStubMD, DWORD dwStubFlags) +PCODE PInvoke::GetStubForILStub(MethodDesc* pManagedMD, MethodDesc** ppStubMD, DWORD dwStubFlags) { CONTRACT(PCODE) { @@ -5561,12 +5561,12 @@ PCODE NDirect::GetStubForILStub(MethodDesc* pManagedMD, MethodDesc** ppStubMD, D CONSISTENCY_CHECK(*ppStubMD == NULL); PInvokeStaticSigInfo sigInfo(pManagedMD); - *ppStubMD = NDirect::CreateCLRToNativeILStub(&sigInfo, dwStubFlags, pManagedMD); + *ppStubMD = PInvoke::CreateCLRToNativeILStub(&sigInfo, dwStubFlags, pManagedMD); RETURN JitILStub(*ppStubMD); } -PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, DWORD dwStubFlags) +PCODE PInvoke::GetStubForILStub(PInvokeMethodDesc* pNMD, MethodDesc** ppStubMD, DWORD dwStubFlags) { STANDARD_VM_CONTRACT; @@ -5575,7 +5575,7 @@ PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, CONSISTENCY_CHECK(*ppStubMD == NULL); PInvokeStaticSigInfo sigInfo; - NDirect::InitializeSigInfoAndPopulateNDirectMethodDesc(pNMD, &sigInfo); + PInvoke::InitializeSigInfoAndPopulatePInvokeMethodDesc(pNMD, &sigInfo); *ppStubMD = GetILStubMethodDesc(pNMD, &sigInfo, dwStubFlags); @@ -5591,24 +5591,24 @@ PCODE NDirect::GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, CONSISTENCY_CHECK(pNMD->IsVarArgs()); // - // varargs goes through vararg NDirect stub + // varargs goes through vararg PInvoke stub // - pStub = TheVarargNDirectStub(pNMD->HasRetBuffArg()); + pStub = TheVarargPInvokeStub(pNMD->HasRetBuffArg()); } if (pNMD->IsEarlyBound()) { - pNMD->InitEarlyBoundNDirectTarget(); + pNMD->InitEarlyBoundPInvokeTarget(); } else { - NDirectLink(pNMD); + PInvokeLink(pNMD); } // // NOTE: there is a race in updating this MethodDesc. We depend on all // threads getting back the same DynamicMethodDesc for a particular - // NDirectMethodDesc, in that case, the locking around the actual JIT + // PInvokeMethodDesc, in that case, the locking around the actual JIT // operation will prevent the code from being jitted more than once. // By the time we get here, all threads get the same address of code // back from the JIT operation and they all just fill in the same value @@ -5676,17 +5676,17 @@ PCODE GetStubForInteropMethod(MethodDesc* pMD, DWORD dwStubFlags) STANDARD_VM_CHECK; PRECONDITION(CheckPointer(pMD)); - PRECONDITION(pMD->IsNDirect() || pMD->IsCLRToCOMCall() || pMD->IsEEImpl() || pMD->IsIL()); + PRECONDITION(pMD->IsPInvoke() || pMD->IsCLRToCOMCall() || pMD->IsEEImpl() || pMD->IsIL()); } CONTRACT_END; PCODE pStub = (PCODE)NULL; MethodDesc* pStubMD = NULL; - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { - NDirectMethodDesc* pNMD = (NDirectMethodDesc*)pMD; - pStub = NDirect::GetStubForILStub(pNMD, &pStubMD, dwStubFlags); + PInvokeMethodDesc* pNMD = (PInvokeMethodDesc*)pMD; + pStub = PInvoke::GetStubForILStub(pNMD, &pStubMD, dwStubFlags); } #ifdef FEATURE_COMINTEROP else @@ -5706,7 +5706,7 @@ PCODE GetStubForInteropMethod(MethodDesc* pMD, DWORD dwStubFlags) if (pMD->IsIL()) { CONSISTENCY_CHECK(SF_IsReverseStub(dwStubFlags)); - pStub = NDirect::GetStubForILStub(pMD, &pStubMD, dwStubFlags); + pStub = PInvoke::GetStubForILStub(pMD, &pStubMD, dwStubFlags); } else { @@ -5727,7 +5727,7 @@ PCODE GetStubForInteropMethod(MethodDesc* pMD, DWORD dwStubFlags) #ifdef FEATURE_COMINTEROP void CreateCLRToDispatchCOMStub( MethodDesc * pMD, - DWORD dwStubFlags) // NDirectStubFlags + DWORD dwStubFlags) // PInvokeStubFlags { CONTRACTL { @@ -5755,7 +5755,7 @@ void CreateCLRToDispatchCOMStub( int numParamTokens = 0; mdParamDef* pParamTokenArray = NULL; - CreateNDirectStubAccessMetadata(&sigDesc, + CreatePInvokeStubAccessMetadata(&sigDesc, CallConv::GetDefaultUnmanagedCallingConvention(), &dwStubFlags, &iLCIDArg, @@ -5767,7 +5767,7 @@ void CreateCLRToDispatchCOMStub( DispatchStubState MyStubState; - CreateNDirectStubWorker(&MyStubState, + CreatePInvokeStubWorker(&MyStubState, &sigDesc, (CorNativeLinkType)0, (CorNativeLinkFlags)0, @@ -5786,7 +5786,7 @@ void CreateCLRToDispatchCOMStub( #endif // FEATURE_COMINTEROP -VOID NDirectMethodDesc::SetNDirectTarget(LPVOID pTarget) +VOID PInvokeMethodDesc::SetPInvokeTarget(LPVOID pTarget) { CONTRACTL { @@ -5794,12 +5794,12 @@ VOID NDirectMethodDesc::SetNDirectTarget(LPVOID pTarget) GC_TRIGGERS; MODE_ANY; - PRECONDITION(IsNDirect()); + PRECONDITION(IsPInvoke()); PRECONDITION(pTarget != NULL); } CONTRACTL_END; - ndirect.m_pNDirectTarget = pTarget; + ndirect.m_pPInvokeTarget = pTarget; } void MarshalStructViaILStub(MethodDesc* pStubMD, void* pManagedData, void* pNativeData, StructMarshalStubs::MarshalOperation operation, void** ppCleanupWorkList /* = nullptr */) @@ -5839,14 +5839,14 @@ void MarshalStructViaILStubCode(PCODE pStubCode, void* pManagedData, void* pNati //========================================================================== -// This function is reached only via NDirectImportThunk. It's purpose +// This function is reached only via PInvokeImportThunk. It's purpose // is to ensure that the target DLL is fully loaded and ready to run. // // FUN FACTS: Though this function is actually entered in unmanaged mode, // it can reenter managed mode and throw a CLR exception if the DLL linking // fails. //========================================================================== -EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) +EXTERN_C LPVOID STDCALL PInvokeImportWorker(PInvokeMethodDesc* pMD) { LPVOID ret = NULL; @@ -5869,10 +5869,10 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) if (pMD->IsEarlyBound()) { // we need the MD to be populated in case we decide to build an intercept - // stub to wrap the target in InitEarlyBoundNDirectTarget - NDirect::PopulateNDirectMethodDesc(pMD); + // stub to wrap the target in InitEarlyBoundPInvokeTarget + PInvoke::PopulatePInvokeMethodDesc(pMD); - pMD->InitEarlyBoundNDirectTarget(); + pMD->InitEarlyBoundPInvokeTarget(); } else { @@ -5884,19 +5884,19 @@ EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc* pMD) _ASSERTE((pThread->GetFrame() != FRAME_TOP && pThread->GetFrame()->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame) || pMD->ShouldSuppressGCTransition()); - CONSISTENCY_CHECK(pMD->IsNDirect()); + CONSISTENCY_CHECK(pMD->IsPInvoke()); // // With IL stubs, we don't have to do anything but ensure the DLL is loaded. // - NDirect::PopulateNDirectMethodDesc(pMD); + PInvoke::PopulatePInvokeMethodDesc(pMD); pMD->CheckRestore(); - NDirectLink(pMD); + PInvokeLink(pMD); } } - ret = pMD->GetNDirectTarget(); + ret = pMD->GetPInvokeTarget(); UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; @@ -6042,7 +6042,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) } else { - _ASSERTE(pMD->IsNDirect()); + _ASSERTE(pMD->IsPInvoke()); dwStubFlags |= NDIRECTSTUB_FL_CONVSIGASVARARG; // vararg P/Invoke must be cdecl @@ -6075,7 +6075,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) StubSigDesc sigDesc(pMD, signature, pVASigCookie->pModule, pVASigCookie->pLoaderModule); sigDesc.InitTypeContext(pVASigCookie->classInst, pVASigCookie->methodInst); - MethodDesc* pStubMD = NDirect::CreateCLRToNativeILStub(&sigDesc, + MethodDesc* pStubMD = PInvoke::CreateCLRToNativeILStub(&sigDesc, nlType, nlFlags, unmgdCallConv, @@ -6083,14 +6083,14 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) pTempILStub = JitILStub(pStubMD); - InterlockedCompareExchangeT(&pVASigCookie->pNDirectILStub, + InterlockedCompareExchangeT(&pVASigCookie->pPInvokeILStub, pTempILStub, (PCODE)NULL); UNINSTALL_UNWIND_AND_CONTINUE_HANDLER; UNINSTALL_MANAGED_EXCEPTION_DISPATCHER; - RETURN pVASigCookie->pNDirectILStub; + RETURN pVASigCookie->pPInvokeILStub; } namespace diff --git a/src/coreclr/vm/dllimport.h b/src/coreclr/vm/dllimport.h index b53222626757c8..9dcff16d7f6e3e 100644 --- a/src/coreclr/vm/dllimport.h +++ b/src/coreclr/vm/dllimport.h @@ -70,9 +70,9 @@ struct StubSigDesc }; //======================================================================= -// Collects code and data pertaining to the NDirect interface. +// Collects code and data pertaining to the PInvoke interface. //======================================================================= -class NDirect +class PInvoke { public: // Get the calling convention and whether to suppress GC transition for a method by checking: @@ -95,7 +95,7 @@ class NDirect static HRESULT HasNAT_LAttribute(IMDInternalImport *pInternalImport, mdToken token, DWORD dwMemberAttrs); // Either MD or signature & module must be given. - // Note: This method can be called at a time when the associated NDirectMethodDesc + // Note: This method can be called at a time when the associated PInvokeMethodDesc // has not been fully populated. This means the optimized path for this call is to rely // on the most basic P/Invoke metadata. An example when this can happen is when the JIT // is compiling a method containing a P/Invoke that is being considered for inlining. @@ -106,15 +106,15 @@ class NDirect _In_opt_ SigTypeContext* pTypeContext = NULL, _In_ bool unmanagedCallersOnlyRequiresMarshalling = true); - static void PopulateNDirectMethodDesc(_Inout_ NDirectMethodDesc* pNMD); - static void InitializeSigInfoAndPopulateNDirectMethodDesc(_Inout_ NDirectMethodDesc* pNMD, _Inout_ PInvokeStaticSigInfo* pSigInfo); + static void PopulatePInvokeMethodDesc(_Inout_ PInvokeMethodDesc* pNMD); + static void InitializeSigInfoAndPopulatePInvokeMethodDesc(_Inout_ PInvokeMethodDesc* pNMD, _Inout_ PInvokeStaticSigInfo* pSigInfo); static MethodDesc* CreateCLRToNativeILStub( StubSigDesc* pSigDesc, CorNativeLinkType nlType, CorNativeLinkFlags nlFlags, CorInfoCallConvExtension unmgdCallConv, - DWORD dwStubFlags); // NDirectStubFlags + DWORD dwStubFlags); // PInvokeStubFlags #ifdef FEATURE_COMINTEROP static MethodDesc* CreateFieldAccessILStub( @@ -122,7 +122,7 @@ class NDirect DWORD cbMetaSigSize, Module* pModule, mdFieldDef fd, - DWORD dwStubFlags, // NDirectStubFlags + DWORD dwStubFlags, // PInvokeStubFlags FieldDesc* pFD); #endif // FEATURE_COMINTEROP @@ -133,17 +133,17 @@ class NDirect DWORD dwStubFlags, MethodDesc* pMD); - static PCODE GetStubForILStub(NDirectMethodDesc* pNMD, MethodDesc** ppStubMD, DWORD dwStubFlags); + static PCODE GetStubForILStub(PInvokeMethodDesc* pNMD, MethodDesc** ppStubMD, DWORD dwStubFlags); static PCODE GetStubForILStub(MethodDesc* pMD, MethodDesc** ppStubMD, DWORD dwStubFlags); private: - NDirect() {LIMITED_METHOD_CONTRACT;}; // prevent "new"'s on this class + PInvoke() {LIMITED_METHOD_CONTRACT;}; // prevent "new"'s on this class }; //---------------------------------------------------------------- -// Flags passed to CreateNDirectStub that control stub generation +// Flags passed to CreatePInvokeStub that control stub generation //---------------------------------------------------------------- -enum NDirectStubFlags +enum PInvokeStubFlags { NDIRECTSTUB_FL_CONVSIGASVARARG = 0x00000001, NDIRECTSTUB_FL_BESTFIT = 0x00000002, @@ -174,7 +174,7 @@ enum NDirectStubFlags // unused = 0x00400000, // unused = 0x00800000, - // internal flags -- these won't ever show up in an NDirectStubHashBlob + // internal flags -- these won't ever show up in an PInvokeStubHashBlob NDIRECTSTUB_FL_FOR_NUMPARAMBYTES = 0x10000000, // do just enough to return the right value from Marshal.NumParamBytes #ifdef FEATURE_COMINTEROP @@ -328,7 +328,7 @@ enum ETW_IL_STUB_FLAGS // each flavor supports roughly the same switches. Those switches which can be // statically determined via CAs (DllImport, UnmanagedFunctionPointer, // BestFitMappingAttribute, etc) or via MetaSig are parsed and unified by this -// class. There are two flavors of constructor, one for NDirectMethodDescs and one +// class. There are two flavors of constructor, one for PInvokeMethodDescs and one // for Delegates. //--------------------------------------------------------- struct PInvokeStaticSigInfo @@ -461,10 +461,10 @@ struct PInvokeStaticSigInfo #include "stubgen.h" #ifndef DACCESS_COMPILE -class NDirectStubLinker : public ILStubLinker +class PInvokeStubLinker : public ILStubLinker { public: - NDirectStubLinker( + PInvokeStubLinker( DWORD dwStubFlags, Module* pModule, const Signature &signature, @@ -476,7 +476,7 @@ class NDirectStubLinker : public ILStubLinker void Begin(DWORD dwStubFlags); void End(DWORD dwStubFlags); - void DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, MethodDesc * pStubMD); + void DoPInvoke(ILCodeStream *pcsEmit, DWORD dwStubFlags, MethodDesc * pStubMD); void EmitLogNativeArgument(ILCodeStream* pslILEmit, DWORD dwPinnedLocal); void LoadCleanupWorkList(ILCodeStream* pcsEmit); #ifdef PROFILING_SUPPORTED diff --git a/src/coreclr/vm/dllimportcallback.cpp b/src/coreclr/vm/dllimportcallback.cpp index fb9d883f905dcd..6e845c2abb72b6 100644 --- a/src/coreclr/vm/dllimportcallback.cpp +++ b/src/coreclr/vm/dllimportcallback.cpp @@ -349,7 +349,7 @@ MethodDesc* UMThunkMarshInfo::GetILStubMethodDesc(MethodDesc* pInvokeMD, PInvoke } #endif // DEBUGGING_SUPPORTED - pStubMD = NDirect::CreateCLRToNativeILStub( + pStubMD = PInvoke::CreateCLRToNativeILStub( pSigInfo, dwStubFlags, pInvokeMD // may be NULL diff --git a/src/coreclr/vm/dllimportcallback.h b/src/coreclr/vm/dllimportcallback.h index 00737aba0ca7d8..5341c1420e4d61 100644 --- a/src/coreclr/vm/dllimportcallback.h +++ b/src/coreclr/vm/dllimportcallback.h @@ -142,7 +142,7 @@ class UMEntryThunk : private StubPrecode class UMEntryThunkData { friend class UMEntryThunkFreeList; - friend class NDirectStubLinker; + friend class PInvokeStubLinker; // The start of the managed code. // if m_pObjectHandle is non-NULL, this field is still set to help with diagnostic of call on collected delegate crashes diff --git a/src/coreclr/vm/exceptionhandling.cpp b/src/coreclr/vm/exceptionhandling.cpp index d450d953c92f6a..1babb39e008dfb 100644 --- a/src/coreclr/vm/exceptionhandling.cpp +++ b/src/coreclr/vm/exceptionhandling.cpp @@ -2985,7 +2985,7 @@ void MarkInlinedCallFrameAsFuncletCall(Frame* pFrame) { _ASSERTE(pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; - pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); + pInlinedCallFrame->m_Datum = (PTR_PInvokeMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper | (TADDR)InlinedCallFrameMarker::SecondPassFuncletCaller); } // Mark the pinvoke frame as invoking any exception handling helper @@ -2993,7 +2993,7 @@ void MarkInlinedCallFrameAsEHHelperCall(Frame* pFrame) { _ASSERTE(pFrame->GetFrameIdentifier() == FrameIdentifier::InlinedCallFrame); InlinedCallFrame* pInlinedCallFrame = (InlinedCallFrame*)pFrame; - pInlinedCallFrame->m_Datum = (PTR_NDirectMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); + pInlinedCallFrame->m_Datum = (PTR_PInvokeMethodDesc)((TADDR)pInlinedCallFrame->m_Datum | (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper); } static TADDR GetSpForDiagnosticReporting(REGDISPLAY *pRD) diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 072613619c5fc9..1e877f8034014c 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -2210,7 +2210,7 @@ class InlinedCallFrame : public Frame // - bit 1 set indicates invoking new exception handling helpers // - bit 2 indicates CallCatchFunclet or CallFinallyFunclet // See code:HasFunction. - PTR_NDirectMethodDesc m_Datum; + PTR_PInvokeMethodDesc m_Datum; // X86: ESP after pushing the outgoing arguments, and just before calling // out to unmanaged code. @@ -2227,7 +2227,7 @@ class InlinedCallFrame : public Frame // This is used only for EBP. Hence, a stackwalk will miss the other // callee-saved registers for the method with the InlinedCallFrame. // To prevent GC-holes, we do not keep any GC references in callee-saved - // registers across an NDirect call. + // registers across an PInvoke call. TADDR m_pCalleeSavedFP; // This field is used to cache the current thread object where this frame is diff --git a/src/coreclr/vm/i386/asmconstants.h b/src/coreclr/vm/i386/asmconstants.h index 82887f9ad9fa61..6f5321582c84dd 100644 --- a/src/coreclr/vm/i386/asmconstants.h +++ b/src/coreclr/vm/i386/asmconstants.h @@ -105,7 +105,7 @@ ASMCONSTANTS_C_ASSERT(EHContext_Eip == offsetof(EHContext,Eip)) #endif // FEATURE_EH_FUNCLETS #define VASigCookie__StubOffset 4 -ASMCONSTANTS_C_ASSERT(VASigCookie__StubOffset == offsetof(VASigCookie, pNDirectILStub)) +ASMCONSTANTS_C_ASSERT(VASigCookie__StubOffset == offsetof(VASigCookie, pPInvokeILStub)) #ifndef UNIX_X86_ABI #define SIZEOF_TailCallFrame 32 diff --git a/src/coreclr/vm/i386/asmhelpers.S b/src/coreclr/vm/i386/asmhelpers.S index b77d482fe2d670..1b112bcb478c89 100644 --- a/src/coreclr/vm/i386/asmhelpers.S +++ b/src/coreclr/vm/i386/asmhelpers.S @@ -299,7 +299,7 @@ NESTED_END OnHijackFPTripThread, _TEXT // ========================================================================== // This function is reached only via the embedded ImportThunkGlue code inside -// an NDirectMethodDesc. It's purpose is to load the DLL associated with an +// an PInvokeMethodDesc. It's purpose is to load the DLL associated with an // N/Direct method, then backpatch the DLL target into the methoddesc. // // Initial state: @@ -318,24 +318,24 @@ NESTED_END OnHijackFPTripThread, _TEXT // // // ========================================================================== -LEAF_ENTRY NDirectImportThunk, _TEXT +LEAF_ENTRY PInvokeImportThunk, _TEXT // Preserve argument registers push ecx push edx // Invoke the function that does the real work. push eax - call C_FUNC(NDirectImportWorker) + call C_FUNC(PInvokeImportWorker) // Restore argument registers pop edx pop ecx - // If we got back from NDirectImportWorker, the MD has been successfully + // If we got back from PInvokeImportWorker, the MD has been successfully // linked and "eax" contains the DLL target. Proceed to execute the // original DLL call. jmp eax // Jump to DLL target -LEAF_END NDirectImportThunk, _TEXT +LEAF_END PInvokeImportThunk, _TEXT // // Used to get the current instruction pointer value @@ -356,7 +356,7 @@ LEAF_END GetCurrentSP, _TEXT // ========================================================================== // Invoked for vararg forward P/Invoke calls as a stub. // Except for secret return buffer, arguments come on the stack so EDX is available as scratch. -// EAX - the NDirectMethodDesc +// EAX - the PInvokeMethodDesc // ECX - may be return buffer address // [ESP + 4] - the VASigCookie // diff --git a/src/coreclr/vm/i386/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index 77d5bd32439551..edc4bf4b038fe6 100644 --- a/src/coreclr/vm/i386/asmhelpers.asm +++ b/src/coreclr/vm/i386/asmhelpers.asm @@ -44,7 +44,7 @@ EXTERN _COMPlusFrameHandlerRevCom:PROC endif ; FEATURE_COMINTEROP endif ; FEATURE_EH_FUNCLETS EXTERN __alloca_probe:PROC -EXTERN _NDirectImportWorker@4:PROC +EXTERN _PInvokeImportWorker@4:PROC EXTERN _VarargPInvokeStubWorker@12:PROC EXTERN _GenericPInvokeCalliStubWorker@12:PROC @@ -618,7 +618,7 @@ endif ; FEATURE_HIJACK ;========================================================================== ; This function is reached only via the embedded ImportThunkGlue code inside -; an NDirectMethodDesc. It's purpose is to load the DLL associated with an +; an PInvokeMethodDesc. It's purpose is to load the DLL associated with an ; N/Direct method, then backpatch the DLL target into the methoddesc. ; ; Initial state: @@ -637,7 +637,7 @@ endif ; FEATURE_HIJACK ; ; ;========================================================================== -_NDirectImportThunk@0 proc public +_PInvokeImportThunk@0 proc public ; Preserve argument registers push ecx @@ -645,17 +645,17 @@ _NDirectImportThunk@0 proc public ; Invoke the function that does the real work. push eax - call _NDirectImportWorker@4 + call _PInvokeImportWorker@4 ; Restore argument registers pop edx pop ecx - ; If we got back from NDirectImportWorker, the MD has been successfully + ; If we got back from PInvokeImportWorker, the MD has been successfully ; linked and "eax" contains the DLL target. Proceed to execute the ; original DLL call. jmp eax ; Jump to DLL target -_NDirectImportThunk@0 endp +_PInvokeImportThunk@0 endp ; void __stdcall setFPReturn(int fpSize, INT64 retVal) _setFPReturn@12 proc public @@ -901,7 +901,7 @@ _ProfileTailcallNaked@4 endp ;========================================================================== ; Invoked for vararg forward P/Invoke calls as a stub. ; Except for secret return buffer, arguments come on the stack so EDX is available as scratch. -; EAX - the NDirectMethodDesc +; EAX - the PInvokeMethodDesc ; ECX - may be return buffer address ; [ESP + 4] - the VASigCookie ; diff --git a/src/coreclr/vm/i386/cgenx86.cpp b/src/coreclr/vm/i386/cgenx86.cpp index e242668963dcd9..394619c7f22054 100644 --- a/src/coreclr/vm/i386/cgenx86.cpp +++ b/src/coreclr/vm/i386/cgenx86.cpp @@ -381,11 +381,11 @@ void InlinedCallFrame::UpdateRegDisplay_Impl(const PREGDISPLAY pRD, bool updateF if (stackArgSize & ~0xFFFF) { - NDirectMethodDesc * pMD = PTR_NDirectMethodDesc(datum); + PInvokeMethodDesc * pMD = PTR_PInvokeMethodDesc(datum); - /* if this is not an NDirect frame, something is really wrong */ + /* if this is not an PInvoke frame, something is really wrong */ - _ASSERTE(pMD->SanityCheck() && pMD->IsNDirect()); + _ASSERTE(pMD->SanityCheck() && pMD->IsPInvoke()); stackArgSize = pMD->GetStackArgumentSize(); } diff --git a/src/coreclr/vm/ilmarshalers.cpp b/src/coreclr/vm/ilmarshalers.cpp index aa9b3d6531553a..82c434bd1a0e88 100644 --- a/src/coreclr/vm/ilmarshalers.cpp +++ b/src/coreclr/vm/ilmarshalers.cpp @@ -1093,7 +1093,7 @@ void ILValueClassMarshaler::EmitClearNative(ILCodeStream * pslILEmit) { STANDARD_VM_CONTRACT; - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedHomeAddr(pslILEmit); EmitLoadNativeHomeAddr(pslILEmit); @@ -1108,7 +1108,7 @@ void ILValueClassMarshaler::EmitConvertContentsCLRToNative(ILCodeStream* pslILEm { STANDARD_VM_CONTRACT; - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedHomeAddr(pslILEmit); EmitLoadNativeHomeAddr(pslILEmit); @@ -1122,7 +1122,7 @@ void ILValueClassMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* pslILEm { STANDARD_VM_CONTRACT; - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedHomeAddr(pslILEmit); EmitLoadNativeHomeAddr(pslILEmit); @@ -2313,7 +2313,7 @@ void ILLayoutClassPtrMarshaler::EmitConvertContentsCLRToNative(ILCodeStream* psl ILCodeLabel* isNotMatchingTypeLabel = pslILEmit->NewCodeLabel(); bool emittedTypeCheck = EmitExactTypeCheck(pslILEmit, isNotMatchingTypeLabel); - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2349,7 +2349,7 @@ void ILLayoutClassPtrMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* psl ILCodeLabel* isNotMatchingTypeLabel = pslILEmit->NewCodeLabel(); bool emittedTypeCheck = EmitExactTypeCheck(pslILEmit, isNotMatchingTypeLabel); - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2378,7 +2378,7 @@ void ILLayoutClassPtrMarshaler::EmitClearNativeContents(ILCodeStream * pslILEmit ILCodeLabel* cleanedUpLabel = pslILEmit->NewCodeLabel(); bool emittedTypeCheck = EmitExactTypeCheck(pslILEmit, isNotMatchingTypeLabel); - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2529,7 +2529,7 @@ void ILLayoutClassMarshaler::EmitConvertContentsCLRToNative(ILCodeStream* pslILE pslILEmit->EmitBRFALSE(pNullRefLabel); - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2553,7 +2553,7 @@ void ILLayoutClassMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* pslILE { STANDARD_VM_CONTRACT; - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2568,7 +2568,7 @@ void ILLayoutClassMarshaler::EmitClearNativeContents(ILCodeStream* pslILEmit) { STANDARD_VM_CONTRACT; - MethodDesc* pStructMarshalStub = NDirect::CreateStructMarshalILStub(m_pargs->m_pMT); + MethodDesc* pStructMarshalStub = PInvoke::CreateStructMarshalILStub(m_pargs->m_pMT); EmitLoadManagedValue(pslILEmit); pslILEmit->EmitCALL(METHOD__RUNTIME_HELPERS__GET_RAW_DATA, 1, 1); @@ -2629,7 +2629,7 @@ void ILBlittableLayoutClassMarshaler::EmitConvertContentsNativeToCLR(ILCodeStrea pslILEmit->EmitCPBLK(); } -MarshalerOverrideStatus ILHandleRefMarshaler::ArgumentOverride(NDirectStubLinker* psl, +MarshalerOverrideStatus ILHandleRefMarshaler::ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -2675,7 +2675,7 @@ MarshalerOverrideStatus ILHandleRefMarshaler::ArgumentOverride(NDirectStubLinker } } -MarshalerOverrideStatus ILHandleRefMarshaler::ReturnOverride(NDirectStubLinker* psl, +MarshalerOverrideStatus ILHandleRefMarshaler::ReturnOverride(PInvokeStubLinker* psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs* pargs, @@ -2721,7 +2721,7 @@ void ILSafeHandleMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* pslILEm pslILEmit->EmitLabel(successLabel); } -MarshalerOverrideStatus ILSafeHandleMarshaler::ArgumentOverride(NDirectStubLinker* psl, +MarshalerOverrideStatus ILSafeHandleMarshaler::ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -2854,7 +2854,7 @@ MarshalerOverrideStatus ILSafeHandleMarshaler::ArgumentOverride(NDirectStubLinke if (fout) { // We will use cleanup stream to avoid leaking the handle on thread abort. - psl->EmitSetArgMarshalIndex(pslIL, NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx); + psl->EmitSetArgMarshalIndex(pslIL, PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx); psl->SetCleanupNeeded(); ILCodeStream *pslCleanupIL = psl->GetCleanupCodeStream(); @@ -2862,8 +2862,8 @@ MarshalerOverrideStatus ILSafeHandleMarshaler::ArgumentOverride(NDirectStubLinke ILCodeLabel *pDoneLabel = pslCleanupIL->NewCodeLabel(); psl->EmitCheckForArgCleanup(pslCleanupIL, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx, - NDirectStubLinker::BranchIfNotMarshaled, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx, + PInvokeStubLinker::BranchIfNotMarshaled, pDoneLabel); // If this is an [in, out] handle check if the native handles have changed. If not we're finished. @@ -2931,7 +2931,7 @@ MarshalerOverrideStatus ILSafeHandleMarshaler::ArgumentOverride(NDirectStubLinke // MarshalerOverrideStatus ILSafeHandleMarshaler::ReturnOverride( - NDirectStubLinker * psl, + PInvokeStubLinker * psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs * pargs, @@ -3013,15 +3013,15 @@ ILSafeHandleMarshaler::ReturnOverride( EmitLoadNativeLocalAddrForByRefDispatch(pslILDispatch, dwReturnNativeHandleLocal); // We will use cleanup stream to avoid leaking the handle on thread abort. - psl->EmitSetArgMarshalIndex(pslIL, NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); + psl->EmitSetArgMarshalIndex(pslIL, PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); psl->SetCleanupNeeded(); ILCodeStream *pslCleanupIL = psl->GetCleanupCodeStream(); ILCodeLabel *pDoneLabel = pslCleanupIL->NewCodeLabel(); psl->EmitCheckForArgCleanup(pslCleanupIL, - NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL, - NDirectStubLinker::BranchIfNotMarshaled, + PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL, + PInvokeStubLinker::BranchIfNotMarshaled, pDoneLabel); // 6) store return value in safehandle @@ -3078,7 +3078,7 @@ void ILCriticalHandleMarshaler::EmitConvertContentsNativeToCLR(ILCodeStream* psl //--------------------------------------------------------------------------------------- // -MarshalerOverrideStatus ILCriticalHandleMarshaler::ArgumentOverride(NDirectStubLinker* psl, +MarshalerOverrideStatus ILCriticalHandleMarshaler::ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -3207,7 +3207,7 @@ MarshalerOverrideStatus ILCriticalHandleMarshaler::ArgumentOverride(NDirectStubL if (fout) { // We will use cleanup stream to avoid leaking the handle on thread abort. - psl->EmitSetArgMarshalIndex(pslIL, NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx); + psl->EmitSetArgMarshalIndex(pslIL, PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx); psl->SetCleanupNeeded(); ILCodeStream *pslCleanupIL = psl->GetCleanupCodeStream(); @@ -3215,8 +3215,8 @@ MarshalerOverrideStatus ILCriticalHandleMarshaler::ArgumentOverride(NDirectStubL ILCodeLabel *pDoneLabel = pslCleanupIL->NewCodeLabel(); psl->EmitCheckForArgCleanup(pslCleanupIL, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx, - NDirectStubLinker::BranchIfNotMarshaled, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + argidx, + PInvokeStubLinker::BranchIfNotMarshaled, pDoneLabel); // If this is an [in, out] handle check if the native handles have changed. If not we're finished. @@ -3264,7 +3264,7 @@ MarshalerOverrideStatus ILCriticalHandleMarshaler::ArgumentOverride(NDirectStubL // MarshalerOverrideStatus ILCriticalHandleMarshaler::ReturnOverride( - NDirectStubLinker * psl, + PInvokeStubLinker * psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs * pargs, @@ -3347,7 +3347,7 @@ ILCriticalHandleMarshaler::ReturnOverride( EmitLoadNativeLocalAddrForByRefDispatch(pslILDispatch, dwReturnNativeHandleLocal); // We will use cleanup stream to avoid leaking the handle on thread abort. - psl->EmitSetArgMarshalIndex(pslIL, NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); + psl->EmitSetArgMarshalIndex(pslIL, PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); psl->SetCleanupNeeded(); ILCodeStream *pslCleanupIL = psl->GetCleanupCodeStream(); @@ -3355,8 +3355,8 @@ ILCriticalHandleMarshaler::ReturnOverride( // 6) store return value in criticalhandle psl->EmitCheckForArgCleanup(pslCleanupIL, - NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL, - NDirectStubLinker::BranchIfNotMarshaled, + PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL, + PInvokeStubLinker::BranchIfNotMarshaled, pDoneLabel); pslCleanupIL->EmitLDLOC(dwReturnHandleLocal); @@ -3384,7 +3384,7 @@ ILCriticalHandleMarshaler::ReturnOverride( } // ILCriticalHandleMarshaler::ReturnOverride #if defined(FEATURE_IJW) -MarshalerOverrideStatus ILBlittableValueClassWithCopyCtorMarshaler::ArgumentOverride(NDirectStubLinker* psl, +MarshalerOverrideStatus ILBlittableValueClassWithCopyCtorMarshaler::ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -3894,7 +3894,7 @@ void ILNativeArrayMarshaler::EmitCreateMngdMarshaler(ILCodeStream* pslILEmit) if (mops.elementType == VT_RECORD && !mops.methodTable->IsBlittable()) { - pslILEmit->EmitLDFTN(pslILEmit->GetToken(NDirect::CreateStructMarshalILStub(mops.methodTable))); + pslILEmit->EmitLDFTN(pslILEmit->GetToken(PInvoke::CreateStructMarshalILStub(mops.methodTable))); } else { @@ -4464,7 +4464,7 @@ void ILFixedArrayMarshaler::EmitCreateMngdMarshaler(ILCodeStream* pslILEmit) if (mops.elementType == VT_RECORD && !mops.methodTable->IsBlittable()) { - pslILEmit->EmitLDFTN(pslILEmit->GetToken(NDirect::CreateStructMarshalILStub(mops.methodTable))); + pslILEmit->EmitLDFTN(pslILEmit->GetToken(PInvoke::CreateStructMarshalILStub(mops.methodTable))); } else { @@ -4662,7 +4662,7 @@ void ILSafeArrayMarshaler::EmitCreateMngdMarshaler(ILCodeStream* pslILEmit) if (mops.elementType == VT_RECORD && !mops.methodTable->IsBlittable()) { - pslILEmit->EmitLDFTN(pslILEmit->GetToken(NDirect::CreateStructMarshalILStub(mops.methodTable))); + pslILEmit->EmitLDFTN(pslILEmit->GetToken(PInvoke::CreateStructMarshalILStub(mops.methodTable))); } else { diff --git a/src/coreclr/vm/ilmarshalers.h b/src/coreclr/vm/ilmarshalers.h index 7f5dad6bb2276d..08e01d3463bab6 100644 --- a/src/coreclr/vm/ilmarshalers.h +++ b/src/coreclr/vm/ilmarshalers.h @@ -273,7 +273,7 @@ class ILMarshaler DWORD m_dwMngdMarshalerLocalNum; private: - NDirectStubLinker* m_pslNDirect; + PInvokeStubLinker* m_pslPInvoke; ILCodeStream* m_pcsMarshal; ILCodeStream* m_pcsUnmarshal; ILStubMarshalHome m_nativeHome; @@ -282,7 +282,7 @@ class ILMarshaler public: ILMarshaler() : - m_pslNDirect(NULL) + m_pslPInvoke(NULL) { } @@ -291,11 +291,11 @@ class ILMarshaler LIMITED_METHOD_CONTRACT; } - void SetNDirectStubLinker(NDirectStubLinker* pslNDirect) + void SetPInvokeStubLinker(PInvokeStubLinker* pslPInvoke) { LIMITED_METHOD_CONTRACT; - CONSISTENCY_CHECK(NULL == m_pslNDirect); - m_pslNDirect = pslNDirect; + CONSISTENCY_CHECK(NULL == m_pslPInvoke); + m_pslPInvoke = pslPInvoke; } private: @@ -306,7 +306,7 @@ class ILMarshaler OverrideProcArgs* pargs) { LIMITED_METHOD_CONTRACT; - CONSISTENCY_CHECK_MSG(m_pslNDirect != NULL, "please call SetNDirectStubLinker() before EmitMarshalArgument or EmitMarshalReturnValue"); + CONSISTENCY_CHECK_MSG(m_pslPInvoke != NULL, "please call SetPInvokeStubLinker() before EmitMarshalArgument or EmitMarshalReturnValue"); m_pcsMarshal = pcsMarshal; m_pcsUnmarshal = pcsUnmarshal; m_pargs = pargs; @@ -431,7 +431,7 @@ class ILMarshaler WRAPPER_NO_CONTRACT; if (g_pConfig->InteropLogArguments()) { - m_pslNDirect->EmitLogNativeArgument(pslILEmit, dwPinnedLocal); + m_pslPInvoke->EmitLogNativeArgument(pslILEmit, dwPinnedLocal); } } @@ -484,12 +484,12 @@ class ILMarshaler // we set the clr-to-native flag so the marshal phase is CLR->Native and the unmarshal phase is Native->CLR Init(pcsMarshal, pcsUnmarshal, argidx, MARSHAL_FLAG_IN | MARSHAL_FLAG_OUT | MARSHAL_FLAG_CLR_TO_NATIVE | MARSHAL_FLAG_FIELD, pargs); - EmitCreateMngdMarshaler(m_pslNDirect->GetSetupCodeStream()); + EmitCreateMngdMarshaler(m_pslPInvoke->GetSetupCodeStream()); - EmitSetupArgumentForMarshalling(m_pslNDirect->GetSetupCodeStream()); + EmitSetupArgumentForMarshalling(m_pslPInvoke->GetSetupCodeStream()); EmitSetupDefaultHomesForField( - m_pslNDirect->GetSetupCodeStream(), + m_pslPInvoke->GetSetupCodeStream(), managedOffset, nativeOffset); @@ -519,10 +519,10 @@ class ILMarshaler // we know that we don't need a managed marshaler since we will just pin. if (!CanMarshalViaPinning()) { - EmitCreateMngdMarshaler(m_pslNDirect->GetSetupCodeStream()); + EmitCreateMngdMarshaler(m_pslPInvoke->GetSetupCodeStream()); } - EmitSetupArgumentForMarshalling(m_pslNDirect->GetSetupCodeStream()); + EmitSetupArgumentForMarshalling(m_pslPInvoke->GetSetupCodeStream()); if (IsCLRToNative(dwMarshalFlags)) { @@ -627,7 +627,7 @@ class ILMarshaler if (NeedsMarshalCleanupIndex()) { - m_pslNDirect->EmitSetArgMarshalIndex(m_pcsUnmarshal, NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx); + m_pslPInvoke->EmitSetArgMarshalIndex(m_pcsUnmarshal, PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx); } EmitConvertSpaceAndContentsNativeToCLR(m_pcsUnmarshal); @@ -642,7 +642,7 @@ class ILMarshaler if (NeedsMarshalCleanupIndex()) { - m_pslNDirect->EmitSetArgMarshalIndex(m_pcsUnmarshal, NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx); + m_pslPInvoke->EmitSetArgMarshalIndex(m_pcsUnmarshal, PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx); } if (IsHresultSwap(dwMarshalFlags)) @@ -665,7 +665,7 @@ class ILMarshaler if (NeedsUnmarshalCleanupIndex()) { // if an exception is thrown after this point, we will clean up the unmarshaled retval - m_pslNDirect->EmitSetArgMarshalIndex(m_pcsUnmarshal, NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); + m_pslPInvoke->EmitSetArgMarshalIndex(m_pcsUnmarshal, PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL); } EmitCleanupNativeToCLR(); @@ -723,12 +723,12 @@ class ILMarshaler void EmitLoadCleanupWorkList(ILCodeStream* pslILEmit) { - m_pslNDirect->LoadCleanupWorkList(pslILEmit); + m_pslPInvoke->LoadCleanupWorkList(pslILEmit); } int GetLCIDParamIndex() { - return m_pslNDirect->GetLCIDParamIdx(); + return m_pslPInvoke->GetLCIDParamIdx(); } void EmitSetupSigAndDefaultHomesCLRToNative() @@ -756,12 +756,12 @@ class ILMarshaler { CONSISTENCY_CHECK(NeedsMarshalCleanupIndex()); - ILCodeStream* pcsCleanup = m_pslNDirect->GetCleanupCodeStream(); + ILCodeStream* pcsCleanup = m_pslPInvoke->GetCleanupCodeStream(); ILCodeLabel* pSkipClearNativeLabel = pcsCleanup->NewCodeLabel(); - m_pslNDirect->EmitCheckForArgCleanup(pcsCleanup, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, - NDirectStubLinker::BranchIfNotMarshaled, + m_pslPInvoke->EmitCheckForArgCleanup(pcsCleanup, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, + PInvokeStubLinker::BranchIfNotMarshaled, pSkipClearNativeLabel); EmitClearNativeTemp(pcsCleanup); @@ -777,12 +777,12 @@ class ILMarshaler { CONSISTENCY_CHECK(NeedsMarshalCleanupIndex()); - ILCodeStream* pcsCleanup = m_pslNDirect->GetCleanupCodeStream(); + ILCodeStream* pcsCleanup = m_pslPInvoke->GetCleanupCodeStream(); ILCodeLabel* pSkipClearNativeLabel = pcsCleanup->NewCodeLabel(); - m_pslNDirect->EmitCheckForArgCleanup(pcsCleanup, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, - NDirectStubLinker::BranchIfNotMarshaled, + m_pslPInvoke->EmitCheckForArgCleanup(pcsCleanup, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, + PInvokeStubLinker::BranchIfNotMarshaled, pSkipClearNativeLabel); EmitClearNative(pcsCleanup); @@ -1021,7 +1021,7 @@ class ILMarshaler EmitConvertSpaceAndContentsNativeToCLR(m_pcsUnmarshal); if (NeedsClearNative()) { - ILCodeStream* pcsCleanup = m_pslNDirect->GetCleanupCodeStream(); + ILCodeStream* pcsCleanup = m_pslPInvoke->GetCleanupCodeStream(); EmitClearNative(pcsCleanup); } } @@ -1034,12 +1034,12 @@ class ILMarshaler { CONSISTENCY_CHECK(NeedsMarshalCleanupIndex()); - ILCodeStream* pcsCleanup = m_pslNDirect->GetCleanupCodeStream(); + ILCodeStream* pcsCleanup = m_pslPInvoke->GetCleanupCodeStream(); ILCodeLabel* pSkipClearCLRLabel = pcsCleanup->NewCodeLabel(); - m_pslNDirect->EmitCheckForArgCleanup(pcsCleanup, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, - NDirectStubLinker::BranchIfNotMarshaled, + m_pslPInvoke->EmitCheckForArgCleanup(pcsCleanup, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, + PInvokeStubLinker::BranchIfNotMarshaled, pSkipClearCLRLabel); EmitClearCLR(pcsCleanup); @@ -1071,11 +1071,11 @@ class ILMarshaler _ASSERTE(IsRetval(m_dwMarshalFlags) || IsOut(m_dwMarshalFlags)); LocalDesc nativeType = GetNativeType(); - ILCodeStream *pcsCleanup = m_pslNDirect->GetExceptionCleanupCodeStream(); + ILCodeStream *pcsCleanup = m_pslPInvoke->GetExceptionCleanupCodeStream(); if (NeedsClearNative()) { - m_pslNDirect->SetExceptionCleanupNeeded(); + m_pslPInvoke->SetExceptionCleanupNeeded(); ILCodeLabel *pSkipCleanupLabel = pcsCleanup->NewCodeLabel(); @@ -1086,9 +1086,9 @@ class ILMarshaler ILCodeLabel *pSkipCopyLabel = pcsCleanup->NewCodeLabel(); CONSISTENCY_CHECK(NeedsMarshalCleanupIndex()); - m_pslNDirect->EmitCheckForArgCleanup(pcsCleanup, - NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, - NDirectStubLinker::BranchIfMarshaled, + m_pslPInvoke->EmitCheckForArgCleanup(pcsCleanup, + PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_argidx, + PInvokeStubLinker::BranchIfMarshaled, pSkipCopyLabel); pcsCleanup->EmitLDARG(m_argidx); @@ -1105,12 +1105,12 @@ class ILMarshaler CONSISTENCY_CHECK(NeedsUnmarshalCleanupIndex()); UINT uArgIdx = (IsRetval(m_dwMarshalFlags) ? - NDirectStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL : - NDirectStubLinker::CLEANUP_INDEX_ARG0_UNMARSHAL + m_argidx); + PInvokeStubLinker::CLEANUP_INDEX_RETVAL_UNMARSHAL : + PInvokeStubLinker::CLEANUP_INDEX_ARG0_UNMARSHAL + m_argidx); - m_pslNDirect->EmitCheckForArgCleanup(pcsCleanup, + m_pslPInvoke->EmitCheckForArgCleanup(pcsCleanup, uArgIdx, - NDirectStubLinker::BranchIfNotMarshaled, + PInvokeStubLinker::BranchIfNotMarshaled, pSkipCleanupLabel); } @@ -1132,7 +1132,7 @@ class ILMarshaler // if there is an output buffer, zero it out so the caller does not get pointer to already freed data if (IsRetval(m_dwMarshalFlags) || (IsOut(m_dwMarshalFlags) && IsByref(m_dwMarshalFlags))) { - m_pslNDirect->SetExceptionCleanupNeeded(); + m_pslPInvoke->SetExceptionCleanupNeeded(); EmitReInitNative(pcsCleanup); if (IsHresultSwap(m_dwMarshalFlags) || IsOut(m_dwMarshalFlags)) @@ -1458,9 +1458,9 @@ class ILMarshaler void EmitKeepAliveManagedValue() { // Don't use the cleanup work list to avoid any extra allocations. - m_pslNDirect->SetCleanupNeeded(); + m_pslPInvoke->SetCleanupNeeded(); - ILCodeStream* pslILEmit = m_pslNDirect->GetCleanupCodeStream(); + ILCodeStream* pslILEmit = m_pslPInvoke->GetCleanupCodeStream(); ILCodeLabel* pNoManagedValueLabel = nullptr; if (IsFieldMarshal(m_dwMarshalFlags)) @@ -1483,7 +1483,7 @@ class ILMarshaler // Extension point to allow a marshaler to conditionally override all of the ILMarshaler logic with its own or block marshalling when marshalling an argument. // See MarshalInfo::GetArgumentOverrideProc for the implementation. - static MarshalerOverrideStatus ArgumentOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -1498,7 +1498,7 @@ class ILMarshaler // Extension point to allow a marshaler to conditionally override all of the ILMarshaler logic with its own or block marshalling when marshalling a return value. // See MarshalInfo::GetReturnOverrideProc for the implementation. - static MarshalerOverrideStatus ReturnOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ReturnOverride(PInvokeStubLinker* psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs* pargs, @@ -2199,7 +2199,7 @@ class ILHandleRefMarshaler : public ILMarshaler return false; } - static MarshalerOverrideStatus ArgumentOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -2208,7 +2208,7 @@ class ILHandleRefMarshaler : public ILMarshaler UINT* pResID, UINT argidx); - static MarshalerOverrideStatus ReturnOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ReturnOverride(PInvokeStubLinker* psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs* pargs, @@ -2239,7 +2239,7 @@ class ILSafeHandleMarshaler : public ILMarshaler void EmitConvertContentsCLRToNative(ILCodeStream* pslILEmit) override; void EmitConvertContentsNativeToCLR(ILCodeStream* pslILEmit) override; - static MarshalerOverrideStatus ArgumentOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -2248,7 +2248,7 @@ class ILSafeHandleMarshaler : public ILMarshaler UINT* pResID, UINT argidx); - static MarshalerOverrideStatus ReturnOverride(NDirectStubLinker *psl, + static MarshalerOverrideStatus ReturnOverride(PInvokeStubLinker *psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs *pargs, @@ -2282,7 +2282,7 @@ class ILCriticalHandleMarshaler : public ILMarshaler void EmitConvertContentsCLRToNative(ILCodeStream* pslILEmit) override; void EmitConvertContentsNativeToCLR(ILCodeStream* pslILEmit) override; - static MarshalerOverrideStatus ArgumentOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -2291,7 +2291,7 @@ class ILCriticalHandleMarshaler : public ILMarshaler UINT* pResID, UINT argidx); - static MarshalerOverrideStatus ReturnOverride(NDirectStubLinker *psl, + static MarshalerOverrideStatus ReturnOverride(PInvokeStubLinker *psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs *pargs, @@ -2941,7 +2941,7 @@ class ILBlittableValueClassWithCopyCtorMarshaler : public ILMarshaler return LocalDesc(); } - static MarshalerOverrideStatus ArgumentOverride(NDirectStubLinker* psl, + static MarshalerOverrideStatus ArgumentOverride(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, diff --git a/src/coreclr/vm/ilstubcache.h b/src/coreclr/vm/ilstubcache.h index c53fd7a1878c28..eb2b22952754df 100644 --- a/src/coreclr/vm/ilstubcache.h +++ b/src/coreclr/vm/ilstubcache.h @@ -51,7 +51,7 @@ class ILStubCache final MethodDesc* GetStubMethodDesc( MethodDesc *pTargetMD, ILStubHashBlob* pHashBlob, - DWORD dwStubFlags, // bitmask of NDirectStubFlags + DWORD dwStubFlags, // bitmask of PInvokeStubFlags Module* pSigModule, Module* pSigLoaderModule, PCCOR_SIGNATURE pSig, @@ -68,7 +68,7 @@ class ILStubCache final static MethodDesc* CreateAndLinkNewILStubMethodDesc( LoaderAllocator* pAllocator, MethodTable* pMT, - DWORD dwStubFlags, // bitmask of NDirectStubFlags + DWORD dwStubFlags, // bitmask of PInvokeStubFlags Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, @@ -93,7 +93,7 @@ class ILStubCache final static MethodDesc* CreateNewMethodDesc( LoaderHeap* pCreationHeap, MethodTable* pMT, - DWORD dwStubFlags, // bitmask of NDirectStubFlags + DWORD dwStubFlags, // bitmask of PInvokeStubFlags Module* pSigModule, PCCOR_SIGNATURE pSig, DWORD cbSig, diff --git a/src/coreclr/vm/interoplibinterface.h b/src/coreclr/vm/interoplibinterface.h index aeffe64d41a4fe..4ab07ddf5979a8 100644 --- a/src/coreclr/vm/interoplibinterface.h +++ b/src/coreclr/vm/interoplibinterface.h @@ -97,7 +97,7 @@ class Interop { public: // Check if pending exceptions are possible for the following native export. - static bool ShouldCheckForPendingException(_In_ NDirectMethodDesc* md); + static bool ShouldCheckForPendingException(_In_ PInvokeMethodDesc* md); // A no return callback that is designed to help propagate a managed // exception going from Managed to Native. diff --git a/src/coreclr/vm/interoplibinterface_shared.cpp b/src/coreclr/vm/interoplibinterface_shared.cpp index 2fc5d604ba394c..5cd3378ff66b72 100644 --- a/src/coreclr/vm/interoplibinterface_shared.cpp +++ b/src/coreclr/vm/interoplibinterface_shared.cpp @@ -9,7 +9,7 @@ using ManagedToNativeExceptionCallback = Interop::ManagedToNativeExceptionCallback; -bool Interop::ShouldCheckForPendingException(_In_ NDirectMethodDesc* md) +bool Interop::ShouldCheckForPendingException(_In_ PInvokeMethodDesc* md) { CONTRACTL { diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index c682ef981649c0..0136b9a90465d8 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -6501,7 +6501,7 @@ DWORD CEEInfo::getMethodAttribsInternal (CORINFO_METHOD_HANDLE ftn) result |= CORINFO_FLG_SHAREDINST; } - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { result |= CORINFO_FLG_PINVOKE; } @@ -9879,11 +9879,11 @@ namespace if (methodCallConv == CORINFO_CALLCONV_DEFAULT || methodCallConv == CORINFO_CALLCONV_VARARG) { - _ASSERTE(pMD->IsNDirect() || pMD->HasUnmanagedCallersOnlyAttribute()); - if (pMD->IsNDirect()) + _ASSERTE(pMD->IsPInvoke() || pMD->HasUnmanagedCallersOnlyAttribute()); + if (pMD->IsPInvoke()) { CorInfoCallConvExtension unmanagedCallConv; - NDirect::GetCallingConvention_IgnoreErrors(pMD, &unmanagedCallConv, pSuppressGCTransition); + PInvoke::GetCallingConvention_IgnoreErrors(pMD, &unmanagedCallConv, pSuppressGCTransition); return unmanagedCallConv; } else @@ -9963,7 +9963,7 @@ bool CEEInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SI // check the call site signature SigTypeContext typeContext; GetTypeContext(&callSiteSig->sigInst, &typeContext); - result = NDirect::MarshalingRequired( + result = PInvoke::MarshalingRequired( NULL, SigPointer{ callSiteSig->pSig, callSiteSig->cbSig }, GetModule(callSiteSig->scope), @@ -9972,13 +9972,13 @@ bool CEEInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SI else { MethodDesc* ftn = GetMethod(method); - _ASSERTE(ftn->IsNDirect()); - NDirectMethodDesc *pMD = (NDirectMethodDesc*)ftn; + _ASSERTE(ftn->IsPInvoke()); + PInvokeMethodDesc *pMD = (PInvokeMethodDesc*)ftn; #if defined(HAS_NDIRECT_IMPORT_PRECODE) if (pMD->IsVarArg()) { - // Varag P/Invoke must not be inlined because its NDirectMethodDesc + // Varag P/Invoke must not be inlined because its PInvokeMethodDesc // does not contain a meaningful stack size (it is call site specific). // See code:InlinedCallFrame.UpdateRegDisplay where this is needed. result = TRUE; @@ -9995,7 +9995,7 @@ bool CEEInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SI } #else // Marshalling is required to lazy initialize the indirection cell - // without NDirectImportPrecode. + // without PInvokeImportPrecode. result = TRUE; #endif } @@ -10076,12 +10076,12 @@ void CEEInfo::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, JIT_TO_EE_TRANSITION(); MethodDesc* pMD = GetMethod(method); - _ASSERTE(pMD->IsNDirect()); + _ASSERTE(pMD->IsPInvoke()); - NDirectMethodDesc* pNMD = reinterpret_cast(pMD); + PInvokeMethodDesc* pNMD = reinterpret_cast(pMD); void* pIndirection; - if (NDirectMethodDesc::TryGetResolvedNDirectTarget(pNMD, &pIndirection)) + if (PInvokeMethodDesc::TryGetResolvedPInvokeTarget(pNMD, &pIndirection)) { pLookup->accessType = IAT_VALUE; pLookup->addr = pIndirection; @@ -10089,7 +10089,7 @@ void CEEInfo::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, else { pLookup->accessType = IAT_PVALUE; - pLookup->addr = (LPVOID)&(pNMD->ndirect.m_pNDirectTarget); + pLookup->addr = (LPVOID)&(pNMD->ndirect.m_pPInvokeTarget); } EE_TO_JIT_TRANSITION(); @@ -13675,7 +13675,7 @@ bool IsInstructionSetSupported(CORJIT_FLAGS jitFlags, ReadyToRunInstructionSet r BOOL LoadDynamicInfoEntry(Module *currentModule, RVA fixupRva, SIZE_T *entry, - BOOL mayUsePrecompiledNDirectMethods) + BOOL mayUsePrecompiledPInvokeMethods) { STANDARD_VM_CONTRACT; @@ -13813,20 +13813,20 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, { MethodDesc *pMethod = ZapSig::DecodeMethod(currentModule, pInfoModule, pBlob); - _ASSERTE(pMethod->IsNDirect()); - NDirectMethodDesc *pMD = (NDirectMethodDesc*)pMethod; - result = (size_t)(LPVOID)&(pMD->ndirect.m_pNDirectTarget); + _ASSERTE(pMethod->IsPInvoke()); + PInvokeMethodDesc *pMD = (PInvokeMethodDesc*)pMethod; + result = (size_t)(LPVOID)&(pMD->ndirect.m_pPInvokeTarget); } break; case READYTORUN_FIXUP_PInvokeTarget: { - if (mayUsePrecompiledNDirectMethods) + if (mayUsePrecompiledPInvokeMethods) { MethodDesc *pMethod = ZapSig::DecodeMethod(currentModule, pInfoModule, pBlob); - _ASSERTE(pMethod->IsNDirect()); - result = (size_t)(LPVOID)NDirectMethodDesc::ResolveAndSetNDirectTarget((NDirectMethodDesc*)pMethod); + _ASSERTE(pMethod->IsPInvoke()); + result = (size_t)(LPVOID)PInvokeMethodDesc::ResolveAndSetPInvokeTarget((PInvokeMethodDesc*)pMethod); } else { diff --git a/src/coreclr/vm/jitinterface.h b/src/coreclr/vm/jitinterface.h index e825d94a129c37..8cc6c6773ed43b 100644 --- a/src/coreclr/vm/jitinterface.h +++ b/src/coreclr/vm/jitinterface.h @@ -84,7 +84,7 @@ void getMethodInfoILMethodHeaderHelper( BOOL LoadDynamicInfoEntry(Module *currentModule, RVA fixupRva, SIZE_T *entry, - BOOL mayUsePrecompiledNDirectMethods = TRUE); + BOOL mayUsePrecompiledPInvokeMethods = TRUE); // These must be implemented in assembly and generate a TransitionBlock then calling JIT_PatchpointWorkerWithPolicy in order to actually be used. EXTERN_C FCDECL2(void, JIT_Patchpoint, int* counter, int ilOffset); diff --git a/src/coreclr/vm/loongarch64/asmconstants.h b/src/coreclr/vm/loongarch64/asmconstants.h index 2ca6ef9a5499db..41589253cb9752 100644 --- a/src/coreclr/vm/loongarch64/asmconstants.h +++ b/src/coreclr/vm/loongarch64/asmconstants.h @@ -90,8 +90,8 @@ ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrD #define FpStruct__BothFloat 0b10 ASMCONSTANTS_C_ASSERT(FpStruct__BothFloat == (int)FpStruct::BothFloat) -#define VASigCookie__pNDirectILStub 0x8 -ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) +#define VASigCookie__pPInvokeILStub 0x8 +ASMCONSTANTS_C_ASSERT(VASigCookie__pPInvokeILStub == offsetof(VASigCookie, pPInvokeILStub)) #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index c40821314bc2ac..1fbb60afbfd647 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -360,7 +360,7 @@ NESTED_END ThePreStub, _TEXT // ------------------------------------------------------------------ // The call in ndirect import precode points to this function. -NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler +NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler // $fp,$ra PROLOG_SAVE_REG_PAIR_INDEXED 22, 1, 0xa0 @@ -369,7 +369,7 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler SAVE_FLOAT_ARGUMENT_REGISTERS $sp, 0x60 ori $a0, $t2, 0 - bl C_FUNC(NDirectImportWorker) + bl C_FUNC(PInvokeImportWorker) ori $t4,$a0,0 // pop the stack and restore original register state @@ -379,10 +379,10 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler // $fp,$ra EPILOG_RESTORE_REG_PAIR_INDEXED 22, 1, 0xa0 - // If we got back from NDirectImportWorker, the MD has been successfully + // If we got back from PInvokeImportWorker, the MD has been successfully // linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG $t4 -NESTED_END NDirectImportThunk, _TEXT +NESTED_END PInvokeImportThunk, _TEXT #ifdef FEATURE_PREJIT //------------------------------------------------ diff --git a/src/coreclr/vm/loongarch64/pinvokestubs.S b/src/coreclr/vm/loongarch64/pinvokestubs.S index 3690f8cc88e2f5..d1bb4e462481a9 100644 --- a/src/coreclr/vm/loongarch64/pinvokestubs.S +++ b/src/coreclr/vm/loongarch64/pinvokestubs.S @@ -21,7 +21,7 @@ NESTED_ENTRY \__PInvokeStubFuncName, _TEXT, NoHandler // get the stub - ld.d $t0, \VASigCookieReg, VASigCookie__pNDirectILStub + ld.d $t0, \VASigCookieReg, VASigCookie__pPInvokeILStub // if null goto stub generation beq $t0, $zero, \__PInvokeGenStubFuncName diff --git a/src/coreclr/vm/marshalnative.cpp b/src/coreclr/vm/marshalnative.cpp index 0bea08d7a75592..eec97703f93eeb 100644 --- a/src/coreclr/vm/marshalnative.cpp +++ b/src/coreclr/vm/marshalnative.cpp @@ -63,7 +63,7 @@ extern "C" VOID QCALLTYPE MarshalNative_Prelink(MethodDesc * pMD) return; // Silently ignore if not N/Direct and not runtime generated. - if (!(pMD->IsNDirect()) && !(pMD->IsRuntimeSupplied())) + if (!(pMD->IsPInvoke()) && !(pMD->IsRuntimeSupplied())) return; BEGIN_QCALL; @@ -126,7 +126,7 @@ extern "C" BOOL QCALLTYPE MarshalNative_TryGetStructMarshalStub(void* enregister if (structMarshalStub == NULL) { - structMarshalStub = NDirect::CreateStructMarshalILStub(pMT); + structMarshalStub = PInvoke::CreateStructMarshalILStub(pMT); } *pStructMarshalStub = structMarshalStub->GetSingleCallableAddrOfCode(); diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 2c0001d95bacee..ba8f0e2c282240 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -59,7 +59,7 @@ bool FixupSignatureContainingInternalTypes( static_assert_no_msg((sizeof(MethodDescChunk) & MethodDesc::ALIGNMENT_MASK) == 0); static_assert_no_msg((sizeof(MethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); static_assert_no_msg((sizeof(FCallMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); -static_assert_no_msg((sizeof(NDirectMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); +static_assert_no_msg((sizeof(PInvokeMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); static_assert_no_msg((sizeof(EEImplMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); static_assert_no_msg((sizeof(ArrayMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); static_assert_no_msg((sizeof(CLRToCOMCallMethodDesc) & MethodDesc::ALIGNMENT_MASK) == 0); @@ -68,7 +68,7 @@ static_assert_no_msg((sizeof(DynamicMethodDesc) & MethodDesc::ALIGNMENT_MASK #define METHOD_DESC_SIZES(adjustment) \ adjustment + sizeof(MethodDesc), /* mcIL */ \ adjustment + sizeof(FCallMethodDesc), /* mcFCall */ \ - adjustment + sizeof(NDirectMethodDesc), /* mcPInvoke */ \ + adjustment + sizeof(PInvokeMethodDesc), /* mcPInvoke */ \ adjustment + sizeof(EEImplMethodDesc), /* mcEEImpl */ \ adjustment + sizeof(ArrayMethodDesc), /* mcArray */ \ adjustment + sizeof(InstantiatedMethodDesc), /* mcInstantiated */ \ @@ -141,7 +141,7 @@ SIZE_T MethodDesc::SizeOf() /*********************************************************************/ #ifndef DACCESS_COMPILE -BOOL NDirectMethodDesc::HasDefaultDllImportSearchPathsAttribute() +BOOL PInvokeMethodDesc::HasDefaultDllImportSearchPathsAttribute() { CONTRACTL { @@ -160,11 +160,11 @@ BOOL NDirectMethodDesc::HasDefaultDllImportSearchPathsAttribute() if(attributeIsFound ) { - InterlockedSetNDirectFlags(kDefaultDllImportSearchPathsIsCached | kDefaultDllImportSearchPathsStatus); + InterlockedSetPInvokeFlags(kDefaultDllImportSearchPathsIsCached | kDefaultDllImportSearchPathsStatus); } else { - InterlockedSetNDirectFlags(kDefaultDllImportSearchPathsIsCached); + InterlockedSetPInvokeFlags(kDefaultDllImportSearchPathsIsCached); } return (ndirect.m_wFlags & kDefaultDllImportSearchPathsStatus) != 0; @@ -1017,7 +1017,7 @@ WORD MethodDescChunk::InterlockedUpdateFlags(WORD wMask, BOOL fSet) // Returns the address of the native code. // // Methods which have no native code are either implemented by stubs or not jitted yet. -// For example, NDirectMethodDesc's have no native code. They are treated as +// For example, PInvokeMethodDesc's have no native code. They are treated as // implemented by stubs. On WIN64, these stubs are IL stubs, which DO have native code. // // This function returns null if the method has no native code. @@ -1167,7 +1167,7 @@ ULONG MethodDesc::GetRVA() _ASSERTE(!"If this ever fires, then this method should return HRESULT"); return 0; } - BAD_FORMAT_NOTHROW_ASSERT(IsNDirect() || IsMiIL(dwImplFlags) || IsMiOPTIL(dwImplFlags) || dwDescrOffset == 0); + BAD_FORMAT_NOTHROW_ASSERT(IsPInvoke() || IsMiIL(dwImplFlags) || IsMiOPTIL(dwImplFlags) || dwDescrOffset == 0); return dwDescrOffset; } @@ -2481,7 +2481,7 @@ BOOL MethodDesc::RequiresMethodDescCallingConvention(BOOL fEstimateForChunk /*=F LIMITED_METHOD_CONTRACT; // Interop marshaling is implemented using shared stubs - if (IsNDirect() || IsCLRToCOMCall()) + if (IsPInvoke() || IsCLRToCOMCall()) return TRUE; @@ -2568,7 +2568,7 @@ BOOL MethodDesc::MayHaveNativeCode() break; case mcFCall: // FCalls do not have real native code. return FALSE; - case mcPInvoke: // NDirect never have native code (note that the NDirect method + case mcPInvoke: // PInvoke never have native code (note that the PInvoke method return FALSE; // does not appear as having a native code even for stubs as IL) case mcEEImpl: // Runtime provided implementation. No native code. return FALSE; @@ -3258,17 +3258,17 @@ BOOL MethodDesc::SetStableEntryPointInterlocked(PCODE addr) return fResult; } -BOOL NDirectMethodDesc::ComputeMarshalingRequired() +BOOL PInvokeMethodDesc::ComputeMarshalingRequired() { WRAPPER_NO_CONTRACT; - return NDirect::MarshalingRequired(this); + return PInvoke::MarshalingRequired(this); } /**********************************************************************************/ -// Forward declare the NDirectImportWorker function - See dllimport.cpp -EXTERN_C LPVOID STDCALL NDirectImportWorker(NDirectMethodDesc*); -void *NDirectMethodDesc::ResolveAndSetNDirectTarget(_In_ NDirectMethodDesc* pMD) +// Forward declare the PInvokeImportWorker function - See dllimport.cpp +EXTERN_C LPVOID STDCALL PInvokeImportWorker(PInvokeMethodDesc*); +void *PInvokeMethodDesc::ResolveAndSetPInvokeTarget(_In_ PInvokeMethodDesc* pMD) { CONTRACTL { @@ -3281,14 +3281,14 @@ void *NDirectMethodDesc::ResolveAndSetNDirectTarget(_In_ NDirectMethodDesc* pMD) // This build conditional is here due to dllimport.cpp // not being relevant during the crossgen build. - LPVOID targetMaybe = NDirectImportWorker(pMD); + LPVOID targetMaybe = PInvokeImportWorker(pMD); _ASSERTE(targetMaybe != nullptr); - pMD->SetNDirectTarget(targetMaybe); + pMD->SetPInvokeTarget(targetMaybe); return targetMaybe; } -BOOL NDirectMethodDesc::TryGetResolvedNDirectTarget(_In_ NDirectMethodDesc* pMD, _Out_ void** ndirectTarget) +BOOL PInvokeMethodDesc::TryGetResolvedPInvokeTarget(_In_ PInvokeMethodDesc* pMD, _Out_ void** ndirectTarget) { CONTRACTL { @@ -3300,23 +3300,23 @@ BOOL NDirectMethodDesc::TryGetResolvedNDirectTarget(_In_ NDirectMethodDesc* pMD, } CONTRACTL_END - if (!pMD->NDirectTargetIsImportThunk()) + if (!pMD->PInvokeTargetIsImportThunk()) { // This is an early out to handle already resolved targets - *ndirectTarget = pMD->GetNDirectTarget(); + *ndirectTarget = pMD->GetPInvokeTarget(); return TRUE; } if (!pMD->ShouldSuppressGCTransition()) return FALSE; - *ndirectTarget = ResolveAndSetNDirectTarget(pMD); + *ndirectTarget = ResolveAndSetPInvokeTarget(pMD); return TRUE; } //******************************************************************************* -void NDirectMethodDesc::InterlockedSetNDirectFlags(WORD wFlags) +void PInvokeMethodDesc::InterlockedSetPInvokeFlags(WORD wFlags) { CONTRACTL { @@ -3333,7 +3333,7 @@ void NDirectMethodDesc::InterlockedSetNDirectFlags(WORD wFlags) // Make sure that m_flags is aligned on a 4 byte boundry _ASSERTE( ( ((size_t) pFlags) & (sizeof(ULONG)-1) ) == 0); - // Ensure we won't be reading or writing outside the bounds of the NDirectMethodDesc. + // Ensure we won't be reading or writing outside the bounds of the PInvokeMethodDesc. _ASSERTE((BYTE*)pFlags >= (BYTE*)this); _ASSERTE((BYTE*)pFlags+sizeof(ULONG) <= (BYTE*)(this+1)); @@ -3348,7 +3348,7 @@ void NDirectMethodDesc::InterlockedSetNDirectFlags(WORD wFlags) #ifdef TARGET_WINDOWS -FARPROC NDirectMethodDesc::FindEntryPointWithMangling(NATIVE_LIBRARY_HANDLE hMod, PTR_CUTF8 entryPointName) +FARPROC PInvokeMethodDesc::FindEntryPointWithMangling(NATIVE_LIBRARY_HANDLE hMod, PTR_CUTF8 entryPointName) { CONTRACTL { @@ -3389,7 +3389,7 @@ FARPROC NDirectMethodDesc::FindEntryPointWithMangling(NATIVE_LIBRARY_HANDLE hMod return pFunc; } -FARPROC NDirectMethodDesc::FindEntryPointWithSuffix(NATIVE_LIBRARY_HANDLE hMod, PTR_CUTF8 entryPointName, char suffix) +FARPROC PInvokeMethodDesc::FindEntryPointWithSuffix(NATIVE_LIBRARY_HANDLE hMod, PTR_CUTF8 entryPointName, char suffix) { // Allocate space for a copy of the entry point name. DWORD entryPointWithSuffixLen = (DWORD)(strlen(entryPointName) + 1); // +1 for charset decorations @@ -3408,7 +3408,7 @@ FARPROC NDirectMethodDesc::FindEntryPointWithSuffix(NATIVE_LIBRARY_HANDLE hMod, #endif //******************************************************************************* -LPVOID NDirectMethodDesc::FindEntryPoint(NATIVE_LIBRARY_HANDLE hMod) +LPVOID PInvokeMethodDesc::FindEntryPoint(NATIVE_LIBRARY_HANDLE hMod) { CONTRACTL { @@ -3459,7 +3459,7 @@ LPVOID NDirectMethodDesc::FindEntryPoint(NATIVE_LIBRARY_HANDLE hMod) #if defined(TARGET_X86) //******************************************************************************* -void NDirectMethodDesc::EnsureStackArgumentSize() +void PInvokeMethodDesc::EnsureStackArgumentSize() { STANDARD_VM_CONTRACT; @@ -3477,7 +3477,7 @@ void NDirectMethodDesc::EnsureStackArgumentSize() //******************************************************************************* -void NDirectMethodDesc::InitEarlyBoundNDirectTarget() +void PInvokeMethodDesc::InitEarlyBoundPInvokeTarget() { CONTRACTL { @@ -3502,10 +3502,10 @@ void NDirectMethodDesc::InitEarlyBoundNDirectTarget() target = (BYTE*)FalseGetLastError; #endif - // As long as we've set the NDirect target field we don't need to backpatch the import thunk glue. - // All NDirect calls all through the NDirect target, so if it's updated, then we won't go into - // NDirectImportThunk(). In fact, backpatching the import thunk glue leads to race conditions. - SetNDirectTarget((LPVOID)target); + // As long as we've set the PInvoke target field we don't need to backpatch the import thunk glue. + // All PInvoke calls all through the PInvoke target, so if it's updated, then we won't go into + // PInvokeImportThunk(). In fact, backpatching the import thunk glue leads to race conditions. + SetPInvokeTarget((LPVOID)target); } //******************************************************************************* @@ -3546,7 +3546,7 @@ BOOL MethodDesc::ShouldSuppressGCTransition() CONTRACTL_END; MethodDesc* tgt = nullptr; - if (IsNDirect()) + if (IsPInvoke()) { tgt = this; } @@ -3570,7 +3570,7 @@ BOOL MethodDesc::ShouldSuppressGCTransition() _ASSERTE(tgt != nullptr); bool suppressGCTransition; - NDirect::GetCallingConvention_IgnoreErrors(tgt, NULL /*callConv*/, &suppressGCTransition); + PInvoke::GetCallingConvention_IgnoreErrors(tgt, NULL /*callConv*/, &suppressGCTransition); return suppressGCTransition ? TRUE : FALSE; } diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 0a7e74658de299..94da4c85d2271b 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -28,7 +28,7 @@ class Stub; class FCallMethodDesc; class FieldDesc; -class NDirect; +class PInvoke; class MethodDescChunk; class InstantiatedMethodDesc; class DictionaryLayout; @@ -53,7 +53,7 @@ GVAL_DECL(DWORD, g_MiniMetaDataBuffMaxSize); GVAL_DECL(TADDR, g_MiniMetaDataBuffAddress); #endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS -EXTERN_C VOID STDCALL NDirectImportThunk(); +EXTERN_C VOID STDCALL PInvokeImportThunk(); #define METHOD_TOKEN_REMAINDER_BIT_COUNT 12 #define METHOD_TOKEN_REMAINDER_MASK ((1 << METHOD_TOKEN_REMAINDER_BIT_COUNT) - 1) @@ -194,7 +194,7 @@ enum MethodDescFlags // Has local slot (vs. has real slot in MethodTable) mdfHasNonVtableSlot = 0x0008, - // Method is a body for a method impl (MI_MethodDesc, MI_NDirectMethodDesc, etc) + // Method is a body for a method impl (MI_MethodDesc, MI_PInvokeMethodDesc, etc) // where the function explicitly implements IInterface.foo() instead of foo(). mdfMethodImpl = 0x0010, @@ -726,7 +726,7 @@ class MethodDesc inline bool IsILStub(); inline bool IsLCGMethod(); - inline DWORD IsNDirect() + inline DWORD IsPInvoke() { LIMITED_METHOD_DAC_CONTRACT; return mcPInvoke == GetClassification(); @@ -2952,10 +2952,10 @@ class ArrayMethodDesc : public StoredSigMethodDesc }; #ifdef HAS_NDIRECT_IMPORT_PRECODE -typedef NDirectImportPrecode NDirectImportThunkGlue; +typedef PInvokeImportPrecode PInvokeImportThunkGlue; #else // HAS_NDIRECT_IMPORT_PRECODE -class NDirectImportThunkGlue +class PInvokeImportThunkGlue { PVOID m_dummy; // Dummy field to make the alignment right @@ -2973,15 +2973,15 @@ class NDirectImportThunkGlue #endif // HAS_NDIRECT_IMPORT_PRECODE -typedef DPTR(NDirectImportThunkGlue) PTR_NDirectImportThunkGlue; +typedef DPTR(PInvokeImportThunkGlue) PTR_PInvokeImportThunkGlue; //----------------------------------------------------------------------- -// Operations specific to NDirect methods. We use a derived class to get +// Operations specific to PInvoke methods. We use a derived class to get // the compiler involved in enforcing proper method type usage. // DO NOT ADD FIELDS TO THIS CLASS. //----------------------------------------------------------------------- -class NDirectMethodDesc : public MethodDesc +class PInvokeMethodDesc : public MethodDesc { public: struct temp1 @@ -2996,14 +2996,14 @@ class NDirectMethodDesc : public MethodDesc }; // The JIT generates an indirect call through this location in some cases. - // Initialized to NDirectImportThunkGlue. Patched to the true target or + // Initialized to PInvokeImportThunkGlue. Patched to the true target or // host interceptor stub or alignment thunk after linking. - LPVOID m_pNDirectTarget; + LPVOID m_pPInvokeTarget; #ifdef HAS_NDIRECT_IMPORT_PRECODE - PTR_NDirectImportThunkGlue m_pImportThunkGlue; + PTR_PInvokeImportThunkGlue m_pImportThunkGlue; #else // HAS_NDIRECT_IMPORT_PRECODE - NDirectImportThunkGlue m_ImportThunkGlue; + PInvokeImportThunkGlue m_ImportThunkGlue; #endif // HAS_NDIRECT_IMPORT_PRECODE ULONG m_DefaultDllImportSearchPathsAttributeValue; // DefaultDllImportSearchPathsAttribute is saved. @@ -3060,15 +3060,15 @@ class NDirectMethodDesc : public MethodDesc kDefaultDllImportSearchPathsStatus = 0x2000, // either method has custom attribute or not. - kNDirectPopulated = 0x8000, // Indicate if the NDirect has been fully populated. + kPInvokePopulated = 0x8000, // Indicate if the PInvoke has been fully populated. }; - // Resolve the import to the NDirect target and set it on the NDirectMethodDesc. - static void* ResolveAndSetNDirectTarget(_In_ NDirectMethodDesc* pMD); + // Resolve the import to the PInvoke target and set it on the PInvokeMethodDesc. + static void* ResolveAndSetPInvokeTarget(_In_ PInvokeMethodDesc* pMD); - // Attempt to get a resolved NDirect target. This will return true for already resolved + // Attempt to get a resolved PInvoke target. This will return true for already resolved // targets and methods that are resolved at JIT time, such as those marked SuppressGCTransition - static BOOL TryGetResolvedNDirectTarget(_In_ NDirectMethodDesc* pMD, _Out_ void** ndirectTarget); + static BOOL TryGetResolvedPInvokeTarget(_In_ PInvokeMethodDesc* pMD, _Out_ void** ndirectTarget); // Retrieves the cached result of marshaling required computation, or performs the computation // if the result is not cached yet. @@ -3079,7 +3079,7 @@ class NDirectMethodDesc : public MethodDesc if ((ndirect.m_wFlags & kIsMarshalingRequiredCached) == 0) { // Compute the flag and cache the result - InterlockedSetNDirectFlags(kIsMarshalingRequiredCached | + InterlockedSetPInvokeFlags(kIsMarshalingRequiredCached | (ComputeMarshalingRequired() ? kCachedMarshalingRequired : 0)); } _ASSERTE((ndirect.m_wFlags & kIsMarshalingRequiredCached) != 0); @@ -3089,7 +3089,7 @@ class NDirectMethodDesc : public MethodDesc BOOL ComputeMarshalingRequired(); // Atomically set specified flags. Only setting of the bits is supported. - void InterlockedSetNDirectFlags(WORD wFlags); + void InterlockedSetPInvokeFlags(WORD wFlags); void SetIsEarlyBound() { @@ -3180,7 +3180,7 @@ class NDirectMethodDesc : public MethodDesc BOOL IsPopulated() { LIMITED_METHOD_CONTRACT; - return (VolatileLoad(&ndirect.m_wFlags) & kNDirectPopulated) != 0; + return (VolatileLoad(&ndirect.m_wFlags) & kPInvokePopulated) != 0; } ULONG DefaultDllImportSearchPathsAttributeCachedValue() @@ -3195,36 +3195,36 @@ class NDirectMethodDesc : public MethodDesc return (ndirect.m_DefaultDllImportSearchPathsAttributeValue & 0x2) != 0; } - PTR_NDirectImportThunkGlue GetNDirectImportThunkGlue() + PTR_PInvokeImportThunkGlue GetPInvokeImportThunkGlue() { LIMITED_METHOD_DAC_CONTRACT; return ndirect.m_pImportThunkGlue; } - LPVOID GetNDirectTarget() + LPVOID GetPInvokeTarget() { LIMITED_METHOD_CONTRACT; - _ASSERTE(IsNDirect()); - return ndirect.m_pNDirectTarget; + _ASSERTE(IsPInvoke()); + return ndirect.m_pPInvokeTarget; } - VOID SetNDirectTarget(LPVOID pTarget); + VOID SetPInvokeTarget(LPVOID pTarget); #ifndef DACCESS_COMPILE - BOOL NDirectTargetIsImportThunk() + BOOL PInvokeTargetIsImportThunk() { WRAPPER_NO_CONTRACT; - _ASSERTE(IsNDirect()); + _ASSERTE(IsPInvoke()); - return (GetNDirectTarget() == GetNDirectImportThunkGlue()->GetEntrypoint()); + return (GetPInvokeTarget() == GetPInvokeImportThunkGlue()->GetEntrypoint()); } #endif // !DACCESS_COMPILE // Find the entry point name and function address - // based on the module and data from NDirectMethodDesc + // based on the module and data from PInvokeMethodDesc // LPVOID FindEntryPoint(NATIVE_LIBRARY_HANDLE hMod); @@ -3274,10 +3274,10 @@ class NDirectMethodDesc : public MethodDesc } #endif // defined(TARGET_X86) - VOID InitEarlyBoundNDirectTarget(); + VOID InitEarlyBoundPInvokeTarget(); // In AppDomains, we can trigger declarer's cctor when we link the P/Invoke, - // which takes care of inlined calls as well. See code:NDirect.NDirectLink. + // which takes care of inlined calls as well. See code:PInvoke.PInvokeLink. // Although the cctor is guaranteed to run in the shared domain before the // target is invoked, we will trigger it at link time as well because linking // may depend on it - cctor may change the target DLL, DLL search path etc. @@ -3290,7 +3290,7 @@ class NDirectMethodDesc : public MethodDesc return FALSE; return !pMT->GetClass()->IsBeforeFieldInit(); } -}; //class NDirectMethodDesc +}; //class PInvokeMethodDesc //----------------------------------------------------------------------- // Operations specific to EEImplCall methods. We use a derived class to get diff --git a/src/coreclr/vm/method.inl b/src/coreclr/vm/method.inl index bf25d6f6955705..475af80856c44a 100644 --- a/src/coreclr/vm/method.inl +++ b/src/coreclr/vm/method.inl @@ -130,7 +130,7 @@ inline bool MethodDesc::IsILStub() inline BOOL MethodDesc::IsQCall() { WRAPPER_NO_CONTRACT; - return (IsNDirect() && dac_cast(this)->IsQCall()); + return (IsPInvoke() && dac_cast(this)->IsQCall()); } #ifdef FEATURE_COMINTEROP diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 631f80b38776f8..9e8c8d42c0d786 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -3151,7 +3151,7 @@ MethodTableBuilder::EnumerateClassMethods() if (IsReallyMdPinvokeImpl(dwMemberAttrs) || IsMiInternalCall(dwImplFlags)) { - hr = NDirect::HasNAT_LAttribute(pMDInternalImport, tok, dwMemberAttrs); + hr = PInvoke::HasNAT_LAttribute(pMDInternalImport, tok, dwMemberAttrs); // There was a problem querying for the attribute if (FAILED(hr)) @@ -3187,7 +3187,7 @@ MethodTableBuilder::EnumerateClassMethods() type = mcPInvoke; } } - // The NAT_L attribute is present, marking this method as NDirect + // The NAT_L attribute is present, marking this method as PInvoke else { CONSISTENCY_CHECK(hr == S_OK); @@ -3807,7 +3807,7 @@ VOID MethodTableBuilder::AllocateFieldDescs() // table in every single method desc, we allocate memory in the // following manner: // o Field descs get a single contiguous block. - // o Method descs of different sizes (normal vs NDirect) are + // o Method descs of different sizes (normal vs PInvoke) are // allocated in different MethodDescChunks. // o Each method desc chunk starts with a header, and has // at most MAX_ method descs (if there are more @@ -6143,8 +6143,8 @@ MethodTableBuilder::InitMethodDesc( DWORD dwImplFlags, DWORD dwMemberAttrs, BOOL fEnC, - DWORD RVA, // Only needed for NDirect case - IMDInternalImport * pIMDII, // Needed for NDirect, EEImpl(Delegate) cases + DWORD RVA, // Only needed for PInvoke case + IMDInternalImport * pIMDII, // Needed for PInvoke, EEImpl(Delegate) cases LPCSTR pMethodName, // Only needed for mcEEImpl (Delegate) case Signature sig, // Only needed for the Async thunk case AsyncMethodKind asyncKind @@ -6172,14 +6172,14 @@ MethodTableBuilder::InitMethodDesc( { case mcPInvoke: { - // NDirect specific initialization. - NDirectMethodDesc *pNewNMD = (NDirectMethodDesc*)pNewMD; + // PInvoke specific initialization. + PInvokeMethodDesc *pNewNMD = (PInvokeMethodDesc*)pNewMD; #ifdef HAS_NDIRECT_IMPORT_PRECODE pNewNMD->ndirect.m_pImportThunkGlue = Precode::Allocate(PRECODE_NDIRECT_IMPORT, pNewMD, - GetLoaderAllocator(), GetMemTracker())->AsNDirectImportPrecode(); + GetLoaderAllocator(), GetMemTracker())->AsPInvokeImportPrecode(); #else // !HAS_NDIRECT_IMPORT_PRECODE - pNewNMD->GetNDirectImportThunkGlue()->Init(pNewNMD); + pNewNMD->GetPInvokeImportThunkGlue()->Init(pNewNMD); #endif // !HAS_NDIRECT_IMPORT_PRECODE #if defined(TARGET_X86) @@ -6194,7 +6194,7 @@ MethodTableBuilder::InitMethodDesc( pNewNMD->SetIsEarlyBound(); } - pNewNMD->ndirect.m_pNDirectTarget = pNewNMD->GetNDirectImportThunkGlue()->GetEntrypoint(); + pNewNMD->ndirect.m_pPInvokeTarget = pNewNMD->GetPInvokeImportThunkGlue()->GetEntrypoint(); } break; @@ -6287,7 +6287,7 @@ MethodTableBuilder::InitMethodDesc( DWORD stressSynchronizedVal = stressSynchronized.val(CLRConfig::INTERNAL_stressSynchronized); bool isStressSynchronized = stressSynchronizedVal && - pNewMD->IsIL() && // Synchronized is not supported on Ecalls, NDirect method, etc + pNewMD->IsIL() && // Synchronized is not supported on Ecalls, PInvoke method, etc // IsValueClass() and IsEnum() do not work for System.ValueType and System.Enum themselves ((g_pValueTypeClass != NULL && g_pEnumClass != NULL && !IsValueClass()) || // Can not synchronize on byref "this" diff --git a/src/coreclr/vm/methodtablebuilder.h b/src/coreclr/vm/methodtablebuilder.h index ebd987467d9c61..825b9ac9ee5f64 100644 --- a/src/coreclr/vm/methodtablebuilder.h +++ b/src/coreclr/vm/methodtablebuilder.h @@ -2701,8 +2701,8 @@ class MethodTableBuilder DWORD dwImplFlags, DWORD dwMemberAttrs, BOOL fEnC, - DWORD RVA, // Only needed for NDirect case - IMDInternalImport * pIMDII, // Needed for NDirect, EEImpl(Delegate) cases + DWORD RVA, // Only needed for PInvoke case + IMDInternalImport * pIMDII, // Needed for PInvoke, EEImpl(Delegate) cases LPCSTR pMethodName, // Only needed for mcEEImpl (Delegate) case Signature sig, // Only needed for the Async thunk case AsyncMethodKind asyncKind diff --git a/src/coreclr/vm/mlinfo.cpp b/src/coreclr/vm/mlinfo.cpp index 27b6d9f83aec97..fd695c46741bc1 100644 --- a/src/coreclr/vm/mlinfo.cpp +++ b/src/coreclr/vm/mlinfo.cpp @@ -2077,7 +2077,7 @@ MarshalInfo::MarshalInfo(Module* pModule, goto lExit; } -VOID MarshalInfo::EmitOrThrowInteropParamException(NDirectStubLinker* psl, BOOL fMngToNative, UINT resID, UINT paramIdx) +VOID MarshalInfo::EmitOrThrowInteropParamException(PInvokeStubLinker* psl, BOOL fMngToNative, UINT resID, UINT paramIdx) { CONTRACTL { @@ -2241,7 +2241,7 @@ HRESULT MarshalInfo::HandleArrayElemType(NativeTypeParamInfo *pParamInfo, TypeHa return S_OK; } -ILMarshaler* CreateILMarshaler(MarshalInfo::MarshalType mtype, NDirectStubLinker* psl) +ILMarshaler* CreateILMarshaler(MarshalInfo::MarshalType mtype, PInvokeStubLinker* psl) { CONTRACTL { @@ -2265,7 +2265,7 @@ ILMarshaler* CreateILMarshaler(MarshalInfo::MarshalType mtype, NDirectStubLinker UNREACHABLE_MSG("unexpected MarshalType passed to CreateILMarshaler"); } - pMarshaler->SetNDirectStubLinker(psl); + pMarshaler->SetPInvokeStubLinker(psl); return pMarshaler; } @@ -2318,7 +2318,7 @@ namespace } } -void MarshalInfo::GenerateArgumentIL(NDirectStubLinker* psl, +void MarshalInfo::GenerateArgumentIL(PInvokeStubLinker* psl, int argOffset, // the argument's index is m_paramidx + argOffset BOOL fMngToNative) { @@ -2388,12 +2388,12 @@ void MarshalInfo::GenerateArgumentIL(NDirectStubLinker* psl, if (pMarshaler->NeedsMarshalCleanupIndex()) { // we don't bother writing to the counter if marshaling does not need cleanup - psl->EmitSetArgMarshalIndex(pcsMarshal, NDirectStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_paramidx + argOffset); + psl->EmitSetArgMarshalIndex(pcsMarshal, PInvokeStubLinker::CLEANUP_INDEX_ARG0_MARSHAL + m_paramidx + argOffset); } if (pMarshaler->NeedsUnmarshalCleanupIndex()) { // we don't bother writing to the counter if unmarshaling does not need exception cleanup - psl->EmitSetArgMarshalIndex(pcsUnmarshal, NDirectStubLinker::CLEANUP_INDEX_ARG0_UNMARSHAL + m_paramidx + argOffset); + psl->EmitSetArgMarshalIndex(pcsUnmarshal, PInvokeStubLinker::CLEANUP_INDEX_ARG0_UNMARSHAL + m_paramidx + argOffset); } pcsMarshal->EmitNOP("// } argument"); @@ -2411,7 +2411,7 @@ void MarshalInfo::GenerateArgumentIL(NDirectStubLinker* psl, } } -void MarshalInfo::GenerateReturnIL(NDirectStubLinker* psl, +void MarshalInfo::GenerateReturnIL(PInvokeStubLinker* psl, int argOffset, BOOL fMngToNative, BOOL fieldGetter, @@ -2489,7 +2489,7 @@ void MarshalInfo::GenerateReturnIL(NDirectStubLinker* psl, } } -void MarshalInfo::GenerateFieldIL(NDirectStubLinker* psl, +void MarshalInfo::GenerateFieldIL(PInvokeStubLinker* psl, UINT32 managedOffset, UINT32 nativeOffset, FieldDesc* pFieldDesc) diff --git a/src/coreclr/vm/mlinfo.h b/src/coreclr/vm/mlinfo.h index 3d2c5186556191..947f8a87f50b39 100644 --- a/src/coreclr/vm/mlinfo.h +++ b/src/coreclr/vm/mlinfo.h @@ -112,7 +112,7 @@ struct OverrideProcArgs }; }; -typedef MarshalerOverrideStatus (*OVERRIDEPROC)(NDirectStubLinker* psl, +typedef MarshalerOverrideStatus (*OVERRIDEPROC)(PInvokeStubLinker* psl, BOOL byref, BOOL fin, BOOL fout, @@ -121,7 +121,7 @@ typedef MarshalerOverrideStatus (*OVERRIDEPROC)(NDirectStubLinker* psl, UINT* pResID, UINT argidx); -typedef MarshalerOverrideStatus (*RETURNOVERRIDEPROC)(NDirectStubLinker* psl, +typedef MarshalerOverrideStatus (*RETURNOVERRIDEPROC)(PInvokeStubLinker* psl, BOOL fManagedToNative, BOOL fHresultSwap, OverrideProcArgs* pargs, @@ -301,7 +301,7 @@ class MarshalInfo ); - VOID EmitOrThrowInteropParamException(NDirectStubLinker* psl, BOOL fMngToNative, UINT resID, UINT paramIdx); + VOID EmitOrThrowInteropParamException(PInvokeStubLinker* psl, BOOL fMngToNative, UINT resID, UINT paramIdx); void ThrowTypeLoadExceptionForInvalidFieldMarshal(FieldDesc* pFieldDesc, UINT resID); @@ -314,17 +314,17 @@ class MarshalInfo Assembly *pAssembly, BOOL isArrayClass = FALSE); - void GenerateArgumentIL(NDirectStubLinker* psl, + void GenerateArgumentIL(PInvokeStubLinker* psl, int argOffset, // the argument's index is m_paramidx + argOffset BOOL fMngToNative); - void GenerateReturnIL(NDirectStubLinker* psl, + void GenerateReturnIL(PInvokeStubLinker* psl, int argOffset, // the argument's index is m_paramidx + argOffset BOOL fMngToNative, BOOL fieldGetter, BOOL retval); - void GenerateFieldIL(NDirectStubLinker* psl, + void GenerateFieldIL(PInvokeStubLinker* psl, UINT32 managedOffset, // the field's byte offset into the managed object UINT32 nativeOffset, // the field's byte offset into the native object FieldDesc* pFieldDesc); // The field descriptor for reporting errors diff --git a/src/coreclr/vm/nativelibrary.cpp b/src/coreclr/vm/nativelibrary.cpp index 4d7bee8c8a74d9..dc31ba99ee6421 100644 --- a/src/coreclr/vm/nativelibrary.cpp +++ b/src/coreclr/vm/nativelibrary.cpp @@ -227,7 +227,7 @@ namespace // If a pInvoke has the DefaultDllImportSearchPathsAttribute, get DllImportSearchPathFlags from it, and returns true. // Otherwise, if the containing assembly has the DefaultDllImportSearchPathsAttribute, get DllImportSearchPathFlags from it, and returns true. // Otherwise, get CoreCLR's default value for DllImportSearchPathFlags, and return false. - BOOL GetDllImportSearchPathFlags(NDirectMethodDesc * pMD, DWORD *dllImportSearchPathFlags, BOOL *searchAssemblyDirectory) + BOOL GetDllImportSearchPathFlags(PInvokeMethodDesc * pMD, DWORD *dllImportSearchPathFlags, BOOL *searchAssemblyDirectory) { STANDARD_VM_CONTRACT; @@ -423,7 +423,7 @@ namespace return hmod; } - NATIVE_LIBRARY_HANDLE LoadNativeLibraryViaDllImportResolver(NDirectMethodDesc * pMD, LPCWSTR wszLibName) + NATIVE_LIBRARY_HANDLE LoadNativeLibraryViaDllImportResolver(PInvokeMethodDesc * pMD, LPCWSTR wszLibName) { STANDARD_VM_CONTRACT; @@ -756,7 +756,7 @@ namespace return hmod; } - NATIVE_LIBRARY_HANDLE LoadNativeLibraryBySearch(NDirectMethodDesc *pMD, LoadLibErrorTracker *pErrorTracker, PCWSTR wszLibName) + NATIVE_LIBRARY_HANDLE LoadNativeLibraryBySearch(PInvokeMethodDesc *pMD, LoadLibErrorTracker *pErrorTracker, PCWSTR wszLibName) { STANDARD_VM_CONTRACT; @@ -828,7 +828,7 @@ NATIVE_LIBRARY_HANDLE NativeLibrary::LoadLibraryByName(LPCWSTR libraryName, Asse namespace { - NATIVE_LIBRARY_HANDLE LoadNativeLibrary(NDirectMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker) + NATIVE_LIBRARY_HANDLE LoadNativeLibrary(PInvokeMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker) { CONTRACTL { @@ -883,7 +883,7 @@ namespace } } -NATIVE_LIBRARY_HANDLE NativeLibrary::LoadLibraryFromMethodDesc(NDirectMethodDesc * pMD) +NATIVE_LIBRARY_HANDLE NativeLibrary::LoadLibraryFromMethodDesc(PInvokeMethodDesc * pMD) { CONTRACT(NATIVE_LIBRARY_HANDLE) { diff --git a/src/coreclr/vm/nativelibrary.h b/src/coreclr/vm/nativelibrary.h index f05146862c285d..0745a5a3e41b03 100644 --- a/src/coreclr/vm/nativelibrary.h +++ b/src/coreclr/vm/nativelibrary.h @@ -16,7 +16,7 @@ class NativeLibrary static void FreeNativeLibrary(NATIVE_LIBRARY_HANDLE handle); static INT_PTR GetNativeLibraryExport(NATIVE_LIBRARY_HANDLE handle, LPCWSTR symbolName, BOOL throwOnError); - static NATIVE_LIBRARY_HANDLE LoadLibraryFromMethodDesc(NDirectMethodDesc *pMD); + static NATIVE_LIBRARY_HANDLE LoadLibraryFromMethodDesc(PInvokeMethodDesc *pMD); }; #endif // _NATIVELIBRARY_H_ diff --git a/src/coreclr/vm/olevariant.cpp b/src/coreclr/vm/olevariant.cpp index 67ea84d55afc5b..78cacd10afbe6a 100644 --- a/src/coreclr/vm/olevariant.cpp +++ b/src/coreclr/vm/olevariant.cpp @@ -3298,7 +3298,7 @@ void OleVariant::MarshalArrayVariantOleToObject(const VARIANT* pOleVariant, { GCX_PREEMP(); - pStructMarshalStub = NDirect::CreateStructMarshalILStub(pElemMT); + pStructMarshalStub = PInvoke::CreateStructMarshalILStub(pElemMT); } BASEARRAYREF pArrayRef = CreateArrayRefForSafeArray(pSafeArray, vt, pElemMT); @@ -3343,7 +3343,7 @@ void OleVariant::MarshalArrayVariantObjectToOle(OBJECTREF * const & pObj, { GCX_PREEMP(); - pStructMarshalStub = NDirect::CreateStructMarshalILStub(pElemMT); + pStructMarshalStub = PInvoke::CreateStructMarshalILStub(pElemMT); } GCPROTECT_END(); @@ -3385,7 +3385,7 @@ void OleVariant::MarshalArrayVariantOleRefToObject(const VARIANT *pOleVariant, { GCX_PREEMP(); - pStructMarshalStub = NDirect::CreateStructMarshalILStub(pElemMT); + pStructMarshalStub = PInvoke::CreateStructMarshalILStub(pElemMT); } BASEARRAYREF pArrayRef = CreateArrayRefForSafeArray(pSafeArray, vt, pElemMT); @@ -3886,7 +3886,7 @@ void OleVariant::ConvertValueClassToVariant(OBJECTREF *pBoxedValueClass, VARIANT MethodDesc* pStructMarshalStub; { GCX_PREEMP(); - pStructMarshalStub = NDirect::CreateStructMarshalILStub(pValueClassMT); + pStructMarshalStub = PInvoke::CreateStructMarshalILStub(pValueClassMT); } MarshalStructViaILStub(pStructMarshalStub, (*pBoxedValueClass)->GetData(), (BYTE*)V_RECORD(pRecHolder), StructMarshalStubs::MarshalOperation::Marshal); diff --git a/src/coreclr/vm/precode.cpp b/src/coreclr/vm/precode.cpp index 44efd650c96cc2..4fe0d7d54e9ee6 100644 --- a/src/coreclr/vm/precode.cpp +++ b/src/coreclr/vm/precode.cpp @@ -69,7 +69,7 @@ SIZE_T Precode::SizeOf(PrecodeType t) return sizeof(StubPrecode); #ifdef HAS_NDIRECT_IMPORT_PRECODE case PRECODE_NDIRECT_IMPORT: - return sizeof(NDirectImportPrecode); + return sizeof(PInvokeImportPrecode); #endif // HAS_NDIRECT_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: @@ -144,7 +144,7 @@ MethodDesc* Precode::GetMethodDesc(BOOL fSpeculative /*= FALSE*/) break; #ifdef HAS_NDIRECT_IMPORT_PRECODE case PRECODE_NDIRECT_IMPORT: - pMD = AsNDirectImportPrecode()->GetMethodDesc(); + pMD = AsPInvokeImportPrecode()->GetMethodDesc(); break; #endif // HAS_NDIRECT_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE @@ -332,7 +332,7 @@ void Precode::Init(Precode* pPrecodeRX, PrecodeType t, MethodDesc* pMD, LoaderAl break; #ifdef HAS_NDIRECT_IMPORT_PRECODE case PRECODE_NDIRECT_IMPORT: - ((NDirectImportPrecode*)this)->Init((NDirectImportPrecode*)pPrecodeRX, pMD, pLoaderAllocator); + ((PInvokeImportPrecode*)this)->Init((PInvokeImportPrecode*)pPrecodeRX, pMD, pLoaderAllocator); break; #endif // HAS_NDIRECT_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE @@ -648,10 +648,10 @@ void InterpreterPrecode::Init(InterpreterPrecode* pPrecodeRX, TADDR byteCodeAddr #ifdef HAS_NDIRECT_IMPORT_PRECODE -void NDirectImportPrecode::Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator) +void PInvokeImportPrecode::Init(PInvokeImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator) { WRAPPER_NO_CONTRACT; - StubPrecode::Init(pPrecodeRX, (TADDR)pMD, pLoaderAllocator, NDirectImportPrecode::Type, GetEEFuncEntryPoint(NDirectImportThunk)); + StubPrecode::Init(pPrecodeRX, (TADDR)pMD, pLoaderAllocator, PInvokeImportPrecode::Type, GetEEFuncEntryPoint(PInvokeImportThunk)); } #endif // HAS_NDIRECT_IMPORT_PRECODE diff --git a/src/coreclr/vm/precode.h b/src/coreclr/vm/precode.h index 5d9bf8c98fdd21..914e45281f6fcd 100644 --- a/src/coreclr/vm/precode.h +++ b/src/coreclr/vm/precode.h @@ -202,13 +202,13 @@ typedef DPTR(StubPrecode) PTR_StubPrecode; #ifdef HAS_NDIRECT_IMPORT_PRECODE -// NDirect import precode +// PInvoke import precode // (This is fake precode. VTable slot does not point to it.) -struct NDirectImportPrecode : StubPrecode +struct PInvokeImportPrecode : StubPrecode { static const int Type = 0x05; - void Init(NDirectImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator); + void Init(PInvokeImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator); LPVOID GetEntrypoint() { @@ -216,7 +216,7 @@ struct NDirectImportPrecode : StubPrecode return (LPVOID)PINSTRToPCODE(dac_cast(this)); } }; -typedef DPTR(NDirectImportPrecode) PTR_NDirectImportPrecode; +typedef DPTR(PInvokeImportPrecode) PTR_PInvokeImportPrecode; #endif // HAS_NDIRECT_IMPORT_PRECODE @@ -486,7 +486,7 @@ enum PrecodeType { PRECODE_INTERPRETER = InterpreterPrecode::Type, // 0x6 #endif // FEATURE_INTERPRETER #ifdef HAS_NDIRECT_IMPORT_PRECODE - PRECODE_NDIRECT_IMPORT = NDirectImportPrecode::Type, // 0x5 + PRECODE_NDIRECT_IMPORT = PInvokeImportPrecode::Type, // 0x5 #endif // HAS_NDIRECT_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE PRECODE_FIXUP = FixupPrecode::Type, @@ -574,12 +574,12 @@ class Precode { #ifdef HAS_NDIRECT_IMPORT_PRECODE public: // Fake precodes has to be exposed - NDirectImportPrecode* AsNDirectImportPrecode() + PInvokeImportPrecode* AsPInvokeImportPrecode() { LIMITED_METHOD_CONTRACT; SUPPORTS_DAC; - return dac_cast(this); + return dac_cast(this); } private: @@ -655,7 +655,7 @@ class Precode { if (basicPrecodeType == PRECODE_STUB) { - // StubPrecode code is used for both StubPrecode, NDirectImportPrecode, InterpreterPrecode, and ThisPtrRetBufPrecode, + // StubPrecode code is used for both StubPrecode, PInvokeImportPrecode, InterpreterPrecode, and ThisPtrRetBufPrecode, // so we need to get the real type return (PrecodeType)AsStubPrecode()->GetType(); } @@ -805,15 +805,15 @@ class Precode { void FlushCacheForDynamicMappedStub(void* code, SIZE_T size); // Verify that the type for each precode is different -static_assert_no_msg(StubPrecode::Type != NDirectImportPrecode::Type); +static_assert_no_msg(StubPrecode::Type != PInvokeImportPrecode::Type); static_assert_no_msg(StubPrecode::Type != FixupPrecode::Type); static_assert_no_msg(StubPrecode::Type != ThisPtrRetBufPrecode::Type); -static_assert_no_msg(FixupPrecode::Type != NDirectImportPrecode::Type); +static_assert_no_msg(FixupPrecode::Type != PInvokeImportPrecode::Type); static_assert_no_msg(FixupPrecode::Type != ThisPtrRetBufPrecode::Type); -static_assert_no_msg(NDirectImportPrecode::Type != ThisPtrRetBufPrecode::Type); +static_assert_no_msg(PInvokeImportPrecode::Type != ThisPtrRetBufPrecode::Type); // Verify that the base type for each precode fits into each specific precode type -static_assert_no_msg(sizeof(Precode) <= sizeof(NDirectImportPrecode)); +static_assert_no_msg(sizeof(Precode) <= sizeof(PInvokeImportPrecode)); static_assert_no_msg(sizeof(Precode) <= sizeof(FixupPrecode)); static_assert_no_msg(sizeof(Precode) <= sizeof(ThisPtrRetBufPrecode)); diff --git a/src/coreclr/vm/prestub.cpp b/src/coreclr/vm/prestub.cpp index a6478d1a8a0cca..edac5d145010aa 100644 --- a/src/coreclr/vm/prestub.cpp +++ b/src/coreclr/vm/prestub.cpp @@ -2235,7 +2235,7 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo } pCode = PrepareInitialCode(callerGCMode); } // end else if (IsIL() || IsNoMetadata()) - else if (IsNDirect()) + else if (IsPInvoke()) { if (GetModule()->IsReadyToRun() && GetModule()->GetReadyToRunInfo()->HasNonShareablePInvokeStubs() && MayUsePrecompiledILStub()) { @@ -2383,7 +2383,7 @@ PCODE TheUMThunkPreStub() return GetEEFuncEntryPoint(TheUMEntryPrestub); } -PCODE TheVarargNDirectStub(BOOL hasRetBuffArg) +PCODE TheVarargPInvokeStub(BOOL hasRetBuffArg) { LIMITED_METHOD_CONTRACT; diff --git a/src/coreclr/vm/proftoeeinterfaceimpl.cpp b/src/coreclr/vm/proftoeeinterfaceimpl.cpp index 5ee0da02ac2a30..effd3b73b37441 100644 --- a/src/coreclr/vm/proftoeeinterfaceimpl.cpp +++ b/src/coreclr/vm/proftoeeinterfaceimpl.cpp @@ -8087,7 +8087,7 @@ StackWalkAction ProfilerStackWalkCallback(CrawlFrame *pCf, PROFILER_STACK_WALK_D { // Skip new exception handling helpers InlinedCallFrame *pInlinedCallFrame = dac_cast(pCf->GetFrame()); - PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum; + PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum; TADDR datum = dac_cast(pMD); if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper) { diff --git a/src/coreclr/vm/readytoruninfo.cpp b/src/coreclr/vm/readytoruninfo.cpp index 4cca5ccc80bfaa..dee2504a637901 100644 --- a/src/coreclr/vm/readytoruninfo.cpp +++ b/src/coreclr/vm/readytoruninfo.cpp @@ -1251,10 +1251,10 @@ PCODE ReadyToRunInfo::GetEntryPoint(MethodDesc * pMD, PrepareCodeConfig* pConfig if (fFixups) { - BOOL mayUsePrecompiledNDirectMethods = TRUE; - mayUsePrecompiledNDirectMethods = !pConfig->IsForMulticoreJit(); + BOOL mayUsePrecompiledPInvokeMethods = TRUE; + mayUsePrecompiledPInvokeMethods = !pConfig->IsForMulticoreJit(); - if (!m_pModule->FixupDelayList(dac_cast(GetImage()->GetBase()) + offset, mayUsePrecompiledNDirectMethods)) + if (!m_pModule->FixupDelayList(dac_cast(GetImage()->GetBase()) + offset, mayUsePrecompiledPInvokeMethods)) { pConfig->SetReadyToRunRejectedPrecompiledCode(); goto done; diff --git a/src/coreclr/vm/riscv64/asmconstants.h b/src/coreclr/vm/riscv64/asmconstants.h index 0b88275bc32870..b2260e8a30f26d 100644 --- a/src/coreclr/vm/riscv64/asmconstants.h +++ b/src/coreclr/vm/riscv64/asmconstants.h @@ -85,8 +85,8 @@ ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrD #define FpStruct__BothFloat 0b10 ASMCONSTANTS_C_ASSERT(FpStruct__BothFloat == (int)FpStruct::BothFloat) -#define VASigCookie__pNDirectILStub 0x8 -ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub)) +#define VASigCookie__pPInvokeILStub 0x8 +ASMCONSTANTS_C_ASSERT(VASigCookie__pPInvokeILStub == offsetof(VASigCookie, pPInvokeILStub)) #define SIZEOF__Frame 0x10 ASMCONSTANTS_C_ASSERT(SIZEOF__Frame == sizeof(Frame)); diff --git a/src/coreclr/vm/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index 69e1acee43767f..beb24c3c5f4516 100644 --- a/src/coreclr/vm/riscv64/asmhelpers.S +++ b/src/coreclr/vm/riscv64/asmhelpers.S @@ -319,13 +319,13 @@ NESTED_END ThePreStub, _TEXT // ------------------------------------------------------------------ // The call in ndirect import precode points to this function. -NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler +NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_SAVE_REG_PAIR_INDEXED fp, ra, 0xa0 SAVE_ARGUMENT_REGISTERS sp, 0x20 SAVE_FLOAT_ARGUMENT_REGISTERS sp, 0x60 addi a0, t2, 0 - call C_FUNC(NDirectImportWorker) + call C_FUNC(PInvokeImportWorker) addi t4, a0, 0 // pop the stack and restore original register state @@ -334,10 +334,10 @@ NESTED_ENTRY NDirectImportThunk, _TEXT, NoHandler //EPILOG_RESTORE_REG gp, 16 EPILOG_RESTORE_REG_PAIR_INDEXED fp, ra, 0xa0 - // If we got back from NDirectImportWorker, the MD has been successfully + // If we got back from PInvokeImportWorker, the MD has been successfully // linked. Proceed to execute the original DLL call. EPILOG_BRANCH_REG t4 -NESTED_END NDirectImportThunk, _TEXT +NESTED_END PInvokeImportThunk, _TEXT // ------------------------------------------------------------------ // ThePreStubPatch() diff --git a/src/coreclr/vm/riscv64/pinvokestubs.S b/src/coreclr/vm/riscv64/pinvokestubs.S index 9f065a37e474d1..85eb386154f905 100644 --- a/src/coreclr/vm/riscv64/pinvokestubs.S +++ b/src/coreclr/vm/riscv64/pinvokestubs.S @@ -21,7 +21,7 @@ NESTED_ENTRY \__PInvokeStubFuncName, _TEXT, NoHandler // get the stub - ld t0, (VASigCookie__pNDirectILStub)(\VASigCookieReg) + ld t0, (VASigCookie__pPInvokeILStub)(\VASigCookieReg) // if null goto stub generation beq t0, zero, \__PInvokeGenStubFuncName diff --git a/src/coreclr/vm/stackingallocator.cpp b/src/coreclr/vm/stackingallocator.cpp index b49a96ccd0ec58..e97ae4a69e8fd3 100644 --- a/src/coreclr/vm/stackingallocator.cpp +++ b/src/coreclr/vm/stackingallocator.cpp @@ -321,7 +321,7 @@ void StackingAllocator::Validate(StackBlock *block, void* spot) { // If this assert goes off then someone overwrote their buffer! // A common candidate is PINVOKE buffer run. To confirm look - // up on the stack for NDirect.* Look for the MethodDesc + // up on the stack for PInvoke.* Look for the MethodDesc // associated with it. Be very suspicious if it is one that // has a return string buffer!. This usually means the end // programmer did not allocate a big enough buffer before passing diff --git a/src/coreclr/vm/stackwalk.cpp b/src/coreclr/vm/stackwalk.cpp index 3a8321a0a8ca6c..3376d945e0ca91 100644 --- a/src/coreclr/vm/stackwalk.cpp +++ b/src/coreclr/vm/stackwalk.cpp @@ -1282,7 +1282,7 @@ BOOL StackFrameIterator::ResetRegDisp(PREGDISPLAY pRegDisp, // 0012e884 ntdll32!DbgBreakPoint // 0012e89c CLRStub[StubLinkStub]@1f0ac1e // 0012e8a4 invalid ESP of Foo() according to the REGDISPLAY specified by the debuggers - // 0012e8b4 address of transition frame (NDirectMethodFrameStandalone) + // 0012e8b4 address of transition frame (PInvokeMethodFrameStandalone) // 0012e8c8 real ESP of Foo() according to the transition frame // 0012e8d8 managed!Dummy.Foo()+0x20 // diff --git a/src/coreclr/vm/stubgen.cpp b/src/coreclr/vm/stubgen.cpp index 14dec4e6bba036..30e5f8f0572b7e 100644 --- a/src/coreclr/vm/stubgen.cpp +++ b/src/coreclr/vm/stubgen.cpp @@ -2680,7 +2680,7 @@ void ILStubLinker::TransformArgForJIT(LocalDesc *pLoc) STANDARD_VM_CONTRACT; // Turn everything into blittable primitives. The reason this method is needed are // byrefs which are OK only when they ref stack data or are pinned. This condition - // cannot be verified by code:NDirect.MarshalingRequired so we explicitly get rid + // cannot be verified by code:PInvoke.MarshalingRequired so we explicitly get rid // of them here. bool again; BYTE* elementType = pLoc->ElementType; diff --git a/src/coreclr/vm/stublink.h b/src/coreclr/vm/stublink.h index cb83cda5c3e9fb..0cadd021266223 100644 --- a/src/coreclr/vm/stublink.h +++ b/src/coreclr/vm/stublink.h @@ -821,7 +821,7 @@ class InstructionFormat #define CPUSTUBLINKER StubLinkerCPU -class NDirectStubLinker; +class PInvokeStubLinker; class CPUSTUBLINKER; #endif // __stublink_h__ diff --git a/src/coreclr/vm/stubmgr.cpp b/src/coreclr/vm/stubmgr.cpp index 12a4ae6abe13ad..91fe34e7c319f5 100644 --- a/src/coreclr/vm/stubmgr.cpp +++ b/src/coreclr/vm/stubmgr.cpp @@ -1077,16 +1077,16 @@ BOOL PrecodeStubManager::DoTraceStub(PCODE stubStartAddress, case PRECODE_NDIRECT_IMPORT: #ifndef DACCESS_COMPILE #if defined(TARGET_ARM64) && defined(__APPLE__) - // On ARM64 Mac, we cannot put a breakpoint inside of NDirectImportThunk + // On ARM64 Mac, we cannot put a breakpoint inside of PInvokeImportThunk LOG((LF_CORDB, LL_INFO10000, "PSM::DoTraceStub: Skipping on arm64-macOS\n")); return FALSE; #else - trace->InitForUnmanaged(GetEEFuncEntryPoint(NDirectImportThunk)); + trace->InitForUnmanaged(GetEEFuncEntryPoint(PInvokeImportThunk)); #endif //defined(TARGET_ARM64) && defined(__APPLE__) #else trace->InitForOther((PCODE)NULL); #endif - LOG_TRACE_DESTINATION(trace, stubStartAddress, "PrecodeStubManager::DoTraceStub - NDirect import"); + LOG_TRACE_DESTINATION(trace, stubStartAddress, "PrecodeStubManager::DoTraceStub - PInvoke import"); return TRUE; #endif // HAS_NDIRECT_IMPORT_PRECODE @@ -1796,11 +1796,11 @@ BOOL ILStubManager::TraceManager(Thread *thread, // This is either direct forward P/Invoke or a CLR-to-COM call, the argument is MD MethodDesc *pMD = (MethodDesc *)arg; - if (pMD->IsNDirect()) + if (pMD->IsPInvoke()) { - NDirectMethodDesc* pNMD = reinterpret_cast(pMD); - _ASSERTE_IMPL(!pNMD->NDirectTargetIsImportThunk()); - target = (PCODE)pNMD->GetNDirectTarget(); + PInvokeMethodDesc* pNMD = reinterpret_cast(pMD); + _ASSERTE_IMPL(!pNMD->PInvokeTargetIsImportThunk()); + target = (PCODE)pNMD->GetPInvokeTarget(); LOG((LF_CORDB, LL_INFO10000, "ILSM::TraceManager: Forward P/Invoke case 0x%p\n", target)); trace->InitForUnmanaged(target); } @@ -1961,9 +1961,9 @@ BOOL InteropDispatchStubManager::TraceManager(Thread *thread, LOG((LF_CORDB, LL_INFO10000, "IDSM::TraceManager: Skipping on arm64-macOS\n")); return FALSE; #else - NDirectMethodDesc *pNMD = (NDirectMethodDesc *)arg; - _ASSERTE(pNMD->IsNDirect()); - PCODE target = (PCODE)pNMD->GetNDirectTarget(); + PInvokeMethodDesc *pNMD = (PInvokeMethodDesc *)arg; + _ASSERTE(pNMD->IsPInvoke()); + PCODE target = (PCODE)pNMD->GetPInvokeTarget(); LOG((LF_CORDB, LL_INFO10000, "IDSM::TraceManager: Vararg P/Invoke case %p\n", target)); trace->InitForUnmanaged(target); diff --git a/src/coreclr/vm/threads.h b/src/coreclr/vm/threads.h index 02fb634057b343..8ff956ff87f9f8 100644 --- a/src/coreclr/vm/threads.h +++ b/src/coreclr/vm/threads.h @@ -126,7 +126,7 @@ class ThreadStore; class MethodDesc; struct PendingSync; class AppDomain; -class NDirect; +class PInvoke; class Frame; class ThreadBaseObject; class AppDomainStack; diff --git a/src/coreclr/vm/threadsuspend.cpp b/src/coreclr/vm/threadsuspend.cpp index 4aa8e67d478bc5..19e40948fe10d2 100644 --- a/src/coreclr/vm/threadsuspend.cpp +++ b/src/coreclr/vm/threadsuspend.cpp @@ -802,7 +802,7 @@ StackWalkAction TAStackCrawlCallBack(CrawlFrame* pCf, void* data) else { MethodDesc *pMD = pCf->GetFunction(); - if (pCf->GetFrame() != NULL && pMD != NULL && (pMD->IsNDirect() || pMD->IsCLRToCOMCall())) + if (pCf->GetFrame() != NULL && pMD != NULL && (pMD->IsPInvoke() || pMD->IsCLRToCOMCall())) { // This may be interop method of an interesting interop call - latch it. frameAction = LatchCurrentFrame; diff --git a/src/coreclr/vm/wasm/helpers.cpp b/src/coreclr/vm/wasm/helpers.cpp index d16676c4408524..7f1fde32c918fc 100644 --- a/src/coreclr/vm/wasm/helpers.cpp +++ b/src/coreclr/vm/wasm/helpers.cpp @@ -58,9 +58,9 @@ extern "C" void STDCALL DelayLoad_Helper_ObjObj() PORTABILITY_ASSERT("DelayLoad_Helper_ObjObj is not implemented on wasm"); } -extern "C" void STDCALL NDirectImportThunk() +extern "C" void STDCALL PInvokeImportThunk() { - PORTABILITY_ASSERT("NDirectImportThunk is not implemented on wasm"); + PORTABILITY_ASSERT("PInvokeImportThunk is not implemented on wasm"); } extern "C" void STDCALL StubPrecodeCode() diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 497a524ed303fa..6ff082cc8805fe 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -633,7 +633,7 @@ Named parameter array cannot be bigger than argument array. - + No PInvoke conversion exists for value passed to Object-typed parameter. diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs index 9e36351239b6bc..eb05f911484605 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs @@ -10,7 +10,7 @@ namespace Microsoft.Diagnostics.DataContractReader.Contracts; internal enum KnownPrecodeType { Stub = 1, - PInvokeImport, // also known as NDirectImport in the runtime + PInvokeImport, // also known as PInvokeImport in the runtime Fixup, ThisPtrRetBuf, UMEntry, diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodDescOptionalSlots.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodDescOptionalSlots.cs index 81efb5b54115b6..028b58f27d1c0c 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodDescOptionalSlots.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/RuntimeTypeSystemHelpers/MethodDescOptionalSlots.cs @@ -37,7 +37,7 @@ private static uint StartOffset(MethodClassification classification, Target targ // See MethodDesc::GetBaseSize and s_ClassificationSizeTable // sizeof(MethodDesc), mcIL // sizeof(FCallMethodDesc), mcFCall - // sizeof(NDirectMethodDesc), mcPInvoke + // sizeof(PInvokeMethodDesc), mcPInvoke // sizeof(EEImplMethodDesc), mcEEImpl // sizeof(ArrayMethodDesc), mcArray // sizeof(InstantiatedMethodDesc), mcInstantiated From 278ebabea7d8770875d0ed6ffebb95ae8ca1a521 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 21:32:48 -0700 Subject: [PATCH 2/8] Rename N/Direct -> PInvoke --- src/coreclr/jit/liveness.cpp | 2 +- src/coreclr/tools/metainfo/mdinfo.cpp | 2 +- src/coreclr/vm/appdomain.cpp | 2 +- src/coreclr/vm/dllimport.cpp | 4 ++-- src/coreclr/vm/frames.h | 2 +- src/coreclr/vm/i386/asmhelpers.S | 2 +- src/coreclr/vm/i386/asmhelpers.asm | 2 +- src/coreclr/vm/jithelpers.cpp | 2 +- src/coreclr/vm/jitinterface.cpp | 2 +- src/coreclr/vm/marshalnative.cpp | 4 ++-- src/coreclr/vm/method.hpp | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/coreclr/jit/liveness.cpp b/src/coreclr/jit/liveness.cpp index 617067e7aeefa8..05786eb1a9045e 100644 --- a/src/coreclr/jit/liveness.cpp +++ b/src/coreclr/jit/liveness.cpp @@ -823,7 +823,7 @@ GenTreeLclVarCommon* Compiler::fgComputeLifeCall(VARSET_TP& life, VARSET_VALARG_ } // TODO: we should generate the code for saving to/restoring - // from the inlined N/Direct frame instead. + // from the inlined PInvoke frame instead. /* Is this call to unmanaged code? */ if (call->IsUnmanaged() && compMethodRequiresPInvokeFrame()) diff --git a/src/coreclr/tools/metainfo/mdinfo.cpp b/src/coreclr/tools/metainfo/mdinfo.cpp index bac3b2158117aa..ced1b33e0903b7 100644 --- a/src/coreclr/tools/metainfo/mdinfo.cpp +++ b/src/coreclr/tools/metainfo/mdinfo.cpp @@ -2912,7 +2912,7 @@ HRESULT MDInfo::GetOneElementType(PCCOR_SIGNATURE pbSigBlob, ULONG ulSigBlob, UL return hr; } // HRESULT MDInfo::GetOneElementType() -// Display the fields of the N/Direct custom value structure. +// Display the fields of the PInvoke custom value structure. void MDInfo::DisplayCorNativeLink(COR_NATIVE_LINK *pCorNLnk, const char *preFix) { diff --git a/src/coreclr/vm/appdomain.cpp b/src/coreclr/vm/appdomain.cpp index 3bc641cda8f3c8..04be5a4fca0b88 100644 --- a/src/coreclr/vm/appdomain.cpp +++ b/src/coreclr/vm/appdomain.cpp @@ -889,7 +889,7 @@ void SystemDomain::Init() { // We are about to start allocating objects, so we must be in cooperative mode. // However, many of the entrypoints to the system (DllGetClassObject and all - // N/Direct exports) get called multiple times. Sometimes they initialize the EE, + // PInvoke exports) get called multiple times. Sometimes they initialize the EE, // but generally they remain in preemptive mode. So we really want to push/pop // the state here: GCX_COOP(); diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 71cd376a9fcd28..60b21f6e3761ae 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -3563,7 +3563,7 @@ static MarshalInfo::MarshalType DoMarshalReturnValue(MetaSig& msig, } //--------------------------------------------------------- -// Creates a new stub for a N/Direct call. Return refcount is 1. +// Creates a new stub for a PInvoke call. Return refcount is 1. // Note that this function may now throw if it fails to create // a stub. //--------------------------------------------------------- @@ -5477,7 +5477,7 @@ namespace } //--------------------------------------------------------- - // Loads the DLL and finds the procaddress for an N/Direct call. + // Loads the DLL and finds the procaddress for an PInvoke call. //--------------------------------------------------------- VOID PInvokeLink(PInvokeMethodDesc *pMD) { diff --git a/src/coreclr/vm/frames.h b/src/coreclr/vm/frames.h index 1e877f8034014c..31b5e321584f46 100644 --- a/src/coreclr/vm/frames.h +++ b/src/coreclr/vm/frames.h @@ -2125,7 +2125,7 @@ struct ReversePInvokeFrame //------------------------------------------------------------------------ // This frame is pushed by any JIT'ted method that contains one or more -// inlined N/Direct calls. Note that the JIT'ted method keeps it pushed +// inlined PInvoke calls. Note that the JIT'ted method keeps it pushed // the whole time to amortize the pushing cost across the entire method. //------------------------------------------------------------------------ diff --git a/src/coreclr/vm/i386/asmhelpers.S b/src/coreclr/vm/i386/asmhelpers.S index 1b112bcb478c89..8d578f3243c5a8 100644 --- a/src/coreclr/vm/i386/asmhelpers.S +++ b/src/coreclr/vm/i386/asmhelpers.S @@ -300,7 +300,7 @@ NESTED_END OnHijackFPTripThread, _TEXT // ========================================================================== // This function is reached only via the embedded ImportThunkGlue code inside // an PInvokeMethodDesc. It's purpose is to load the DLL associated with an -// N/Direct method, then backpatch the DLL target into the methoddesc. +// PInvoke method, then backpatch the DLL target into the methoddesc. // // Initial state: // diff --git a/src/coreclr/vm/i386/asmhelpers.asm b/src/coreclr/vm/i386/asmhelpers.asm index edc4bf4b038fe6..798fefe9f564a4 100644 --- a/src/coreclr/vm/i386/asmhelpers.asm +++ b/src/coreclr/vm/i386/asmhelpers.asm @@ -619,7 +619,7 @@ endif ; FEATURE_HIJACK ;========================================================================== ; This function is reached only via the embedded ImportThunkGlue code inside ; an PInvokeMethodDesc. It's purpose is to load the DLL associated with an -; N/Direct method, then backpatch the DLL target into the methoddesc. +; PInvoke method, then backpatch the DLL target into the methoddesc. ; ; Initial state: ; diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index d14f3155e5310f..b93e15ad331e78 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -1176,7 +1176,7 @@ void JIT_PInvokeEndRarePath() } /*************************************************************/ -// For an inlined N/Direct call (and possibly for other places that need this service) +// For an inlined PInvoke call (and possibly for other places that need this service) // we have noticed that the returning thread should trap for one reason or another. // ECall sets up the frame. diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 0136b9a90465d8..6b76e77ce34014 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10063,7 +10063,7 @@ bool CEEInfo::satisfiesMethodConstraints( /*********************************************************************/ -// return address of fixup area for late-bound N/Direct calls. +// return address of fixup area for late-bound PInvoke calls. void CEEInfo::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, CORINFO_CONST_LOOKUP *pLookup) { diff --git a/src/coreclr/vm/marshalnative.cpp b/src/coreclr/vm/marshalnative.cpp index eec97703f93eeb..f0e5d17c81963e 100644 --- a/src/coreclr/vm/marshalnative.cpp +++ b/src/coreclr/vm/marshalnative.cpp @@ -49,7 +49,7 @@ #endif // FEATURE_JAVAMARSHAL // Prelink -// Does advance loading of an N/Direct library +// Does advance loading of an PInvoke library extern "C" VOID QCALLTYPE MarshalNative_Prelink(MethodDesc * pMD) { QCALL_CONTRACT; @@ -62,7 +62,7 @@ extern "C" VOID QCALLTYPE MarshalNative_Prelink(MethodDesc * pMD) if (!pMD->IsPointingToPrestub()) return; - // Silently ignore if not N/Direct and not runtime generated. + // Silently ignore if not PInvoke and not runtime generated. if (!(pMD->IsPInvoke()) && !(pMD->IsRuntimeSupplied())) return; diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 94da4c85d2271b..1ad5d83156c011 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -166,7 +166,7 @@ enum MethodClassification { mcIL = 0, // IL mcFCall = 1, // FCall (also includes tlbimped ctor, Delegate ctor) - mcPInvoke = 2, // PInvoke method also known as N/Direct in this codebase + mcPInvoke = 2, // PInvoke method also known as PInvoke in this codebase mcEEImpl = 3, // special method; implementation provided by EE (like Delegate Invoke) mcArray = 4, // Array ECall mcInstantiated = 5, // Instantiated generic methods, including descriptors From b6e9dd86b07332d4eee361ba8290a9af678ce4c3 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 21:28:04 -0700 Subject: [PATCH 3/8] Manual touch up --- docs/design/coreclr/botr/profiling.md | 2 +- src/coreclr/debug/ee/controller.cpp | 6 +- src/coreclr/vm/amd64/AsmHelpers.asm | 5 +- src/coreclr/vm/amd64/unixasmhelpers.S | 5 +- src/coreclr/vm/arm/asmhelpers.S | 2 +- src/coreclr/vm/arm64/asmhelpers.S | 2 +- src/coreclr/vm/arm64/asmhelpers.asm | 2 +- src/coreclr/vm/dllimport.cpp | 10 +-- src/coreclr/vm/ilmarshalers.cpp | 2 +- src/coreclr/vm/jitinterface.cpp | 4 +- src/coreclr/vm/loongarch64/asmhelpers.S | 2 +- src/coreclr/vm/method.cpp | 10 +-- src/coreclr/vm/method.hpp | 90 ++++++++++++------------- src/coreclr/vm/methodtablebuilder.cpp | 6 +- src/coreclr/vm/riscv64/asmhelpers.S | 2 +- src/coreclr/vm/stubgen.cpp | 2 +- 16 files changed, 71 insertions(+), 81 deletions(-) diff --git a/docs/design/coreclr/botr/profiling.md b/docs/design/coreclr/botr/profiling.md index 35d57b37c1c166..a01f12bf259216 100644 --- a/docs/design/coreclr/botr/profiling.md +++ b/docs/design/coreclr/botr/profiling.md @@ -477,7 +477,7 @@ A profiler DLL is an unmanaged DLL that is effectively running as part of the CL Combining Managed and Unmanaged Code in a Code Profiler ======================================================= -A close review of the CLR Profiling API creates the impression that you could write a profiler that has managed and unmanaged components that call to each other through COM Interop or ndirect calls. +A close review of the CLR Profiling API creates the impression that you could write a profiler that has managed and unmanaged components that call to each other through COM Interop or PInvoke calls. Although this is possible from a design perspective, the CLR Profiling API does not support it. A CLR profiler is supposed to be purely unmanaged. Attempts to combine managed and unmanaged code from a CLR profiler can cause crashes, hangs and deadlocks. The danger is clear since the managed parts of the profiler will "fire" events back to its unmanaged component, which subsequently would call into the managed part of the profiler etc. The danger at this point is clear. diff --git a/src/coreclr/debug/ee/controller.cpp b/src/coreclr/debug/ee/controller.cpp index f7dfde2ae67f83..794f0a693bfeb8 100644 --- a/src/coreclr/debug/ee/controller.cpp +++ b/src/coreclr/debug/ee/controller.cpp @@ -5921,7 +5921,7 @@ bool DebuggerStepper::TrapStep(ControllerStackInfo *info, bool in) #endif // Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value in that, and - // it was causing problems creating a stepper while sitting in ndirect stubs after we'd returned from the unmanaged + // it was causing problems creating a stepper while sitting in PInvoke stubs after we'd returned from the unmanaged // function that had been called. DebuggerJitInfo *ji = info->m_activeFrame.GetJitInfoFromFrame(); if( ji != NULL ) @@ -6537,7 +6537,7 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio _ASSERTE(dji != NULL); // Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value - // in that, and it was causing problems creating a stepper while sitting in ndirect stubs after we'd + // in that, and it was causing problems creating a stepper while sitting in PInvoke stubs after we'd // returned from the unmanaged function that had been called. ULONG reloffset = info->m_activeFrame.relOffset; @@ -6816,7 +6816,7 @@ bool DebuggerStepper::SetRangesFromIL(DebuggerJitInfo *dji, COR_DEBUG_STEP_RANGE CONTRACTL_END; // Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value in that, and - // it was causing problems creating a stepper while sitting in ndirect stubs after we'd returned from the unmanaged + // it was causing problems creating a stepper while sitting in PInvoke stubs after we'd returned from the unmanaged // function that had been called. MethodDesc *fd = dji->m_nativeCodeVersion.GetMethodDesc(); diff --git a/src/coreclr/vm/amd64/AsmHelpers.asm b/src/coreclr/vm/amd64/AsmHelpers.asm index ee580ba7ec2583..178ffe4bddcbe0 100644 --- a/src/coreclr/vm/amd64/AsmHelpers.asm +++ b/src/coreclr/vm/amd64/AsmHelpers.asm @@ -25,10 +25,7 @@ extern g_TrapReturningThreads:DWORD ;; ;; PInvokeImportThunk ;; -;; In addition to being called by the EE, this function can be called -;; directly from code generated by JIT64 for CRT optimized direct -;; P/Invoke calls. If it is modified, the JIT64 compiler's code -;; generation will need to altered accordingly. +;; The call in PInvokeImportPrecode points to this function. ;; ; EXTERN_C VOID __stdcall PInvokeImportThunk(); NESTED_ENTRY PInvokeImportThunk, _TEXT diff --git a/src/coreclr/vm/amd64/unixasmhelpers.S b/src/coreclr/vm/amd64/unixasmhelpers.S index a3491cb2affeaf..53115def14a26b 100644 --- a/src/coreclr/vm/amd64/unixasmhelpers.S +++ b/src/coreclr/vm/amd64/unixasmhelpers.S @@ -9,10 +9,7 @@ // // PInvokeImportThunk // -// In addition to being called by the EE, this function can be called -// directly from code generated by JIT64 for CRT optimized direct -// P/Invoke calls. If it is modified, the JIT64 compiler's code -// generation will need to altered accordingly. +// The call in PInvokeImportPrecode points to this function // // EXTERN_C VOID __stdcall PInvokeImportThunk()// NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler diff --git a/src/coreclr/vm/arm/asmhelpers.S b/src/coreclr/vm/arm/asmhelpers.S index a929e8121d73da..1e485992c09ec9 100644 --- a/src/coreclr/vm/arm/asmhelpers.S +++ b/src/coreclr/vm/arm/asmhelpers.S @@ -187,7 +187,7 @@ ThePreStubPatchLabel: LEAF_END ThePreStubPatch, _TEXT // ------------------------------------------------------------------ -// The call in ndirect import precode points to this function. +// The call in PInvokeImportPrecode points to this function. NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_PUSH "{r0-r4,r7,r8,lr}" // Spill general argument registers, return address and diff --git a/src/coreclr/vm/arm64/asmhelpers.S b/src/coreclr/vm/arm64/asmhelpers.S index b37ad6186019ba..801995254258d7 100644 --- a/src/coreclr/vm/arm64/asmhelpers.S +++ b/src/coreclr/vm/arm64/asmhelpers.S @@ -31,7 +31,7 @@ LEAF_END GetDataCacheZeroIDReg, _TEXT LEAF_END GetSveLengthFromOS, _TEXT // ------------------------------------------------------------------ -// The call in ndirect import precode points to this function. +// The call in PInvokeImportPrecode points to this function. NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_SAVE_REG_PAIR_INDEXED fp, lr, -224 diff --git a/src/coreclr/vm/arm64/asmhelpers.asm b/src/coreclr/vm/arm64/asmhelpers.asm index 95551bf24d95b3..72804cc6084350 100644 --- a/src/coreclr/vm/arm64/asmhelpers.asm +++ b/src/coreclr/vm/arm64/asmhelpers.asm @@ -96,7 +96,7 @@ LEAF_END ; ------------------------------------------------------------------ -; The call in ndirect import precode points to this function. +; The call in PInvokeImportPrecode points to this function. NESTED_ENTRY PInvokeImportThunk PROLOG_SAVE_REG_PAIR fp, lr, #-224! diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 60b21f6e3761ae..4a65bf986d23d2 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -2123,7 +2123,7 @@ void PInvokeStubLinker::DoPInvoke(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth { EmitLoadStubContext(pcsEmit, dwStubFlags); - pcsEmit->EmitLDC(offsetof(PInvokeMethodDesc, ndirect.m_pPInvokeTarget)); + pcsEmit->EmitLDC(offsetof(PInvokeMethodDesc, m_pPInvokeTarget)); pcsEmit->EmitADD(); pcsEmit->EmitLDIND_I(); } @@ -2699,7 +2699,7 @@ void PInvokeStaticSigInfo::DllImportInit( PRECONDITION(CheckPointer(pMD)); // These preconditions to prevent multithreaded regression - // where pMD->ndirect.m_szLibName was passed in directly, cleared + // where pMD->m_szLibName was passed in directly, cleared // by this API, then accessed on another thread before being reset here. PRECONDITION(CheckPointer(ppLibName, NULL_OK) && (!ppLibName || *ppLibName == NULL)); PRECONDITION(CheckPointer(ppEntryPointName, NULL_OK) && (!ppEntryPointName || *ppEntryPointName == NULL)); @@ -4379,10 +4379,10 @@ namespace } else { - pNMD->ndirect.m_pszLibName = libName; + pNMD->m_pszLibName = libName; } - pNMD->ndirect.m_pszEntrypointName = entryPointName; + pNMD->m_pszEntrypointName = entryPointName; // Do not publish incomplete prestub flags or you will introduce a race condition. pNMD->InterlockedSetPInvokeFlags(ndirectflags | PInvokeMethodDesc::kPInvokePopulated); @@ -5799,7 +5799,7 @@ VOID PInvokeMethodDesc::SetPInvokeTarget(LPVOID pTarget) } CONTRACTL_END; - ndirect.m_pPInvokeTarget = pTarget; + m_pPInvokeTarget = pTarget; } void MarshalStructViaILStub(MethodDesc* pStubMD, void* pManagedData, void* pNativeData, StructMarshalStubs::MarshalOperation operation, void** ppCleanupWorkList /* = nullptr */) diff --git a/src/coreclr/vm/ilmarshalers.cpp b/src/coreclr/vm/ilmarshalers.cpp index 82c434bd1a0e88..b8bd7360dbe5b4 100644 --- a/src/coreclr/vm/ilmarshalers.cpp +++ b/src/coreclr/vm/ilmarshalers.cpp @@ -3985,7 +3985,7 @@ BOOL ILNativeArrayMarshaler::CheckSizeParamIndexArg( Module *pModule = m_pargs->m_pMarshalInfo->GetModule(); _ASSERT(pModule); - SigTypeContext emptyTypeContext; // this is an empty type context: ndirect and COM calls are guaranteed to not be generics. + SigTypeContext emptyTypeContext; // this is an empty type context: PInvoke and COM calls are guaranteed to not be generics. MetaSig msig(pMD->GetSignature(), pModule, &emptyTypeContext); diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index 6b76e77ce34014..ee739879b6649c 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -10089,7 +10089,7 @@ void CEEInfo::getAddressOfPInvokeTarget(CORINFO_METHOD_HANDLE method, else { pLookup->accessType = IAT_PVALUE; - pLookup->addr = (LPVOID)&(pNMD->ndirect.m_pPInvokeTarget); + pLookup->addr = (LPVOID)&(pNMD->m_pPInvokeTarget); } EE_TO_JIT_TRANSITION(); @@ -13815,7 +13815,7 @@ BOOL LoadDynamicInfoEntry(Module *currentModule, _ASSERTE(pMethod->IsPInvoke()); PInvokeMethodDesc *pMD = (PInvokeMethodDesc*)pMethod; - result = (size_t)(LPVOID)&(pMD->ndirect.m_pPInvokeTarget); + result = (size_t)(LPVOID)&(pMD->m_pPInvokeTarget); } break; diff --git a/src/coreclr/vm/loongarch64/asmhelpers.S b/src/coreclr/vm/loongarch64/asmhelpers.S index 1fbb60afbfd647..fce422d96d711e 100644 --- a/src/coreclr/vm/loongarch64/asmhelpers.S +++ b/src/coreclr/vm/loongarch64/asmhelpers.S @@ -359,7 +359,7 @@ NESTED_ENTRY ThePreStub, _TEXT, NoHandler NESTED_END ThePreStub, _TEXT // ------------------------------------------------------------------ -// The call in ndirect import precode points to this function. +// The call in PInvokeImportPrecode points to this function. NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler // $fp,$ra diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index ba8f0e2c282240..68da9a8f26fafc 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -153,10 +153,10 @@ BOOL PInvokeMethodDesc::HasDefaultDllImportSearchPathsAttribute() if(IsDefaultDllImportSearchPathsAttributeCached()) { - return (ndirect.m_wFlags & kDefaultDllImportSearchPathsStatus) != 0; + return (m_wPInvokeFlags & kDefaultDllImportSearchPathsStatus) != 0; } - BOOL attributeIsFound = GetDefaultDllImportSearchPathsAttributeValue(GetModule(),GetMemberDef(),&ndirect.m_DefaultDllImportSearchPathsAttributeValue); + BOOL attributeIsFound = GetDefaultDllImportSearchPathsAttributeValue(GetModule(),GetMemberDef(),&m_DefaultDllImportSearchPathsAttributeValue); if(attributeIsFound ) { @@ -167,7 +167,7 @@ BOOL PInvokeMethodDesc::HasDefaultDllImportSearchPathsAttribute() InterlockedSetPInvokeFlags(kDefaultDllImportSearchPathsIsCached); } - return (ndirect.m_wFlags & kDefaultDllImportSearchPathsStatus) != 0; + return (m_wPInvokeFlags & kDefaultDllImportSearchPathsStatus) != 0; } #endif //!DACCESS_COMPILE @@ -3328,7 +3328,7 @@ void PInvokeMethodDesc::InterlockedSetPInvokeFlags(WORD wFlags) // Since InterlockedCompareExchange only works on ULONGs, // we'll have to operate on the entire ULONG. Ugh. - WORD *pFlags = &ndirect.m_wFlags; + WORD *pFlags = &m_wPInvokeFlags; // Make sure that m_flags is aligned on a 4 byte boundry _ASSERTE( ( ((size_t) pFlags) & (sizeof(ULONG)-1) ) == 0); @@ -3463,7 +3463,7 @@ void PInvokeMethodDesc::EnsureStackArgumentSize() { STANDARD_VM_CONTRACT; - if (ndirect.m_cbStackArgumentSize == 0xFFFF) + if (m_cbStackArgumentSize == 0xFFFF) { // Marshalling required check sets the stack size as side-effect when marshalling is not required. if (MarshalingRequired()) diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 1ad5d83156c011..d03df25824f0d8 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -2984,40 +2984,36 @@ typedef DPTR(PInvokeImportThunkGlue) PTR_PInvokeImportThunkGlue; class PInvokeMethodDesc : public MethodDesc { public: - struct temp1 - { - // Information about the entrypoint - PTR_CUTF8 m_pszEntrypointName; + // Information about the entrypoint + PTR_CUTF8 m_pszEntrypointName; - union - { - PTR_CUTF8 m_pszLibName; - DWORD m_dwECallID; // ECallID for QCalls - }; + union + { + PTR_CUTF8 m_pszLibName; + DWORD m_dwECallID; // ECallID for QCalls + }; - // The JIT generates an indirect call through this location in some cases. - // Initialized to PInvokeImportThunkGlue. Patched to the true target or - // host interceptor stub or alignment thunk after linking. - LPVOID m_pPInvokeTarget; + // The JIT generates an indirect call through this location in some cases. + // Initialized to PInvokeImportThunkGlue. Patched to the true target or + // host interceptor stub or alignment thunk after linking. + LPVOID m_pPInvokeTarget; #ifdef HAS_NDIRECT_IMPORT_PRECODE - PTR_PInvokeImportThunkGlue m_pImportThunkGlue; + PTR_PInvokeImportThunkGlue m_pImportThunkGlue; #else // HAS_NDIRECT_IMPORT_PRECODE - PInvokeImportThunkGlue m_ImportThunkGlue; + PInvokeImportThunkGlue m_ImportThunkGlue; #endif // HAS_NDIRECT_IMPORT_PRECODE - ULONG m_DefaultDllImportSearchPathsAttributeValue; // DefaultDllImportSearchPathsAttribute is saved. + ULONG m_DefaultDllImportSearchPathsAttributeValue; // DefaultDllImportSearchPathsAttribute is saved. - // Various attributes needed at runtime. - WORD m_wFlags; + // Various attributes needed at runtime. + WORD m_wPInvokeFlags; #if defined(TARGET_X86) - // Size of outgoing arguments (on stack). Note that in order to get the @n stdcall name decoration, - WORD m_cbStackArgumentSize; + // Size of outgoing arguments (on stack). Note that in order to get the @n stdcall name decoration, + WORD m_cbStackArgumentSize; #endif // defined(TARGET_X86) - } ndirect; - enum Flags { // There are two groups of flag bits here each which gets initialized @@ -3076,14 +3072,14 @@ class PInvokeMethodDesc : public MethodDesc { STANDARD_VM_CONTRACT; - if ((ndirect.m_wFlags & kIsMarshalingRequiredCached) == 0) + if ((m_wPInvokeFlags & kIsMarshalingRequiredCached) == 0) { // Compute the flag and cache the result InterlockedSetPInvokeFlags(kIsMarshalingRequiredCached | (ComputeMarshalingRequired() ? kCachedMarshalingRequired : 0)); } - _ASSERTE((ndirect.m_wFlags & kIsMarshalingRequiredCached) != 0); - return (ndirect.m_wFlags & kCachedMarshalingRequired) != 0; + _ASSERTE((m_wPInvokeFlags & kIsMarshalingRequiredCached) != 0); + return (m_wPInvokeFlags & kCachedMarshalingRequired) != 0; } BOOL ComputeMarshalingRequired(); @@ -3094,34 +3090,34 @@ class PInvokeMethodDesc : public MethodDesc void SetIsEarlyBound() { LIMITED_METHOD_CONTRACT; - ndirect.m_wFlags |= kEarlyBound; + m_wPInvokeFlags |= kEarlyBound; } BOOL IsEarlyBound() { LIMITED_METHOD_CONTRACT; - return (ndirect.m_wFlags & kEarlyBound) != 0; + return (m_wPInvokeFlags & kEarlyBound) != 0; } BOOL IsNativeAnsi() const { LIMITED_METHOD_CONTRACT; - return (ndirect.m_wFlags & kNativeAnsi) != 0; + return (m_wPInvokeFlags & kNativeAnsi) != 0; } BOOL IsNativeNoMangled() const { LIMITED_METHOD_CONTRACT; - return (ndirect.m_wFlags & kNativeNoMangle) != 0; + return (m_wPInvokeFlags & kNativeNoMangle) != 0; } PTR_CUTF8 GetLibNameRaw() { LIMITED_METHOD_DAC_CONTRACT; - return ndirect.m_pszLibName; + return m_pszLibName; } #ifndef DACCESS_COMPILE @@ -3129,7 +3125,7 @@ class PInvokeMethodDesc : public MethodDesc { LIMITED_METHOD_CONTRACT; - return IsQCall() ? "QCall" : ndirect.m_pszLibName; + return IsQCall() ? "QCall" : m_pszLibName; } #endif // !DACCESS_COMPILE @@ -3137,28 +3133,28 @@ class PInvokeMethodDesc : public MethodDesc { LIMITED_METHOD_DAC_CONTRACT; - return ndirect.m_pszEntrypointName; + return m_pszEntrypointName; } BOOL IsVarArgs() const { LIMITED_METHOD_DAC_CONTRACT; - return (ndirect.m_wFlags & kVarArgs) != 0; + return (m_wPInvokeFlags & kVarArgs) != 0; } BOOL IsStdCall() const { LIMITED_METHOD_DAC_CONTRACT; - return (ndirect.m_wFlags & kStdCall) != 0; + return (m_wPInvokeFlags & kStdCall) != 0; } BOOL IsThisCall() const { LIMITED_METHOD_DAC_CONTRACT; - return (ndirect.m_wFlags & kThisCall) != 0; + return (m_wPInvokeFlags & kThisCall) != 0; } // Returns TRUE if this MethodDesc is internal call from CoreLib to VM @@ -3166,7 +3162,7 @@ class PInvokeMethodDesc : public MethodDesc { LIMITED_METHOD_DAC_CONTRACT; - return (ndirect.m_wFlags & kIsQCall) != 0; + return (m_wPInvokeFlags & kIsQCall) != 0; } BOOL HasDefaultDllImportSearchPathsAttribute(); @@ -3174,32 +3170,32 @@ class PInvokeMethodDesc : public MethodDesc BOOL IsDefaultDllImportSearchPathsAttributeCached() { LIMITED_METHOD_CONTRACT; - return (ndirect.m_wFlags & kDefaultDllImportSearchPathsIsCached) != 0; + return (m_wPInvokeFlags & kDefaultDllImportSearchPathsIsCached) != 0; } BOOL IsPopulated() { LIMITED_METHOD_CONTRACT; - return (VolatileLoad(&ndirect.m_wFlags) & kPInvokePopulated) != 0; + return (VolatileLoad(&m_wPInvokeFlags) & kPInvokePopulated) != 0; } ULONG DefaultDllImportSearchPathsAttributeCachedValue() { LIMITED_METHOD_CONTRACT; - return ndirect.m_DefaultDllImportSearchPathsAttributeValue & 0xFFFFFFFD; + return m_DefaultDllImportSearchPathsAttributeValue & 0xFFFFFFFD; } BOOL DllImportSearchAssemblyDirectory() { LIMITED_METHOD_CONTRACT; - return (ndirect.m_DefaultDllImportSearchPathsAttributeValue & 0x2) != 0; + return (m_DefaultDllImportSearchPathsAttributeValue & 0x2) != 0; } PTR_PInvokeImportThunkGlue GetPInvokeImportThunkGlue() { LIMITED_METHOD_DAC_CONTRACT; - return ndirect.m_pImportThunkGlue; + return m_pImportThunkGlue; } LPVOID GetPInvokeTarget() @@ -3207,7 +3203,7 @@ class PInvokeMethodDesc : public MethodDesc LIMITED_METHOD_CONTRACT; _ASSERTE(IsPInvoke()); - return ndirect.m_pPInvokeTarget; + return m_pPInvokeTarget; } VOID SetPInvokeTarget(LPVOID pTarget); @@ -3248,13 +3244,13 @@ class PInvokeMethodDesc : public MethodDesc } // Don't write to the field if it's already initialized to avoid creating private pages (NGEN) - if (ndirect.m_cbStackArgumentSize == 0xFFFF) + if (m_cbStackArgumentSize == 0xFFFF) { - ndirect.m_cbStackArgumentSize = cbDstBuffer; + m_cbStackArgumentSize = cbDstBuffer; } else { - _ASSERTE(ndirect.m_cbStackArgumentSize == cbDstBuffer); + _ASSERTE(m_cbStackArgumentSize == cbDstBuffer); } #endif // defined(TARGET_X86) } @@ -3266,11 +3262,11 @@ class PInvokeMethodDesc : public MethodDesc { LIMITED_METHOD_DAC_CONTRACT; - _ASSERTE(ndirect.m_cbStackArgumentSize != 0xFFFF); + _ASSERTE(m_cbStackArgumentSize != 0xFFFF); // If we have a methoddesc, stackArgSize is the number of bytes of // the outgoing marshalling buffer. - return ndirect.m_cbStackArgumentSize; + return m_cbStackArgumentSize; } #endif // defined(TARGET_X86) diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 9e8c8d42c0d786..54e32b82d7fe77 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -6176,14 +6176,14 @@ MethodTableBuilder::InitMethodDesc( PInvokeMethodDesc *pNewNMD = (PInvokeMethodDesc*)pNewMD; #ifdef HAS_NDIRECT_IMPORT_PRECODE - pNewNMD->ndirect.m_pImportThunkGlue = Precode::Allocate(PRECODE_NDIRECT_IMPORT, pNewMD, + pNewNMD->m_pImportThunkGlue = Precode::Allocate(PRECODE_NDIRECT_IMPORT, pNewMD, GetLoaderAllocator(), GetMemTracker())->AsPInvokeImportPrecode(); #else // !HAS_NDIRECT_IMPORT_PRECODE pNewNMD->GetPInvokeImportThunkGlue()->Init(pNewNMD); #endif // !HAS_NDIRECT_IMPORT_PRECODE #if defined(TARGET_X86) - pNewNMD->ndirect.m_cbStackArgumentSize = 0xFFFF; + pNewNMD->m_cbStackArgumentSize = 0xFFFF; #endif // defined(TARGET_X86) // If the RVA of a native method is set, this is an early-bound IJW call @@ -6194,7 +6194,7 @@ MethodTableBuilder::InitMethodDesc( pNewNMD->SetIsEarlyBound(); } - pNewNMD->ndirect.m_pPInvokeTarget = pNewNMD->GetPInvokeImportThunkGlue()->GetEntrypoint(); + pNewNMD->m_pPInvokeTarget = pNewNMD->GetPInvokeImportThunkGlue()->GetEntrypoint(); } break; diff --git a/src/coreclr/vm/riscv64/asmhelpers.S b/src/coreclr/vm/riscv64/asmhelpers.S index beb24c3c5f4516..1c03436880c0cc 100644 --- a/src/coreclr/vm/riscv64/asmhelpers.S +++ b/src/coreclr/vm/riscv64/asmhelpers.S @@ -318,7 +318,7 @@ NESTED_ENTRY ThePreStub, _TEXT, NoHandler NESTED_END ThePreStub, _TEXT // ------------------------------------------------------------------ -// The call in ndirect import precode points to this function. +// The call in PInvokeImportPrecode points to this function. NESTED_ENTRY PInvokeImportThunk, _TEXT, NoHandler PROLOG_SAVE_REG_PAIR_INDEXED fp, ra, 0xa0 SAVE_ARGUMENT_REGISTERS sp, 0x20 diff --git a/src/coreclr/vm/stubgen.cpp b/src/coreclr/vm/stubgen.cpp index 30e5f8f0572b7e..06c99d1cb0cbd6 100644 --- a/src/coreclr/vm/stubgen.cpp +++ b/src/coreclr/vm/stubgen.cpp @@ -2517,7 +2517,7 @@ ILStubLinker::ILStubLinker(Module* pStubSigModule, const Signature &signature, S if ((flags & (ILSTUB_LINKER_FLAG_TARGET_HAS_THIS | ILSTUB_LINKER_FLAG_NDIRECT)) == ILSTUB_LINKER_FLAG_TARGET_HAS_THIS) { - // ndirect native sig never has a 'this' pointer + // PInvoke native sig never has a 'this' pointer uNativeCallingConv |= IMAGE_CEE_CS_CALLCONV_HASTHIS; } From 2b765677d47f85fb6b5e7dc125f03a3e9b5b996c Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 22:16:24 -0700 Subject: [PATCH 4/8] Update src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../Contracts/PrecodeStubs_Common.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs index eb05f911484605..88c61ef14cb742 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs @@ -10,7 +10,7 @@ namespace Microsoft.Diagnostics.DataContractReader.Contracts; internal enum KnownPrecodeType { Stub = 1, - PInvokeImport, // also known as PInvokeImport in the runtime + PInvokeImport, Fixup, ThisPtrRetBuf, UMEntry, From 62954aee76ed6cf65a6fdcc1bb022d7c968d2472 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 22:16:34 -0700 Subject: [PATCH 5/8] Update src/coreclr/vm/method.hpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/coreclr/vm/method.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index d03df25824f0d8..18d27fad3bf141 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -166,7 +166,7 @@ enum MethodClassification { mcIL = 0, // IL mcFCall = 1, // FCall (also includes tlbimped ctor, Delegate ctor) - mcPInvoke = 2, // PInvoke method also known as PInvoke in this codebase + mcPInvoke = 2, // PInvoke method mcEEImpl = 3, // special method; implementation provided by EE (like Delegate Invoke) mcArray = 4, // Array ECall mcInstantiated = 5, // Instantiated generic methods, including descriptors From 0987dfa2062a98680e3d85cfd7ecab3eb4ce403f Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 22:18:30 -0700 Subject: [PATCH 6/8] Update src/libraries/System.Private.CoreLib/src/Resources/Strings.resx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/libraries/System.Private.CoreLib/src/Resources/Strings.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx index 6ff082cc8805fe..ed416b75f944c2 100644 --- a/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx +++ b/src/libraries/System.Private.CoreLib/src/Resources/Strings.resx @@ -634,7 +634,7 @@ Named parameter array cannot be bigger than argument array. - No PInvoke conversion exists for value passed to Object-typed parameter. + No PInvoke conversion exists for the value passed to an Object-typed parameter. Array was not a one-dimensional array. From ee98291563776b2e76d8be0c9ebb4afcd0db1834 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 30 Jul 2025 22:48:14 -0700 Subject: [PATCH 7/8] NDIRECTSTUB -> PINVOKESTUB --- src/coreclr/vm/clrtocomcall.cpp | 10 +-- src/coreclr/vm/comdelegate.cpp | 4 +- src/coreclr/vm/comtoclrcall.cpp | 10 +-- src/coreclr/vm/dllimport.cpp | 118 +++++++++++++-------------- src/coreclr/vm/dllimport.h | 86 +++++++++---------- src/coreclr/vm/dllimportcallback.cpp | 6 +- src/coreclr/vm/method.cpp | 2 +- 7 files changed, 118 insertions(+), 118 deletions(-) diff --git a/src/coreclr/vm/clrtocomcall.cpp b/src/coreclr/vm/clrtocomcall.cpp index ced3bda43099bc..c4983ca0dd2cce 100644 --- a/src/coreclr/vm/clrtocomcall.cpp +++ b/src/coreclr/vm/clrtocomcall.cpp @@ -111,7 +111,7 @@ CLRToCOMCallInfo *CLRToCOMCall::PopulateCLRToCOMCallMethodDesc(MethodDesc* pMD, // Compute PInvokeStubFlags // - DWORD dwStubFlags = NDIRECTSTUB_FL_COM; + DWORD dwStubFlags = PINVOKESTUB_FL_COM; // Determine if this is a special COM event call. BOOL fComEventCall = pItfMT->IsComEventItfType(); @@ -120,10 +120,10 @@ CLRToCOMCallInfo *CLRToCOMCall::PopulateCLRToCOMCallMethodDesc(MethodDesc* pMD, BOOL fLateBound = !fComEventCall && pItfMT->IsInterface() && pItfMT->GetComInterfaceType() == ifDispatch; if (fLateBound) - dwStubFlags |= NDIRECTSTUB_FL_COMLATEBOUND; + dwStubFlags |= PINVOKESTUB_FL_COMLATEBOUND; if (fComEventCall) - dwStubFlags |= NDIRECTSTUB_FL_COMEVENTCALL; + dwStubFlags |= PINVOKESTUB_FL_COMEVENTCALL; BOOL BestFit = TRUE; BOOL ThrowOnUnmappableChar = FALSE; @@ -131,10 +131,10 @@ CLRToCOMCallInfo *CLRToCOMCall::PopulateCLRToCOMCallMethodDesc(MethodDesc* pMD, ReadBestFitCustomAttribute(pMD, &BestFit, &ThrowOnUnmappableChar); if (BestFit) - dwStubFlags |= NDIRECTSTUB_FL_BESTFIT; + dwStubFlags |= PINVOKESTUB_FL_BESTFIT; if (ThrowOnUnmappableChar) - dwStubFlags |= NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR; + dwStubFlags |= PINVOKESTUB_FL_THROWONUNMAPPABLECHAR; // // fill in out param diff --git a/src/coreclr/vm/comdelegate.cpp b/src/coreclr/vm/comdelegate.cpp index f11387d569b18f..28b75bdf0d6932 100644 --- a/src/coreclr/vm/comdelegate.cpp +++ b/src/coreclr/vm/comdelegate.cpp @@ -1541,7 +1541,7 @@ PCODE COMDelegate::GetStubForILStub(EEImplMethodDesc* pDelegateMD, MethodDesc** ValidateDelegatePInvoke(pDelegateMD); - dwStubFlags |= NDIRECTSTUB_FL_DELEGATE; + dwStubFlags |= PINVOKESTUB_FL_DELEGATE; RETURN PInvoke::GetStubForILStub(pDelegateMD, ppStubMD, dwStubFlags); } @@ -1555,7 +1555,7 @@ MethodDesc* COMDelegate::GetILStubMethodDesc(EEImplMethodDesc* pDelegateMD, DWOR MethodTable *pMT = pDelegateMD->GetMethodTable(); - dwStubFlags |= NDIRECTSTUB_FL_DELEGATE; + dwStubFlags |= PINVOKESTUB_FL_DELEGATE; PInvokeStaticSigInfo sigInfo(pDelegateMD); return PInvoke::CreateCLRToNativeILStub(&sigInfo, dwStubFlags, pDelegateMD); diff --git a/src/coreclr/vm/comtoclrcall.cpp b/src/coreclr/vm/comtoclrcall.cpp index 45e2c0554aba0f..14d78fd04dab29 100644 --- a/src/coreclr/vm/comtoclrcall.cpp +++ b/src/coreclr/vm/comtoclrcall.cpp @@ -1212,7 +1212,7 @@ void ComCall::PopulateComCallMethodDesc(ComCallMethodDesc *pCMD, DWORD *pdwStubF } CONTRACTL_END; - DWORD dwStubFlags = NDIRECTSTUB_FL_COM | NDIRECTSTUB_FL_REVERSE_INTEROP; + DWORD dwStubFlags = PINVOKESTUB_FL_COM | PINVOKESTUB_FL_REVERSE_INTEROP; BOOL BestFit = TRUE; BOOL ThrowOnUnmappableChar = FALSE; @@ -1220,9 +1220,9 @@ void ComCall::PopulateComCallMethodDesc(ComCallMethodDesc *pCMD, DWORD *pdwStubF if (pCMD->IsFieldCall()) { if (pCMD->IsFieldGetter()) - dwStubFlags |= NDIRECTSTUB_FL_FIELDGETTER; + dwStubFlags |= PINVOKESTUB_FL_FIELDGETTER; else - dwStubFlags |= NDIRECTSTUB_FL_FIELDSETTER; + dwStubFlags |= PINVOKESTUB_FL_FIELDSETTER; FieldDesc *pFD = pCMD->GetFieldDesc(); _ASSERTE(IsMemberVisibleFromCom(pFD->GetApproxEnclosingMethodTable(), pFD->GetMemberDef(), mdTokenNil) && "Calls are not permitted on this member since it isn't visible from COM. The only way you can have reached this code path is if your native interface doesn't match the managed interface."); @@ -1241,10 +1241,10 @@ void ComCall::PopulateComCallMethodDesc(ComCallMethodDesc *pCMD, DWORD *pdwStubF } if (BestFit) - dwStubFlags |= NDIRECTSTUB_FL_BESTFIT; + dwStubFlags |= PINVOKESTUB_FL_BESTFIT; if (ThrowOnUnmappableChar) - dwStubFlags |= NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR; + dwStubFlags |= PINVOKESTUB_FL_THROWONUNMAPPABLECHAR; // // fill in out param diff --git a/src/coreclr/vm/dllimport.cpp b/src/coreclr/vm/dllimport.cpp index 4a65bf986d23d2..e6171f60ebebe2 100644 --- a/src/coreclr/vm/dllimport.cpp +++ b/src/coreclr/vm/dllimport.cpp @@ -1014,7 +1014,7 @@ class ILStubState : public StubState // Native Signature // SString strNativeSignature; - if (m_dwStubFlags & NDIRECTSTUB_FL_REVERSE_INTEROP) + if (m_dwStubFlags & PINVOKESTUB_FL_REVERSE_INTEROP) { // Reverse interop. Use StubSignature strNativeSignature = stubMethodSignature; @@ -1068,19 +1068,19 @@ class ILStubState : public StubState // Fire the event // DWORD dwFlags = 0; - if (m_dwStubFlags & NDIRECTSTUB_FL_REVERSE_INTEROP) + if (m_dwStubFlags & PINVOKESTUB_FL_REVERSE_INTEROP) dwFlags |= ETW_IL_STUB_FLAGS_REVERSE_INTEROP; #ifdef FEATURE_COMINTEROP - if (m_dwStubFlags & NDIRECTSTUB_FL_COM) + if (m_dwStubFlags & PINVOKESTUB_FL_COM) dwFlags |= ETW_IL_STUB_FLAGS_COM_INTEROP; #endif // FEATURE_COMINTEROP - if (m_dwStubFlags & NDIRECTSTUB_FL_DELEGATE) + if (m_dwStubFlags & PINVOKESTUB_FL_DELEGATE) dwFlags |= ETW_IL_STUB_FLAGS_DELEGATE; - if (m_dwStubFlags & NDIRECTSTUB_FL_CONVSIGASVARARG) + if (m_dwStubFlags & PINVOKESTUB_FL_CONVSIGASVARARG) dwFlags |= ETW_IL_STUB_FLAGS_VARARG; - if (m_dwStubFlags & NDIRECTSTUB_FL_UNMANAGED_CALLI) + if (m_dwStubFlags & PINVOKESTUB_FL_UNMANAGED_CALLI) dwFlags |= ETW_IL_STUB_FLAGS_UNMANAGED_CALLI; - if (m_dwStubFlags & NDIRECTSTUB_FL_STRUCT_MARSHAL) + if (m_dwStubFlags & PINVOKESTUB_FL_STRUCT_MARSHAL) dwFlags |= ETW_IL_STUB_FLAGS_STRUCT_MARSHAL; DWORD dwToken = 0; @@ -1137,22 +1137,22 @@ class ILStubState : public StubState { LIMITED_METHOD_CONTRACT; LOG((facility, level, "dwStubFlags: 0x%08x\n", dwStubFlags)); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_CONVSIGASVARARG, " NDIRECTSTUB_FL_CONVSIGASVARARG\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_BESTFIT, " NDIRECTSTUB_FL_BESTFIT\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR, " NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY, " NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_DELEGATE, " NDIRECTSTUB_FL_DELEGATE\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_DOHRESULTSWAPPING, " NDIRECTSTUB_FL_DOHRESULTSWAPPING\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_REVERSE_INTEROP, " NDIRECTSTUB_FL_REVERSE_INTEROP\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_STRUCT_MARSHAL, " NDIRECTSTUB_FL_STRUCT_MARSHAL\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_CONVSIGASVARARG, " PINVOKESTUB_FL_CONVSIGASVARARG\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_BESTFIT, " PINVOKESTUB_FL_BESTFIT\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_THROWONUNMAPPABLECHAR, " PINVOKESTUB_FL_THROWONUNMAPPABLECHAR\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY, " PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_DELEGATE, " PINVOKESTUB_FL_DELEGATE\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_DOHRESULTSWAPPING, " PINVOKESTUB_FL_DOHRESULTSWAPPING\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_REVERSE_INTEROP, " PINVOKESTUB_FL_REVERSE_INTEROP\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_STRUCT_MARSHAL, " PINVOKESTUB_FL_STRUCT_MARSHAL\n", facility, level); #ifdef FEATURE_COMINTEROP - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_COM, " NDIRECTSTUB_FL_COM\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_COM, " PINVOKESTUB_FL_COM\n", facility, level); #endif // FEATURE_COMINTEROP - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL, " NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_UNMANAGED_CALLI, " NDIRECTSTUB_FL_UNMANAGED_CALLI\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_GENERATEDEBUGGABLEIL, " PINVOKESTUB_FL_GENERATEDEBUGGABLEIL\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_UNMANAGED_CALLI, " PINVOKESTUB_FL_UNMANAGED_CALLI\n", facility, level); #ifdef FEATURE_COMINTEROP - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_FIELDGETTER, " NDIRECTSTUB_FL_FIELDGETTER\n", facility, level); - LogOneFlag(dwStubFlags, NDIRECTSTUB_FL_FIELDSETTER, " NDIRECTSTUB_FL_FIELDSETTER\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_FIELDGETTER, " PINVOKESTUB_FL_FIELDGETTER\n", facility, level); + LogOneFlag(dwStubFlags, PINVOKESTUB_FL_FIELDSETTER, " PINVOKESTUB_FL_FIELDSETTER\n", facility, level); #endif // FEATURE_COMINTEROP // @@ -1162,22 +1162,22 @@ class ILStubState : public StubState CONSISTENCY_CHECK(!SF_IsCOMEventCallStub(dwStubFlags)); DWORD dwKnownMask = - NDIRECTSTUB_FL_CONVSIGASVARARG | - NDIRECTSTUB_FL_BESTFIT | - NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR | - NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY | - NDIRECTSTUB_FL_DELEGATE | - NDIRECTSTUB_FL_DOHRESULTSWAPPING | - NDIRECTSTUB_FL_REVERSE_INTEROP | - NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL | - NDIRECTSTUB_FL_UNMANAGED_CALLI | - NDIRECTSTUB_FL_STRUCT_MARSHAL | + PINVOKESTUB_FL_CONVSIGASVARARG | + PINVOKESTUB_FL_BESTFIT | + PINVOKESTUB_FL_THROWONUNMAPPABLECHAR | + PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY | + PINVOKESTUB_FL_DELEGATE | + PINVOKESTUB_FL_DOHRESULTSWAPPING | + PINVOKESTUB_FL_REVERSE_INTEROP | + PINVOKESTUB_FL_GENERATEDEBUGGABLEIL | + PINVOKESTUB_FL_UNMANAGED_CALLI | + PINVOKESTUB_FL_STRUCT_MARSHAL | #ifdef FEATURE_COMINTEROP - NDIRECTSTUB_FL_COM | - NDIRECTSTUB_FL_COMLATEBOUND | // internal - NDIRECTSTUB_FL_COMEVENTCALL | // internal - NDIRECTSTUB_FL_FIELDGETTER | - NDIRECTSTUB_FL_FIELDSETTER | + PINVOKESTUB_FL_COM | + PINVOKESTUB_FL_COMLATEBOUND | // internal + PINVOKESTUB_FL_COMEVENTCALL | // internal + PINVOKESTUB_FL_FIELDGETTER | + PINVOKESTUB_FL_FIELDSETTER | #endif // FEATURE_COMINTEROP 0; @@ -1390,20 +1390,20 @@ class PInvoke_ILStubState : public ILStubState { if (TargetHasThis(dwStubFlags)) { - dwStubFlags |= NDIRECTSTUB_FL_TARGET_HAS_THIS; + dwStubFlags |= PINVOKESTUB_FL_TARGET_HAS_THIS; } if (StubHasThis(dwStubFlags)) { - dwStubFlags |= NDIRECTSTUB_FL_STUB_HAS_THIS; + dwStubFlags |= PINVOKESTUB_FL_STUB_HAS_THIS; } - if ((dwStubFlags & NDIRECTSTUB_FL_SUPPRESSGCTRANSITION) == 0 + if ((dwStubFlags & PINVOKESTUB_FL_SUPPRESSGCTRANSITION) == 0 && TargetSuppressGCTransition(dwStubFlags, pTargetMD)) { - dwStubFlags |= NDIRECTSTUB_FL_SUPPRESSGCTRANSITION; + dwStubFlags |= PINVOKESTUB_FL_SUPPRESSGCTRANSITION; } if (HasCheckForPendingException(pTargetMD)) { - dwStubFlags |= NDIRECTSTUB_FL_CHECK_PENDING_EXCEPTION; + dwStubFlags |= PINVOKESTUB_FL_CHECK_PENDING_EXCEPTION; } return dwStubFlags; } @@ -1456,7 +1456,7 @@ class CLRToCOM_ILStubState : public ILStubState pStubModule, signature, pTypeContext, - dwStubFlags | NDIRECTSTUB_FL_STUB_HAS_THIS | NDIRECTSTUB_FL_TARGET_HAS_THIS, + dwStubFlags | PINVOKESTUB_FL_STUB_HAS_THIS | PINVOKESTUB_FL_TARGET_HAS_THIS, iLCIDParamIdx, pTargetMD) { @@ -1522,7 +1522,7 @@ class COMToCLR_ILStubState : public ILStubState pStubModule, signature, pTypeContext, - dwStubFlags | NDIRECTSTUB_FL_STUB_HAS_THIS | NDIRECTSTUB_FL_TARGET_HAS_THIS, + dwStubFlags | PINVOKESTUB_FL_STUB_HAS_THIS | PINVOKESTUB_FL_TARGET_HAS_THIS, iLCIDParamIdx, pTargetMD) { @@ -1592,15 +1592,15 @@ ILStubLinkerFlags GetILStubLinkerFlagsForPInvokeStubFlags(PInvokeStubFlags flags { result |= ILSTUB_LINKER_FLAG_REVERSE; } - if (flags & NDIRECTSTUB_FL_SUPPRESSGCTRANSITION) + if (flags & PINVOKESTUB_FL_SUPPRESSGCTRANSITION) { result |= ILSTUB_LINKER_FLAG_SUPPRESSGCTRANSITION; } - if (flags & NDIRECTSTUB_FL_STUB_HAS_THIS) + if (flags & PINVOKESTUB_FL_STUB_HAS_THIS) { result |= ILSTUB_LINKER_FLAG_STUB_HAS_THIS; } - if (flags & NDIRECTSTUB_FL_TARGET_HAS_THIS) + if (flags & PINVOKESTUB_FL_TARGET_HAS_THIS) { result |= ILSTUB_LINKER_FLAG_TARGET_HAS_THIS; } @@ -1621,7 +1621,7 @@ PInvokeStubLinker::PInvokeStubLinker( m_fHasCleanupCode(FALSE), m_fHasExceptionCleanupCode(FALSE), m_fCleanupWorkListIsSetup(FALSE), - m_targetHasThis((dwStubFlags & NDIRECTSTUB_FL_TARGET_HAS_THIS) != 0), + m_targetHasThis((dwStubFlags & PINVOKESTUB_FL_TARGET_HAS_THIS) != 0), m_dwCleanupWorkListLocalNum(-1), m_dwRetValLocalNum(-1), m_ErrorResID(-1), @@ -4281,7 +4281,7 @@ static void CreatePInvokeStubAccessMetadata( // only COM-to-CLR call supports hresult swapping in the reverse direction if (SF_IsCOMStub(*pdwStubFlags) && !IsMiPreserveSig(dwImplFlags)) { - (*pdwStubFlags) |= NDIRECTSTUB_FL_DOHRESULTSWAPPING; + (*pdwStubFlags) |= PINVOKESTUB_FL_DOHRESULTSWAPPING; } } else @@ -4290,7 +4290,7 @@ static void CreatePInvokeStubAccessMetadata( // delegate to an unmanaged method does not. if (!IsMiPreserveSig(dwImplFlags) && !SF_IsDelegateStub(*pdwStubFlags)) { - (*pdwStubFlags) |= NDIRECTSTUB_FL_DOHRESULTSWAPPING; + (*pdwStubFlags) |= PINVOKESTUB_FL_DOHRESULTSWAPPING; } } } @@ -4321,7 +4321,7 @@ static void CreatePInvokeStubAccessMetadata( // Do not notify the profiler about QCalls // See ProfilerManagedToUnmanagedTransitionMD() if (pMD->IsQCall()) - *pdwStubFlags |= NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY; + *pdwStubFlags |= PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY; } (*piLCIDArg) = lcidArg; @@ -5240,7 +5240,7 @@ MethodDesc* PInvoke::CreateFieldAccessILStub( pParamTokenArray[numArgs] = (mdParamDef)fd; // fields are never preserve-sig - dwStubFlags |= NDIRECTSTUB_FL_DOHRESULTSWAPPING; + dwStubFlags |= PINVOKESTUB_FL_DOHRESULTSWAPPING; // convert field signature to getter/setter signature SigBuilder sigBuilder; @@ -5305,7 +5305,7 @@ MethodDesc* PInvoke::CreateStructMarshalILStub(MethodTable* pMT) if (pCachedStubMD != NULL) RETURN pCachedStubMD; - DWORD dwStubFlags = NDIRECTSTUB_FL_STRUCT_MARSHAL; + DWORD dwStubFlags = PINVOKESTUB_FL_STRUCT_MARSHAL; BOOL bestFit, throwOnUnmappableChar; @@ -5313,11 +5313,11 @@ MethodDesc* PInvoke::CreateStructMarshalILStub(MethodTable* pMT) if (bestFit == TRUE) { - dwStubFlags |= NDIRECTSTUB_FL_BESTFIT; + dwStubFlags |= PINVOKESTUB_FL_BESTFIT; } if (throwOnUnmappableChar == TRUE) { - dwStubFlags |= NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR; + dwStubFlags |= PINVOKESTUB_FL_THROWONUNMAPPABLECHAR; } // ValueClass signature: @@ -5454,7 +5454,7 @@ namespace { pStubMD = PInvoke::CreateCLRToNativeILStub( pSigInfo, - dwStubFlags & ~NDIRECTSTUB_FL_FOR_NUMPARAMBYTES, + dwStubFlags & ~PINVOKESTUB_FL_FOR_NUMPARAMBYTES, pNMD); } @@ -5772,7 +5772,7 @@ void CreateCLRToDispatchCOMStub( (CorNativeLinkType)0, (CorNativeLinkFlags)0, CallConv::GetDefaultUnmanagedCallingConvention(), - dwStubFlags | NDIRECTSTUB_FL_COM, + dwStubFlags | PINVOKESTUB_FL_COM, pMD, pParamTokenArray, iLCIDArg); @@ -5994,13 +5994,13 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) Signature signature = pVASigCookie->signature; CorInfoCallConvExtension unmgdCallConv = CorInfoCallConvExtension::Managed; - DWORD dwStubFlags = NDIRECTSTUB_FL_BESTFIT; + DWORD dwStubFlags = PINVOKESTUB_FL_BESTFIT; // The MethodDesc pointer may in fact be the unmanaged target, see PInvokeStubs.asm. if (pMD == NULL || (UINT_PTR)pMD & 0x1) { pMD = NULL; - dwStubFlags |= NDIRECTSTUB_FL_UNMANAGED_CALLI; + dwStubFlags |= PINVOKESTUB_FL_UNMANAGED_CALLI; // need to convert the CALLI signature to stub signature with managed calling convention BYTE callConv = MetaSig::GetCallingConvention(signature); @@ -6026,7 +6026,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) if (builder.IsCurrentCallConvModSet(CallConvBuilder::CALL_CONV_MOD_SUPPRESSGCTRANSITION)) { - dwStubFlags |= NDIRECTSTUB_FL_SUPPRESSGCTRANSITION; + dwStubFlags |= PINVOKESTUB_FL_SUPPRESSGCTRANSITION; } } @@ -6043,7 +6043,7 @@ PCODE GetILStubForCalli(VASigCookie *pVASigCookie, MethodDesc *pMD) else { _ASSERTE(pMD->IsPInvoke()); - dwStubFlags |= NDIRECTSTUB_FL_CONVSIGASVARARG; + dwStubFlags |= PINVOKESTUB_FL_CONVSIGASVARARG; // vararg P/Invoke must be cdecl unmgdCallConv = CorInfoCallConvExtension::C; diff --git a/src/coreclr/vm/dllimport.h b/src/coreclr/vm/dllimport.h index 9dcff16d7f6e3e..c9a079f727e106 100644 --- a/src/coreclr/vm/dllimport.h +++ b/src/coreclr/vm/dllimport.h @@ -145,29 +145,29 @@ class PInvoke //---------------------------------------------------------------- enum PInvokeStubFlags { - NDIRECTSTUB_FL_CONVSIGASVARARG = 0x00000001, - NDIRECTSTUB_FL_BESTFIT = 0x00000002, - NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR = 0x00000004, - NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY = 0x00000008, - NDIRECTSTUB_FL_DELEGATE = 0x00000010, - NDIRECTSTUB_FL_DOHRESULTSWAPPING = 0x00000020, - NDIRECTSTUB_FL_REVERSE_INTEROP = 0x00000040, + PINVOKESTUB_FL_CONVSIGASVARARG = 0x00000001, + PINVOKESTUB_FL_BESTFIT = 0x00000002, + PINVOKESTUB_FL_THROWONUNMAPPABLECHAR = 0x00000004, + PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY = 0x00000008, + PINVOKESTUB_FL_DELEGATE = 0x00000010, + PINVOKESTUB_FL_DOHRESULTSWAPPING = 0x00000020, + PINVOKESTUB_FL_REVERSE_INTEROP = 0x00000040, #ifdef FEATURE_COMINTEROP - NDIRECTSTUB_FL_COM = 0x00000080, + PINVOKESTUB_FL_COM = 0x00000080, #endif // FEATURE_COMINTEROP // unused = 0x00000100, - NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL = 0x00000200, - NDIRECTSTUB_FL_STRUCT_MARSHAL = 0x00000400, - NDIRECTSTUB_FL_UNMANAGED_CALLI = 0x00000800, + PINVOKESTUB_FL_GENERATEDEBUGGABLEIL = 0x00000200, + PINVOKESTUB_FL_STRUCT_MARSHAL = 0x00000400, + PINVOKESTUB_FL_UNMANAGED_CALLI = 0x00000800, // unused = 0x00001000, #ifdef FEATURE_COMINTEROP - NDIRECTSTUB_FL_FIELDGETTER = 0x00002000, // COM->CLR field getter - NDIRECTSTUB_FL_FIELDSETTER = 0x00004000, // COM->CLR field setter + PINVOKESTUB_FL_FIELDGETTER = 0x00002000, // COM->CLR field getter + PINVOKESTUB_FL_FIELDSETTER = 0x00004000, // COM->CLR field setter #endif // FEATURE_COMINTEROP - NDIRECTSTUB_FL_SUPPRESSGCTRANSITION = 0x00008000, - NDIRECTSTUB_FL_STUB_HAS_THIS = 0x00010000, - NDIRECTSTUB_FL_TARGET_HAS_THIS = 0x00020000, - NDIRECTSTUB_FL_CHECK_PENDING_EXCEPTION = 0x00040000, + PINVOKESTUB_FL_SUPPRESSGCTRANSITION = 0x00008000, + PINVOKESTUB_FL_STUB_HAS_THIS = 0x00010000, + PINVOKESTUB_FL_TARGET_HAS_THIS = 0x00020000, + PINVOKESTUB_FL_CHECK_PENDING_EXCEPTION = 0x00040000, // unused = 0x00080000, // unused = 0x00100000, // unused = 0x00200000, @@ -175,16 +175,16 @@ enum PInvokeStubFlags // unused = 0x00800000, // internal flags -- these won't ever show up in an PInvokeStubHashBlob - NDIRECTSTUB_FL_FOR_NUMPARAMBYTES = 0x10000000, // do just enough to return the right value from Marshal.NumParamBytes + PINVOKESTUB_FL_FOR_NUMPARAMBYTES = 0x10000000, // do just enough to return the right value from Marshal.NumParamBytes #ifdef FEATURE_COMINTEROP - NDIRECTSTUB_FL_COMLATEBOUND = 0x20000000, // we use a generic stub for late bound calls - NDIRECTSTUB_FL_COMEVENTCALL = 0x40000000, // we use a generic stub for event calls + PINVOKESTUB_FL_COMLATEBOUND = 0x20000000, // we use a generic stub for late bound calls + PINVOKESTUB_FL_COMEVENTCALL = 0x40000000, // we use a generic stub for event calls #endif // FEATURE_COMINTEROP // Note: The upper half of the range is reserved for ILStubTypes enum - NDIRECTSTUB_FL_MASK = 0x7FFFFFFF, - NDIRECTSTUB_FL_INVALID = 0x80000000, + PINVOKESTUB_FL_MASK = 0x7FFFFFFF, + PINVOKESTUB_FL_INVALID = 0x80000000, }; enum ILStubTypes @@ -213,18 +213,18 @@ enum ILStubTypes #define COM_ONLY(x) false #endif // FEATURE_COMINTEROP -inline bool SF_IsVarArgStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_CONVSIGASVARARG)); } -inline bool SF_IsBestFit (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_BESTFIT)); } -inline bool SF_IsThrowOnUnmappableChar (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR)); } -inline bool SF_SkipTransitionNotify (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_SKIP_TRANSITION_NOTIFY)); } -inline bool SF_IsDelegateStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_DELEGATE)); } -inline bool SF_IsHRESULTSwapping (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_DOHRESULTSWAPPING)); } -inline bool SF_IsReverseStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_REVERSE_INTEROP)); } -inline bool SF_IsDebuggableStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL)); } -inline bool SF_IsCALLIStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_UNMANAGED_CALLI)); } -inline bool SF_IsForNumParamBytes (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_FOR_NUMPARAMBYTES)); } -inline bool SF_IsStructMarshalStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_STRUCT_MARSHAL)); } -inline bool SF_IsCheckPendingException (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_CHECK_PENDING_EXCEPTION)); } +inline bool SF_IsVarArgStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_CONVSIGASVARARG)); } +inline bool SF_IsBestFit (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_BESTFIT)); } +inline bool SF_IsThrowOnUnmappableChar (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_THROWONUNMAPPABLECHAR)); } +inline bool SF_SkipTransitionNotify (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_SKIP_TRANSITION_NOTIFY)); } +inline bool SF_IsDelegateStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_DELEGATE)); } +inline bool SF_IsHRESULTSwapping (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_DOHRESULTSWAPPING)); } +inline bool SF_IsReverseStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_REVERSE_INTEROP)); } +inline bool SF_IsDebuggableStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_GENERATEDEBUGGABLEIL)); } +inline bool SF_IsCALLIStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_UNMANAGED_CALLI)); } +inline bool SF_IsForNumParamBytes (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_FOR_NUMPARAMBYTES)); } +inline bool SF_IsStructMarshalStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_STRUCT_MARSHAL)); } +inline bool SF_IsCheckPendingException (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_CHECK_PENDING_EXCEPTION)); } inline bool SF_IsVirtualStaticMethodDispatchStub(DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return dwStubFlags == ILSTUB_STATIC_VIRTUAL_DISPATCH_STUB; } @@ -245,11 +245,11 @@ inline bool SF_IsTailCallCallTargetStub (DWORD dwStubFlags) { LIMITED_METHOD_CON inline bool SF_IsDelegateShuffleThunk (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags == ILSTUB_DELEGATE_SHUFFLE_THUNK); } inline bool SF_IsAsyncResumeStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return (dwStubFlags == ILSTUB_ASYNC_RESUME); } -inline bool SF_IsCOMStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_COM)); } -inline bool SF_IsCOMLateBoundStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_COMLATEBOUND)); } -inline bool SF_IsCOMEventCallStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_COMEVENTCALL)); } -inline bool SF_IsFieldGetterStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_FIELDGETTER)); } -inline bool SF_IsFieldSetterStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < NDIRECTSTUB_FL_INVALID && 0 != (dwStubFlags & NDIRECTSTUB_FL_FIELDSETTER)); } +inline bool SF_IsCOMStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_COM)); } +inline bool SF_IsCOMLateBoundStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_COMLATEBOUND)); } +inline bool SF_IsCOMEventCallStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_COMEVENTCALL)); } +inline bool SF_IsFieldGetterStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_FIELDGETTER)); } +inline bool SF_IsFieldSetterStub (DWORD dwStubFlags) { LIMITED_METHOD_CONTRACT; return COM_ONLY(dwStubFlags < PINVOKESTUB_FL_INVALID && 0 != (dwStubFlags & PINVOKESTUB_FL_FIELDSETTER)); } inline bool SF_IsSharedStub(DWORD dwStubFlags) { @@ -373,16 +373,16 @@ struct PInvokeStaticSigInfo WRAPPER_NO_CONTRACT; DWORD flags = 0; if (GetThrowOnUnmappableChar()) - flags |= NDIRECTSTUB_FL_THROWONUNMAPPABLECHAR; + flags |= PINVOKESTUB_FL_THROWONUNMAPPABLECHAR; if (GetBestFitMapping()) - flags |= NDIRECTSTUB_FL_BESTFIT; + flags |= PINVOKESTUB_FL_BESTFIT; if (IsDelegateInterop()) - flags |= NDIRECTSTUB_FL_DELEGATE; + flags |= PINVOKESTUB_FL_DELEGATE; if (ShouldSuppressGCTransition()) - flags |= NDIRECTSTUB_FL_SUPPRESSGCTRANSITION; + flags |= PINVOKESTUB_FL_SUPPRESSGCTRANSITION; return flags; } diff --git a/src/coreclr/vm/dllimportcallback.cpp b/src/coreclr/vm/dllimportcallback.cpp index 6e845c2abb72b6..58cd290172cbc3 100644 --- a/src/coreclr/vm/dllimportcallback.cpp +++ b/src/coreclr/vm/dllimportcallback.cpp @@ -338,14 +338,14 @@ MethodDesc* UMThunkMarshInfo::GetILStubMethodDesc(MethodDesc* pInvokeMD, PInvoke STANDARD_VM_CONTRACT; MethodDesc* pStubMD = NULL; - dwStubFlags |= NDIRECTSTUB_FL_REVERSE_INTEROP; // could be either delegate interop or not--that info is passed in from the caller + dwStubFlags |= PINVOKESTUB_FL_REVERSE_INTEROP; // could be either delegate interop or not--that info is passed in from the caller #if defined(DEBUGGING_SUPPORTED) // Combining the next two lines, and eliminating jitDebuggerFlags, leads to bad codegen in x86 Release builds using Visual C++ 19.00.24215.1. CORJIT_FLAGS jitDebuggerFlags = GetDebuggerCompileFlags(pSigInfo->GetModule(), CORJIT_FLAGS()); if (jitDebuggerFlags.IsSet(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_CODE)) { - dwStubFlags |= NDIRECTSTUB_FL_GENERATEDEBUGGABLEIL; + dwStubFlags |= PINVOKESTUB_FL_GENERATEDEBUGGABLEIL; } #endif // DEBUGGING_SUPPORTED @@ -413,7 +413,7 @@ VOID UMThunkMarshInfo::RunTimeInit() DWORD dwStubFlags = 0; if (sigInfo.IsDelegateInterop()) - dwStubFlags |= NDIRECTSTUB_FL_DELEGATE; + dwStubFlags |= PINVOKESTUB_FL_DELEGATE; MethodDesc* pStubMD = GetILStubMethodDesc(pMD, &sigInfo, dwStubFlags); PCODE pFinalILStub = JitILStub(pStubMD); diff --git a/src/coreclr/vm/method.cpp b/src/coreclr/vm/method.cpp index 68da9a8f26fafc..00391739b915bb 100644 --- a/src/coreclr/vm/method.cpp +++ b/src/coreclr/vm/method.cpp @@ -3469,7 +3469,7 @@ void PInvokeMethodDesc::EnsureStackArgumentSize() if (MarshalingRequired()) { // Generating interop stub sets the stack size as side-effect in all cases - GetStubForInteropMethod(this, NDIRECTSTUB_FL_FOR_NUMPARAMBYTES); + GetStubForInteropMethod(this, PINVOKESTUB_FL_FOR_NUMPARAMBYTES); } } } From 817d1c3f46d0168d23dc7f8b12b11a0f61301797 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 31 Jul 2025 12:02:13 -0700 Subject: [PATCH 8/8] More renames --- .../debug/runtimeinfo/datadescriptor.inc | 2 +- src/coreclr/vm/amd64/cgencpu.h | 2 +- src/coreclr/vm/arm/cgencpu.h | 2 +- src/coreclr/vm/arm64/cgencpu.h | 2 +- src/coreclr/vm/gccover.cpp | 2 +- src/coreclr/vm/i386/cgencpu.h | 2 +- src/coreclr/vm/jitinterface.cpp | 2 +- src/coreclr/vm/loongarch64/cgencpu.h | 2 +- src/coreclr/vm/method.hpp | 12 +++--- src/coreclr/vm/methodtablebuilder.cpp | 8 ++-- src/coreclr/vm/precode.cpp | 40 +++++++++---------- src/coreclr/vm/precode.h | 20 +++++----- src/coreclr/vm/riscv64/cgencpu.h | 2 +- src/coreclr/vm/stubmgr.cpp | 8 ++-- src/coreclr/vm/wasm/cgencpu.h | 2 +- 15 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/coreclr/debug/runtimeinfo/datadescriptor.inc b/src/coreclr/debug/runtimeinfo/datadescriptor.inc index ada0cb8d88054c..18f29289e2b38d 100644 --- a/src/coreclr/debug/runtimeinfo/datadescriptor.inc +++ b/src/coreclr/debug/runtimeinfo/datadescriptor.inc @@ -543,7 +543,7 @@ CDAC_TYPE_END(MethodDescVersioningState) CDAC_TYPE_BEGIN(PrecodeMachineDescriptor) CDAC_TYPE_INDETERMINATE(PrecodeMachineDescriptor) CDAC_TYPE_FIELD(PrecodeMachineDescriptor, /*uint8*/, InvalidPrecodeType, offsetof(PrecodeMachineDescriptor, InvalidPrecodeType)) -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE CDAC_TYPE_FIELD(PrecodeMachineDescriptor, /*uint8*/, PInvokeImportPrecodeType, offsetof(PrecodeMachineDescriptor, PInvokeImportPrecodeType)) #endif diff --git a/src/coreclr/vm/amd64/cgencpu.h b/src/coreclr/vm/amd64/cgencpu.h index db9e1c717b53e2..bf50d7941adab4 100644 --- a/src/coreclr/vm/amd64/cgencpu.h +++ b/src/coreclr/vm/amd64/cgencpu.h @@ -43,7 +43,7 @@ class ComCallMethodDesc; #define SIZEOF_LOAD_AND_JUMP_THUNK 22 // # bytes to mov r10, X; jmp Z #define SIZEOF_LOAD2_AND_JUMP_THUNK 32 // # bytes to mov r10, X; mov r11, Y; jmp Z -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 // ThisPtrRetBufPrecode one is necessary for closed delegates over static methods with return buffer diff --git a/src/coreclr/vm/arm/cgencpu.h b/src/coreclr/vm/arm/cgencpu.h index 1d3c5c6a207123..1b019a0f2c5153 100644 --- a/src/coreclr/vm/arm/cgencpu.h +++ b/src/coreclr/vm/arm/cgencpu.h @@ -67,7 +67,7 @@ EXTERN_C void checkStack(void); #define JUMP_ALLOCATE_SIZE 8 // # bytes to allocate for a jump instruction #define BACK_TO_BACK_JUMP_ALLOCATE_SIZE 8 // # bytes to allocate for a back to back jump instruction -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 EXTERN_C void getFPReturn(int fpSize, INT64 *pRetVal); EXTERN_C void setFPReturn(int fpSize, INT64 retVal); diff --git a/src/coreclr/vm/arm64/cgencpu.h b/src/coreclr/vm/arm64/cgencpu.h index 769c7ab31d702b..aa668e54a99a2a 100644 --- a/src/coreclr/vm/arm64/cgencpu.h +++ b/src/coreclr/vm/arm64/cgencpu.h @@ -60,7 +60,7 @@ extern PCODE GetPreStubEntryPoint(); #define JUMP_ALLOCATE_SIZE 16 // # bytes to allocate for a jump instruction #define BACK_TO_BACK_JUMP_ALLOCATE_SIZE 16 // # bytes to allocate for a back to back jump instruction -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 diff --git a/src/coreclr/vm/gccover.cpp b/src/coreclr/vm/gccover.cpp index 036c6d675e44d7..26d0f0b78efa8b 100644 --- a/src/coreclr/vm/gccover.cpp +++ b/src/coreclr/vm/gccover.cpp @@ -406,7 +406,7 @@ static MethodDesc* getTargetMethodDesc(PCODE target) switch (pPrecode->GetType()) { case PRECODE_STUB: - case PRECODE_NDIRECT_IMPORT: + case PRECODE_PINVOKE_IMPORT: case PRECODE_THISPTR_RETBUF: return dac_cast(pPrecode->AsStubPrecode()->GetMethodDesc()); default: diff --git a/src/coreclr/vm/i386/cgencpu.h b/src/coreclr/vm/i386/cgencpu.h index 1a9d9145d8a439..7eacba4cf74234 100644 --- a/src/coreclr/vm/i386/cgencpu.h +++ b/src/coreclr/vm/i386/cgencpu.h @@ -44,7 +44,7 @@ class ComCallMethodDesc; #define BACK_TO_BACK_JUMP_ALLOCATE_SIZE 8 // # bytes to allocate for a back to back jump instruction // Needed for PInvoke inlining in ngened images -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 diff --git a/src/coreclr/vm/jitinterface.cpp b/src/coreclr/vm/jitinterface.cpp index ee739879b6649c..0635f5ddb053dd 100644 --- a/src/coreclr/vm/jitinterface.cpp +++ b/src/coreclr/vm/jitinterface.cpp @@ -9975,7 +9975,7 @@ bool CEEInfo::pInvokeMarshalingRequired(CORINFO_METHOD_HANDLE method, CORINFO_SI _ASSERTE(ftn->IsPInvoke()); PInvokeMethodDesc *pMD = (PInvokeMethodDesc*)ftn; -#if defined(HAS_NDIRECT_IMPORT_PRECODE) +#if defined(HAS_PINVOKE_IMPORT_PRECODE) if (pMD->IsVarArg()) { // Varag P/Invoke must not be inlined because its PInvokeMethodDesc diff --git a/src/coreclr/vm/loongarch64/cgencpu.h b/src/coreclr/vm/loongarch64/cgencpu.h index 08a147b4a0d713..608c9ec356a7c5 100644 --- a/src/coreclr/vm/loongarch64/cgencpu.h +++ b/src/coreclr/vm/loongarch64/cgencpu.h @@ -57,7 +57,7 @@ extern PCODE GetPreStubEntryPoint(); #define JUMP_ALLOCATE_SIZE 40 // # bytes to allocate for a jump instruction #define BACK_TO_BACK_JUMP_ALLOCATE_SIZE 40 // # bytes to allocate for a back to back jump instruction -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 #define HAS_FIXUP_PRECODE_CHUNKS 1 diff --git a/src/coreclr/vm/method.hpp b/src/coreclr/vm/method.hpp index 18d27fad3bf141..1db0dab8ea5dfb 100644 --- a/src/coreclr/vm/method.hpp +++ b/src/coreclr/vm/method.hpp @@ -2951,9 +2951,9 @@ class ArrayMethodDesc : public StoredSigMethodDesc DWORD GetAttrs(); }; -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE typedef PInvokeImportPrecode PInvokeImportThunkGlue; -#else // HAS_NDIRECT_IMPORT_PRECODE +#else // HAS_PINVOKE_IMPORT_PRECODE class PInvokeImportThunkGlue { @@ -2971,7 +2971,7 @@ class PInvokeImportThunkGlue } }; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE typedef DPTR(PInvokeImportThunkGlue) PTR_PInvokeImportThunkGlue; @@ -2998,11 +2998,11 @@ class PInvokeMethodDesc : public MethodDesc // host interceptor stub or alignment thunk after linking. LPVOID m_pPInvokeTarget; -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE PTR_PInvokeImportThunkGlue m_pImportThunkGlue; -#else // HAS_NDIRECT_IMPORT_PRECODE +#else // HAS_PINVOKE_IMPORT_PRECODE PInvokeImportThunkGlue m_ImportThunkGlue; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE ULONG m_DefaultDllImportSearchPathsAttributeValue; // DefaultDllImportSearchPathsAttribute is saved. diff --git a/src/coreclr/vm/methodtablebuilder.cpp b/src/coreclr/vm/methodtablebuilder.cpp index 54e32b82d7fe77..7d581ac8b79f90 100644 --- a/src/coreclr/vm/methodtablebuilder.cpp +++ b/src/coreclr/vm/methodtablebuilder.cpp @@ -6175,12 +6175,12 @@ MethodTableBuilder::InitMethodDesc( // PInvoke specific initialization. PInvokeMethodDesc *pNewNMD = (PInvokeMethodDesc*)pNewMD; -#ifdef HAS_NDIRECT_IMPORT_PRECODE - pNewNMD->m_pImportThunkGlue = Precode::Allocate(PRECODE_NDIRECT_IMPORT, pNewMD, +#ifdef HAS_PINVOKE_IMPORT_PRECODE + pNewNMD->m_pImportThunkGlue = Precode::Allocate(PRECODE_PINVOKE_IMPORT, pNewMD, GetLoaderAllocator(), GetMemTracker())->AsPInvokeImportPrecode(); -#else // !HAS_NDIRECT_IMPORT_PRECODE +#else // !HAS_PINVOKE_IMPORT_PRECODE pNewNMD->GetPInvokeImportThunkGlue()->Init(pNewNMD); -#endif // !HAS_NDIRECT_IMPORT_PRECODE +#endif // !HAS_PINVOKE_IMPORT_PRECODE #if defined(TARGET_X86) pNewNMD->m_cbStackArgumentSize = 0xFFFF; diff --git a/src/coreclr/vm/precode.cpp b/src/coreclr/vm/precode.cpp index 4fe0d7d54e9ee6..d5d8cffdec6487 100644 --- a/src/coreclr/vm/precode.cpp +++ b/src/coreclr/vm/precode.cpp @@ -31,9 +31,9 @@ BOOL Precode::IsValidType(PrecodeType t) switch (t) { case PRECODE_STUB: -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: -#endif // HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: #endif // HAS_FIXUP_PRECODE @@ -67,10 +67,10 @@ SIZE_T Precode::SizeOf(PrecodeType t) { case PRECODE_STUB: return sizeof(StubPrecode); -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: return sizeof(PInvokeImportPrecode); -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: return sizeof(FixupPrecode); @@ -142,11 +142,11 @@ MethodDesc* Precode::GetMethodDesc(BOOL fSpeculative /*= FALSE*/) case PRECODE_STUB: pMD = AsStubPrecode()->GetMethodDesc(); break; -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: pMD = AsPInvokeImportPrecode()->GetMethodDesc(); break; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: pMD = AsFixupPrecode()->GetMethodDesc(); @@ -304,7 +304,7 @@ Precode* Precode::Allocate(PrecodeType t, MethodDesc* pMD, #endif // HAS_THISPTR_RETBUF_PRECODE else { - _ASSERTE(t == PRECODE_STUB || t == PRECODE_NDIRECT_IMPORT); + _ASSERTE(t == PRECODE_STUB || t == PRECODE_PINVOKE_IMPORT); pPrecode = (Precode*)pamTracker->Track(pLoaderAllocator->GetNewStubPrecodeHeap()->AllocStub()); pPrecode->Init(pPrecode, t, pMD, pLoaderAllocator); @@ -330,11 +330,11 @@ void Precode::Init(Precode* pPrecodeRX, PrecodeType t, MethodDesc* pMD, LoaderAl case PRECODE_STUB: ((StubPrecode*)this)->Init((StubPrecode*)pPrecodeRX, (TADDR)pMD, pLoaderAllocator); break; -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: ((PInvokeImportPrecode*)this)->Init((PInvokeImportPrecode*)pPrecodeRX, pMD, pLoaderAllocator); break; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: ((FixupPrecode*)this)->Init((FixupPrecode*)pPrecodeRX, pMD, pLoaderAllocator); @@ -433,9 +433,9 @@ void Precode::Reset() switch (t) { case PRECODE_STUB: -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: -#endif // HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: #endif // HAS_FIXUP_PRECODE @@ -646,7 +646,7 @@ void InterpreterPrecode::Init(InterpreterPrecode* pPrecodeRX, TADDR byteCodeAddr } #endif // FEATURE_INTERPRETER -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE void PInvokeImportPrecode::Init(PInvokeImportPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator) { @@ -654,7 +654,7 @@ void PInvokeImportPrecode::Init(PInvokeImportPrecode* pPrecodeRX, MethodDesc* pM StubPrecode::Init(pPrecodeRX, (TADDR)pMD, pLoaderAllocator, PInvokeImportPrecode::Type, GetEEFuncEntryPoint(PInvokeImportThunk)); } -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE void FixupPrecode::Init(FixupPrecode* pPrecodeRX, MethodDesc* pMD, LoaderAllocator *pLoaderAllocator) @@ -857,8 +857,8 @@ BOOL DoesSlotCallPrestub(PCODE pCode) void PrecodeMachineDescriptor::Init(PrecodeMachineDescriptor *dest) { dest->InvalidPrecodeType = PRECODE_INVALID; -#ifdef HAS_NDIRECT_IMPORT_PRECODE - dest->PInvokeImportPrecodeType = PRECODE_NDIRECT_IMPORT; +#ifdef HAS_PINVOKE_IMPORT_PRECODE + dest->PInvokeImportPrecodeType = PRECODE_PINVOKE_IMPORT; #endif #ifdef HAS_FIXUP_PRECODE diff --git a/src/coreclr/vm/precode.h b/src/coreclr/vm/precode.h index 914e45281f6fcd..410c99847ae574 100644 --- a/src/coreclr/vm/precode.h +++ b/src/coreclr/vm/precode.h @@ -200,7 +200,7 @@ struct StubPrecode typedef DPTR(StubPrecode) PTR_StubPrecode; -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE // PInvoke import precode // (This is fake precode. VTable slot does not point to it.) @@ -218,7 +218,7 @@ struct PInvokeImportPrecode : StubPrecode }; typedef DPTR(PInvokeImportPrecode) PTR_PInvokeImportPrecode; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_THISPTR_RETBUF_PRECODE @@ -485,9 +485,9 @@ enum PrecodeType { #ifdef FEATURE_INTERPRETER PRECODE_INTERPRETER = InterpreterPrecode::Type, // 0x6 #endif // FEATURE_INTERPRETER -#ifdef HAS_NDIRECT_IMPORT_PRECODE - PRECODE_NDIRECT_IMPORT = PInvokeImportPrecode::Type, // 0x5 -#endif // HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE + PRECODE_PINVOKE_IMPORT = PInvokeImportPrecode::Type, // 0x5 +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE PRECODE_FIXUP = FixupPrecode::Type, #endif // HAS_FIXUP_PRECODE @@ -507,7 +507,7 @@ inline TADDR StubPrecode::GetMethodDesc() switch (GetType()) { case PRECODE_STUB: - case PRECODE_NDIRECT_IMPORT: + case PRECODE_PINVOKE_IMPORT: return GetSecretParam(); case PRECODE_UMENTRY_THUNK: @@ -543,7 +543,7 @@ inline BYTE StubPrecode::GetType() { case PRECODE_UMENTRY_THUNK: case PRECODE_STUB: - case PRECODE_NDIRECT_IMPORT: + case PRECODE_PINVOKE_IMPORT: case PRECODE_THISPTR_RETBUF: #ifdef FEATURE_INTERPRETER case PRECODE_INTERPRETER: @@ -571,7 +571,7 @@ class Precode { } private: -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE public: // Fake precodes has to be exposed PInvokeImportPrecode* AsPInvokeImportPrecode() @@ -583,7 +583,7 @@ class Precode { } private: -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE PTR_FixupPrecode AsFixupPrecode() @@ -829,7 +829,7 @@ struct PrecodeMachineDescriptor { uint32_t StubCodePageSize; uint8_t InvalidPrecodeType; -#ifdef HAS_NDIRECT_IMPORT_PRECODE +#ifdef HAS_PINVOKE_IMPORT_PRECODE uint8_t PInvokeImportPrecodeType; #endif diff --git a/src/coreclr/vm/riscv64/cgencpu.h b/src/coreclr/vm/riscv64/cgencpu.h index 8f09e0ed6433e9..f4c10a3d0e7c04 100644 --- a/src/coreclr/vm/riscv64/cgencpu.h +++ b/src/coreclr/vm/riscv64/cgencpu.h @@ -65,7 +65,7 @@ extern PCODE GetPreStubEntryPoint(); #define JUMP_ALLOCATE_SIZE 40 // # bytes to allocate for a jump instruction #define BACK_TO_BACK_JUMP_ALLOCATE_SIZE 40 // # bytes to allocate for a back to back jump instruction -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 diff --git a/src/coreclr/vm/stubmgr.cpp b/src/coreclr/vm/stubmgr.cpp index 91fe34e7c319f5..19159828008faa 100644 --- a/src/coreclr/vm/stubmgr.cpp +++ b/src/coreclr/vm/stubmgr.cpp @@ -1013,7 +1013,7 @@ BOOL PrecodeStubManager::CheckIsStub_Internal(PCODE stubStartAddress) switch (pPrecode->GetType()) { case PRECODE_STUB: - case PRECODE_NDIRECT_IMPORT: + case PRECODE_PINVOKE_IMPORT: case PRECODE_UMENTRY_THUNK: #ifdef HAS_THISPTR_RETBUF_PRECODE case PRECODE_THISPTR_RETBUF: @@ -1073,8 +1073,8 @@ BOOL PrecodeStubManager::DoTraceStub(PCODE stubStartAddress, case PRECODE_STUB: break; -#ifdef HAS_NDIRECT_IMPORT_PRECODE - case PRECODE_NDIRECT_IMPORT: +#ifdef HAS_PINVOKE_IMPORT_PRECODE + case PRECODE_PINVOKE_IMPORT: #ifndef DACCESS_COMPILE #if defined(TARGET_ARM64) && defined(__APPLE__) // On ARM64 Mac, we cannot put a breakpoint inside of PInvokeImportThunk @@ -1088,7 +1088,7 @@ BOOL PrecodeStubManager::DoTraceStub(PCODE stubStartAddress, #endif LOG_TRACE_DESTINATION(trace, stubStartAddress, "PrecodeStubManager::DoTraceStub - PInvoke import"); return TRUE; -#endif // HAS_NDIRECT_IMPORT_PRECODE +#endif // HAS_PINVOKE_IMPORT_PRECODE #ifdef HAS_FIXUP_PRECODE case PRECODE_FIXUP: diff --git a/src/coreclr/vm/wasm/cgencpu.h b/src/coreclr/vm/wasm/cgencpu.h index ca996b269a1859..975f892a17f1f1 100644 --- a/src/coreclr/vm/wasm/cgencpu.h +++ b/src/coreclr/vm/wasm/cgencpu.h @@ -15,7 +15,7 @@ #define LOG2SLOT LOG2_PTRSIZE // looks like this is mandatory for now -#define HAS_NDIRECT_IMPORT_PRECODE 1 +#define HAS_PINVOKE_IMPORT_PRECODE 1 #define HAS_FIXUP_PRECODE 1 // ThisPtrRetBufPrecode one is necessary for closed delegates over static methods with return buffer #define HAS_THISPTR_RETBUF_PRECODE 1