예제 #1
0
        private void CreateNodeCaches()
        {
            _allMethodsOnType = new NodeCache <TypeDesc, AllMethodsOnTypeNode>(type =>
            {
                return(new AllMethodsOnTypeNode(type));
            });

            _genericReadyToRunHelpersFromDict = new NodeCache <ReadyToRunGenericHelperKey, ISymbolNode>(helperKey =>
            {
                return(new DelayLoadHelperImport(
                           this,
                           HelperImports,
                           GetGenericStaticHelper(helperKey.HelperId),
                           TypeSignature(
                               ReadyToRunFixupKind.Invalid,
                               (TypeDesc)helperKey.Target)));
            });

            _genericReadyToRunHelpersFromType = new NodeCache <ReadyToRunGenericHelperKey, ISymbolNode>(helperKey =>
            {
                return(new DelayLoadHelperImport(
                           this,
                           HelperImports,
                           GetGenericStaticHelper(helperKey.HelperId),
                           TypeSignature(
                               ReadyToRunFixupKind.Invalid,
                               (TypeDesc)helperKey.Target)));
            });

            _constructedHelpers = new NodeCache <ReadyToRunHelper, Import>(helperId =>
            {
                return(new Import(EagerImports, new ReadyToRunHelperSignature(helperId)));
            });

            _importThunks = new NodeCache <ImportThunkKey, ImportThunk>(key =>
            {
                return(new ImportThunk(this, key.Helper, key.ContainingImportSection, key.UseVirtualCall, key.UseJumpableStub));
            });

            _importMethods = new NodeCache <TypeAndMethod, IMethodNode>(CreateMethodEntrypoint);

            _localMethodCache = new NodeCache <MethodDesc, MethodWithGCInfo>(key =>
            {
                return(new MethodWithGCInfo(key));
            });

            _methodSignatures = new NodeCache <MethodFixupKey, MethodFixupSignature>(key =>
            {
                return(new MethodFixupSignature(
                           key.FixupKind,
                           key.TypeAndMethod.Method,
                           key.TypeAndMethod.IsInstantiatingStub
                           ));
            });

            _typeSignatures = new NodeCache <TypeFixupKey, TypeFixupSignature>(key =>
            {
                return(new TypeFixupSignature(key.FixupKind, key.TypeDesc));
            });

            _virtualResolutionSignatures = new NodeCache <VirtualResolutionFixupSignatureFixupKey, VirtualResolutionFixupSignature>(key =>
            {
                return(new ReadyToRun.VirtualResolutionFixupSignature(key.FixupKind, key.DeclMethod, key.ImplType, key.ImplMethod));
            });

            _dynamicHelperCellCache = new NodeCache <DynamicHelperCellKey, ISymbolNode>(key =>
            {
                return(new DelayLoadHelperMethodImport(
                           this,
                           DispatchImports,
                           ReadyToRunHelper.DelayLoad_Helper_Obj,
                           key.Method,
                           useVirtualCall: false,
                           useInstantiatingStub: true,
                           MethodSignature(
                               ReadyToRunFixupKind.VirtualEntry,
                               key.Method,
                               isInstantiatingStub: key.IsInstantiatingStub)));
            });

            _copiedCorHeaders = new NodeCache <EcmaModule, CopiedCorHeaderNode>(module =>
            {
                return(new CopiedCorHeaderNode(module));
            });

            _debugDirectoryEntries = new NodeCache <ModuleAndIntValueKey, DebugDirectoryEntryNode>(key =>
            {
                return(new CopiedDebugDirectoryEntryNode(key.Module, key.IntValue));
            });

            _copiedMetadataBlobs = new NodeCache <EcmaModule, CopiedMetadataBlobNode>(module =>
            {
                return(new CopiedMetadataBlobNode(module));
            });

            _copiedMethodIL = new NodeCache <MethodDesc, CopiedMethodILNode>(method =>
            {
                return(new CopiedMethodILNode((EcmaMethod)method));
            });

            _copiedFieldRvas = new NodeCache <ModuleAndIntValueKey, CopiedFieldRvaNode>(key =>
            {
                return(new CopiedFieldRvaNode(key.Module, key.IntValue));
            });

            _copiedStrongNameSignatures = new NodeCache <EcmaModule, CopiedStrongNameSignatureNode>(module =>
            {
                return(new CopiedStrongNameSignatureNode(module));
            });

            _copiedManagedResources = new NodeCache <EcmaModule, CopiedManagedResourcesNode>(module =>
            {
                return(new CopiedManagedResourcesNode(module));
            });
        }
