/// <summary> /// Import thunks are used to call a runtime-provided helper which fixes up an indirection cell in a particular /// import section. Optionally they may also contain a relocation for a specific indirection cell to fix up. /// </summary> public ImportThunk(NodeFactory factory, ReadyToRunHelper helperId, ImportSectionNode containingImportSection, bool useVirtualCall) { _helperCell = factory.GetReadyToRunHelperCell(helperId); _containingImportSection = containingImportSection; if (useVirtualCall) { _thunkKind = Kind.VirtualStubDispatch; } else if (helperId == ReadyToRunHelper.GetString) { _thunkKind = Kind.Lazy; } else if (helperId == ReadyToRunHelper.DelayLoad_MethodCall || helperId == ReadyToRunHelper.DelayLoad_Helper || helperId == ReadyToRunHelper.DelayLoad_Helper_Obj || helperId == ReadyToRunHelper.DelayLoad_Helper_ObjObj) { _thunkKind = Kind.DelayLoadHelper; } else { _thunkKind = Kind.Eager; } }
public ImportThunk(ReadyToRunHelper helperId, ReadyToRunCodegenNodeFactory factory, Import instanceCell) { _helperCell = factory.GetReadyToRunHelperCell(helperId & ~ReadyToRunHelper.READYTORUN_HELPER_FLAG_VSD); _instanceCell = instanceCell; _moduleImport = factory.ModuleImport; if ((uint)(helperId & ReadyToRunHelper.READYTORUN_HELPER_FLAG_VSD) != 0) { _thunkKind = Kind.VirtualStubDispatch; } else if (helperId == ReadyToRunHelper.READYTORUN_HELPER_GetString) { _thunkKind = Kind.Lazy; } else if (helperId == ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_MethodCall || helperId == ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_Helper || helperId == ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_Helper_Obj || helperId == ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_Helper_ObjObj) { _thunkKind = Kind.DelayLoadHelper; } else { _thunkKind = Kind.Eager; } }
public ImportThunkKey(ReadyToRunHelper helper, ImportSectionNode containingImportSection, bool useVirtualCall, bool useJumpableStub) { Helper = helper; ContainingImportSection = containingImportSection; UseVirtualCall = useVirtualCall; UseJumpableStub = useJumpableStub; }
public ImportThunk(ReadyToRunHelper helperId, ReadyToRunCodegenNodeFactory factory, Import instanceCell, bool useVirtualCall) { _helperCell = factory.GetReadyToRunHelperCell(helperId); _instanceCell = instanceCell; _moduleImport = factory.ModuleImport; if (useVirtualCall) { _thunkKind = Kind.VirtualStubDispatch; } else if (helperId == ReadyToRunHelper.GetString) { _thunkKind = Kind.Lazy; } else if (helperId == ReadyToRunHelper.DelayLoad_MethodCall || helperId == ReadyToRunHelper.DelayLoad_Helper || helperId == ReadyToRunHelper.DelayLoad_Helper_Obj || helperId == ReadyToRunHelper.DelayLoad_Helper_ObjObj) { _thunkKind = Kind.DelayLoadHelper; } else { _thunkKind = Kind.Eager; } }
public ISymbolNode GetReadyToRunHelperCell(ReadyToRunHelper helperId) { if (!_constructedHelpers.TryGetValue(helperId, out ISymbolNode helperCell)) { helperCell = CreateReadyToRunHelperCell(helperId); _constructedHelpers.Add(helperId, helperCell); } return(helperCell); }
public IActionResult Post([FromBody] QuoterRequestArgument arguments) { string prefix = null; string responseText = "Quoter is currently down for maintenance. Please check back later."; if (arguments is null) { return BadRequest(responseText); } if (string.IsNullOrEmpty(arguments.SourceText)) { responseText = "Please specify the source text."; } else if (arguments.SourceText.Length > 2000) { responseText = "Only strings shorter than 2000 characters are supported; your input string is " + arguments.SourceText.Length + " characters long."; } else { try { var quoter = new Quoter { OpenParenthesisOnNewLine = arguments.OpenCurlyOnNewLine, ClosingParenthesisOnNewLine = arguments.CloseCurlyOnNewLine, UseDefaultFormatting = !arguments.PreserveOriginalWhitespace, RemoveRedundantModifyingCalls = !arguments.KeepRedundantApiCalls, ShortenCodeWithUsingStatic = !arguments.AvoidUsingStatic }; responseText = quoter.QuoteText(arguments.SourceText, arguments.NodeKind); if (arguments.ReadyToRun) { responseText = ReadyToRunHelper.CreateReadyToRunCode(arguments, responseText); } } catch (Exception ex) { responseText = ex.ToString(); prefix = "Congratulations! You've found a bug in Quoter! Please open an issue at <a href=\"https://github.com/KirillOsenkov/RoslynQuoter/issues/new\" target=\"_blank\">https://github.com/KirillOsenkov/RoslynQuoter/issues/new</a> and paste the code you've typed above and this stack:"; } } responseText = HttpUtility.HtmlEncode(responseText); if (prefix != null) { responseText = "<div class=\"error\"><p>" + prefix + "</p><p>" + responseText + "</p><p><br/>P.S. Sorry!</p></div>"; } return Ok(responseText); }
public DelayLoadHelperImport( ReadyToRunCodegenNodeFactory factory, ImportSectionNode importSectionNode, ReadyToRunHelper helper, Signature instanceSignature, bool useVirtualCall = false, string callSite = null) : base(importSectionNode, instanceSignature, callSite) { _helper = helper; _useVirtualCall = useVirtualCall; _delayLoadHelper = new ImportThunk(helper, factory, this, useVirtualCall); }
public DelayLoadHelperMethodImport( ReadyToRunCodegenNodeFactory factory, ImportSectionNode importSectionNode, ReadyToRunHelper helper, MethodDesc methodDesc, Signature instanceSignature, string callSite = null) : base(factory, importSectionNode, helper, instanceSignature, callSite) { _helper = helper; _methodDesc = methodDesc; _delayLoadHelper = new ImportThunk(helper, factory, this); }
public DelayLoadHelperImport( NodeFactory factory, ImportSectionNode importSectionNode, ReadyToRunHelper helper, Signature instanceSignature, bool useVirtualCall = false, MethodDesc callingMethod = null) : base(importSectionNode, instanceSignature, callingMethod) { _helper = helper; _useVirtualCall = useVirtualCall; _delayLoadHelper = new ImportThunk(helper, factory, this, useVirtualCall); }
public DelayLoadHelperMethodImport( NodeFactory factory, ImportSectionNode importSectionNode, ReadyToRunHelper helper, MethodWithToken method, bool useVirtualCall, bool useInstantiatingStub, Signature instanceSignature, MethodDesc callingMethod = null) : base(factory, importSectionNode, helper, instanceSignature, useVirtualCall, callingMethod) { _method = method; _useInstantiatingStub = useInstantiatingStub; }
public DelayLoadHelperMethodImport( ReadyToRunCodegenNodeFactory factory, ImportSectionNode importSectionNode, ReadyToRunHelper helper, MethodWithToken method, bool useVirtualCall, bool useInstantiatingStub, Signature instanceSignature, SignatureContext signatureContext, string callSite = null) : base(factory, importSectionNode, helper, instanceSignature, useVirtualCall, callSite) { _method = method; _useInstantiatingStub = useInstantiatingStub; _signatureContext = signatureContext; }
private ISymbolNode GetHelperEntrypoint(ReadyToRunHelper helper) { string mangledName; MethodDesc methodDesc; JitHelper.GetEntryPoint(_compilation.TypeSystemContext, helper, out mangledName, out methodDesc); Debug.Assert(mangledName != null || methodDesc != null); ISymbolNode entryPoint; if (mangledName != null) { entryPoint = _compilation.NodeFactory.ExternSymbol(mangledName); } else { entryPoint = _compilation.NodeFactory.MethodEntrypoint(methodDesc); } return(entryPoint); }
public ImportThunk ImportThunk(ReadyToRunHelper helper, ImportSectionNode containingImportSection, bool useVirtualCall, bool useJumpableStub) { ImportThunkKey thunkKey = new ImportThunkKey(helper, containingImportSection, useVirtualCall, useJumpableStub); return(_importThunks.GetOrAdd(thunkKey)); }
public ReadyToRunHelperNode ReadyToRunHelper(ReadyToRunHelper helper) { return(_readyToRunHelpers.GetOrAdd(helper)); }
public Import GetReadyToRunHelperCell(ReadyToRunHelper helperId) { return(_constructedHelpers.GetOrAdd(helperId)); }
public ReadyToRunHelperNode(ReadyToRunHelper helper) { _helper = helper; }
private ISymbolNode CreateReadyToRunHelperCell(ReadyToRunHelper helperId) { return(new Import(EagerImports, new ReadyToRunHelperSignature(helperId))); }
public ISymbolNode GetReadyToRunHelperCell(ReadyToRunHelper helperId) { return(_constructedHelpers.GetOrAdd(helperId)); }
public ReadyToRunHelperSignature(ReadyToRunHelper helper) { _helperID = helper; }
public ReadyToRunHelperSignature(ReadyToRunHelper helper) { Debug.Assert(helper < ReadyToRunHelper.FirstFakeHelper); _helperID = helper; }
/// <summary> /// Returns JIT helper entrypoint. JIT helpers can be either implemented by entrypoint with given mangled name or /// by a method in class library. /// </summary> static public void GetEntryPoint(TypeSystemContext context, ReadyToRunHelper id, out string mangledName, out MethodDesc methodDesc) { mangledName = null; methodDesc = null; switch (id) { case ReadyToRunHelper.Throw: mangledName = "RhpThrowEx"; break; case ReadyToRunHelper.Rethrow: mangledName = "RhpRethrow"; break; case ReadyToRunHelper.Overflow: methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowOverflowException"); break; case ReadyToRunHelper.RngChkFail: methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowIndexOutOfRangeException"); break; case ReadyToRunHelper.FailFast: mangledName = "__fail_fast"; // TODO: Report stack buffer overrun break; case ReadyToRunHelper.ThrowNullRef: methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowNullReferenceException"); break; case ReadyToRunHelper.ThrowDivZero: methodDesc = context.GetHelperEntryPoint("ThrowHelpers", "ThrowDivideByZeroException"); break; case ReadyToRunHelper.DebugBreak: mangledName = "RhDebugBreak"; break; case ReadyToRunHelper.WriteBarrier: mangledName = "RhpAssignRef"; break; case ReadyToRunHelper.CheckedWriteBarrier: mangledName = "RhpCheckedAssignRef"; break; case ReadyToRunHelper.ByRefWriteBarrier: mangledName = "RhpByRefAssignRef"; break; case ReadyToRunHelper.Box: case ReadyToRunHelper.Box_Nullable: mangledName = "RhBox"; break; case ReadyToRunHelper.Unbox: mangledName = "RhUnbox2"; break; case ReadyToRunHelper.Unbox_Nullable: mangledName = "RhUnboxNullable"; break; case ReadyToRunHelper.NewMultiDimArr_NonVarArg: methodDesc = context.GetHelperEntryPoint("ArrayHelpers", "NewObjArray"); break; case ReadyToRunHelper.Stelem_Ref: mangledName = "RhpStelemRef"; break; case ReadyToRunHelper.Ldelema_Ref: mangledName = "RhpLdelemaRef"; break; case ReadyToRunHelper.MemCpy: mangledName = "memcpy"; // TODO: Null reference handling break; case ReadyToRunHelper.MemSet: mangledName = "memset"; // TODO: Null reference handling break; case ReadyToRunHelper.GetRuntimeTypeHandle: methodDesc = context.GetHelperEntryPoint("LdTokenHelpers", "GetRuntimeTypeHandle"); break; case ReadyToRunHelper.GetRuntimeMethodHandle: // TODO: Reflection case ReadyToRunHelper.GetRuntimeFieldHandle: // TODO: Reflection mangledName = "__fail_fast"; break; case ReadyToRunHelper.Lng2Dbl: mangledName = "RhpLng2Dbl"; break; case ReadyToRunHelper.ULng2Dbl: mangledName = "RhpULng2Dbl"; break; case ReadyToRunHelper.Dbl2Lng: mangledName = "RhpDbl2Lng"; break; case ReadyToRunHelper.Dbl2ULng: mangledName = "RhpDbl2ULng"; break; case ReadyToRunHelper.Dbl2IntOvf: methodDesc = context.GetHelperEntryPoint("MathHelpers", "Dbl2IntOvf"); break; case ReadyToRunHelper.Dbl2LngOvf: methodDesc = context.GetHelperEntryPoint("MathHelpers", "Dbl2LngOvf"); break; case ReadyToRunHelper.Dbl2ULngOvf: methodDesc = context.GetHelperEntryPoint("MathHelpers", "Dbl2ULngOvf"); break; case ReadyToRunHelper.DblRem: mangledName = "RhpDblRem"; break; case ReadyToRunHelper.FltRem: mangledName = "RhpFltRem"; break; case ReadyToRunHelper.PInvokeBegin: mangledName = "RhpPInvoke"; break; case ReadyToRunHelper.PInvokeEnd: mangledName = "RhpPInvokeReturn"; break; case ReadyToRunHelper.ReversePInvokeEnter: mangledName = "RhpReversePInvoke2"; break; case ReadyToRunHelper.ReversePInvokeExit: mangledName = "RhpReversePInvokeReturn2"; break; default: throw new NotImplementedException(id.ToString()); } }
public ReadyToRunHelperNode(ReadyToRunHelper helper) { _helper = helper; }