Exemplo n.º 1
0
        public static tMethodState *Direct(tThread *pThread, tMD_MethodDef *pMethod, tMethodState *pCaller, uint isInternalNewObjCall)
        {
            tMethodState *pThis;

            Mem.heapcheck();

            if (pMethod->isFilled == 0)
            {
                tMD_TypeDef *pTypeDef;

                pTypeDef = MetaData.GetTypeDefFromMethodDef(pMethod);
                MetaData.Fill_TypeDef(pTypeDef, null, null);
            }

            pThis = (tMethodState *)Thread.StackAlloc(pThread, (uint)sizeof(tMethodState));
            pThis->finalizerThis = null;
            pThis->pCaller       = pCaller;
            pThis->pMetaData     = pMethod->pMetaData;
            pThis->pMethod       = pMethod;
            if (pMethod->pJITted == null)
            {
                // If method has not already been JITted
                JIT.Prepare(pMethod, 0);
            }
            pThis->pJIT                 = pMethod->pJITted;
            pThis->ipOffset             = 0;
            pThis->pEvalStack           = (byte *)Thread.StackAlloc(pThread, pThis->pMethod->pJITted->maxStack);
            pThis->stackOfs             = 0;
            pThis->isInternalNewObjCall = isInternalNewObjCall;
            pThis->pNextDelegate        = null;
            pThis->pDelegateParams      = null;

            pThis->pParamsLocals = (byte *)Thread.StackAlloc(pThread, pMethod->parameterStackSize + pMethod->pJITted->localsStackSize);
            Mem.memset(pThis->pParamsLocals, 0, pMethod->parameterStackSize + pMethod->pJITted->localsStackSize);

#if DIAG_METHOD_CALLS
            // Keep track of the number of times this method is called
            pMethod->callCount++;
            pThis->startTime = microTime();
#endif

            Mem.heapcheck();

            return(pThis);
        }