예제 #2
0
        private void CreateNodeCaches()
        {
            _typeSymbols = new NodeCache <TypeDesc, EETypeNode>((TypeDesc type) =>
            {
                Debug.Assert(type.IsTypeDefinition || !type.HasSameTypeDefinition(ArrayOfTClass), "Asking for Array<T> EEType");
                return(new EETypeNode(type, false));
            });

            _constructedTypeSymbols = new NodeCache <TypeDesc, EETypeNode>((TypeDesc type) =>
            {
                Debug.Assert(type.IsTypeDefinition || !type.HasSameTypeDefinition(ArrayOfTClass), "Asking for Array<T> EEType");
                return(new EETypeNode(type, true));
            });

            _nonGCStatics = new NodeCache <MetadataType, NonGCStaticsNode>((MetadataType type) =>
            {
                return(new NonGCStaticsNode(type, this));
            });

            _GCStatics = new NodeCache <MetadataType, GCStaticsNode>((MetadataType type) =>
            {
                return(new GCStaticsNode(type));
            });

            _threadStatics = new NodeCache <MetadataType, ThreadStaticsNode>((MetadataType type) =>
            {
                return(new ThreadStaticsNode(type, this));
            });

            _GCStaticEETypes = new NodeCache <bool[], GCStaticEETypeNode>((bool[] gcdesc) =>
            {
                return(new GCStaticEETypeNode(gcdesc, this));
            }, new BoolArrayEqualityComparer());

            _readOnlyDataBlobs = new NodeCache <Tuple <string, byte[], int>, BlobNode>((Tuple <string, byte[], int> key) =>
            {
                return(new BlobNode(key.Item1, "rdata", key.Item2, key.Item3));
            }, new BlobTupleEqualityComparer());

            _externSymbols = new NodeCache <string, ExternSymbolNode>((string name) =>
            {
                return(new ExternSymbolNode(name));
            });

            _internalSymbols = new NodeCache <Tuple <ObjectNode, int, string>, ObjectAndOffsetSymbolNode>(
                (Tuple <ObjectNode, int, string> key) =>
            {
                return(new ObjectAndOffsetSymbolNode(key.Item1, key.Item2, key.Item3));
            });

            _methodCode = new NodeCache <MethodDesc, ISymbolNode>((MethodDesc method) =>
            {
                if (_cppCodeGen)
                {
                    return(new CppMethodCodeNode(method));
                }
                else
                {
                    return(new MethodCodeNode(method));
                }
            });

            _unboxingStubs = new NodeCache <MethodDesc, IMethodNode>((MethodDesc method) =>
            {
                return(new UnboxingStubNode(method));
            });

            _jumpStubs = new NodeCache <ISymbolNode, JumpStubNode>((ISymbolNode node) =>
            {
                return(new JumpStubNode(node));
            });

            _virtMethods = new NodeCache <MethodDesc, VirtualMethodUseNode>((MethodDesc method) =>
            {
                return(new VirtualMethodUseNode(method));
            });

            _readyToRunHelpers = new NodeCache <Tuple <ReadyToRunHelperId, Object>, ReadyToRunHelperNode>((Tuple <ReadyToRunHelperId, Object> helper) =>
            {
                return(new ReadyToRunHelperNode(helper.Item1, helper.Item2));
            });

            _stringDataNodes = new NodeCache <string, StringDataNode>((string data) =>
            {
                return(new StringDataNode(data));
            });

            _stringIndirectionNodes = new NodeCache <string, StringIndirectionNode>((string data) =>
            {
                return(new StringIndirectionNode(data));
            });

            _typeOptionalFields = new NodeCache <EETypeOptionalFieldsBuilder, EETypeOptionalFieldsNode>((EETypeOptionalFieldsBuilder fieldBuilder) =>
            {
                return(new EETypeOptionalFieldsNode(fieldBuilder, this.Target));
            });

            _interfaceDispatchCells = new NodeCache <MethodDesc, InterfaceDispatchCellNode>((MethodDesc method) =>
            {
                return(new InterfaceDispatchCellNode(method));
            });

            _interfaceDispatchMaps = new NodeCache <TypeDesc, InterfaceDispatchMapNode>((TypeDesc type) =>
            {
                return(new InterfaceDispatchMapNode(type));
            });

            _interfaceDispatchMapIndirectionNodes = new NodeCache <TypeDesc, EmbeddedObjectNode>((TypeDesc type) =>
            {
                var dispatchMap = InterfaceDispatchMap(type);
                return(DispatchMapTable.NewNodeWithSymbol(dispatchMap, (indirectionNode) =>
                {
                    dispatchMap.SetDispatchMapIndex(this, DispatchMapTable.IndexOfEmbeddedObject(indirectionNode));
                }));
            });

            _eagerCctorIndirectionNodes = new NodeCache <MethodDesc, EmbeddedObjectNode>((MethodDesc method) =>
            {
                Debug.Assert(method.IsStaticConstructor);
                Debug.Assert(TypeInitializationManager.HasEagerStaticConstructor((MetadataType)method.OwningType));

                ISymbolNode entrypoint = MethodEntrypoint(method);

                // TODO: multifile: We will likely hit this assert with ExternSymbolNode. We probably need ExternMethodSymbolNode
                //       deriving from ExternSymbolNode that carries around the target method.
                Debug.Assert(entrypoint is IMethodNode);

                return(EagerCctorTable.NewNode((IMethodNode)entrypoint));
            });
        }
