コード例 #1
0
        public StackObject *PopFrame(ref StackFrame frame, StackObject *esp)
        {
#if DEBUG
            if (frames.Count > 0 && frames.Peek().BasePointer == frame.BasePointer)
#endif
            frames.Pop();
#if DEBUG
            else
            {
                throw new NotSupportedException();
            }
#endif
            StackObject *returnVal  = esp - 1;
            var          method     = frame.Method;
            StackObject *ret        = ILIntepreter.Minus(frame.LocalVarPointer, method.ParameterCount);
            int          mStackBase = frame.ManagedStackBase;
            if (method.HasThis)
            {
                ret--;
            }
            if (allocator != null)
            {
                allocator.FreeBefore(frame.ValueTypeBasePointer);
            }
            for (StackObject *ptr = ret; ptr < frame.LocalVarPointer; ptr++)
            {
                if (ptr->ObjectType == ObjectTypes.ValueTypeObjectReference)
                {
                    var addr  = ILIntepreter.ResolveReference(ptr);
                    int start = int.MaxValue;
                    int end   = int.MaxValue;
                    var tmp   = addr;
                    CountValueTypeManaged(ptr, ref start, ref end, &tmp);

                    if (addr > frame.ValueTypeBasePointer)
                    {
                        frame.ValueTypeBasePointer = addr;
                    }
                    if (start < mStackBase)
                    {
                        mStackBase = start;
                    }
                }
            }
            if (method.ReturnType != intepreter.AppDomain.VoidType)
            {
                *ret = *returnVal;
                if (ret->ObjectType == ObjectTypes.Object)
                {
                    ret->Value = mStackBase;
                    managedStack[mStackBase] = managedStack[returnVal->Value];
                    mStackBase++;
                }
                else if (ret->ObjectType == ObjectTypes.ValueTypeObjectReference)
                {
                    StackObject *oriAddr = frame.ValueTypeBasePointer;
                    RelocateValueType(ret, ref frame.ValueTypeBasePointer, ref mStackBase);
                    *(long *)&ret->Value = (long)oriAddr;
                }
                ret++;
            }
#if DEBUG && !DISABLE_ILRUNTIME_DEBUG
            ((List <object>)managedStack).RemoveRange(mStackBase, managedStack.Count - mStackBase);
#else
            ((UncheckedList <object>)managedStack).RemoveRange(mStackBase, managedStack.Count - mStackBase);
#endif
            valueTypePtr = frame.ValueTypeBasePointer;
            return(ret);
        }
コード例 #2
0
 public void PushFrame(ref StackFrame frame)
 {
     frames.Push(ref frame);
 }