Example #1
0
        protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method)
        {
            if (method.IsInternalCall)
            {
                if (TypeSystemContext.IsSpecialUnboxingThunkTargetMethod(method))
                {
                    return(MethodEntrypoint(TypeSystemContext.GetRealSpecialUnboxingThunkTargetMethod(method)));
                }
                else if (TypeSystemContext.IsDefaultInterfaceMethodImplementationThunkTargetMethod(method))
                {
                    return(MethodEntrypoint(TypeSystemContext.GetRealDefaultInterfaceMethodImplementationThunkTargetMethod(method)));
                }
                else if (method.IsArrayAddressMethod())
                {
                    return(MethodEntrypoint(((ArrayType)method.OwningType).GetArrayMethod(ArrayMethodKind.AddressWithHiddenArg)));
                }
                else if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
                {
                    return(new RuntimeImportMethodNode(method));
                }
            }

            // MethodDesc that represents an unboxing thunk is a thing that is internal to the JitInterface.
            // It should not leak out of JitInterface.
            Debug.Assert(!Internal.JitInterface.UnboxingMethodDescExtensions.IsUnboxingThunk(method));

            if (CompilationModuleGroup.ContainsMethodBody(method, false))
            {
                // We might be able to optimize the method body away if the owning type was never seen as allocated.
                if (method.NotCallableWithoutOwningEEType() && CompilationModuleGroup.AllowInstanceMethodOptimization(method))
                {
                    return(new TentativeInstanceMethodNode(new MethodCodeNode(method)));
                }

                return(new MethodCodeNode(method));
            }
            else
            {
                return(_importedNodeProvider.ImportedMethodCodeNode(this, method, false));
            }
        }
Example #2
0
        protected override IMethodNode CreateMethodEntrypointNode(MethodDesc method)
        {
            if (method.IsInternalCall)
            {
                // TODO: come up with a scheme where this can be shared between codegen backends and the scanner
                if (TypeSystemContext.IsSpecialUnboxingThunkTargetMethod(method))
                {
                    return(MethodEntrypoint(TypeSystemContext.GetRealSpecialUnboxingThunkTargetMethod(method)));
                }
                else if (TypeSystemContext.IsDefaultInterfaceMethodImplementationThunkTargetMethod(method))
                {
                    return(MethodEntrypoint(TypeSystemContext.GetRealDefaultInterfaceMethodImplementationThunkTargetMethod(method)));
                }
                else if (method.IsArrayAddressMethod())
                {
                    return(new ScannedMethodNode(((ArrayType)method.OwningType).GetArrayMethod(ArrayMethodKind.AddressWithHiddenArg)));
                }
                else if (method.HasCustomAttribute("System.Runtime", "RuntimeImportAttribute"))
                {
                    return(new RuntimeImportMethodNode(method));
                }
            }

            if (CompilationModuleGroup.ContainsMethodBody(method, false))
            {
                // We might be able to optimize the method body away if the owning type was never seen as allocated.
                if (method.NotCallableWithoutOwningEEType() && CompilationModuleGroup.AllowInstanceMethodOptimization(method))
                {
                    return(new TentativeInstanceMethodNode(new ScannedMethodNode(method)));
                }

                return(new ScannedMethodNode(method));
            }
            else
            {
                return(new ExternMethodSymbolNode(this, method));
            }
        }