Skip to content

Commit e58b345

Browse files
jkotasCopilot
andauthored
Rename NDirect -> PInvoke (#118228)
* Rename NDirect -> PInvoke * Rename N/Direct -> PInvoke * NDIRECTSTUB -> PINVOKESTUB * Manual touch up Co-authored-by: Copilot <[email protected]>
1 parent 48af0f9 commit e58b345

File tree

101 files changed

+796
-806
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+796
-806
lines changed

docs/design/coreclr/botr/guide-for-porting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Here is an annotated list of the stubs implemented for Unix on Arm64.
340340
calls. Necessary for all applications as this is how the main method is
341341
called.
342342

343-
2. `NDirectImportThunk` – Needed to support saving off a set of arguments to
343+
2. `PInvokeImportThunk` – Needed to support saving off a set of arguments to
344344
a p/invoke so that the runtime can find the actual target. Also uses one
345345
of the secret arguments (Used by all p/invoke methods)
346346

docs/design/coreclr/botr/method-descriptor.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ Used for less common IL methods that have generic instantiation or that do not h
4444

4545
Internal methods implemented in unmanaged code. These are [methods marked with MethodImplAttribute(MethodImplOptions.InternalCall) attribute](corelib.md), delegate constructors and tlbimp constructors.
4646

47-
**NDirect**
47+
**PInvoke**
4848

4949
P/Invoke methods. These are methods marked with DllImport attribute.
5050

@@ -270,14 +270,14 @@ ThisPtrRetBufPrecode looks like this:
270270
jmp entrypoint
271271
dw pMethodDesc
272272

273-
**NDirectImportPrecode**
273+
**PInvokeImportPrecode**
274274

275-
NDirectImportPrecode is used for lazy binding of unmanaged P/Invoke targets. This precode is for convenience and to reduce amount of platform specific plumbing.
275+
PInvokeImportPrecode is used for lazy binding of unmanaged P/Invoke targets. This precode is for convenience and to reduce amount of platform specific plumbing.
276276

277-
Each NDirectMethodDesc has NDirectImportPrecode in addition to the regular precode.
277+
Each PInvokeMethodDesc has PInvokeImportPrecode in addition to the regular precode.
278278

279-
NDirectImportPrecode looks like this on x86:
279+
PInvokeImportPrecode looks like this on x86:
280280

281281
mov eax,pMethodDesc
282282
mov eax,eax // dummy instruction that marks the type of the precode
283-
jmp NDirectImportThunk // loads P/Invoke target for pMethodDesc lazily
283+
jmp PInvokeImportThunk // loads P/Invoke target for pMethodDesc lazily

docs/design/coreclr/botr/profiling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ A profiler DLL is an unmanaged DLL that is effectively running as part of the CL
477477
Combining Managed and Unmanaged Code in a Code Profiler
478478
=======================================================
479479

480-
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.
480+
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.
481481

482482
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.
483483

docs/design/datacontracts/PrecodeStubs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ After the initial precode type is determined, for stub precodes a refined precod
194194
internal enum KnownPrecodeType
195195
{
196196
Stub = 1,
197-
PInvokeImport, // also known as NDirectImport in the runtime
197+
PInvokeImport,
198198
Fixup,
199199
ThisPtrRetBuf,
200200
UMEntry,

docs/design/datacontracts/RuntimeTypeSystem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1083,7 +1083,7 @@ Checking if a method has a native code slot and getting its address
10831083
{
10841084
MethodClassification.IL => /*size of MethodDesc*/,
10851085
MethodClassification.FCall => /* size of FCallMethodDesc */
1086-
MethodClassification.PInvoke => /* size of NDirectMethodDesc */
1086+
MethodClassification.PInvoke => /* size of PInvokeMethodDesc */
10871087
MethodClassification.EEImpl => /* size of EEImplMethodDesc */
10881088
MethodClassification.Array => /* size of ArrayMethodDesc */
10891089
MethodClassification.Instantiated => /* size of InstantiatedMethodDesc */

src/coreclr/System.Private.CoreLib/src/System/StubHelpers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ private unsafe IntPtr ConvertArrayToNative(object pManagedHome, int dwFlags)
944944
}
945945

946946
default:
947-
throw new ArgumentException(SR.Arg_NDirectBadObject);
947+
throw new ArgumentException(SR.Arg_PInvokeBadObject);
948948
}
949949

950950
// marshal the object as C-style array (UnmanagedType.LPArray)
@@ -1151,7 +1151,7 @@ internal IntPtr ConvertToNative(object pManagedHome, int dwFlags)
11511151
else
11521152
{
11531153
// this type is not supported for AsAny marshaling
1154-
throw new ArgumentException(SR.Arg_NDirectBadObject);
1154+
throw new ArgumentException(SR.Arg_PInvokeBadObject);
11551155
}
11561156
}
11571157

