public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; byte[] data; RelocType relocType; switch (factory.Target.PointerSize) { case 4: data = BitConverter.GetBytes(_sectionRelativeOffset); relocType = RelocType.IMAGE_REL_BASED_HIGHLOW; break; case 8: data = BitConverter.GetBytes((long)_sectionRelativeOffset); relocType = RelocType.IMAGE_REL_BASED_DIR64; break; default: throw new NotImplementedException(); } return(new ObjectData( data: data, relocs: new Relocation[] { new Relocation(relocType, 0, _sectionStartNode) }, alignment: factory.Target.PointerSize, definedSymbols: new ISymbolDefinitionNode[] { this } )); }
public ExternalMethodImport( ReadyToRunCodegenNodeFactory factory, ReadyToRunFixupKind fixupKind, MethodDesc methodDesc, TypeDesc constrainedType, ModuleToken methodToken, bool isUnboxingStub, bool isInstantiatingStub, SignatureContext signatureContext) : base( factory, factory.MethodImports, ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_MethodCall, factory.MethodSignature( fixupKind, methodDesc, constrainedType, methodToken, isUnboxingStub, isInstantiatingStub, signatureContext)) { _methodDesc = methodDesc; _signatureContext = signatureContext; }
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 override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder builder = new ObjectDataSignatureBuilder(); builder.AddSymbol(this); if (!relocsOnly) { SignatureContext innerContext = builder.EmitFixup(r2rFactory, ReadyToRunFixupKind.READYTORUN_FIXUP_DelegateCtor, _methodToken.Module, _signatureContext); builder.EmitMethodSignature( _targetMethod.Method, constrainedType: null, methodToken: _methodToken, enforceDefEncoding: false, innerContext, isUnboxingStub: false, isInstantiatingStub: false); builder.EmitTypeSignature(_delegateType, innerContext); } return(builder.ToObjectData()); }
internal ReadyToRunCodegenCompilation( DependencyAnalyzerBase <NodeFactory> dependencyGraph, ReadyToRunCodegenNodeFactory nodeFactory, IEnumerable <ICompilationRootProvider> roots, ILProvider ilProvider, Logger logger, DevirtualizationManager devirtualizationManager, JitConfigProvider configProvider, string inputFilePath, IEnumerable <ModuleDesc> modulesBeingInstrumented, bool resilient, bool generateMapFile, int parallelism) : base(dependencyGraph, nodeFactory, roots, ilProvider, devirtualizationManager, modulesBeingInstrumented, logger) { _resilient = resilient; _parallelism = parallelism; _generateMapFile = generateMapFile; NodeFactory = nodeFactory; SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory); _jitConfigProvider = configProvider; _inputFilePath = inputFilePath; _corInfoImpls = new ConditionalWeakTable <Thread, CorInfoImpl>(); CorInfoImpl.RegisterJITModule(configProvider); }
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 override ICompilation ToCompilation() { ModuleTokenResolver moduleTokenResolver = new ModuleTokenResolver(_compilationGroup, _context); SignatureContext signatureContext = new SignatureContext(_inputModule, moduleTokenResolver); CopiedCorHeaderNode corHeaderNode = new CopiedCorHeaderNode(_inputModule); ReadyToRunCodegenNodeFactory factory = new ReadyToRunCodegenNodeFactory( _context, _compilationGroup, _nameMangler, moduleTokenResolver, signatureContext, corHeaderNode); DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory); List <CorJitFlag> corJitFlags = new List <CorJitFlag> { CorJitFlag.CORJIT_FLAG_DEBUG_INFO }; switch (_optimizationMode) { case OptimizationMode.None: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE); break; case OptimizationMode.PreferSize: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT); break; case OptimizationMode.PreferSpeed: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT); break; default: // Not setting a flag results in BLENDED_CODE. break; } if (_ibcTuning) { corJitFlags.Add(CorJitFlag.CORJIT_FLAG_BBINSTR); } corJitFlags.Add(CorJitFlag.CORJIT_FLAG_PROF_REJIT_NOPS); var jitConfig = new JitConfigProvider(corJitFlags, _ryujitOptions); return(new ReadyToRunCodegenCompilation( graph, factory, _compilationRoots, _ilProvider, _logger, new DependencyAnalysis.ReadyToRun.DevirtualizationManager(_compilationGroup), jitConfig, _inputFilePath, new ModuleDesc[] { _inputModule })); }
public override ICompilation ToCompilation() { var interopStubManager = new EmptyInteropStubManager(); ModuleTokenResolver moduleTokenResolver = new ModuleTokenResolver(_compilationGroup, _context); SignatureContext signatureContext = new SignatureContext(_inputModule, moduleTokenResolver); ReadyToRunCodegenNodeFactory factory = new ReadyToRunCodegenNodeFactory( _context, _compilationGroup, _metadataManager, interopStubManager, _nameMangler, _vtableSliceProvider, _dictionaryLayoutProvider, moduleTokenResolver, signatureContext); DependencyAnalyzerBase <NodeFactory> graph = CreateDependencyGraph(factory); List <CorJitFlag> corJitFlags = new List <CorJitFlag> { CorJitFlag.CORJIT_FLAG_DEBUG_INFO }; switch (_optimizationMode) { case OptimizationMode.None: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_DEBUG_CODE); break; case OptimizationMode.PreferSize: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_SIZE_OPT); break; case OptimizationMode.PreferSpeed: corJitFlags.Add(CorJitFlag.CORJIT_FLAG_SPEED_OPT); break; default: // Not setting a flag results in BLENDED_CODE. break; } corJitFlags.Add(CorJitFlag.CORJIT_FLAG_PROF_REJIT_NOPS); var jitConfig = new JitConfigProvider(corJitFlags, _ryujitOptions); return(new ReadyToRunCodegenCompilation( graph, factory, _compilationRoots, _ilProvider, _debugInformationProvider, _logger, _devirtualizationManager, jitConfig, _inputFilePath)); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { // This node does not trigger generation of other nodes. if (relocsOnly) { return(new ObjectData(Array.Empty <byte>(), Array.Empty <Relocation>(), 1, new ISymbolDefinitionNode[] { this })); } NativeWriter writer = new NativeWriter(); Section section = writer.NewSection(); VertexArray vertexArray = new VertexArray(section); section.Place(vertexArray); ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; foreach (MethodWithGCInfo method in r2rFactory.EnumerateCompiledMethods()) { MemoryStream methodDebugBlob = new MemoryStream(); byte[] bounds = CreateBoundsBlobForMethod(method); byte[] vars = CreateVarBlobForMethod(method); NibbleWriter nibbleWriter = new NibbleWriter(); nibbleWriter.WriteUInt((uint)(bounds?.Length ?? 0)); nibbleWriter.WriteUInt((uint)(vars?.Length ?? 0)); byte[] header = nibbleWriter.ToArray(); methodDebugBlob.Write(header, 0, header.Length); if (bounds?.Length > 0) { methodDebugBlob.Write(bounds, 0, bounds.Length); } if (vars?.Length > 0) { methodDebugBlob.Write(vars, 0, vars.Length); } BlobVertex debugBlob = new BlobVertex(methodDebugBlob.ToArray()); vertexArray.Set(r2rFactory.RuntimeFunctionsTable.GetIndex(method), new DebugInfoVertex(debugBlob)); } vertexArray.ExpandLayout(); MemoryStream writerContent = new MemoryStream(); writer.Save(writerContent); return(new ObjectData( data: writerContent.ToArray(), relocs: null, alignment: 8, definedSymbols: new ISymbolDefinitionNode[] { this })); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); if (!relocsOnly) { dataBuilder.AddSymbol(this); switch (_runtimeLookupKind) { case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_CLASSPARAM: dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_TypeDictionaryLookup); break; case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_METHODPARAM: dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_MethodDictionaryLookup); break; case CORINFO_RUNTIME_LOOKUP_KIND.CORINFO_LOOKUP_THISOBJ: dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_ThisObjDictionaryLookup); dataBuilder.EmitTypeSignature(_methodContext.ContextType, _signatureContext); break; default: throw new NotImplementedException(); } dataBuilder.EmitByte((byte)_fixupKind); if (_typeArgument != null) { dataBuilder.EmitTypeSignature(_typeArgument, _signatureContext); } else if (_methodArgument != null) { dataBuilder.EmitMethodSignature( method: _methodArgument.Method, constrainedType: null, methodToken: _methodArgument.Token, enforceDefEncoding: false, context: _signatureContext, isUnboxingStub: false, isInstantiatingStub: true); } else if (_fieldArgument != null) { dataBuilder.EmitFieldSignature(_fieldArgument, _signatureContext); } else { throw new NotImplementedException(); } } return(dataBuilder.ToObjectData()); }
public void MaterializeSignature(ReadyToRunCodegenNodeFactory r2rFactory) { if (!_materializedSignature) { foreach (Signature signature in _signatureList) { signature.GetData(r2rFactory, relocsOnly: false); } _materializedSignature = true; } }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_NewArray); dataBuilder.EmitTypeSignature(_arrayType, _signatureContext); return(dataBuilder.ToObjectData()); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); dataBuilder.EmitFixup(r2rFactory, ReadyToRunFixupKind.READYTORUN_FIXUP_StringHandle, _token.Module, _signatureContext); dataBuilder.EmitUInt(_token.TokenRid); return(dataBuilder.ToObjectData()); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); // TODO: module override for external module strings dataBuilder.EmitByte((byte)ReadyToRunFixupKind.READYTORUN_FIXUP_StringHandle); dataBuilder.EmitUInt(_token.TokenRid); return(dataBuilder.ToObjectData()); }
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( 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 override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { if (relocsOnly) { // Method fixup signature doesn't contain any direct relocs return(new ObjectData(data: Array.Empty <byte>(), relocs: null, alignment: 0, definedSymbols: null)); } ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); // Optimize some of the fixups into a more compact form ReadyToRunFixupKind fixupKind = _fixupKind; bool optimized = false; if (!_isUnboxingStub && !_isInstantiatingStub && _method.ConstrainedType == null && fixupKind == ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry) { if (!_method.Method.OwningType.HasInstantiation) { if (_method.Token.TokenType == CorTokenType.mdtMethodDef) { fixupKind = ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry_DefToken; } else if (_method.Token.TokenType == CorTokenType.mdtMemberRef) { fixupKind = ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry_RefToken; } optimized = true; } } SignatureContext innerContext = dataBuilder.EmitFixup(r2rFactory, fixupKind, _method.Token.Module, _signatureContext); if (optimized && _method.Token.TokenType == CorTokenType.mdtMethodDef) { dataBuilder.EmitMethodDefToken(_method.Token); } else if (optimized && _method.Token.TokenType == CorTokenType.mdtMemberRef) { dataBuilder.EmitMethodRefToken(_method.Token); } else { dataBuilder.EmitMethodSignature(_method, enforceDefEncoding: false, enforceOwningType: false, innerContext, _isUnboxingStub, _isInstantiatingStub); } return(dataBuilder.ToObjectData()); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); EcmaModule targetModule = _signatureContext.GetTargetModule(_arrayType); SignatureContext innerContext = dataBuilder.EmitFixup(r2rFactory, ReadyToRunFixupKind.READYTORUN_FIXUP_NewArray, targetModule, _signatureContext); dataBuilder.EmitTypeSignature(_arrayType, innerContext); return(dataBuilder.ToObjectData()); }
public SignatureContext EmitFixup(ReadyToRunCodegenNodeFactory factory, ReadyToRunFixupKind fixupKind, EcmaModule targetModule, SignatureContext outerContext) { if (targetModule == outerContext.LocalContext) { EmitByte((byte)fixupKind); return(outerContext); } else { EmitByte((byte)(fixupKind | ReadyToRunFixupKind.READYTORUN_FIXUP_ModuleOverride)); EmitUInt((uint)factory.ManifestMetadataTable.ModuleToIndex(targetModule)); return(outerContext.InnerContext(targetModule)); } }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); if (!relocsOnly) { dataBuilder.AddSymbol(this); dataBuilder.EmitByte((byte)_fixupKind); dataBuilder.EmitFieldSignature(_fieldDesc, _signatureContext); } return(dataBuilder.ToObjectData()); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); if (!relocsOnly) { dataBuilder.AddSymbol(this); EcmaModule targetModule = _signatureContext.GetTargetModule(_typeDesc); SignatureContext innerContext = dataBuilder.EmitFixup(r2rFactory, ReadyToRunFixupKind.NewObject, targetModule, _signatureContext); dataBuilder.EmitTypeSignature(_typeDesc, innerContext); } return(dataBuilder.ToObjectData()); }
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; }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { // This node does not trigger generation of other nodes. if (relocsOnly) { return(new ObjectData(Array.Empty <byte>(), Array.Empty <Relocation>(), 1, new ISymbolDefinitionNode[] { this })); } if (_methodNodes == null) { LayoutRuntimeFunctions(); } ObjectDataBuilder runtimeFunctionsBuilder = new ObjectDataBuilder(factory, relocsOnly); ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; // Add the symbol representing this object node runtimeFunctionsBuilder.AddSymbol(this); foreach (MethodWithGCInfo method in _methodNodes) { int methodOffset = runtimeFunctionsBuilder.CountBytes; int[] funcletOffsets = method.GCInfoNode.CalculateFuncletOffsets(factory); for (int frameIndex = 0; frameIndex < method.FrameInfos.Length; frameIndex++) { FrameInfo frameInfo = method.FrameInfos[frameIndex]; // StartOffset of the runtime function runtimeFunctionsBuilder.EmitReloc(method, RelocType.IMAGE_REL_BASED_ADDR32NB, delta: frameInfo.StartOffset); if (!relocsOnly && Target.Architecture == TargetArchitecture.X64) { // On Amd64, the 2nd word contains the EndOffset of the runtime function runtimeFunctionsBuilder.EmitReloc(method, RelocType.IMAGE_REL_BASED_ADDR32NB, delta: frameInfo.EndOffset); } runtimeFunctionsBuilder.EmitReloc(r2rFactory.RuntimeFunctionsGCInfo.StartSymbol, RelocType.IMAGE_REL_BASED_ADDR32NB, funcletOffsets[frameIndex]); } } // Emit sentinel entry runtimeFunctionsBuilder.EmitUInt(~0u); _tableSize = runtimeFunctionsBuilder.CountBytes; return(runtimeFunctionsBuilder.ToObjectData()); }
public override ObjectData GetData(NodeFactory factory, bool relocsOnly = false) { if (relocsOnly) { // Method fixup signature doesn't contain any direct relocs return(new ObjectData(data: Array.Empty <byte>(), relocs: null, alignment: 0, definedSymbols: null)); } ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ObjectDataSignatureBuilder dataBuilder = new ObjectDataSignatureBuilder(); dataBuilder.AddSymbol(this); SignatureContext innerContext = dataBuilder.EmitFixup(r2rFactory, _fixupKind, _method.Token.Module, _signatureContext); dataBuilder.EmitMethodSignature(_method, enforceDefEncoding: false, innerContext, _isUnboxingStub, _isInstantiatingStub); return(dataBuilder.ToObjectData()); }
internal ReadyToRunCodegenCompilation( DependencyAnalyzerBase <NodeFactory> dependencyGraph, ReadyToRunCodegenNodeFactory nodeFactory, IEnumerable <ICompilationRootProvider> roots, ILProvider ilProvider, DebugInformationProvider debugInformationProvider, Logger logger, DevirtualizationManager devirtualizationManager, JitConfigProvider configProvider, string inputFilePath) : base(dependencyGraph, nodeFactory, roots, ilProvider, debugInformationProvider, devirtualizationManager, logger) { NodeFactory = nodeFactory; SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory); _corInfo = new Dictionary <EcmaModule, CorInfoImpl>(); _jitConfigProvider = configProvider; _inputFilePath = inputFilePath; }
internal ReadyToRunCodegenCompilation( DependencyAnalyzerBase <NodeFactory> dependencyGraph, ReadyToRunCodegenNodeFactory nodeFactory, IEnumerable <ICompilationRootProvider> roots, ILProvider ilProvider, Logger logger, DevirtualizationManager devirtualizationManager, JitConfigProvider configProvider, string inputFilePath, IEnumerable <ModuleDesc> modulesBeingInstrumented) : base(dependencyGraph, nodeFactory, roots, ilProvider, devirtualizationManager, modulesBeingInstrumented, logger) { NodeFactory = nodeFactory; SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory); _jitConfigProvider = configProvider; _inputFilePath = inputFilePath; _corInfo = new CorInfoImpl(this, _jitConfigProvider); }
public override IEnumerable <DependencyListEntry> GetStaticDependencies(NodeFactory factory) { foreach (DependencyListEntry baseEntry in base.GetStaticDependencies(factory)) { yield return(baseEntry); } if (_useInstantiatingStub) { // Require compilation of the canonical version for instantiating stubs MethodDesc canonMethod = _method.Method.GetCanonMethodTarget(CanonicalFormKind.Specific); ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ISymbolNode canonMethodNode = r2rFactory.MethodEntrypoint( new MethodWithToken(canonMethod, _method.Token, constrainedType: null), isUnboxingStub: false, isInstantiatingStub: false, signatureContext: _signatureContext); yield return(new DependencyListEntry(canonMethodNode, "Canonical method for instantiating stub")); } }
public override void EncodeData(ref ObjectDataBuilder dataBuilder, NodeFactory factory, bool relocsOnly) { if (relocsOnly) { return; } for (int frameInfoIndex = 0; frameInfoIndex < _methodNode.FrameInfos.Length; frameInfoIndex++) { byte[] unwindInfo = _methodNode.FrameInfos[frameInfoIndex].BlobData; if (factory.Target.Architecture == Internal.TypeSystem.TargetArchitecture.X64) { // On Amd64, patch the first byte of the unwind info by setting the flags to EHANDLER | UHANDLER // as that's what CoreCLR does (zapcode.cpp, ZapUnwindData::Save). const byte UNW_FLAG_EHANDLER = 1; const byte UNW_FLAG_UHANDLER = 2; const byte FlagsShift = 3; unwindInfo[0] |= (byte)((UNW_FLAG_EHANDLER | UNW_FLAG_UHANDLER) << FlagsShift); } dataBuilder.EmitBytes(unwindInfo); // 4-align after emitting the unwind info dataBuilder.EmitZeros(-unwindInfo.Length & 3); if (factory.Target.Architecture != Internal.TypeSystem.TargetArchitecture.X86) { bool isFilterFunclet = (_methodNode.FrameInfos[frameInfoIndex].Flags & FrameInfoFlags.Filter) != 0; ReadyToRunCodegenNodeFactory r2rFactory = (ReadyToRunCodegenNodeFactory)factory; ISymbolNode personalityRoutine = (isFilterFunclet ? r2rFactory.FilterFuncletPersonalityRoutine : r2rFactory.PersonalityRoutine); dataBuilder.EmitReloc(personalityRoutine, RelocType.IMAGE_REL_BASED_ADDR32NB); } if (frameInfoIndex == 0 && _methodNode.GCInfo != null) { dataBuilder.EmitBytes(_methodNode.GCInfo); // Maintain 4-alignment for the next unwind / GC info block int align4Pad = -_methodNode.GCInfo.Length & 3; dataBuilder.EmitZeros(align4Pad); } } }
public ExternalMethodImport( ReadyToRunCodegenNodeFactory factory, ReadyToRunFixupKind fixupKind, MethodWithToken method, bool isUnboxingStub, bool isInstantiatingStub, SignatureContext signatureContext) : base( factory, factory.MethodImports, ReadyToRunHelper.DelayLoad_MethodCall, factory.MethodSignature( fixupKind, method, isUnboxingStub, isInstantiatingStub, signatureContext)) { _method = method; }
internal ReadyToRunCodegenCompilation( DependencyAnalyzerBase <NodeFactory> dependencyGraph, ReadyToRunCodegenNodeFactory nodeFactory, IEnumerable <ICompilationRootProvider> roots, ILProvider ilProvider, DebugInformationProvider debugInformationProvider, PInvokeILEmitterConfiguration pInvokePolicy, Logger logger, DevirtualizationManager devirtualizationManager, JitConfigProvider configProvider, string inputFilePath) : base(dependencyGraph, nodeFactory, roots, ilProvider, debugInformationProvider, devirtualizationManager, pInvokePolicy, logger) { NodeFactory = nodeFactory; SymbolNodeFactory = new ReadyToRunSymbolNodeFactory(nodeFactory); _jitConfigProvider = configProvider; _inputFilePath = inputFilePath; _corInfo = new CorInfoImpl(this, _jitConfigProvider); }