Ejemplo n.º 1
0
        private void CreateNodeCaches()
        {
            _typeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                if (_compilationModuleGroup.ContainsType(type))
                {
                    return(new EETypeNode(type, false));
                }
                else
                {
                    return(new ExternEETypeSymbolNode(type));
                }
            });

            _constructedTypeSymbols = new NodeCache <TypeDesc, IEETypeNode>((TypeDesc type) =>
            {
                if (_compilationModuleGroup.ContainsType(type))
                {
                    return(new EETypeNode(type, true));
                }
                else
                {
                    return(new ExternEETypeSymbolNode(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));
            });

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

            _readOnlyDataBlobs = new NodeCache <Tuple <string, byte[], int>, BlobNode>((Tuple <string, 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));
            });

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

            _methodEntrypoints = new NodeCache <MethodDesc, IMethodNode>((MethodDesc method) =>
            {
                if (!_cppCodeGen)
                {
                    if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
                    {
                        return(new RuntimeImportMethodNode(method));
                    }
                }

                if (_compilationModuleGroup.ContainsMethod(method))
                {
                    if (_cppCodeGen)
                    {
                        return(new CppMethodCodeNode(method));
                    }
                    else
                    {
                        return(new MethodCodeNode(method));
                    }
                }
                else
                {
                    return(new ExternMethodSymbolNode(method));
                }
            });

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

            _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));
                }));
            });

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

            _eagerCctorIndirectionNodes = new NodeCache <MethodDesc, EmbeddedObjectNode>((MethodDesc method) =>
            {
                Debug.Assert(method.IsStaticConstructor);
                Debug.Assert(TypeInitializationManager.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));
                }
            });

            _jumpThunks = new NodeCache <Tuple <ExternSymbolNode, ISymbolNode>, SingleArgumentJumpThunk>((Tuple <ExternSymbolNode, ISymbolNode> data) =>
            {
                return(new SingleArgumentJumpThunk(data.Item1, data.Item2));
            });
        }
Ejemplo n.º 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));
            });
        }