diff options
author | Michal Strehovský <MichalStrehovsky@users.noreply.github.com> | 2017-06-11 08:10:37 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-06-11 08:10:37 +0300 |
commit | 566051d731c0191eed1c674fecd5fbbe9823738d (patch) | |
tree | 519df40de3eae679a007fd6444a49c1e2e991b22 | |
parent | 42fd6d0fc5d695afeb79745936afd6a1ce8b74c8 (diff) |
Move the code that throws for varargs out of the parser (#3861)
4 files changed, 11 insertions, 4 deletions
diff --git a/src/Common/src/TypeSystem/Common/MethodDesc.cs b/src/Common/src/TypeSystem/Common/MethodDesc.cs index 44dca5049..fcab153bb 100644 --- a/src/Common/src/TypeSystem/Common/MethodDesc.cs +++ b/src/Common/src/TypeSystem/Common/MethodDesc.cs @@ -19,6 +19,7 @@ namespace Internal.TypeSystem UnmanagedCallingConventionCdecl = 0x0001, UnmanagedCallingConventionStdCall = 0x0002, UnmanagedCallingConventionThisCall = 0x0003, + CallingConventionVarargs = 0x0005, Static = 0x0010, } diff --git a/src/Common/src/TypeSystem/Ecma/EcmaSignatureParser.cs b/src/Common/src/TypeSystem/Ecma/EcmaSignatureParser.cs index 749f1ca22..74d604347 100644 --- a/src/Common/src/TypeSystem/Ecma/EcmaSignatureParser.cs +++ b/src/Common/src/TypeSystem/Ecma/EcmaSignatureParser.cs @@ -169,10 +169,7 @@ namespace Internal.TypeSystem.Ecma Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConventionCdecl == (int)SignatureCallingConvention.CDecl); Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConventionStdCall == (int)SignatureCallingConvention.StdCall); Debug.Assert((int)MethodSignatureFlags.UnmanagedCallingConventionThisCall == (int)SignatureCallingConvention.ThisCall); - - // Vararg methods are not supported in .NET Core - if (signatureCallConv == SignatureCallingConvention.VarArgs) - throw new TypeSystemException.BadImageFormatException(); + Debug.Assert((int)MethodSignatureFlags.CallingConventionVarargs == (int)SignatureCallingConvention.VarArgs); flags = (MethodSignatureFlags)signatureCallConv; } diff --git a/src/ILCompiler.Compiler/src/Compiler/LibraryRootProvider.cs b/src/ILCompiler.Compiler/src/Compiler/LibraryRootProvider.cs index c4a3805cb..80f6b0171 100644 --- a/src/ILCompiler.Compiler/src/Compiler/LibraryRootProvider.cs +++ b/src/ILCompiler.Compiler/src/Compiler/LibraryRootProvider.cs @@ -84,6 +84,10 @@ namespace ILCompiler { MethodSignature signature = method.Signature; + // Vararg methods are not supported in .NET Core + if ((signature.Flags & MethodSignatureFlags.UnmanagedCallingConventionMask) == MethodSignatureFlags.CallingConventionVarargs) + throw new TypeSystemException.BadImageFormatException(); + CheckTypeCanBeUsedInSignature(signature.ReturnType); for (int i = 0; i < signature.Length; i++) diff --git a/src/JitInterface/src/CorInfoImpl.cs b/src/JitInterface/src/CorInfoImpl.cs index 9e8c802bf..0e483a666 100644 --- a/src/JitInterface/src/CorInfoImpl.cs +++ b/src/JitInterface/src/CorInfoImpl.cs @@ -534,6 +534,11 @@ namespace Internal.JitInterface private void Get_CORINFO_SIG_INFO(MethodSignature signature, out CORINFO_SIG_INFO sig) { sig.callConv = (CorInfoCallConv)(signature.Flags & MethodSignatureFlags.UnmanagedCallingConventionMask); + + // Varargs are not supported in .NET Core + if (sig.callConv == CorInfoCallConv.CORINFO_CALLCONV_VARARG) + throw new TypeSystemException.BadImageFormatException(); + if (!signature.IsStatic) sig.callConv |= CorInfoCallConv.CORINFO_CALLCONV_HASTHIS; TypeDesc returnType = signature.ReturnType; |