Please see below... Barry This posting is provided "AS IS" with no warranties, and confers no rights.
> -----Original Message----- > From: Archana [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 23, 2003 3:46 AM > To: [EMAIL PROTECTED] > Subject: Re: [DOTNET-ROTOR] implementation of pinning objects > > > Hi, > > Barry Bond wrote: > > > Pinned objects fall into two categories. First, all > arguments passed > > via P/Invoke (also called NDirect) are implicitly pinned. Second, > > objects can be explicitly allocated as pinned via the managed > > System.Runtime.InteropServices.GCHandle.Alloc(Object, GCHandleType) > > method, which adds entries to the objecthandle table. > > what is an NDirect call? where can i find more info about > this Are weak pointers also dealt in the same way ie, are > they also formed similarly (via two categories etc..)? NDirect is called "Platform Invoke" in the ECMA standard, see Partition II (Metadata), section 14.5.2, for more information. In the objecthandle table, weak pointers are implemented similarly to pinned. Week pointers have no equivalent in NDirect: they are all created explicitly. If you do a case-insensitive grep in sscli/clr/src/vm for "weak", you won't find many matches - it's instructive to read through them all. > > > In both cases, > > pinning doesn't incur runtime overhead until the GC runs, > and the GC > > isn't involved with pinning until GCHeap::Promote() is called, with > > GC_CALL_PINNED set in its 'flags' parameter. > > > > In the case of P/Invoke, this is the sequence of events as > the stack > > is being crawled during a GC and an NDirectMethodFrame is > encountered: > > gcscan.cpp's GcStackCrawlCallback() calls a pFrame->GcScanRoots. > > For P/Invoke, pFrame is an NDirectMethodFrame. > > frames.h's NDirectMethodFrame::GcScanRoots() calls > > frames.h's FrameMethodFrame::PromoteCallerStackWithPinning() calls > > frames.cpp's FramedMethodFrame::PromoteCallerStackWorker() calls > > frames.cpp's FrameMethodFrame::PromoteCallerStackHelper() > takes an > > fPinArgs parameter which is TRUE in this code path. For > each object > > pointer in a jitted method's stack frame, it calls > > GCHeap::Promote(..., > > GC_CALL_PINNED) > > > > the Promote either copies/marks the object depending on the > generation, where does the call for GCHeap::Relocate actually > occur for the NDirectMethodFrame? >From gcsmp.cpp's gc_heap::copy_phase(), when it calls CNameSpace::GcScanRoots(), passing GCHeap::Relocate as the first parameter. > > Thank you, > archana >