예제 #3
0
        private void CreateNodeCaches()
        {
            _typeSymbols = new NodeCache <TypeDesc, IEETypeNode>(CreateNecessaryTypeNode);

            _constructedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>(CreateConstructedTypeNode);

            _clonedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                // Only types that reside in other binaries should be cloned
                Debug.Assert(_compilationModuleGroup.ShouldReferenceThroughImportTable(type));
                return(new ClonedConstructedEETypeNode(this, type));
            });

            _importedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                Debug.Assert(_compilationModuleGroup.ShouldReferenceThroughImportTable(type));
                return(_importedNodeProvider.ImportedEETypeNode(this, type));
            });

            _nonGCStatics = new NodeCache <MetadataType, ISortableSymbolNode>((MetadataType type) =>
            {
                if (_compilationModuleGroup.ContainsType(type) && !_compilationModuleGroup.ShouldReferenceThroughImportTable(type))
                {
                    return(new NonGCStaticsNode(type, this));
                }
                else
                {
                    return(_importedNodeProvider.ImportedNonGCStaticNode(this, type));
                }
            });

            _GCStatics = new NodeCache <MetadataType, ISortableSymbolNode>((MetadataType type) =>
            {
                if (_compilationModuleGroup.ContainsType(type) && !_compilationModuleGroup.ShouldReferenceThroughImportTable(type))
                {
                    return(new GCStaticsNode(type));
                }
                else
                {
                    return(_importedNodeProvider.ImportedGCStaticNode(this, type));
                }
            });

            _GCStaticsPreInitDataNodes = new NodeCache <MetadataType, GCStaticsPreInitDataNode>((MetadataType type) =>
            {
                ISymbolNode gcStaticsNode = TypeGCStaticsSymbol(type);
                Debug.Assert(gcStaticsNode is GCStaticsNode);
                return(((GCStaticsNode)gcStaticsNode).NewPreInitDataNode());
            });

            _GCStaticIndirectionNodes = new NodeCache <MetadataType, EmbeddedObjectNode>((MetadataType type) =>
            {
                ISymbolNode gcStaticsNode = TypeGCStaticsSymbol(type);
                Debug.Assert(gcStaticsNode is GCStaticsNode);
                return(GCStaticsRegion.NewNode((GCStaticsNode)gcStaticsNode));
            });

            _threadStatics = new NodeCache <MetadataType, ISymbolDefinitionNode>(CreateThreadStaticsNode);

            _typeThreadStaticIndices = new NodeCache <MetadataType, TypeThreadStaticIndexNode>(type =>
            {
                return(new TypeThreadStaticIndexNode(type));
            });

            _GCStaticEETypes = new NodeCache <GCPointerMap, GCStaticEETypeNode>((GCPointerMap gcMap) =>
            {
                return(new GCStaticEETypeNode(Target, gcMap));
            });

            _readOnlyDataBlobs = new NodeCache <ReadOnlyDataBlobKey, BlobNode>(key =>
            {
                return(new BlobNode(key.Name, ObjectNodeSection.ReadOnlyDataSection, key.Data, key.Alignment));
            });

            _externSymbols = new NodeCache <string, ExternSymbolNode>((string name) =>
            {
                return(new ExternSymbolNode(name));
            });

            _pInvokeModuleFixups = new NodeCache <PInvokeModuleData, PInvokeModuleFixupNode>((PInvokeModuleData moduleData) =>
            {
                return(new PInvokeModuleFixupNode(moduleData));
            });

            _pInvokeMethodFixups = new NodeCache <Tuple <PInvokeModuleData, string, PInvokeFlags>, PInvokeMethodFixupNode>((Tuple <PInvokeModuleData, string, PInvokeFlags> key) =>
            {
                return(new PInvokeMethodFixupNode(key.Item1, key.Item2, key.Item3));
            });

            _methodEntrypoints = new NodeCache <MethodDesc, IMethodNode>(CreateMethodEntrypointNode);

            _unboxingStubs = new NodeCache <MethodDesc, IMethodNode>(CreateUnboxingStubNode);

            _methodAssociatedData = new NodeCache <IMethodNode, MethodAssociatedDataNode>(methodNode =>
            {
                return(new MethodAssociatedDataNode(methodNode));
            });

            _fatFunctionPointers = new NodeCache <MethodKey, FatFunctionPointerNode>(method =>
            {
                return(new FatFunctionPointerNode(method.Method, method.IsUnboxingStub));
            });

            _gvmDependenciesNode = new NodeCache <MethodDesc, GVMDependenciesNode>(method =>
            {
                return(new GVMDependenciesNode(method));
            });

            _gvmTableEntries = new NodeCache <TypeDesc, TypeGVMEntriesNode>(type =>
            {
                return(new TypeGVMEntriesNode(type));
            });

            _dynamicInvokeTemplates = new NodeCache <MethodDesc, DynamicInvokeTemplateNode>(method =>
            {
                return(new DynamicInvokeTemplateNode(method));
            });

            _reflectableMethods = new NodeCache <MethodDesc, ReflectableMethodNode>(method =>
            {
                return(new ReflectableMethodNode(method));
            });

            _shadowConcreteMethods = new NodeCache <MethodKey, IMethodNode>(methodKey =>
            {
                MethodDesc canonMethod = methodKey.Method.GetCanonMethodTarget(CanonicalFormKind.Specific);

                if (methodKey.IsUnboxingStub)
                {
                    return(new ShadowConcreteUnboxingThunkNode(methodKey.Method, MethodEntrypoint(canonMethod, true)));
                }
                else
                {
                    return(new ShadowConcreteMethodNode(methodKey.Method, MethodEntrypoint(canonMethod)));
                }
            });

            _virtMethods = new NodeCache <MethodDesc, VirtualMethodUseNode>((MethodDesc method) =>
            {
                // We don't need to track virtual method uses for types that have a vtable with a known layout.
                // It's a waste of CPU time and memory.
                Debug.Assert(!VTable(method.OwningType).HasFixedSlots);

                return(new VirtualMethodUseNode(method));
            });

            _readyToRunHelpers = new NodeCache <ReadyToRunHelperKey, ISymbolNode>(CreateReadyToRunHelperNode);

            _genericReadyToRunHelpersFromDict = new NodeCache <ReadyToRunGenericHelperKey, ISymbolNode>(CreateGenericLookupFromDictionaryNode);
            _genericReadyToRunHelpersFromType = new NodeCache <ReadyToRunGenericHelperKey, ISymbolNode>(CreateGenericLookupFromTypeNode);

            _indirectionNodes = new NodeCache <ISortableSymbolNode, ISymbolNode>(indirectedNode =>
            {
                return(new IndirectionNode(Target, indirectedNode, 0));
            });

            _frozenStringNodes = new NodeCache <string, FrozenStringNode>((string data) =>
            {
                return(new FrozenStringNode(data, Target));
            });

            _frozenArrayNodes = new NodeCache <PreInitFieldInfo, FrozenArrayNode>((PreInitFieldInfo fieldInfo) =>
            {
                return(new FrozenArrayNode(fieldInfo));
            });

            _interfaceDispatchCells = new NodeCache <DispatchCellKey, InterfaceDispatchCellNode>(callSiteCell =>
            {
                return(new InterfaceDispatchCellNode(callSiteCell.Target, callSiteCell.CallsiteId));
            });

            _interfaceDispatchMaps = new NodeCache <TypeDesc, InterfaceDispatchMapNode>((TypeDesc type) =>
            {
                return(new InterfaceDispatchMapNode(this, type));
            });

            _sealedVtableNodes = new NodeCache <TypeDesc, SealedVTableNode>((TypeDesc type) =>
            {
                return(new SealedVTableNode(type));
            });

            _runtimeMethodHandles = new NodeCache <MethodDesc, RuntimeMethodHandleNode>((MethodDesc method) =>
            {
                return(new RuntimeMethodHandleNode(method));
            });

            _runtimeFieldHandles = new NodeCache <FieldDesc, RuntimeFieldHandleNode>((FieldDesc field) =>
            {
                return(new RuntimeFieldHandleNode(field));
            });

            _interfaceDispatchMapIndirectionNodes = new NodeCache <TypeDesc, EmbeddedObjectNode>((TypeDesc type) =>
            {
                return(DispatchMapTable.NewNodeWithSymbol(InterfaceDispatchMap(type)));
            });

            _genericCompositions = new NodeCache <GenericCompositionDetails, GenericCompositionNode>((GenericCompositionDetails details) =>
            {
                return(new GenericCompositionNode(details));
            });

            _eagerCctorIndirectionNodes = new NodeCache <MethodDesc, EmbeddedObjectNode>((MethodDesc method) =>
            {
                Debug.Assert(method.IsStaticConstructor);
                Debug.Assert(TypeSystemContext.HasEagerStaticConstructor((MetadataType)method.OwningType));
                return(EagerCctorTable.NewNode(MethodEntrypoint(method)));
            });

            _delegateMarshalingDataNodes = new NodeCache <DefType, DelegateMarshallingDataNode>(type =>
            {
                return(new DelegateMarshallingDataNode(type));
            });

            _structMarshalingDataNodes = new NodeCache <DefType, StructMarshallingDataNode>(type =>
            {
                return(new StructMarshallingDataNode(type));
            });

            _vTableNodes = new NodeCache <TypeDesc, VTableSliceNode>((TypeDesc type ) =>
            {
                if (CompilationModuleGroup.ShouldProduceFullVTable(type))
                {
                    return(new EagerlyBuiltVTableSliceNode(type));
                }
                else
                {
                    return(_vtableSliceProvider.GetSlice(type));
                }
            });

            _methodGenericDictionaries = new NodeCache <MethodDesc, ISortableSymbolNode>(method =>
            {
                if (CompilationModuleGroup.ContainsMethodDictionary(method))
                {
                    return(new MethodGenericDictionaryNode(method, this));
                }
                else
                {
                    return(_importedNodeProvider.ImportedMethodDictionaryNode(this, method));
                }
            });

            _typeGenericDictionaries = new NodeCache <TypeDesc, ISortableSymbolNode>(type =>
            {
                if (CompilationModuleGroup.ContainsTypeDictionary(type))
                {
                    Debug.Assert(!this.LazyGenericsPolicy.UsesLazyGenerics(type));
                    return(new TypeGenericDictionaryNode(type, this));
                }
                else
                {
                    return(_importedNodeProvider.ImportedTypeDictionaryNode(this, type));
                }
            });

            _typesWithMetadata = new NodeCache <MetadataType, TypeMetadataNode>(type =>
            {
                return(new TypeMetadataNode(type));
            });

            _methodsWithMetadata = new NodeCache <MethodDesc, MethodMetadataNode>(method =>
            {
                return(new MethodMetadataNode(method));
            });

            _fieldsWithMetadata = new NodeCache <FieldDesc, FieldMetadataNode>(field =>
            {
                return(new FieldMetadataNode(field));
            });

            _modulesWithMetadata = new NodeCache <ModuleDesc, ModuleMetadataNode>(module =>
            {
                return(new ModuleMetadataNode(module));
            });

            _genericDictionaryLayouts = new NodeCache <TypeSystemEntity, DictionaryLayoutNode>(_dictionaryLayoutProvider.GetLayout);

            _stringAllocators = new NodeCache <MethodDesc, IMethodNode>(constructor =>
            {
                return(new StringAllocatorMethodNode(constructor));
            });

            NativeLayout     = new NativeLayoutHelper(this);
            WindowsDebugData = new WindowsDebugDataHelper(this);
        }
        private void CreateNodeCaches()
        {
            _importStrings = new NodeCache <ModuleToken, ISymbolNode>(key =>
            {
                return(new StringImport(_codegenNodeFactory.StringImports, key));
            });

            _r2rHelpers = new NodeCache <ReadyToRunHelperKey, ISymbolNode>(CreateReadyToRunHelper);

            _fieldAddressCache = new NodeCache <FieldDesc, ISymbolNode>(key =>
            {
                return(new DelayLoadHelperImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.HelperImports,
                           ReadyToRunHelper.DelayLoad_Helper,
                           new FieldFixupSignature(ReadyToRunFixupKind.FieldAddress, key)
                           ));
            });

            _fieldOffsetCache = new NodeCache <FieldDesc, ISymbolNode>(key =>
            {
                return(new PrecodeHelperImport(
                           _codegenNodeFactory,
                           new FieldFixupSignature(ReadyToRunFixupKind.FieldOffset, key)
                           ));
            });

            _fieldBaseOffsetCache = new NodeCache <TypeDesc, ISymbolNode>(key =>
            {
                return(new PrecodeHelperImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.TypeSignature(ReadyToRunFixupKind.FieldBaseOffset, key)
                           ));
            });

            _interfaceDispatchCells = new NodeCache <MethodAndCallSite, ISymbolNode>(cellKey =>
            {
                return(new DelayLoadHelperMethodImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.DispatchImports,
                           ReadyToRunHelper.DelayLoad_MethodCall,
                           cellKey.Method,
                           useVirtualCall: true,
                           useInstantiatingStub: false,
                           _codegenNodeFactory.MethodSignature(ReadyToRunFixupKind.VirtualEntry,
                                                               cellKey.Method,
                                                               cellKey.IsUnboxingStub, isInstantiatingStub: false),
                           cellKey.CallSite));
            });

            _delegateCtors = new NodeCache <TypeAndMethod, ISymbolNode>(ctorKey =>
            {
                IMethodNode targetMethodNode = _codegenNodeFactory.MethodEntrypoint(
                    ctorKey.Method,
                    isUnboxingStub: false,
                    isInstantiatingStub: ctorKey.Method.Method.HasInstantiation,
                    isPrecodeImportRequired: false);

                return(new DelayLoadHelperImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.HelperImports,
                           ReadyToRunHelper.DelayLoad_Helper_ObjObj,
                           new DelegateCtorSignature(ctorKey.Type, targetMethodNode, ctorKey.Method.Token)));
            });

            _genericLookupHelpers = new NodeCache <GenericLookupKey, ISymbolNode>(key =>
            {
                return(new DelayLoadHelperImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.HelperImports,
                           ReadyToRunHelper.DelayLoad_Helper,
                           new GenericLookupSignature(
                               key.LookupKind,
                               key.FixupKind,
                               key.TypeArgument,
                               key.MethodArgument,
                               key.FieldArgument,
                               key.MethodContext)));
            });

            _pInvokeTargetNodes = new NodeCache <PInvokeTargetKey, ISymbolNode>(key =>
            {
                return(new PrecodeHelperImport(
                           _codegenNodeFactory,
                           _codegenNodeFactory.MethodSignature(
                               key.IsIndirect ? ReadyToRunFixupKind.IndirectPInvokeTarget : ReadyToRunFixupKind.PInvokeTarget,
                               key.MethodWithToken,
                               isUnboxingStub: false,
                               isInstantiatingStub: false)));
            });
        }
