コード例 #1
0
        public IMethodNode MethodEntrypoint(
            MethodWithToken method,
            bool isUnboxingStub,
            bool isInstantiatingStub,
            bool isPrecodeImportRequired,
            SignatureContext signatureContext)
        {
            IMethodNode   methodImport;
            TypeAndMethod key = new TypeAndMethod(method.ConstrainedType, method, isUnboxingStub, isInstantiatingStub, isPrecodeImportRequired);

            if (!_importMethods.TryGetValue(key, out methodImport))
            {
                if (CompilationModuleGroup.ContainsMethodBody(method.Method, false))
                {
                    if (isPrecodeImportRequired)
                    {
                        methodImport = new PrecodeMethodImport(
                            this,
                            ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry,
                            method,
                            CreateMethodEntrypointNode(method, isUnboxingStub, isInstantiatingStub, signatureContext),
                            isUnboxingStub,
                            isInstantiatingStub,
                            signatureContext);
                    }
                    else
                    {
                        methodImport = new LocalMethodImport(
                            this,
                            ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry,
                            method,
                            CreateMethodEntrypointNode(method, isUnboxingStub, isInstantiatingStub, signatureContext),
                            isUnboxingStub,
                            isInstantiatingStub,
                            signatureContext);
                    }
                }
                else
                {
                    // First time we see a given external method - emit indirection cell and the import entry
                    methodImport = new ExternalMethodImport(
                        this,
                        ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry,
                        method,
                        isUnboxingStub,
                        isInstantiatingStub,
                        signatureContext);
                }
                _importMethods.Add(key, methodImport);
            }

            return(methodImport);
        }
コード例 #2
0
        public IMethodNode MethodEntrypoint(
            MethodDesc targetMethod,
            TypeDesc constrainedType,
            MethodDesc originalMethod,
            ModuleToken methodToken,
            bool isUnboxingStub,
            bool isInstantiatingStub,
            SignatureContext signatureContext)
        {
            bool isLocalMethod = CompilationModuleGroup.ContainsMethodBody(targetMethod, false);

            if (targetMethod == originalMethod || isLocalMethod)
            {
                constrainedType = null;
            }

            IMethodNode   methodImport;
            TypeAndMethod key = new TypeAndMethod(constrainedType, targetMethod, methodToken, isUnboxingStub, isInstantiatingStub);

            if (!_importMethods.TryGetValue(key, out methodImport))
            {
                if (!isLocalMethod)
                {
                    // First time we see a given external method - emit indirection cell and the import entry
                    methodImport = new ExternalMethodImport(
                        this,
                        ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry,
                        targetMethod,
                        constrainedType,
                        methodToken,
                        isUnboxingStub,
                        isInstantiatingStub,
                        signatureContext);
                }
                else
                {
                    MethodWithToken methodWithToken = new MethodWithToken(targetMethod, methodToken);

                    methodImport = new LocalMethodImport(
                        this,
                        ReadyToRunFixupKind.READYTORUN_FIXUP_MethodEntry,
                        methodWithToken,
                        CreateMethodEntrypointNode(methodWithToken, isUnboxingStub, isInstantiatingStub, signatureContext),
                        isUnboxingStub,
                        isInstantiatingStub,
                        signatureContext);
                }
                _importMethods.Add(key, methodImport);
            }

            return(methodImport);
        }