private void PlugMethod() { var plugMethod = Compiler.PlugSystem.GetReplacement(Method); if (plugMethod == null) { return; } Compiler.MethodScanner.MethodInvoked(plugMethod, Method); IsMethodPlugged = true; Debug.Assert(plugMethod != null); var plugSymbol = Operand.CreateSymbolFromMethod(plugMethod, TypeSystem); var block = BasicBlocks.CreateBlock(BasicBlock.PrologueLabel); BasicBlocks.AddHeadBlock(block); var ctx = new Context(block); ctx.AppendInstruction(IRInstruction.Jmp, null, plugSymbol); IsCILDecodeRequired = false; IsExecutePipeline = true; IsStackFrameRequired = false; }
private void StubMethod() { var intrinsicAttribute = Method.FindCustomAttribute("System.Runtime.CompilerServices.IntrinsicAttribute"); if (intrinsicAttribute == null) { return; } var methodName = $"{Method.DeclaringType.Namespace}.{Method.DeclaringType.Name}::{Method.Name}"; var stub = Compiler.GetStubMethod(methodName); if (stub == null) { return; } IsCILStream = false; IsExecutePipeline = true; // Create the prologue block var prologue = BasicBlocks.CreateBlock(BasicBlock.PrologueLabel); BasicBlocks.AddHeadBlock(prologue); // Create the epilogue block var epilogue = BasicBlocks.CreateBlock(BasicBlock.EpilogueLabel); var start = BasicBlocks.CreateBlock(BasicBlock.StartLabel); // Add a jump instruction to the first block from the prologue prologue.First.Insert(new InstructionNode(IRInstruction.Jmp, start)); stub(new Context(start), this); if (NotifyInstructionTraceHandler != null) { var traceLog = new TraceLog(TraceType.MethodInstructions, Method, "XX-Stubbed Method", MethodData.Version); traceLog?.Log($"This method is a stubbed method"); NotifyInstructionTraceHandler.Invoke(traceLog); } }
/// <summary> /// Creates the new block. /// </summary> /// <param name="blockLabel">The label.</param> /// <param name="instructionLabel">The instruction label.</param> /// <returns></returns> protected BasicBlock CreateNewBlock(int blockLabel, int instructionLabel) { return(BasicBlocks.CreateBlock(blockLabel, instructionLabel)); }
/// <summary> /// Create an empty block. /// </summary> /// <param name="blockLabel">The label.</param> /// <returns></returns> protected BasicBlock CreateNewBlock(int blockLabel) { return(BasicBlocks.CreateBlock(blockLabel)); }
/// <summary> /// Create an empty block. /// </summary> /// <returns></returns> protected BasicBlock CreateNewBlock() { return(BasicBlocks.CreateBlock()); }