Пример #1
0
        internal static unsafe IntPtr GetCastableObjectDispatchCellThunk(EEType *pInstanceType, IntPtr pDispatchCell)
        {
            IntPtr pTargetCode = CacheLookup(s_ThunkBasedDispatchCellTargets, pDispatchCell);

            if (pTargetCode != default(IntPtr))
            {
                return(pTargetCode);
            }

            InternalCalls.RhpAcquireCastCacheLock();
            {
                // Look in the cache again after taking the lock

                pTargetCode = CacheLookup(s_ThunkBasedDispatchCellTargets, pDispatchCell);
                if (pTargetCode != default(IntPtr))
                {
                    return(pTargetCode);
                }

                // Allocate a new thunk. Failure to allocate one will result in a fail-fast. We don't return nulls from this API.

                if (s_thunksHeap == null)
                {
                    s_thunksHeap = ThunksHeap.CreateThunksHeap(InternalCalls.RhpGetCastableObjectDispatch_CommonStub());
                    if (s_thunksHeap == null)
                    {
                        EH.FallbackFailFast(RhFailFastReason.InternalError, null);
                    }
                }

                pTargetCode = s_thunksHeap.AllocateThunk();
                if (pTargetCode == IntPtr.Zero)
                {
                    EH.FallbackFailFast(RhFailFastReason.InternalError, null);
                }

                s_thunksHeap.SetThunkData(pTargetCode, pDispatchCell, InternalCalls.RhpGetCastableObjectDispatchHelper_TailCalled());

                AddToThunkCache(pDispatchCell, pTargetCode);
            }
            InternalCalls.RhpReleaseCastCacheLock();

            return(pTargetCode);
        }
Пример #2
0
 public static object RhCreateThunksHeap(IntPtr commonStubAddress)
 {
     return(ThunksHeap.CreateThunksHeap(commonStubAddress));
 }