public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation) { ArrayBuilder <DependencyListEntry> result = new ArrayBuilder <DependencyListEntry>(); var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation); switch (_id) { case ReadyToRunHelperId.GetGCStaticBase: case ReadyToRunHelperId.GetThreadStaticBase: { // If the type has a lazy static constructor, we also need the non-GC static base // because that's where the class constructor context is. TypeDesc type = (TypeDesc)_target; if (factory.TypeSystemContext.HasLazyStaticConstructor(type)) { result.Add( new DependencyListEntry( factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext), "Dictionary dependency")); } } break; case ReadyToRunHelperId.DelegateCtor: { DelegateCreationInfo createInfo = (DelegateCreationInfo)_target; if (createInfo.NeedsVirtualMethodUseTracking) { MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation); if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots) { result.Add( new DependencyListEntry( factory.VirtualMethodUse(instantiatedTargetMethod), "Dictionary dependency")); } // TODO: https://github.com/dotnet/corert/issues/3224 if (instantiatedTargetMethod.IsAbstract) { result.Add(new DependencyListEntry(factory.ReflectableMethod(instantiatedTargetMethod), "Abstract reflectable method")); } } } break; } // All generic lookups depend on the thing they point to result.Add(new DependencyListEntry( _lookupSignature.GetTarget(factory, lookupContext), "Dictionary dependency")); return(result.ToArray()); }
public IEnumerable <DependencyListEntry> InstantiateDependencies(NodeFactory factory, Instantiation typeInstantiation, Instantiation methodInstantiation) { DependencyList result = new DependencyList(); var lookupContext = new GenericLookupResultContext(_dictionaryOwner, typeInstantiation, methodInstantiation); switch (_id) { case ReadyToRunHelperId.GetGCStaticBase: case ReadyToRunHelperId.GetThreadStaticBase: { // If the type has a lazy static constructor, we also need the non-GC static base // because that's where the class constructor context is. TypeDesc type = (TypeDesc)_target; if (factory.PreinitializationManager.HasLazyStaticConstructor(type)) { result.Add( new DependencyListEntry( factory.GenericLookup.TypeNonGCStaticBase(type).GetTarget(factory, lookupContext), "Dictionary dependency")); } } break; case ReadyToRunHelperId.DelegateCtor: { DelegateCreationInfo createInfo = (DelegateCreationInfo)_target; if (createInfo.NeedsVirtualMethodUseTracking) { MethodDesc instantiatedTargetMethod = createInfo.TargetMethod.GetNonRuntimeDeterminedMethodFromRuntimeDeterminedMethodViaSubstitution(typeInstantiation, methodInstantiation); if (!factory.VTable(instantiatedTargetMethod.OwningType).HasFixedSlots) { result.Add( new DependencyListEntry( factory.VirtualMethodUse(instantiatedTargetMethod), "Dictionary dependency")); } factory.MetadataManager.GetDependenciesDueToVirtualMethodReflectability(ref result, factory, instantiatedTargetMethod); } } break; } // All generic lookups depend on the thing they point to result.Add(new DependencyListEntry( _lookupSignature.GetTarget(factory, lookupContext), "Dictionary dependency")); return(result.ToArray()); }
public virtual void EmitDictionaryData(ref ObjectDataBuilder builder, NodeFactory factory, GenericDictionaryNode dictionary) { var context = new GenericLookupResultContext(dictionary.OwningEntity, dictionary.TypeInstantiation, dictionary.MethodInstantiation); foreach (GenericLookupResult lookupResult in Entries) { #if DEBUG int offsetBefore = builder.CountBytes; #endif lookupResult.EmitDictionaryEntry(ref builder, factory, context); #if DEBUG Debug.Assert(builder.CountBytes - offsetBefore == factory.Target.PointerSize); #endif } }