src/coreclr/debug/daccess/dacdbiimplstackwalk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ ULONG32 DacDbiInterfaceImpl::GetCountOfInternalFrames(VMPTR_Thread vmThread)
474474
{
475475
// Skip new exception handling helpers
476476
InlinedCallFrame *pInlinedCallFrame = dac_cast<PTR_InlinedCallFrame>(pFrame);
477-
PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum;
477+
PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum;
478478
TADDR datum = dac_cast<TADDR>(pMD);
479479
if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper)
480480
{
@@ -527,7 +527,7 @@ void DacDbiInterfaceImpl::EnumerateInternalFrames(VMPTR_Thread
527527
{
528528
// Skip new exception handling helpers
529529
InlinedCallFrame *pInlinedCallFrame = dac_cast<PTR_InlinedCallFrame>(pFrame);
530-
PTR_NDirectMethodDesc pMD = pInlinedCallFrame->m_Datum;
530+
PTR_PInvokeMethodDesc pMD = pInlinedCallFrame->m_Datum;
531531
TADDR datum = dac_cast<TADDR>(pMD);
532532
if ((datum & (TADDR)InlinedCallFrameMarker::Mask) == (TADDR)InlinedCallFrameMarker::ExceptionHandlingHelper)
533533
{

src/coreclr/debug/di/shimstackwalk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ BOOL ShimStackWalk::CheckInternalFrame(ICorDebugFrame * pNextStackFrame,
12021202
// Special handling for the case where a managed method contains a M2U internal frame.
12031203
// Normally only IL stubs contain M2U internal frames, but we may have inlined pinvoke calls in
12041204
// optimized code. In that case, we would have an InlinedCallFrame in a normal managed method on x86.
1205-
// On WIN64, we would have a normal NDirectMethodFrame* in a normal managed method.
1205+
// On WIN64, we would have a normal PInvokeMethodFrame* in a normal managed method.
12061206
if (pStackWalkInfo->m_internalFrameType == STUBFRAME_M2U)
12071207
{
12081208
// create a temporary ICDStackWalk

src/coreclr/debug/ee/controller.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5921,7 +5921,7 @@ bool DebuggerStepper::TrapStep(ControllerStackInfo *info, bool in)
59215921
#endif
59225922

59235923
// Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value in that, and
5924-
// it was causing problems creating a stepper while sitting in ndirect stubs after we'd returned from the unmanaged
5924+
// it was causing problems creating a stepper while sitting in PInvoke stubs after we'd returned from the unmanaged
59255925
// function that had been called.
59265926
DebuggerJitInfo *ji = info->m_activeFrame.GetJitInfoFromFrame();
59275927
if( ji != NULL )
@@ -6537,7 +6537,7 @@ void DebuggerStepper::TrapStepOut(ControllerStackInfo *info, bool fForceTraditio
65376537
_ASSERTE(dji != NULL);
65386538

65396539
// Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value
6540-
// in that, and it was causing problems creating a stepper while sitting in ndirect stubs after we'd
6540+
// in that, and it was causing problems creating a stepper while sitting in PInvoke stubs after we'd
65416541
// returned from the unmanaged function that had been called.
65426542
ULONG reloffset = info->m_activeFrame.relOffset;
65436543

@@ -6816,7 +6816,7 @@ bool DebuggerStepper::SetRangesFromIL(DebuggerJitInfo *dji, COR_DEBUG_STEP_RANGE
68166816
CONTRACTL_END;
68176817

68186818
// Note: we used to pass in the IP from the active frame to GetJitInfo, but there seems to be no value in that, and
6819-
// it was causing problems creating a stepper while sitting in ndirect stubs after we'd returned from the unmanaged
6819+
// it was causing problems creating a stepper while sitting in PInvoke stubs after we'd returned from the unmanaged
68206820
// function that had been called.
68216821
MethodDesc *fd = dji->m_nativeCodeVersion.GetMethodDesc();
68226822

src/coreclr/debug/ee/frameinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data)
15031503
(pPrevFrame->GetFrameType() == Frame::TYPE_EXIT) &&
15041504
!HasExitRuntime(pPrevFrame, d, NULL) )
15051505
{
1506-
// This is for the inlined NDirectMethodFrameGeneric case. We have not exit the runtime yet, so the current
1506+
// This is for the inlined PInvokeMethodFrameGeneric case. We have not exit the runtime yet, so the current
15071507
// frame should still be regarded as the leaf frame.
15081508
d->info.fIsLeaf = true;
15091509
}

0 commit comments

Comments
 (0)