public VirtualResolutionFixupSignatureFixupKey(ReadyToRunFixupKind fixupKind, MethodWithToken declMethod, TypeDesc implType, MethodWithToken implMethod) { FixupKind = fixupKind; DeclMethod = declMethod; ImplType = implType; ImplMethod = implMethod; }
public MethodFixupSignature MethodSignature( ReadyToRunFixupKind fixupKind, MethodDesc methodDesc, TypeDesc constrainedType, ModuleToken methodToken, bool isUnboxingStub, bool isInstantiatingStub, SignatureContext signatureContext) { Dictionary <TypeAndMethod, MethodFixupSignature> perFixupKindMap; if (!_methodSignatures.TryGetValue(fixupKind, out perFixupKindMap)) { perFixupKindMap = new Dictionary <TypeAndMethod, MethodFixupSignature>(); _methodSignatures.Add(fixupKind, perFixupKindMap); } TypeAndMethod key = new TypeAndMethod(constrainedType, methodDesc, methodToken, isUnboxingStub, isInstantiatingStub); MethodFixupSignature signature; if (!perFixupKindMap.TryGetValue(key, out signature)) { signature = new MethodFixupSignature(fixupKind, methodDesc, constrainedType, methodToken, signatureContext, isUnboxingStub, isInstantiatingStub); perFixupKindMap.Add(key, signature); } return(signature); }
private ISymbolNode GenericLookupTypeHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, object helperArgument, GenericContext methodContext) { TypeDesc typeArgument; if (helperArgument is MethodWithToken methodWithToken) { typeArgument = methodWithToken.Method.OwningType; } else if (helperArgument is FieldDesc fieldDesc) { typeArgument = fieldDesc.OwningType; } else { typeArgument = (TypeDesc)helperArgument; } GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument, methodArgument: null, fieldArgument: null, methodContext); return(_genericLookupHelpers.GetOrAdd(key)); }
private ISymbolNode GenericLookupMethodHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, MethodWithToken methodArgument, GenericContext methodContext, SignatureContext signatureContext) { GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument, fieldArgument: null, methodContext); ISymbolNode node; if (!_genericLookupHelpers.TryGetValue(key, out node)) { node = new DelayLoadHelperMethodImport( _codegenNodeFactory, _codegenNodeFactory.HelperImports, ILCompiler.DependencyAnalysis.ReadyToRun.ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_Helper, methodArgument, useVirtualCall: false, useInstantiatingStub: false, new GenericLookupSignature(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument, fieldArgument: null, methodContext, signatureContext), signatureContext); _genericLookupHelpers.Add(key, node); } return(node); }
public FieldFixupSignature(ReadyToRunFixupKind fixupKind, FieldDesc fieldDesc) { _fixupKind = fixupKind; _fieldDesc = fieldDesc; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature ((CompilerTypeSystemContext)fieldDesc.Context).EnsureLoadableType(fieldDesc.OwningType); }
public TypeFixupSignature(ReadyToRunFixupKind fixupKind, TypeDesc typeDesc) { _fixupKind = fixupKind; _typeDesc = typeDesc; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature ((CompilerTypeSystemContext)typeDesc.Context).EnsureLoadableType(typeDesc); }
public GenericLookupKey(CORINFO_RUNTIME_LOOKUP_KIND lookupKind, ReadyToRunFixupKind fixupKind, TypeDesc typeArgument, MethodWithToken methodArgument, TypeDesc contextType) { LookupKind = lookupKind; FixupKind = fixupKind; TypeArgument = typeArgument; MethodArgument = methodArgument; ContextType = contextType; }
public FieldFixupSignature(ReadyToRunFixupKind fixupKind, FieldWithToken fieldWithToken, NodeFactory factory) { _fixupKind = fixupKind; _fieldWithToken = fieldWithToken; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature ((CompilerTypeSystemContext)fieldWithToken.Field.Context).EnsureLoadableType(fieldWithToken.Field.OwningType); }
public TypeFixupSignature(ReadyToRunFixupKind fixupKind, TypeDesc typeDesc, SignatureContext signatureContext) { _fixupKind = fixupKind; _typeDesc = typeDesc; _signatureContext = signatureContext; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature signatureContext.Resolver.CompilerContext.EnsureLoadableType(typeDesc); }
public FieldFixupSignature(ReadyToRunFixupKind fixupKind, FieldDesc fieldDesc, NodeFactory factory) { _fixupKind = fixupKind; _fieldDesc = fieldDesc; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature ((CompilerTypeSystemContext)fieldDesc.Context).EnsureLoadableType(fieldDesc.OwningType); Debug.Assert(factory.SignatureContext.GetTargetModule(_fieldDesc) != null); }
public MethodFixupSignature MethodSignature( ReadyToRunFixupKind fixupKind, MethodWithToken method, bool isInstantiatingStub) { TypeAndMethod key = new TypeAndMethod(method.ConstrainedType, method, isInstantiatingStub, false, false); return(_methodSignatures.GetOrAdd(new MethodFixupKey(fixupKind, key))); }
public FieldFixupSignature(ReadyToRunFixupKind fixupKind, FieldDesc fieldDesc, SignatureContext signatureContext) { _fixupKind = fixupKind; _fieldDesc = fieldDesc; _signatureContext = signatureContext; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature signatureContext.Resolver.CompilerContext.EnsureLoadableType(fieldDesc.OwningType); }
private ISymbolNode GenericLookupMethodHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, MethodWithToken methodArgument, GenericContext methodContext) { GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument, fieldArgument: null, methodContext); return(_genericLookupHelpers.GetOrAdd(key)); }
private ISymbolNode GenericLookupFieldHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, FieldDesc fieldArgument, GenericContext methodContext, SignatureContext signatureContext) { GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument: null, fieldArgument: fieldArgument, methodContext, signatureContext); return(_genericLookupHelpers.GetOrAdd(key)); }
public MethodFixupSignature( ReadyToRunFixupKind fixupKind, MethodWithToken method, SignatureContext signatureContext, bool isUnboxingStub, bool isInstantiatingStub) { _fixupKind = fixupKind; _method = method; _signatureContext = signatureContext; _isUnboxingStub = isUnboxingStub; _isInstantiatingStub = isInstantiatingStub; }
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 SignatureContext EmitFixup(NodeFactory factory, ReadyToRunFixupKind fixupKind, EcmaModule targetModule, SignatureContext outerContext) { if (targetModule == outerContext.LocalContext) { EmitByte((byte)fixupKind); return(outerContext); } else { EmitByte((byte)(fixupKind | ReadyToRunFixupKind.ModuleOverride)); EmitUInt((uint)factory.ManifestMetadataTable.ModuleToIndex(targetModule)); return(new SignatureContext(targetModule, outerContext.Resolver)); } }
public GenericLookupSignature( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, TypeDesc typeArgument, MethodWithToken methodArgument, GenericContext methodContext, SignatureContext signatureContext) { _runtimeLookupKind = runtimeLookupKind; _fixupKind = fixupKind; _typeArgument = typeArgument; _methodArgument = methodArgument; _methodContext = methodContext; _signatureContext = signatureContext; }
public GenericLookupKey( CORINFO_RUNTIME_LOOKUP_KIND lookupKind, ReadyToRunFixupKind fixupKind, TypeDesc typeArgument, MethodWithToken methodArgument, FieldDesc fieldArgument, GenericContext methodContext) { LookupKind = lookupKind; FixupKind = fixupKind; TypeArgument = typeArgument; MethodArgument = methodArgument; FieldArgument = fieldArgument; MethodContext = methodContext; }
public GenericLookupSignature( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, TypeDesc typeArgument, MethodWithToken methodArgument, FieldDesc fieldArgument, GenericContext methodContext) { Debug.Assert(typeArgument != null || methodArgument != null || fieldArgument != null); _runtimeLookupKind = runtimeLookupKind; _fixupKind = fixupKind; _typeArgument = typeArgument; _methodArgument = methodArgument; _fieldArgument = fieldArgument; _methodContext = methodContext; }
public PrecodeMethodImport( NodeFactory factory, ReadyToRunFixupKind fixupKind, MethodWithToken method, MethodWithGCInfo localMethod, bool isInstantiatingStub) : base( factory, factory.MethodSignature( fixupKind, method, isInstantiatingStub) ) { _localMethod = localMethod; _method = method; }
public VirtualResolutionFixupSignature(ReadyToRunFixupKind fixupKind, MethodWithToken declMethod, TypeDesc implType, MethodWithToken implMethod) { _fixupKind = fixupKind; _declMethod = declMethod; _implType = implType; _implMethod = implMethod; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature CompilerTypeSystemContext compilerContext = (CompilerTypeSystemContext)declMethod.Method.Context; compilerContext.EnsureLoadableMethod(declMethod.Method); compilerContext.EnsureLoadableType(implType); if (implMethod != null) { compilerContext.EnsureLoadableMethod(implMethod.Method); } }
public MethodFixupSignature( ReadyToRunFixupKind fixupKind, MethodDesc methodDesc, TypeDesc constrainedType, ModuleToken methodToken, SignatureContext signatureContext, bool isUnboxingStub, bool isInstantiatingStub) { _fixupKind = fixupKind; _methodDesc = methodDesc; _methodToken = methodToken; _constrainedType = constrainedType; _signatureContext = signatureContext; _isUnboxingStub = isUnboxingStub; _isInstantiatingStub = isInstantiatingStub; }
public ExternalMethodImport( NodeFactory factory, ReadyToRunFixupKind fixupKind, MethodWithToken method, bool isUnboxingStub, bool isInstantiatingStub) : base( factory, factory.MethodImports, ReadyToRunHelper.DelayLoad_MethodCall, factory.MethodSignature( fixupKind, method, isUnboxingStub, isInstantiatingStub)) { _method = method; }
public DelayLoadMethodImport( NodeFactory factory, ReadyToRunFixupKind fixupKind, MethodWithToken method, MethodWithGCInfo localMethod, bool isInstantiatingStub) : base( factory, factory.MethodImports, ReadyToRunHelper.DelayLoad_MethodCall, factory.MethodSignature( fixupKind, method, isInstantiatingStub)) { _localMethod = localMethod; _method = method; }
public MethodFixupSignature( ReadyToRunFixupKind fixupKind, MethodWithToken method, bool isInstantiatingStub) { _fixupKind = fixupKind; _method = method; _isInstantiatingStub = isInstantiatingStub; // Ensure types in signature are loadable and resolvable, otherwise we'll fail later while emitting the signature CompilerTypeSystemContext compilerContext = (CompilerTypeSystemContext)method.Method.Context; compilerContext.EnsureLoadableMethod(method.Method); if (method.ConstrainedType != null) { compilerContext.EnsureLoadableType(method.ConstrainedType); } }
public TypeFixupSignature TypeSignature(ReadyToRunFixupKind fixupKind, TypeDesc typeDesc, SignatureContext signatureContext) { Dictionary <TypeDesc, TypeFixupSignature> perFixupKindMap; if (!_typeSignatures.TryGetValue(fixupKind, out perFixupKindMap)) { perFixupKindMap = new Dictionary <TypeDesc, TypeFixupSignature>(); _typeSignatures.Add(fixupKind, perFixupKindMap); } TypeFixupSignature signature; if (!perFixupKindMap.TryGetValue(typeDesc, out signature)) { signature = new TypeFixupSignature(fixupKind, typeDesc, signatureContext); perFixupKindMap.Add(typeDesc, signature); } return(signature); }
public PrecodeMethodImport( ReadyToRunCodegenNodeFactory factory, ReadyToRunFixupKind fixupKind, MethodWithToken method, MethodWithGCInfo localMethod, bool isUnboxingStub, bool isInstantiatingStub, SignatureContext signatureContext) : base( factory, factory.MethodSignature( fixupKind, method, isUnboxingStub, isInstantiatingStub, signatureContext) ) { _localMethod = localMethod; }
private ISymbolNode GenericLookupTypeHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, TypeDesc typeArgument, TypeDesc contextType, SignatureContext signatureContext) { GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument, methodArgument: null, contextType); ISymbolNode node; if (!_genericLookupHelpers.TryGetValue(key, out node)) { node = new DelayLoadHelperImport( _codegenNodeFactory, _codegenNodeFactory.HelperImports, ILCompiler.DependencyAnalysis.ReadyToRun.ReadyToRunHelper.READYTORUN_HELPER_DelayLoad_Helper, new GenericLookupSignature(runtimeLookupKind, fixupKind, typeArgument, methodArgument: null, contextType, signatureContext)); _genericLookupHelpers.Add(key, node); } return(node); }
private ISymbolNode GenericLookupFieldHelper( CORINFO_RUNTIME_LOOKUP_KIND runtimeLookupKind, ReadyToRunFixupKind fixupKind, FieldDesc fieldArgument, GenericContext methodContext, SignatureContext signatureContext) { GenericLookupKey key = new GenericLookupKey(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument: null, fieldArgument: fieldArgument, methodContext); ISymbolNode node; if (!_genericLookupHelpers.TryGetValue(key, out node)) { node = new DelayLoadHelperImport( _codegenNodeFactory, _codegenNodeFactory.HelperImports, ILCompiler.ReadyToRunHelper.DelayLoad_Helper, new GenericLookupSignature(runtimeLookupKind, fixupKind, typeArgument: null, methodArgument: null, fieldArgument: fieldArgument, methodContext, signatureContext)); _genericLookupHelpers.Add(key, node); } return(node); }
private GenericLookupResult GetTargetForFixup(object resolvedToken, ReadyToRunFixupKind fixupKind) { switch (fixupKind) { case ReadyToRunFixupKind.TypeHandle: if (resolvedToken is TypeDesc) return _compilation.NodeFactory.GenericLookup.Type((TypeDesc)resolvedToken); else return _compilation.NodeFactory.GenericLookup.Type(((MethodDesc)resolvedToken).OwningType); case ReadyToRunFixupKind.MethodHandle: return _compilation.NodeFactory.GenericLookup.MethodDictionary((MethodDesc)resolvedToken); case ReadyToRunFixupKind.VirtualEntry: return _compilation.NodeFactory.GenericLookup.VirtualCall((MethodDesc)resolvedToken); default: throw new NotImplementedException(); } }