예제 #5
0
        private void CreateNodeCaches()
        {
            _typeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                if (_compilationModuleGroup.ContainsType(type))
                {
                    if (type.IsGenericDefinition)
                    {
                        return(new GenericDefinitionEETypeNode(this, type));
                    }
                    else
                    {
                        return(new EETypeNode(this, type));
                    }
                }
                else
                {
                    return(new ExternEETypeSymbolNode(this, type));
                }
            });

            _constructedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                if (_compilationModuleGroup.ContainsType(type))
                {
                    return(new ConstructedEETypeNode(this, type));
                }
                else
                {
                    return(new ExternEETypeSymbolNode(this, type));
                }
            });

            _clonedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                // Only types that reside in other binaries should be cloned
                Debug.Assert(_compilationModuleGroup.ShouldReferenceThroughImportTable(type));
                return(new ClonedConstructedEETypeNode(this, type));
            });

            _nonGCStatics = new NodeCache <MetadataType, NonGCStaticsNode>((MetadataType type) =>
            {
                return(new NonGCStaticsNode(type, this));
            });

            _GCStatics = new NodeCache <MetadataType, GCStaticsNode>((MetadataType type) =>
            {
                return(new GCStaticsNode(type));
            });

            _GCStaticIndirectionNodes = new NodeCache <MetadataType, EmbeddedObjectNode>((MetadataType type) =>
            {
                ISymbolNode gcStaticsNode = TypeGCStaticsSymbol(type);
                Debug.Assert(gcStaticsNode is GCStaticsNode);
                return(GCStaticsRegion.NewNode((GCStaticsNode)gcStaticsNode));
            });

            _threadStatics = new NodeCache <MetadataType, ThreadStaticsNode>((MetadataType type) =>
            {
                return(new ThreadStaticsNode(type, this));
            });

            _typeThreadStaticIndices = new NodeCache <MetadataType, TypeThreadStaticIndexNode>(type =>
            {
                return(new TypeThreadStaticIndexNode(type));
            });

            _GCStaticEETypes = new NodeCache <GCPointerMap, GCStaticEETypeNode>((GCPointerMap gcMap) =>
            {
                return(new GCStaticEETypeNode(Target, gcMap));
            });

            _readOnlyDataBlobs = new NodeCache <Tuple <Utf8String, byte[], int>, BlobNode>((Tuple <Utf8String, byte[], int> key) =>
            {
                return(new BlobNode(key.Item1, ObjectNodeSection.ReadOnlyDataSection, key.Item2, key.Item3));
            }, new BlobTupleEqualityComparer());

            _externSymbols = new NodeCache <string, ExternSymbolNode>((string name) =>
            {
                return(new ExternSymbolNode(name));
            });

            _pInvokeModuleFixups = new NodeCache <string, PInvokeModuleFixupNode>((string name) =>
            {
                return(new PInvokeModuleFixupNode(name));
            });

            _pInvokeMethodFixups = new NodeCache <Tuple <string, string>, PInvokeMethodFixupNode>((Tuple <string, string> key) =>
            {
                return(new PInvokeMethodFixupNode(key.Item1, key.Item2));
            });

            _methodEntrypoints = new NodeCache <MethodDesc, IMethodNode>(CreateMethodEntrypointNode);

            _unboxingStubs = new NodeCache <MethodDesc, IMethodNode>(CreateUnboxingStubNode);

            _fatFunctionPointers = new NodeCache <MethodDesc, FatFunctionPointerNode>(method =>
            {
                return(new FatFunctionPointerNode(method));
            });

            _gvmDependenciesNode = new NodeCache <MethodDesc, GVMDependenciesNode>(method =>
            {
                return(new GVMDependenciesNode(method));
            });

            _gvmTableEntries = new NodeCache <TypeDesc, TypeGVMEntriesNode>(type =>
            {
                return(new TypeGVMEntriesNode(type));
            });

            _shadowConcreteMethods = new NodeCache <MethodDesc, IMethodNode>(method =>
            {
                return(new ShadowConcreteMethodNode <MethodCodeNode>(method,
                                                                     (MethodCodeNode)MethodEntrypoint(method.GetCanonMethodTarget(CanonicalFormKind.Specific))));
            });

            _runtimeDeterminedMethods = new NodeCache <MethodDesc, IMethodNode>(method =>
            {
                return(new RuntimeDeterminedMethodNode(method,
                                                       MethodEntrypoint(method.GetCanonMethodTarget(CanonicalFormKind.Specific))));
            });

            _virtMethods = new NodeCache <MethodDesc, VirtualMethodUseNode>((MethodDesc method) =>
            {
                return(new VirtualMethodUseNode(method));
            });

            _readyToRunHelpers = new NodeCache <Tuple <ReadyToRunHelperId, Object>, ISymbolNode>(CreateReadyToRunHelperNode);

            _genericReadyToRunHelpersFromDict = new NodeCache <Tuple <ReadyToRunHelperId, object, TypeSystemEntity>, ISymbolNode>(data =>
            {
                return(new ReadyToRunGenericLookupFromDictionaryNode(this, data.Item1, data.Item2, data.Item3));
            });

            _genericReadyToRunHelpersFromType = new NodeCache <Tuple <ReadyToRunHelperId, object, TypeSystemEntity>, ISymbolNode>(data =>
            {
                return(new ReadyToRunGenericLookupFromTypeNode(this, data.Item1, data.Item2, data.Item3));
            });

            _indirectionNodes = new NodeCache <ISymbolNode, IndirectionNode>(symbol =>
            {
                return(new IndirectionNode(symbol));
            });

            _frozenStringNodes = new NodeCache <string, FrozenStringNode>((string data) =>
            {
                return(new FrozenStringNode(data, Target));
            });

            _interfaceDispatchCells = new NodeCache <MethodDesc, InterfaceDispatchCellNode>((MethodDesc method) =>
            {
                return(new InterfaceDispatchCellNode(method));
            });

            _interfaceDispatchMaps = new NodeCache <TypeDesc, InterfaceDispatchMapNode>((TypeDesc type) =>
            {
                return(new InterfaceDispatchMapNode(type));
            });

            _runtimeMethodHandles = new NodeCache <MethodDesc, RuntimeMethodHandleNode>((MethodDesc method) =>
            {
                return(new RuntimeMethodHandleNode(this, method));
            });

            _interfaceDispatchMapIndirectionNodes = new NodeCache <TypeDesc, EmbeddedObjectNode>((TypeDesc type) =>
            {
                var dispatchMap = InterfaceDispatchMap(type);
                return(DispatchMapTable.NewNodeWithSymbol(dispatchMap, (indirectionNode) =>
                {
                    dispatchMap.SetDispatchMapIndex(this, DispatchMapTable.IndexOfEmbeddedObject(indirectionNode));
                }));
            });

            _genericCompositions = new NodeCache <GenericCompositionDetails, GenericCompositionNode>((GenericCompositionDetails details) =>
            {
                return(new GenericCompositionNode(details));
            });

            _eagerCctorIndirectionNodes = new NodeCache <MethodDesc, EmbeddedObjectNode>((MethodDesc method) =>
            {
                Debug.Assert(method.IsStaticConstructor);
                Debug.Assert(TypeSystemContext.HasEagerStaticConstructor((MetadataType)method.OwningType));
                return(EagerCctorTable.NewNode(MethodEntrypoint(method)));
            });

            _vTableNodes = new NodeCache <TypeDesc, VTableSliceNode>((TypeDesc type ) =>
            {
                if (CompilationModuleGroup.ShouldProduceFullType(type))
                {
                    return(new EagerlyBuiltVTableSliceNode(type));
                }
                else
                {
                    return(new LazilyBuiltVTableSliceNode(type));
                }
            });

            _methodGenericDictionaries = new NodeCache <MethodDesc, GenericDictionaryNode>(method =>
            {
                return(new MethodGenericDictionaryNode(method));
            });

            _typeGenericDictionaries = new NodeCache <TypeDesc, GenericDictionaryNode>(type =>
            {
                return(new TypeGenericDictionaryNode(type));
            });

            _genericDictionaryLayouts = new NodeCache <TypeSystemEntity, DictionaryLayoutNode>(methodOrType =>
            {
                return(new DictionaryLayoutNode(methodOrType));
            });

            _stringAllocators = new NodeCache <MethodDesc, IMethodNode>(constructor =>
            {
                return(new StringAllocatorMethodNode(constructor));
            });

            NativeLayout = new NativeLayoutHelper(this);
        }