コード例 #1
0
        /// <summary>
        /// Check if MethodImpl requires slot unification.
        /// </summary>
        /// <param name="method">Method to check</param>
        /// <returns>True when the method is marked with the PreserveBaseOverrides custom attribute, false otherwise.</returns>
        public static bool RequiresSlotUnification(this MethodDesc method)
        {
            if (method.HasCustomAttribute("System.Runtime.CompilerServices", "PreserveBaseOverridesAttribute"))
            {
#if DEBUG
                // We shouldn't be calling this for non-MethodImpls, so verify that the method being checked is really a MethodImpl
                MetadataType mdType = method.OwningType as MetadataType;
                if (mdType != null)
                {
                    bool isMethodImpl = false;
                    foreach (MethodImplRecord methodImplRecord in mdType.VirtualMethodImplsForType)
                    {
                        if (method == methodImplRecord.Body)
                        {
                            isMethodImpl = true;
                            break;
                        }
                    }
                    Debug.Assert(isMethodImpl);
                }
#endif
                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: CallConvHelpers.cs プロジェクト: z77ma/runtime
        /// <summary>
        /// Gets a value indicating whether the method has the SuppressGCTransition attribute
        /// </summary>
        public static bool HasSuppressGCTransitionAttribute(this MethodDesc method)
        {
            Debug.Assert(method.IsPInvoke);

            if (method is Internal.IL.Stubs.PInvokeTargetNativeMethod rawPinvoke)
            {
                method = rawPinvoke.Target;
            }

            // Check SuppressGCTransition attribute
            return(method.HasCustomAttribute("System.Runtime.InteropServices", "SuppressGCTransitionAttribute"));
        }
コード例 #3
0
ファイル: RyuJitNodeFactory.cs プロジェクト: tijoytom/corert
        protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method)
        {
            if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
            {
                return new RuntimeImportMethodNode(method);
            }

            if (CompilationModuleGroup.ContainsMethod(method))
            {
                return new MethodCodeNode(method);
            }
            else
            {
                return new ExternMethodSymbolNode(method);
            }
        }
コード例 #4
0
        protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method)
        {
            if (method.IsInternalCall)
            {
                // The only way to locate the entrypoint for an internal call is through the RuntimeImportAttribute.
                // If this is a method that doesn't have it (e.g. a string constructor), the method should never
                // have reached this code path.
                Debug.Assert(method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"));
                return new RuntimeImportMethodNode(method);
            }

            if (CompilationModuleGroup.ContainsMethod(method))
            {
                return new MethodCodeNode(method);
            }
            else
            {
                return new ExternMethodSymbolNode(method);
            }
        }
コード例 #5
0
        public static UnmanagedCallingConventions GetPInvokeMethodCallingConventions(this MethodDesc method)
        {
            Debug.Assert(method.IsPInvoke);

            UnmanagedCallingConventions result;

            if (method is Internal.IL.Stubs.PInvokeTargetNativeMethod pinvokeTarget)
            {
                method = pinvokeTarget.Target;
            }

            MethodSignatureFlags unmanagedCallConv = method.GetPInvokeMethodMetadata().Flags.UnmanagedCallingConvention;

            if (unmanagedCallConv != MethodSignatureFlags.None)
            {
                Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConventionCdecl == (int)UnmanagedCallingConventions.Cdecl &&
                             (int)MethodSignatureFlags.UnmanagedCallingConventionStdCall == (int)UnmanagedCallingConventions.Stdcall &&
                             (int)MethodSignatureFlags.UnmanagedCallingConventionThisCall == (int)UnmanagedCallingConventions.Thiscall);
                result = (UnmanagedCallingConventions)unmanagedCallConv;
            }
            else
            {
                CustomAttributeValue <TypeDesc>?unmanagedCallConvAttribute = ((EcmaMethod)method).GetDecodedCustomAttribute("System.Runtime.InteropServices", "UnmanagedCallConvAttribute");
                if (unmanagedCallConvAttribute != null)
                {
                    result = GetUnmanagedCallingConventionFromAttribute(unmanagedCallConvAttribute.Value, method.Context);
                }
                else
                {
                    result = GetPlatformDefaultUnmanagedCallingConvention(method.Context);
                }
            }

            if (method.HasCustomAttribute("System.Runtime.InteropServices", "SuppressGCTransitionAttribute"))
            {
                result |= UnmanagedCallingConventions.IsSuppressGcTransition;
            }

            return(result);
        }
コード例 #6
0
ファイル: RyuJitNodeFactory.cs プロジェクト: nattress/corert
        protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method)
        {
            if (method.IsInternalCall)
            {
                // The only way to locate the entrypoint for an internal call is through the RuntimeImportAttribute.
                if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
                {
                    return new RuntimeImportMethodNode(method);
                }

                // On CLR this would throw a SecurityException with "ECall methods must be packaged into a system module."
                // This is a corner case that nobody is likely to care about.
                throw new TypeSystemException.InvalidProgramException(ExceptionStringID.InvalidProgramSpecific, method);
            }

            if (CompilationModuleGroup.ContainsMethod(method))
            {
                return new MethodCodeNode(method);
            }
            else
            {
                return new ExternMethodSymbolNode(method);
            }
        }
コード例 #7
0
 public override bool HasCustomAttribute(string attributeNamespace, string attributeName)
 {
     return(_typicalMethodDef.HasCustomAttribute(attributeNamespace, attributeName));
 }