本文整理汇总了C#中ProtoCore.DSASM.Instruction类的典型用法代码示例。如果您正苦于以下问题:C# Instruction类的具体用法?C# Instruction怎么用?C# Instruction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Instruction类属于ProtoCore.DSASM命名空间,在下文中一共展示了Instruction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RETC_Handler
private void RETC_Handler(Instruction instruction)
{
runtimeVerify(rmem.ValidateStackFrame());
RX = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexThisPtr);
int ci = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
int fi = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunction).opdata;
pc = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexReturnAddress).opdata;
// block id is used in ReturnSiteGC to get the procedure node if it is not a member function
// not meaningful here, because we are inside a constructor
int blockId = (int)SX.opdata;
if (core.ExecMode != ProtoCore.DSASM.InterpreterMode.kExpressionInterpreter)
{
ReturnSiteGC(blockId, ci, fi);
}
RestoreFromCall();
core.RunningBlock = executingBlock;
// If we're returning from a block to a function, the instruction stream needs to be restored.
StackValue sv = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexRegisterTX);
Validity.Assert(AddressType.CallingConvention == sv.optype);
CallingConvention.CallType callType = (CallingConvention.CallType)sv.opdata;
bool explicitCall = CallingConvention.CallType.kExplicit == callType || CallingConvention.CallType.kExplicitBase == callType;
isExplicitCall = explicitCall;
if (!core.Options.IDEDebugMode || core.ExecMode == InterpreterMode.kExpressionInterpreter)
{
int localCount = 0;
int paramCount = 0;
GetLocalAndParamCount(blockId, ci, fi, out localCount, out paramCount);
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(ProtoCore.DSASM.StackFrame.kStackFrameSize + localCount + paramCount);
if (core.ExecMode != InterpreterMode.kExpressionInterpreter)
{
// Restoring the registers require the current frame pointer of the stack frame
RestoreRegistersFromStackFrame();
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
}
}
terminate = !explicitCall;
Properties = PopInterpreterProps();
ProcedureNode procNode = GetProcedureNode(blockId, ci, fi);
if (explicitCall)
{
//RX = CallSite.PerformReturnTypeCoerce(procNode, core, RX);
bool wasDebugPropsPopped = DebugReturn(procNode, pc);
// Comment Jun: For explicit calls, we need to manually GC decrement the arguments.
// These arguments were GC incremented on callr
if (!wasDebugPropsPopped)
//if (!core.Options.IDEDebugMode || core.ExecMode == ExecutionMode.kExpressionInterpreter)
{
for (int i = 0; i < Properties.functionCallArguments.Count; ++i)
{
GCUtils.GCRelease(Properties.functionCallArguments[i], core);
}
}
if (CallingConvention.CallType.kExplicitBase != callType)
{
//if (!core.Options.IDEDebugMode || core.ExecMode == ExecutionMode.kExpressionInterpreter)
if (!wasDebugPropsPopped)
{
DecRefCounter(RX);
}
}
}
return;
}
示例2: EmitAllocc
private void EmitAllocc(int type)
{
SetEntry();
Instruction instr = new Instruction();
instr.opCode = ProtoCore.DSASM.OpCode.ALLOCC;
instr.op1 = StackValue.BuildClassIndex(type);
++pc;
codeBlock.instrStream.instrList.Add(instr);
// TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter
//AppendInstruction(instr);
}
示例3: EmitJumpDependency
protected void EmitJumpDependency()
{
EmitInstrConsole(ProtoCore.DSASM.kw.jdep);
Instruction instr = new Instruction();
instr.opCode = ProtoCore.DSASM.OpCode.JDEP;
++pc;
codeBlock.instrStream.instrList.Add(instr);
}
示例4: EmitPushDep
private void EmitPushDep(int block, int depth, int classScope)
{
EmitInstrConsole(ProtoCore.DSASM.kw.pushdep, block.ToString() + "[block]", depth.ToString() + "[depth]", classScope.ToString() + "[classScope]");
ProtoCore.DSASM.Instruction instr = new ProtoCore.DSASM.Instruction();
instr.opCode = ProtoCore.DSASM.OpCode.PUSHDEP;
ProtoCore.DSASM.StackValue opBlock = new ProtoCore.DSASM.StackValue();
opBlock.optype = ProtoCore.DSASM.AddressType.BlockIndex;
opBlock.opdata = block;
ProtoCore.DSASM.StackValue opDepth = new ProtoCore.DSASM.StackValue();
opDepth.optype = ProtoCore.DSASM.AddressType.Int;
opDepth.opdata = depth;
ProtoCore.DSASM.StackValue opClass = new ProtoCore.DSASM.StackValue();
opClass.optype = ProtoCore.DSASM.AddressType.ClassIndex;
opClass.opdata = classScope;
instr.op1 = opBlock;
instr.op2 = opDepth;
instr.op3 = opClass;
++pc;
codeBlock.instrStream.instrList.Add(instr);
// TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter
//AppendInstruction(instr);
}
示例5: EmitSetExpressionUID
private void EmitSetExpressionUID(int exprId)
{
EmitInstrConsole(ProtoCore.DSASM.kw.setexpuid, exprId.ToString() + "[exprId]");
ProtoCore.DSASM.Instruction instr = new ProtoCore.DSASM.Instruction();
instr.opCode = ProtoCore.DSASM.OpCode.SETEXPUID;
ProtoCore.DSASM.StackValue opExId = new ProtoCore.DSASM.StackValue();
opExId.optype = ProtoCore.DSASM.AddressType.Int;
opExId.opdata = exprId;
instr.op1 = opExId;
++pc;
codeBlock.instrStream.instrList.Add(instr);
// TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter
//AppendInstruction(instr);
}
示例6: Exec
private void Exec(Instruction instruction)
{
switch (instruction.opCode)
{
case OpCode.ALLOC:
{
ALLOC_Handler(instruction);
return;
}
case OpCode.ALLOCC:
{
ALLOCC_Handler(instruction);
return;
}
case OpCode.ALLOCM:
{
ALLOCM_Handler(instruction);
return;
}
case OpCode.PUSH:
{
PUSH_Handler(instruction);
return;
}
case OpCode.PUSHW:
{
PUSHW_Handler(instruction);
return;
}
case OpCode.PUSHINDEX:
{
PUSHINDEX_Handler(instruction);
return;
}
case OpCode.PUSHG:
{
PUSHG_Handler(instruction);
return;
}
case OpCode.PUSHB:
{
PUSHB_Handler(instruction);
return;
}
case OpCode.POPB:
{
POPB_Handler(instruction);
return;
}
case OpCode.PUSHM:
{
PUSHM_Handler(instruction);
return;
}
case OpCode.PUSHLIST:
{
PUSHLIST_Handler(instruction);
return;
}
case OpCode.PUSH_ARRAYKEY:
{
PUSH_VARSIZE_Handler(instruction);
return;
}
case OpCode.POP:
{
POP_Handler(instruction);
return;
}
case OpCode.POPW:
{
POPW_Handler(instruction);
return;
}
case OpCode.POPG:
{
POPG_Handler(instruction);
return;
}
case OpCode.POPM:
{
POPM_Handler(instruction);
return;
}
case OpCode.POPLIST:
{
POPLIST_Handler(instruction);
//.........这里部分代码省略.........
示例7: EmitAllocc
private void EmitAllocc(int type)
{
SetEntry();
ProtoCore.DSASM.Instruction instr = new ProtoCore.DSASM.Instruction();
instr.opCode = ProtoCore.DSASM.OpCode.ALLOCC;
ProtoCore.DSASM.StackValue op = new ProtoCore.DSASM.StackValue();
op.optype = ProtoCore.DSASM.AddressType.ClassIndex;
op.opdata = type;
instr.op1 = op;
++pc;
codeBlock.instrStream.instrList.Add(instr);
// TODO: Figure out why using AppendInstruction fails for adding these instructions to ExpressionInterpreter
//AppendInstruction(instr);
}
示例8: JMP_GT_Handler
private void JMP_GT_Handler(Instruction instruction)
{
StackValue opdata1 = GetOperandData(instruction.op1);
StackValue opdata2 = GetOperandData(instruction.op2);
bool isGT = false;
if (AddressType.Double == opdata1.optype || AddressType.Double == opdata2.optype)
{
isGT = opdata1.opdata_d > opdata2.opdata_d;
}
else
{
isGT = opdata1.opdata > opdata2.opdata;
}
if (isGT)
{
pc = (int)instruction.op3.opdata;
}
else
{
++pc;
}
return;
}
示例9: JMP_LT_Handler
private void JMP_LT_Handler(Instruction instruction)
{
StackValue opdata1 = GetOperandData(instruction.op1);
StackValue opdata2 = GetOperandData(instruction.op2);
if (AddressType.Double == opdata1.optype || AddressType.Double == opdata2.optype)
{
if (opdata1.opdata_d < opdata2.opdata_d)
{
pc = (int)instruction.op3.opdata;
}
else
{
++pc;
}
}
else
{
if (opdata1.opdata < opdata2.opdata)
{
pc = (int)instruction.op3.opdata;
}
else
{
++pc;
}
}
return;
}
示例10: JMP_Handler
private void JMP_Handler(Instruction instruction)
{
pc = (int)instruction.op1.opdata;
return;
}
示例11: CJMP_Handler
private void CJMP_Handler(Instruction instruction)
{
StackValue opdata1 = GetOperandData(instruction.op1);
if (opdata1.optype == ProtoCore.DSASM.AddressType.Double)
{
if (0 == opdata1.opdata_d)
{
pc = (int)GetOperandData(instruction.op3).opdata;
}
else
{
pc = (int)GetOperandData(instruction.op2).opdata;
}
}
else
{
if (opdata1.optype == ProtoCore.DSASM.AddressType.Pointer)
{
pc = (int)GetOperandData(instruction.op2).opdata;
}
else if (0 == opdata1.opdata)
{
pc = (int)GetOperandData(instruction.op3).opdata;
}
else
{
pc = (int)GetOperandData(instruction.op2).opdata;
}
}
return;
}
示例12: RETURN_Handler
private void RETURN_Handler(Instruction instruction)
{
isGlobScope = true;
runtimeVerify(rmem.ValidateStackFrame());
int ptr = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexThisPtr).opdata;
int ci = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexClass).opdata;
int fi = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunction).opdata;
int blockId = (int)SX.opdata;
StackValue svBlockDecl = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexRegisterSX);
Validity.Assert(AddressType.BlockIndex == svBlockDecl.optype);
blockId = (int)svBlockDecl.opdata;
ProcedureNode procNode = GetProcedureNode(blockId, ci, fi);
if (core.Options.ExecuteSSA)
{
if (core.Options.GCTempVarsOnDebug && core.Options.IDEDebugMode)
{
// GC anonymous variables in the return stmt
if (null != Properties.executingGraphNode && !Properties.executingGraphNode.IsSSANode())
{
GCAnonymousSymbols(Properties.executingGraphNode.symbolListWithinExpression);
Properties.executingGraphNode.symbolListWithinExpression.Clear();
}
}
}
pc = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexReturnAddress).opdata;
executingBlock = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFunctionCallerBlock).opdata;
if (core.ExecMode != ProtoCore.DSASM.InterpreterMode.kExpressionInterpreter)
{
ReturnSiteGC(blockId, ci, fi);
}
RestoreFromCall();
core.RunningBlock = executingBlock;
// If we're returning from a block to a function, the instruction stream needs to be restored.
StackValue sv = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexRegisterTX);
Validity.Assert(AddressType.CallingConvention == sv.optype);
CallingConvention.CallType callType = (CallingConvention.CallType)sv.opdata;
bool explicitCall = CallingConvention.CallType.kExplicit == callType;
isExplicitCall = explicitCall;
List<bool> execStateRestore = new List<bool>();
if (!core.Options.IDEDebugMode || core.ExecMode == InterpreterMode.kExpressionInterpreter)
{
// Get stack frame size
int localCount = 0;
int paramCount = 0;
GetLocalAndParamCount(blockId, ci, fi, out localCount, out paramCount);
// Retrieve the execution execution states
int execstates = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexExecutionStates).opdata;
if (execstates > 0)
{
int offset = ProtoCore.DSASM.StackFrame.kStackFrameSize + localCount + paramCount;
for (int n = 0; n < execstates; ++n)
{
int relativeIndex = -offset - n - 1;
StackValue svState = rmem.GetAtRelative(relativeIndex);
Validity.Assert(svState.optype == AddressType.Boolean);
execStateRestore.Add(svState.opdata == 0 ? false : true);
}
}
// Pop the stackframe
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
// Get the size of the stackframe and all variable size contents (local, args and exec states)
int stackFrameSize = ProtoCore.DSASM.StackFrame.kStackFrameSize + localCount + paramCount + execstates;
rmem.PopFrame(stackFrameSize);
if (core.ExecMode != InterpreterMode.kExpressionInterpreter)
{
// Restoring the registers require the current frame pointer of the stack frame
RestoreRegistersFromStackFrame();
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
}
}
terminate = !explicitCall;
// Comment Jun: Dispose calls are always implicit and need to terminate
// TODO Jun: This instruction should not know about dispose
bool isDispose = CoreUtils.IsDisposeMethod(procNode.name);
if (isDispose)
{
terminate = true;
}
//.........这里部分代码省略.........
示例13: RETCN_Handler
private void RETCN_Handler(Instruction instruction)
{
if (core.ExecMode != InterpreterMode.kExpressionInterpreter)
{
core.Rmem.PopConstructBlockId();
}
StackValue op1 = instruction.op1;
runtimeVerify(op1.optype == AddressType.BlockIndex);
int blockId = (int)op1.opdata;
CodeBlock codeBlock = core.CompleteCodeBlockList[blockId];
runtimeVerify(codeBlock.blockType == CodeBlockType.kConstruct);
GCCodeBlock(blockId);
pc++;
return;
}
示例14: RETB_Handler
private void RETB_Handler(Instruction instruction)
{
if (core.ExecMode != InterpreterMode.kExpressionInterpreter)
{
core.Rmem.PopConstructBlockId();
}
if (!core.Options.IsDeltaExecution || (core.Options.IsDeltaExecution && 0 != core.RunningBlock))
{
GCCodeBlock(core.RunningBlock);
}
if (ProtoCore.DSASM.CallingConvention.BounceType.kExplicit == bounceType)
{
RestoreFromBounce();
core.RunningBlock = executingBlock;
}
if (ProtoCore.DSASM.CallingConvention.BounceType.kImplicit == bounceType)
{
pc = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexReturnAddress).opdata;
terminate = true;
}
ProtoCore.DSASM.StackFrameType type = StackFrameType.kTypeLanguage;
// Comment Jun: Just want to see if this is the global rerb, in which case we dont retrieve anything
//if (executingBlock > 0)
{
StackValue svCallerType = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexCallerStackFrameType);
type = (ProtoCore.DSASM.StackFrameType)svCallerType.opdata;
}
// Pop the frame as we are adding stackframes for language blocks as well - pratapa
// Do not do this for the final Retb
//if (core.RunningBlock != 0)
if (!core.Options.IDEDebugMode || core.ExecMode == InterpreterMode.kExpressionInterpreter)
{
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(ProtoCore.DSASM.StackFrame.kStackFrameSize);
if (bounceType == CallingConvention.BounceType.kExplicit)
{
// Restoring the registers require the current frame pointer of the stack frame
RestoreRegistersFromStackFrame();
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
#if ENABLE_EXCEPTION_HANDLING
core.ExceptionHandlingManager.CurrentActiveRegistration = core.stackActiveExceptionRegistration.Pop();
if (core.ExceptionHandlingManager.IsStackUnwinding)
{
#region __MERGE_WITH_STACKUNWIND
// The excecution of last langage block is interrupted
// abnormally because of stack unwinding, so we need to
// run GC to reclaim those allocated memory.
GCCodeBlock(core.RunningBlock);
int newpc = ProtoCore.DSASM.Constants.kInvalidIndex;
if (core.ExceptionHandlingManager.CanHandleIt(ref newpc))
{
LX = RX;
pc = newpc;
core.ExceptionHandlingManager.SetHandled();
}
// else cannot handle in this scope, so in the next
// loop of Execute(), current executive will be ;
// ended and returns to the last scope, continues
// stack unwinding
int origRunningBlock = executingBlock;
core.RunningBlock = origRunningBlock;
#endregion
}
else
{
DecRefCounter(RX);
}
#else
DecRefCounter(RX);
#endif
}
}
else
{
DecRefCounter(RX);
}
if (type == StackFrameType.kTypeFunction)
{
// Comment Jun:
// Consider moving this to a restore to function method
// If this language block was called explicitly, only then do we need to restore the instruction stream
if (bounceType == CallingConvention.BounceType.kExplicit)
{
// If we're returning from a block to a function, the instruction stream needs to be restored.
StackValue sv = rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexRegisterTX);
Validity.Assert(AddressType.CallingConvention == sv.optype);
//.........这里部分代码省略.........
示例15: THROW_Handler
private void THROW_Handler(Instruction instruction)
{
#if ENABLE_EXCEPTION_HANDLING
runtimeVerify(ProtoCore.DSASM.AddressType.BlockIndex == instruction.op1.optype);
int blockId = (int)instruction.op1.opdata;
runtimeVerify(ProtoCore.DSASM.AddressType.ClassIndex == instruction.op2.optype);
int classScope = (int)instruction.op2.opdata;
runtimeVerify(ProtoCore.DSASM.AddressType.FunctionIndex == instruction.op3.optype);
int functionScope = (int)instruction.op3.opdata;
StackValue exceptionValue = LX;
ProtoCore.Exceptions.ExceptionContext context = new Exceptions.ExceptionContext();
context.pc = pc;
context.codeBlockId = blockId;
context.functionScope = functionScope;
context.classScope = classScope;
switch (exceptionValue.optype)
{
case AddressType.Int:
context.typeUID = (int)ProtoCore.PrimitiveType.kTypeInt;
break;
case AddressType.Double:
context.typeUID = (int)ProtoCore.PrimitiveType.kTypeDouble;
break;
case AddressType.Boolean:
context.typeUID = (int)ProtoCore.PrimitiveType.kTypeBool;
break;
case AddressType.Pointer:
context.typeUID = (int)exceptionValue.metaData.type;
break;
default:
context.typeUID = (int)ProtoCore.PrimitiveType.kTypeVar;
break;
}
// Walk through exception chain, a.k.a. 1st hand exception
// handling
core.ExceptionHandlingManager.HandleFirstHandException(context);
// The exception can be handled in current scope, so simply jmp to
// the corresponding catch block
int newpc = ProtoCore.DSASM.Constants.kInvalidIndex;
if (core.ExceptionHandlingManager.CanHandleIt(ref newpc))
{
pc = newpc;
core.ExceptionHandlingManager.SetHandled();
}
else
{
RX = LX;
}
if (core.ExceptionHandlingManager.IsStackUnwinding)
{
while (core.stackActiveExceptionRegistration.Count > 1)
{
StackValue svType = rmem.GetAtRelative(StackFrame.kFrameIndexStackFrameType);
StackFrameType type = (StackFrameType)svType.opdata;
if (StackFrameType.kTypeLanguage == type)
{
RestoreFromBounce();
rmem.FramePointer = (int)rmem.GetAtRelative(ProtoCore.DSASM.StackFrame.kFrameIndexFramePointer).opdata;
rmem.PopFrame(ProtoCore.DSASM.StackFrame.kStackFrameSize);
// Restoring the registers require the current frame pointer of the stack frame
RestoreRegistersFromStackFrame();
bounceType = (ProtoCore.DSASM.CallingConvention.BounceType)TX.opdata;
core.ExceptionHandlingManager.CurrentActiveRegistration = core.stackActiveExceptionRegistration.Pop();
#region __MERGE_WITH_STACKUNWIND
// The excecution of last langage block is interrupted
// abnormally because of stack unwinding, so we need to
// run GC to reclaim those allocated memory.
GCCodeBlock(core.RunningBlock);
newpc = ProtoCore.DSASM.Constants.kInvalidIndex;
if (core.ExceptionHandlingManager.CanHandleIt(ref newpc))
{
LX = RX;
pc = newpc;
core.ExceptionHandlingManager.SetHandled();
break;
}
// else cannot handle in this scope, so in the next
// loop of Execute(), current executive will be ;
// ended and returns to the last scope, continues
// stack unwinding
int origRunningBlock = executingBlock;
core.RunningBlock = origRunningBlock;
#endregion
}
else
{
RestoreFromCall();
//.........这里部分代码省略.........