Merge pull request #444 from knocte/xbuild_improvements
authorAnkit Jain <radical@corewars.org>
Mon, 3 Sep 2012 11:28:32 +0000 (04:28 -0700)
committerAnkit Jain <radical@corewars.org>
Mon, 3 Sep 2012 11:28:32 +0000 (04:28 -0700)
MSBuild.Engine: use a buildtask enumerator that throws exceptions

55 files changed:
configure.in
mcs/class/Microsoft.Build.Tasks/Microsoft.Build.Tasks/ResolveAssemblyReference.cs
mcs/class/Microsoft.Build.Tasks/Test/Microsoft.Build.Tasks/ResolveAssemblyReferenceTest.cs
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll [new file with mode: 0755]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll.mdb [new file with mode: 0644]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll [new file with mode: 0755]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll.mdb [new file with mode: 0644]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll [new file with mode: 0755]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll.mdb [new file with mode: 0644]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe [new file with mode: 0755]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe.mdb [new file with mode: 0644]
mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest2.exe [new file with mode: 0755]
mcs/class/Mono.Data.Sqlite/Makefile
mcs/class/Mono.Data.Sqlite/resources/SR.resources.prebuilt [new file with mode: 0644]
mcs/class/System/System.Net.NetworkInformation/Ping.cs
mcs/class/System/System.Net/ServicePointManager.cs
mcs/class/System/System.Security.Cryptography.X509Certificates/OSX509Certificates.cs
mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
mcs/mcs/context.cs
mcs/mcs/ecore.cs
mcs/tests/gtest-iter-27.cs [new file with mode: 0644]
mcs/tests/gtest-optional-25.cs [new file with mode: 0644]
mcs/tests/test-async-39.cs [new file with mode: 0644]
mcs/tests/ver-il-net_4_5.xml
mono/metadata/class-internals.h
mono/metadata/class.c
mono/metadata/marshal.c
mono/metadata/marshal.h
mono/metadata/metadata.c
mono/metadata/threads.c
mono/mini/Makefile.am
mono/mini/aot-compiler.c
mono/mini/aot-runtime.c
mono/mini/dwarfwriter.c
mono/mini/exceptions-x86.c
mono/mini/gc-test.cs
mono/mini/method-to-ir.c
mono/mini/mini-alpha.c
mono/mini/mini-amd64.c
mono/mini/mini-arm.c
mono/mini/mini-codegen.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-hppa.c
mono/mini/mini-ia64.c
mono/mini/mini-llvm.c [changed mode: 0755->0644]
mono/mini/mini-mips.c
mono/mini/mini-ppc.c
mono/mini/mini-s390.c
mono/mini/mini-s390x.c
mono/mini/mini-sparc.c
mono/mini/mini-x86.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/trace.c
mono/utils/mono-mmap.c

index 69f966b4ff79bd3db938e42fce13c3b0c570db6b..38cc6dc29257fe25a36439284f0e9de7a4f29b00 100644 (file)
@@ -1125,19 +1125,18 @@ if test x$target_win32 = xno; then
        AC_DEFUN([LARGE_FILES], [
                large_CPPFLAGS=$CPPFLAGS
                CPPFLAGS="$CPPFLAGS $1"
-               AC_TRY_RUN([
+               AC_TRY_COMPILE([
                        #include <sys/types.h>
+                       #include <limits.h>
+               ], [
+                       /* Lifted this compile time assert method from: http://www.jaggersoft.com/pubs/CVu11_3.html */
+                       #define COMPILE_TIME_ASSERT(pred) \
+                               switch(0){case 0:case pred:;}
 
-                       #define BIG_OFF_T (((off_t)1<<62)-1+((off_t)1<<62))
-
-                       int main(void) {
-                               int big_off_t=((BIG_OFF_T%2147483629==721) &&
-                                              (BIG_OFF_T%2147483647==1));
-                               if(big_off_t) {
-                                       exit(0);
-                               } else {
-                                       exit(1);
-                               }
+                       int main(void)
+                       {
+                               COMPILE_TIME_ASSERT(sizeof(off_t) * CHAR_BIT == 64);
+                               return 0;
                        }
                ], [
                        AC_MSG_RESULT(ok)
@@ -1146,7 +1145,7 @@ if test x$target_win32 = xno; then
                        large_offt=yes
                ], [
                        AC_MSG_RESULT(no)
-               ], "")
+               ])
                CPPFLAGS=$large_CPPFLAGS
        ])
 
index bb667015d77513cb3a2d420bfec14e0d34374166..e9a26a444eb3d8951d944d8213c99a244ff4f8e5 100644 (file)
@@ -114,6 +114,7 @@ namespace Microsoft.Build.Tasks {
 
                        ResolveAssemblies ();
                        ResolveAssemblyFiles ();
+                       resolvedFiles = tempResolvedFiles.ToArray ();
 
                        alreadyScannedAssemblyNames = new Dictionary<string, string> ();
 
@@ -125,7 +126,6 @@ namespace Microsoft.Build.Tasks {
                        foreach (PrimaryReference pref in primaryReferences)
                                ResolveAssemblyFileDependencies (pref.TaskItem, pref.ParentCopyLocal);
 
-                       resolvedFiles = tempResolvedFiles.ToArray ();
                        copyLocalFiles = tempCopyLocalFiles.Values.ToArray ();
                        satelliteFiles = tempSatelliteFiles.Values.ToArray ();
                        relatedFiles = tempRelatedFiles.Values.ToArray ();
@@ -337,8 +337,10 @@ namespace Microsoft.Build.Tasks {
                                                        aname, asm.FullName, parent_copy_local);
 
                                        if (resolved_ref != null && !IsFromGacOrTargetFramework (resolved_ref)
-                                                       && resolved_ref.FoundInSearchPath != SearchPath.PkgConfig)
+                                                       && resolved_ref.FoundInSearchPath != SearchPath.PkgConfig) {
+                                               tempResolvedDepFiles[resolved_ref.AssemblyName.FullName] = resolved_ref.TaskItem;
                                                dependencies.Enqueue (resolved_ref.TaskItem.ItemSpec);
+                                       }
                                }
                                alreadyScannedAssemblyNames.Add (asm.FullName, String.Empty);
                        }
index a29ef8f46a30e6d2e8b0143dfb6060167b064039..5816d7adf5ccb09c891470760f3a6fd01e05b3c1 100644 (file)
@@ -27,6 +27,7 @@
 
 using System;
 using System.Collections;
+using System.Linq;
 using Microsoft.Build.BuildEngine;
 using Microsoft.Build.Framework;
 using Microsoft.Build.Tasks;
@@ -34,66 +35,166 @@ using Microsoft.Build.Utilities;
 using NUnit.Framework;
 
 namespace MonoTests.Microsoft.Build.Tasks {
-
+       
        [TestFixture]
        public class ResolveAssemblyReferenceTest {
-
+               
                Engine engine;
                Project project;
                BuildItemGroup big;
 
                [Test]
-               [Ignore ("it won't succeed if mono is not installed")]
                public void TestGac1 ()
                {
-                       string documentString = @"
-                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
-                                       <ItemGroup>
-                                               <Reference Include='System' />
-                                       </ItemGroup>
-                                       <PropertyGroup>
-                                               <SearchPaths>
-                                                       {CandidateAssemblyFiles};
-                                                       $(ReferencePath);
-                                                       {HintPathFromItem};
-                                                       {TargetFrameworkDirectory};
-                                                       {AssemblyFolders};
-                                                       {GAC};
-                                                       {RawFileName};
-                                                       $(OutputPath)
-                                               </SearchPaths>
-                                       </PropertyGroup>
-                                       <Target Name='A'>
-                                               <ResolveAssemblyReference
-                                                       Assemblies='@(Reference)'
-                                                       SearchPaths='$(SearchPaths)'
-                                               >
-                                                       <Output TaskParameter='ResolvedFiles' ItemName='ResolvedFiles'/>
-                                               </ResolveAssemblyReference>
-                                       </Target>
-                               </Project>
-                       ";
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly ("System", null));
                        
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (1, big.Count, "A2");
+                       Assert.IsTrue (big [0].Include.EndsWith (".dll"), "A3");
+               }
+               
+               [Test]
+               public void TestHintPath1 ()
+               {
                        engine = new Engine (Consts.BinPath);
                        project = engine.CreateNewProject ();
-                       project.LoadXml (documentString);
-
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\test.dll"));
+                       
                        Assert.IsTrue (project.Build ("A"), "A1");
                        big = project.GetEvaluatedItemsByName ("ResolvedFiles");
                        Assert.AreEqual (1, big.Count, "A2");
                        Assert.IsTrue (big [0].Include.EndsWith (".dll"), "A3");
                }
+               
+               [Test]
+               public void ResolveBinary_FancyStuff ()
+               {
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\FancyStuff.dll"));
+                       
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (1, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("FancyStuff.dll"), "A3");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (1, big.Count, "A4");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("SimpleWrite.dll")), "A5");
+               }
+               
+               [Test]
+               public void ResolveBinary_SimpleWrite ()
+               {
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\SimpleWrite.dll"));
+                       
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (1, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("SimpleWrite.dll"), "A3");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (0, big.Count, "A4");
+               }
+               
+               [Test]
+               public void ResolveBinary_Testing ()
+               {
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\Testing.dll"));
+                       
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (1, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("Testing.dll"), "A3");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (0, big.Count, "A4");
+               }
+               
+               [Test]
+               public void ResolveBinary_XbuildReferenceBugTest ()
+               {
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\XbuildReferenceBugTest.exe"));
+                       
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (1, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("XbuildReferenceBugTest.exe"), "A3");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (3, big.Count, "A4");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("SimpleWrite.dll")), "A5");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("FancyStuff.dll")), "A6");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("Testing.dll")), "A7");
+               }
 
                [Test]
-               [Ignore ("it won't succeed if mono is not installed")]
-               public void TestHintPath1 ()
+               public void ResolveBinary_FancyStuffAndXbuild ()
                {
-                       string documentString = @"
-                                <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\FancyStuff.dll", @"Test\resources\binary\XbuildReferenceBugTest.exe"));
+                       
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (2, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("FancyStuff.dll"), "A3");
+                       Assert.IsTrue (big[1].Include.EndsWith ("XbuildReferenceBugTest.exe"), "A3");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (2, big.Count, "A4");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("SimpleWrite.dll")), "A5");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("Testing.dll")), "A6");
+               }
+
+               [Test]
+               public void ResolveBinary_SameAssemblyTwice ()
+               {
+                       engine = new Engine (Consts.BinPath);
+                       project = engine.CreateNewProject ();
+                       project.LoadXml (ResolveAssembly (null, @"Test\resources\binary\XbuildReferenceBugTest.exe", @"Test\resources\binary\XbuildReferenceBugTest2.exe"));
+
+                       Assert.IsTrue (project.Build ("A"), "A1");
+                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
+                       Assert.AreEqual (2, big.Count, "A2");
+                       Assert.IsTrue (big[0].Include.EndsWith ("XbuildReferenceBugTest.exe"), "A3");
+                       Assert.IsTrue (big[1].Include.EndsWith ("XbuildReferenceBugTest2.exe"), "A3b");
+                       
+                       big = project.GetEvaluatedItemsByName ("ResolvedDependencyFiles");
+                       Assert.AreEqual (3, big.Count, "A4");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("SimpleWrite.dll")), "A5");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("FancyStuff.dll")), "A6");
+                       Assert.IsTrue (big.Cast<BuildItem> ().Any (item => item.Include.EndsWith ("Testing.dll")), "A7");
+               }
+
+               string ResolveAssembly (string gacAssembly, params string[] hintPaths)
+               {
+                       string reference = "";
+                       if (string.IsNullOrEmpty (gacAssembly)) {
+                               foreach (var hintPath in hintPaths) {
+                                       reference += string.Format (
+                                               @"<Reference Include='{0}'>
+                                                               <HintPath>{1}</HintPath>
+                                                       </Reference>", System.IO.Path.GetFileNameWithoutExtension (hintPath), hintPath);
+                               }
+                       } else {
+                               reference += string.Format (
+                                       @"<Reference Include='{0}'/>", gacAssembly);
+                       }
+                       
+                       return @"
+                  <Project xmlns=""http://schemas.microsoft.com/developer/msbuild/2003"">
                                        <ItemGroup>
-                                               <Reference Include='test'>
-                                                       <HintPath>Test\resources\test.dll</HintPath>
-                                               </Reference>
+                                       " + reference + @"      
                                        </ItemGroup>
                                        <PropertyGroup>
                                                <SearchPaths>
@@ -113,19 +214,11 @@ namespace MonoTests.Microsoft.Build.Tasks {
                                                        SearchPaths='$(SearchPaths)'
                                                >
                                                        <Output TaskParameter='ResolvedFiles' ItemName='ResolvedFiles'/>
+                                                       <Output TaskParameter='ResolvedDependencyFiles' ItemName='ResolvedDependencyFiles'/>
                                                </ResolveAssemblyReference>
                                        </Target>
                                </Project>
                        ";
-                       
-                       engine = new Engine (Consts.BinPath);
-                       project = engine.CreateNewProject ();
-                       project.LoadXml (documentString);
-
-                       Assert.IsTrue (project.Build ("A"), "A1");
-                       big = project.GetEvaluatedItemsByName ("ResolvedFiles");
-                       Assert.AreEqual (1, big.Count, "A2");
-                       Assert.IsTrue (big [0].Include.EndsWith (".dll"), "A3");
                }
        }
 } 
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll
new file mode 100755 (executable)
index 0000000..38f3033
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll.mdb b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll.mdb
new file mode 100644 (file)
index 0000000..61c4ed3
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/FancyStuff.dll.mdb differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll
new file mode 100755 (executable)
index 0000000..0152e51
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll.mdb b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll.mdb
new file mode 100644 (file)
index 0000000..8480d3c
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/SimpleWrite.dll.mdb differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll
new file mode 100755 (executable)
index 0000000..f04aca0
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll.mdb b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll.mdb
new file mode 100644 (file)
index 0000000..3dcceb0
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/Testing.dll.mdb differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe
new file mode 100755 (executable)
index 0000000..c57f791
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe.mdb b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe.mdb
new file mode 100644 (file)
index 0000000..e924bd7
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest.exe.mdb differ
diff --git a/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest2.exe b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest2.exe
new file mode 100755 (executable)
index 0000000..2f2d165
Binary files /dev/null and b/mcs/class/Microsoft.Build.Tasks/Test/resources/binary/XbuildReferenceBugTest2.exe differ
index 09811f7dad0d37df5af10f671d03a7ea39f48c1d..f0d38ab1280f19f4baec199049696f11440261d2 100644 (file)
@@ -7,6 +7,8 @@ OTHER_RESOURCES = $(wildcard resources/*.bmp)
 
 RESOURCES = $(RESX_RESOURCES) $(OTHER_RESOURCES)
 
+PREBUILT = $(RESX_RESOURCES:=.prebuilt)
+
 LIBRARY = Mono.Data.Sqlite.dll
 LIB_MCS_FLAGS = /unsafe /r:System.dll /r:System.Data.dll /r:System.Transactions.dll /r:System.Xml.dll \
        $(RESOURCES:%=-resource:%) -d:SQLITE_STANDARD
@@ -19,10 +21,13 @@ EXTRA_DISTFILES = Test/SqliteTest.cs \
        resources/ChangeLog     \
        resources/DataTypes.xml \
        resources/MetaDataCollections.xml \
+       $(PREBUILT) \
        $(wildcard resources/*.bmp)
        
 CLEAN_FILES += $(RESX_RESOURCES)
 
+CLEAN_FILES = $(RESX_RESOURCES)
+
 test-local: test.db 
 
 test.db: Test/test.sql
@@ -33,5 +38,9 @@ include ../../build/library.make
 
 $(the_lib): $(RESOURCES)
 
+$(PREBUILT): %.prebuilt: %
+       cp $* $@
+
 $(RESX_RESOURCES): %.resources: %.resx
-       $(RESGEN) $<
+       $(RESGEN) $< || cp $@.prebuilt $@
+
diff --git a/mcs/class/Mono.Data.Sqlite/resources/SR.resources.prebuilt b/mcs/class/Mono.Data.Sqlite/resources/SR.resources.prebuilt
new file mode 100644 (file)
index 0000000..2b09f9e
Binary files /dev/null and b/mcs/class/Mono.Data.Sqlite/resources/SR.resources.prebuilt differ
index e7b65d0ae35a8ad5f03ec43e4f25806282550701..e0d29b8e084416ddf4b06658944917c73c2ff0f1 100644 (file)
@@ -150,13 +150,14 @@ namespace System.Net.NetworkInformation {
 
                protected void OnPingCompleted (PingCompletedEventArgs e)
                {
-                       if (PingCompleted != null)
-                               PingCompleted (this, e);
                        user_async_state = null;
                        worker = null;
 #if NET_4_5
                        cts = null;
 #endif
+
+                       if (PingCompleted != null)
+                               PingCompleted (this, e);
                }
 
                // Sync
index d64f58cd1e53ea2b9a4dbf954471e3da70928092..951389772dfd98d64db0fc519bbc58d775bea8f9 100644 (file)
@@ -453,6 +453,7 @@ namespace System.Net
                                int status11 = 0; // Error code passed to the obsolete ICertificatePolicy callback
                                SslPolicyErrors errors = 0;
                                X509Chain chain = null;
+                               bool result = false;
 #if !MONOTOUCH
                                chain = new X509Chain ();
                                chain.ChainPolicy = new X509ChainPolicy ();
@@ -470,27 +471,25 @@ namespace System.Net
                                        Console.Error.WriteLine ("Please, report this problem to the Mono team");
                                        errors |= SslPolicyErrors.RemoteCertificateChainErrors;
                                }
-#endif
-                               if (!CheckCertificateUsage (leaf)) {
-                                       errors |= SslPolicyErrors.RemoteCertificateChainErrors;
-                                       status11 = -2146762490; //CERT_E_PURPOSE 0x800B0106
-                               }
 
-                               if (!CheckServerIdentity (certs [0], Host)) {
-                                       errors |= SslPolicyErrors.RemoteCertificateNameMismatch;
-                                       status11 = -2146762481; // CERT_E_CN_NO_MATCH 0x800B010F
-                               }
+                               // for OSX and iOS we're using the native API to check for the SSL server policy and host names
+                               if (!is_macosx) {
+                                       if (!CheckCertificateUsage (leaf)) {
+                                               errors |= SslPolicyErrors.RemoteCertificateChainErrors;
+                                               status11 = -2146762490; //CERT_E_PURPOSE 0x800B0106
+                                       }
 
-                               bool result = false;
-                               // No certificate root found means no mozroots or monotouch
-#if !MONOTOUCH
-                               if (is_macosx) {
+                                       if (!CheckServerIdentity (certs [0], Host)) {
+                                               errors |= SslPolicyErrors.RemoteCertificateNameMismatch;
+                                               status11 = -2146762481; // CERT_E_CN_NO_MATCH 0x800B010F
+                                       }
+                               } else {
 #endif
                                        // Attempt to use OSX certificates
                                        // Ideally we should return the SecTrustResult
                                        MSX.OSX509Certificates.SecTrustResult trustResult = MSX.OSX509Certificates.SecTrustResult.Deny;
                                        try {
-                                               trustResult = MSX.OSX509Certificates.TrustEvaluateSsl (certs);
+                                               trustResult = MSX.OSX509Certificates.TrustEvaluateSsl (certs, Host);
                                                // We could use the other values of trustResult to pass this extra information
                                                // to the .NET 2 callback for values like SecTrustResult.Confirm
                                                result = (trustResult == MSX.OSX509Certificates.SecTrustResult.Proceed ||
@@ -499,11 +498,8 @@ namespace System.Net
                                        } catch {
                                                // Ignore
                                        }
-                                       // Clear error status if the OS told us to trust the certificate
-                                       if (result) {
-                                               status11 = 0;
-                                               errors = 0;
-                                       } else {
+                                       
+                                       if (!result) {
                                                // callback and DefaultCertificatePolicy needs this since 'result' is not specified
                                                status11 = (int) trustResult;
                                                errors |= SslPolicyErrors.RemoteCertificateChainErrors;
@@ -514,10 +510,6 @@ namespace System.Net
 
 #if MONODROID
                                result = AndroidPlatform.TrustEvaluateSsl (certs, sender, leaf, chain, errors);
-                               if (result) {
-                                       status11 = 0;
-                                       errors = 0;
-                               }
 #endif
 
                                if (policy != null && (!(policy is DefaultCertificatePolicy) || cb == null)) {
@@ -598,7 +590,7 @@ namespace System.Net
                                }
                                return (int) result;
                        }
-
+#if !MONOTOUCH
                        static SslPolicyErrors GetErrorsFromChain (X509Chain chain)
                        {
                                SslPolicyErrors errors = SslPolicyErrors.None;
@@ -759,6 +751,7 @@ namespace System.Net
                                string start = pattern.Substring (0, index);
                                return (String.Compare (hostname, 0, start, 0, start.Length, true, CultureInfo.InvariantCulture) == 0);
                        }
+#endif
                }
 #endif
        }
index 905d6324474f41fdc9047538c0e66e7f97be4129..19ed3a07c734380581f5a666fc97335490f8e3e4 100644 (file)
@@ -1,4 +1,5 @@
 // Copyright (C) 2010 Novell, Inc (http://www.novell.com)
+// Copyright 2012 Xamarin Inc.
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -38,11 +39,14 @@ namespace Mono.Security.X509 {
                extern static int SecTrustCreateWithCertificates (IntPtr certOrCertArray, IntPtr policies, out IntPtr sectrustref);
                
                [DllImport (SecurityLibrary)]
-               extern static IntPtr SecPolicyCreateSSL (int server, IntPtr cfStringHostname);
+               extern static IntPtr SecPolicyCreateSSL (bool server, IntPtr cfStringHostname);
                
                [DllImport (SecurityLibrary)]
                extern static int SecTrustEvaluate (IntPtr secTrustRef, out SecTrustResult secTrustResultTime);
 
+               [DllImport (CoreFoundationLibrary, CharSet=CharSet.Unicode)]
+               extern static IntPtr CFStringCreateWithCharacters (IntPtr allocator, string str, int count);
+
                [DllImport (CoreFoundationLibrary)]
                unsafe extern static IntPtr CFDataCreate (IntPtr allocator, byte *bytes, IntPtr length);
 
@@ -63,8 +67,6 @@ namespace Mono.Security.X509 {
                        ResultOtherError,
                }
 
-               static IntPtr sslsecpolicy = SecPolicyCreateSSL (0, IntPtr.Zero);
-
                static IntPtr MakeCFData (byte [] data)
                {
                        unsafe {
@@ -84,24 +86,26 @@ namespace Mono.Security.X509 {
                        }
                }
                
-               public static SecTrustResult TrustEvaluateSsl (X509CertificateCollection certificates)
+               public static SecTrustResult TrustEvaluateSsl (X509CertificateCollection certificates, string host)
                {
+                       if (certificates == null)
+                               return SecTrustResult.Deny;
+
                        try {
-                               return _TrustEvaluateSsl (certificates);
+                               return _TrustEvaluateSsl (certificates, host);
                        } catch {
                                return SecTrustResult.Deny;
                        }
                }
                
-               static SecTrustResult _TrustEvaluateSsl (X509CertificateCollection certificates)
+               static SecTrustResult _TrustEvaluateSsl (X509CertificateCollection certificates, string hostName)
                {
-                       if (certificates == null)
-                               throw new ArgumentNullException ("certificates");
-
                        int certCount = certificates.Count;
                        IntPtr [] cfDataPtrs = new IntPtr [certCount];
                        IntPtr [] secCerts = new IntPtr [certCount];
                        IntPtr certArray = IntPtr.Zero;
+                       IntPtr sslsecpolicy = IntPtr.Zero;
+                       IntPtr host = IntPtr.Zero;
                        
                        try {
                                for (int i = 0; i < certCount; i++)
@@ -113,6 +117,8 @@ namespace Mono.Security.X509 {
                                                return SecTrustResult.Deny;
                                }
                                certArray = FromIntPtrs (secCerts);
+                               host = CFStringCreateWithCharacters (IntPtr.Zero, hostName, hostName.Length);
+                               sslsecpolicy = SecPolicyCreateSSL (true, host);
                                IntPtr sectrust;
                                int code = SecTrustCreateWithCertificates (certArray, sslsecpolicy, out sectrust);
                                if (code == 0){
@@ -137,6 +143,11 @@ namespace Mono.Security.X509 {
                                for (int i = 0; i < certCount; i++)
                                        if (secCerts [i] != IntPtr.Zero)
                                                CFRelease (secCerts [i]);
+
+                               if (sslsecpolicy != IntPtr.Zero)
+                                       CFRelease (sslsecpolicy);
+                               if (host != IntPtr.Zero)
+                                       CFRelease (host);
                        }
                }
        }
index 2608859aa8ad9a10265860e9b3840f6658ab4c0c..6f6c04cbbf8a69069bcf1cf7f434f2017a1da8bc 100644 (file)
@@ -94,11 +94,11 @@ namespace Mono.Interop
                        Marshal.ThrowExceptionForHR (hr);
                        ComInteropProxy obj = FindProxy (ppv);
                        if (obj == null) {
-                               Marshal.Release (pItf);
+                               Marshal.Release (ppv);
                                return new ComInteropProxy (ppv);
                        }
                        else {
-                               Marshal.Release (pItf);
+                               Marshal.Release (ppv);
                                System.Threading.Interlocked.Increment (ref obj.ref_count);
                                return obj;
                        }
index 0e45bd5deb2a66ec4f70d8eec6d0062f5354e492..7192d305db6a0a7e6313805a831c1ac04e1cec96 100644 (file)
@@ -475,14 +475,14 @@ namespace Mono.CSharp
                        // or it's a parameter
                        //
                        if (CurrentAnonymousMethod.IsIterator)
-                               return local.IsParameter || CurrentBlock.Explicit.HasYield;
+                               return local.IsParameter || local.Block.Explicit.HasYield;
 
                        //
                        // Capture only if this or any of child blocks contain await
                        // or it's a parameter
                        //
                        if (CurrentAnonymousMethod is AsyncInitializer)
-                               return local.IsParameter || CurrentBlock.Explicit.HasAwait;
+                               return local.IsParameter || local.Block.Explicit.HasAwait || CurrentBlock.Explicit.HasAwait;
 
                        return local.Block.ParametersBlock != CurrentBlock.ParametersBlock.Original;
                }
index fa9d7a134f38c029dac0a205e89ec26b5c3fa8c4..a5e86a1d8ba8585dff1c180726da52b34bf4fc36 100644 (file)
@@ -4370,16 +4370,32 @@ namespace Mono.CSharp {
                                        // if the type matches
                                        //
                                        Expression e = fp.DefaultValue;
-                                       if (!(e is Constant) || e.Type.IsGenericOrParentIsGeneric || e.Type.IsGenericParameter) {
+                                       if (!(e is Constant) || e.Type != ptypes [i]) {
                                                //
                                                // LAMESPEC: No idea what the exact rules are for System.Reflection.Missing.Value instead of null
                                                //
-                                               if (e == EmptyExpression.MissingValue && ptypes[i].BuiltinType == BuiltinTypeSpec.Type.Object || ptypes[i].BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
+                                               var ptype = ptypes [i];
+                                               if (e == EmptyExpression.MissingValue && ptype.BuiltinType == BuiltinTypeSpec.Type.Object || ptype.BuiltinType == BuiltinTypeSpec.Type.Dynamic) {
                                                        e = new MemberAccess (new MemberAccess (new MemberAccess (
                                                                new QualifiedAliasMember (QualifiedAliasMember.GlobalAlias, "System", loc), "Reflection", loc), "Missing", loc), "Value", loc);
+                                               } else if (e is Constant) {
+                                                       //
+                                                       // Handles int to int? conversions
+                                                       //
+                                                       e = Convert.ImplicitConversionStandard (ec, e, ptype, loc);
+                                                       
+                                                       //
+                                                       // When constant type paramter contains type argument
+                                                       //
+                                                       // Foo (T[] arg = null)
+                                                       //
+                                                       if (e == null) {
+                                                               e = new DefaultValueExpression (new TypeExpression (ptype, loc), loc);
+                                                       }
                                                } else {
-                                                       e = new DefaultValueExpression (new TypeExpression (ptypes [i], loc), loc);
+                                                       e = new DefaultValueExpression (new TypeExpression (ptype, loc), loc);
                                                }
+                                       
 
                                                e = e.Resolve (ec);
                                        }
diff --git a/mcs/tests/gtest-iter-27.cs b/mcs/tests/gtest-iter-27.cs
new file mode 100644 (file)
index 0000000..202964d
--- /dev/null
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+public class CompilerBug
+{
+       static void Main ()
+       {
+               foreach (string message in Foo ())
+                       Console.WriteLine (message);
+       }
+
+       static IEnumerable<string> Foo ()
+       {
+               Action fnAction;
+               {
+                       fnAction = () => { };
+               }
+               yield return "Executing action";
+               {
+                       fnAction ();
+               }
+               yield return "Action executed";
+       }
+}
diff --git a/mcs/tests/gtest-optional-25.cs b/mcs/tests/gtest-optional-25.cs
new file mode 100644 (file)
index 0000000..4d67dc9
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+
+public class Usage
+{
+       public static void Main ()
+       {
+               var bug = new Bug ();
+               string[] tags = bug.MethodWithOptionalParameter<string> (0);
+       }
+}
+
+public class Bug
+{
+       public TValue[] MethodWithOptionalParameter<TValue> (int index, TValue[] defaultValue = null)
+       {
+               return null;
+       }
+}
+
diff --git a/mcs/tests/test-async-39.cs b/mcs/tests/test-async-39.cs
new file mode 100644 (file)
index 0000000..d02772f
--- /dev/null
@@ -0,0 +1,25 @@
+using System;
+using System.Threading.Tasks;
+
+public class CompilerBug
+{
+       static void Main ()
+       {
+               var res = Foo ().Result;
+               Console.WriteLine (res);
+               return;
+       }
+
+       static async Task<string> Foo ()
+       {
+               Action fnAction;
+               {
+                       fnAction = () => { };
+               }
+               await Task.Delay (10);
+               {
+                       fnAction ();
+               }
+               return "val";
+       }
+}
index 3afbfd6288963a484d5685ee900d8f41c61d179d..b61237acaa6052d52b89a4404b33e3a6280f5d59 100644 (file)
       </method>\r
     </type>\r
   </test>\r
+  <test name="gtest-iter-27.cs">\r
+    <type name="CompilerBug">\r
+      <method name="Void Main()" attrs="145">\r
+        <size>61</size>\r
+      </method>\r
+      <method name="IEnumerable`1 Foo()" attrs="145">\r
+        <size>23</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="CompilerBug+&lt;Foo&gt;c__Iterator0">\r
+      <method name="System.String System.Collections.Generic.IEnumerator&lt;string&gt;.get_Current()" attrs="2529">\r
+        <size>14</size>\r
+      </method>\r
+      <method name="System.Object System.Collections.IEnumerator.get_Current()" attrs="2529">\r
+        <size>14</size>\r
+      </method>\r
+      <method name="IEnumerator System.Collections.IEnumerable.GetEnumerator()" attrs="481">\r
+        <size>14</size>\r
+      </method>\r
+      <method name="IEnumerator`1 System.Collections.Generic.IEnumerable&lt;string&gt;.GetEnumerator()" attrs="481">\r
+        <size>26</size>\r
+      </method>\r
+      <method name="Boolean MoveNext()" attrs="486">\r
+        <size>161</size>\r
+      </method>\r
+      <method name="Void Dispose()" attrs="486">\r
+        <size>15</size>\r
+      </method>\r
+      <method name="Void Reset()" attrs="486">\r
+        <size>6</size>\r
+      </method>\r
+      <method name="Void &lt;&gt;m__0()" attrs="145">\r
+        <size>2</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="gtest-lambda-01.cs">\r
     <type name="IntFunc">\r
       <method name="Int32 Invoke(Int32)" attrs="454">\r
       </method>\r
     </type>\r
   </test>\r
+  <test name="gtest-optional-25.cs">\r
+    <type name="Usage">\r
+      <method name="Void Main()" attrs="150">\r
+        <size>17</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="Bug">\r
+      <method name="TValue[] MethodWithOptionalParameter[TValue](Int32, TValue[])" attrs="134">\r
+        <size>10</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="gtest-partial-01.cs">\r
     <type name="B`1[U]">\r
       <method name="Void .ctor()" attrs="6278">\r
       </method>\r
     </type>\r
   </test>\r
+  <test name="test-async-39.cs">\r
+    <type name="CompilerBug">\r
+      <method name="Void Main()" attrs="145">\r
+        <size>24</size>\r
+      </method>\r
+      <method name="System.Threading.Tasks.Task`1[System.String] Foo()" attrs="145">\r
+        <size>33</size>\r
+      </method>\r
+      <method name="Void .ctor()" attrs="6278">\r
+        <size>7</size>\r
+      </method>\r
+    </type>\r
+    <type name="CompilerBug+&lt;Foo&gt;c__async0">\r
+      <method name="Void MoveNext()" attrs="486">\r
+        <size>220</size>\r
+      </method>\r
+      <method name="Void SetStateMachine(IAsyncStateMachine)" attrs="486">\r
+        <size>13</size>\r
+      </method>\r
+      <method name="Void &lt;&gt;m__0()" attrs="145">\r
+        <size>2</size>\r
+      </method>\r
+    </type>\r
+  </test>\r
   <test name="test-cls-00.cs">\r
     <type name="CLSCLass_6">\r
       <method name="Void add_Disposed(Delegate)" attrs="2182">\r
index 8b559e274cb9a39631b0e01e7b371f37ea016bd3..bc4469196a3fef66884bcf07940f342e80448662 100644 (file)
@@ -536,6 +536,8 @@ struct _MonoDynamicGenericClass {
 struct _MonoGenericParam {
        MonoGenericContainer *owner;    /* Type or method this parameter was defined in. */
        guint16 num;
+       /* For internal runtime use, used to make different versions of the same param */
+       guint16 serial;
        /* 
         * If owner is NULL, or owner is 'owned' by this gparam,
         * then this is the image whose mempool this struct was allocated from.
index bb722b4d077dea2bdee473307a7cfd2ae59ff992..bef40e06e5ac208f7320a5ff7cc381476fbff47f 100644 (file)
@@ -5748,7 +5748,7 @@ make_generic_param_class (MonoGenericParam *param, MonoImage *image, gboolean is
 static MonoClass *
 get_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar)
 {
-       int n = mono_generic_param_num (param);
+       int n = mono_generic_param_num (param) | ((guint32)param->serial << 16);
        MonoImage *image = param->image;
        GHashTable *ht;
 
@@ -5771,7 +5771,7 @@ get_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar)
 static void
 set_anon_gparam_class (MonoGenericParam *param, gboolean is_mvar, MonoClass *klass)
 {
-       int n = mono_generic_param_num (param);
+       int n = mono_generic_param_num (param) | ((guint32)param->serial << 16);
        MonoImage *image = param->image;
        GHashTable *ht;
 
index f2499953aa3ba217482023ae7299fa2cd496cf60..48328cd8d65fa01c91eaa8ca382adcf16c1274e3 100644 (file)
@@ -11995,6 +11995,7 @@ mono_marshal_get_generic_array_helper (MonoClass *class, MonoClass *iface, gchar
        MonoMethodSignature *sig, *csig;
        MonoMethodBuilder *mb;
        MonoMethod *res;
+       WrapperInfo *info;
        int i;
 
        mb = mono_mb_new_no_dup_name (class, name, MONO_WRAPPER_MANAGED_TO_MANAGED);
@@ -12018,6 +12019,10 @@ mono_marshal_get_generic_array_helper (MonoClass *class, MonoClass *iface, gchar
 
        res = mono_mb_create_method (mb, csig, csig->param_count + 16);
 
+       info = mono_wrapper_info_create (res, WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER);
+       info->d.generic_array_helper.method = method;
+       mono_marshal_set_wrapper_info (res, info);
+
        mono_mb_free (mb);
 
        return res;
index 9db6cf0e2fd0d6b5b5fba65bb2b7b9ced5c4e009..9ca76c7ea3640c437c3702aeafc69e1b057c119c 100644 (file)
@@ -104,7 +104,9 @@ typedef enum {
        WRAPPER_SUBTYPE_ICALL_WRAPPER,
        WRAPPER_SUBTYPE_NATIVE_FUNC_AOT,
        /* Subtypes of MONO_WRAPPER_UNKNOWN */
-       WRAPPER_SUBTYPE_SYNCHRONIZED_INNER
+       WRAPPER_SUBTYPE_SYNCHRONIZED_INNER,
+       /* Subtypes of MONO_WRAPPER_MANAGED_TO_MANAGED */
+       WRAPPER_SUBTYPE_GENERIC_ARRAY_HELPER
 } WrapperSubtype;
 
 typedef struct {
@@ -136,6 +138,10 @@ typedef struct {
        MonoMethod *method;
 } SynchronizedInnerWrapperInfo;
 
+typedef struct {
+       MonoMethod *method;
+} GenericArrayHelperWrapperInfo;
+
 /*
  * This structure contains additional information to uniquely identify a given wrapper
  * method. It can be retrieved by mono_marshal_get_wrapper_info () for certain types
@@ -158,6 +164,8 @@ typedef struct {
                ManagedToNativeWrapperInfo managed_to_native;
                /* SYNCHRONIZED_INNER */
                SynchronizedInnerWrapperInfo synchronized_inner;
+               /* GENERIC_ARRAY_HELPER */
+               GenericArrayHelperWrapperInfo generic_array_helper;
        } d;
 } WrapperInfo;
 
index 5a12af08f87d5383589eb67868e3c2c0f1a1a782..5eaed077e273b45e61763b37cd60993ab1df5332 100644 (file)
@@ -4599,6 +4599,8 @@ mono_metadata_generic_param_equal (MonoGenericParam *p1, MonoGenericParam *p2, g
                return TRUE;
        if (mono_generic_param_num (p1) != mono_generic_param_num (p2))
                return FALSE;
+       if (p1->serial != p2->serial)
+               return FALSE;
 
        /*
         * We have to compare the image as well because if we didn't,
index e3b9e1a569dd3eccfe36042ab9c0aea4d3de9da0..5391a25eaa47cf780d2e8da69572e8b0e7e4d18e 100644 (file)
@@ -3699,7 +3699,7 @@ update_tls_reference_bitmap (guint32 offset, uintptr_t *bitmap, int max_set)
        offset &= 0xffffff;
        offset /= sizeof (gpointer);
        /* offset is now the bitmap offset */
-       for (i = 0; i < max_set; ++i) {
+       for (i = 0; i <= max_set; ++i) {
                if (bitmap [i / sizeof (uintptr_t)] & (1L << (i & (sizeof (uintptr_t) * 8 -1))))
                        rb [(offset + i) / (sizeof (uintptr_t) * 8)] |= (1L << ((offset + i) & (sizeof (uintptr_t) * 8 -1)));
        }
index eee3604facaca452b4855348613a1d4dff035221..299f89437c287611e763a793276584e54baa907e 100644 (file)
@@ -411,7 +411,8 @@ test_sources =                      \
        generics.cs             \
        generics-variant-types.il\
        basic-simd.cs \
-       aot-tests.cs
+       aot-tests.cs \
+       gc-test.cs
 
 regtests=basic.exe basic-float.exe basic-long.exe basic-calls.exe objects.exe arrays.exe basic-math.exe exceptions.exe iltests.exe devirtualization.exe generics.exe basic-simd.exe
 
@@ -650,13 +651,16 @@ checktests: $(regtests)
 rcheck: mono $(regtests)
        $(RUNTIME) --regression $(regtests)
 
+gctest: mono gc-test.exe
+       MONO_DEBUG_OPTIONS=clear-nursery-at-gc $(RUNTIME) --regression gc-test.exe
+
 LLVM_AOT_RUNTIME_OPTS=$(if $(LLVM),--llvm,)
 
 aotcheck: mono $(regtests)
-       rm -f *.exe.so
+       rm -f *.exe.so *.exe.dylib
        $(RUNTIME) $(LLVM_AOT_RUNTIME_OPTS) --aot $(regtests) || exit 1
        for i in $(regtests); do $(RUNTIME_AOTCHECK) --regression $$i || exit 1; done
-       rm -f *.exe.so
+       rm -f *.exe.so *.exe.dylib
 
 llvmaotcheck:
        $(MAKE) aotcheck LLVM=1
index 43eedc64d27704afbd9db3d8f4af402bb719a5dd..0972981aae0ef7cd0153ed3a1e11652e975a1721 100644 (file)
@@ -1947,17 +1947,23 @@ encode_klass_ref_inner (MonoAotCompile *acfg, MonoClass *klass, guint8 *buf, gui
                }
        } else if ((klass->byval_arg.type == MONO_TYPE_VAR) || (klass->byval_arg.type == MONO_TYPE_MVAR)) {
                MonoGenericContainer *container = mono_type_get_generic_param_owner (&klass->byval_arg);
-               g_assert (container);
+               MonoGenericParam *par = klass->byval_arg.data.generic_param;
 
                encode_value (MONO_AOT_TYPEREF_VAR, p, &p);
                encode_value (klass->byval_arg.type, p, &p);
                encode_value (mono_type_get_generic_param_num (&klass->byval_arg), p, &p);
-               
-               encode_value (container->is_method, p, &p);
-               if (container->is_method)
-                       encode_method_ref (acfg, container->owner.method, p, &p);
-               else
-                       encode_klass_ref (acfg, container->owner.klass, p, &p);
+
+               encode_value (container ? 1 : 0, p, &p);
+               if (container) {
+                       encode_value (container->is_method, p, &p);
+                       g_assert (par->serial == 0);
+                       if (container->is_method)
+                               encode_method_ref (acfg, container->owner.method, p, &p);
+                       else
+                               encode_klass_ref (acfg, container->owner.klass, p, &p);
+               } else {
+                       encode_value (par->serial, p, &p);
+               }
        } else if (klass->byval_arg.type == MONO_TYPE_PTR) {
                encode_value (MONO_AOT_TYPEREF_PTR, p, &p);
                encode_type (acfg, &klass->byval_arg, p, &p);
index e3aadec4ff018d8fe98e9aeb129b2845936a2ba2..0a51626141dfc6f64b9af4413a05d1a0e7671186 100644 (file)
@@ -415,35 +415,52 @@ decode_klass_ref (MonoAotModule *module, guint8 *buf, guint8 **endbuf)
        }
        case MONO_AOT_TYPEREF_VAR: {
                MonoType *t;
-               MonoGenericContainer *container;
+               MonoGenericContainer *container = NULL;
                int type = decode_value (p, &p);
                int num = decode_value (p, &p);
-               gboolean is_method = decode_value (p, &p);
+               gboolean has_container = decode_value (p, &p);
+               int serial = 0;
 
-               if (is_method) {
-                       MonoMethod *method_def;
-                       g_assert (type == MONO_TYPE_MVAR);
-                       method_def = decode_resolve_method_ref (module, p, &p);
-                       if (!method_def)
-                               return NULL;
-
-                       container = mono_method_get_generic_container (method_def);
+               if (has_container) {
+                       gboolean is_method = decode_value (p, &p);
+                       
+                       if (is_method) {
+                               MonoMethod *method_def;
+                               g_assert (type == MONO_TYPE_MVAR);
+                               method_def = decode_resolve_method_ref (module, p, &p);
+                               if (!method_def)
+                                       return NULL;
+
+                               container = mono_method_get_generic_container (method_def);
+                       } else {
+                               MonoClass *class_def;
+                               g_assert (type == MONO_TYPE_VAR);
+                               class_def = decode_klass_ref (module, p, &p);
+                               if (!class_def)
+                                       return NULL;
+                               container = class_def->generic_container;
+                       }
                } else {
-                       MonoClass *class_def;
-                       g_assert (type == MONO_TYPE_VAR);
-                       class_def = decode_klass_ref (module, p, &p);
-                       if (!class_def)
-                               return NULL;
-
-                       container = class_def->generic_container;
+                       serial = decode_value (p, &p);
                }
 
-               g_assert (container);
-
                // FIXME: Memory management
                t = g_new0 (MonoType, 1);
                t->type = type;
-               t->data.generic_param = mono_generic_container_get_param (container, num);
+
+               if (container) {
+                       t->data.generic_param = mono_generic_container_get_param (container, num);
+                       g_assert (serial == 0);
+               } else {
+                       /* Anonymous */
+                       MonoGenericParam *par = (MonoGenericParam*)g_new0 (MonoGenericParamFull, 1);
+                       par->num = num;
+                       par->serial = serial;
+                       // FIXME:
+                       par->image = mono_defaults.corlib;
+                       t->data.generic_param = par;
+               }
 
                // FIXME: Maybe use types directly to avoid
                // the overhead of creating MonoClass-es
index 714abf94d6a39004ba6a29ce66245496836c897f..23b422919a9b92bf6706161e3f880ec782dd3c70 100644 (file)
@@ -435,6 +435,7 @@ emit_fde (MonoDwarfWriter *w, int fde_index, char *start_symbol, char *end_symbo
 #define ABBREV_PARAM_LOCLIST 15
 #define ABBREV_INHERITANCE 16
 #define ABBREV_STRUCT_TYPE_NOCHILDREN 17
+#define ABBREV_TRAMP_SUBPROGRAM 18
 
 static int compile_unit_attr [] = {
        DW_AT_producer     ,DW_FORM_string,
@@ -454,6 +455,13 @@ static int subprogram_attr [] = {
        DW_AT_frame_base   , DW_FORM_block1
 };
 
+static int tramp_subprogram_attr [] = {
+       DW_AT_name         , DW_FORM_string,
+       DW_AT_description  , DW_FORM_string,
+    DW_AT_low_pc       , DW_FORM_addr,
+    DW_AT_high_pc      , DW_FORM_addr,
+};
+
 static int param_attr [] = {
        DW_AT_name,     DW_FORM_string,
        DW_AT_type,     DW_FORM_ref4,
@@ -937,6 +945,8 @@ mono_dwarf_writer_emit_base_info (MonoDwarfWriter *w, GSList *base_unwind_progra
                                           reference_type_attr, G_N_ELEMENTS (reference_type_attr));
        emit_dwarf_abbrev (w, ABBREV_INHERITANCE, DW_TAG_inheritance, FALSE,
                                           inheritance_attr, G_N_ELEMENTS (inheritance_attr));
+       emit_dwarf_abbrev (w, ABBREV_TRAMP_SUBPROGRAM, DW_TAG_subprogram, FALSE,
+                                          tramp_subprogram_attr, G_N_ELEMENTS (tramp_subprogram_attr));
        emit_byte (w, 0);
 
        emit_section_change (w, ".debug_info", 0);
@@ -2067,14 +2077,10 @@ mono_dwarf_writer_emit_trampoline (MonoDwarfWriter *w, const char *tramp_name, c
        emit_section_change (w, ".debug_info", 0);
 
        /* Subprogram */
-       emit_uleb128 (w, ABBREV_SUBPROGRAM);
+       emit_uleb128 (w, ABBREV_TRAMP_SUBPROGRAM);
        emit_string (w, tramp_name);
        emit_pointer_value (w, code);
        emit_pointer_value (w, code + code_size);
-       /* frame_base */
-       emit_byte (w, 2);
-       emit_byte (w, DW_OP_breg6);
-       emit_byte (w, 16);
 
        /* Subprogram end */
        emit_uleb128 (w, 0x0);
index d0adec98f0d26e16cc06c667142727ea0cd86d46..dc2cbb3f4452f1af4522cfb5a4ba71e56cd38b05 100644 (file)
@@ -809,7 +809,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                /* Pop arguments off the stack */
                /* 
                 * FIXME: LLVM doesn't push these, we can't use ji->from_llvm as it describes
-                * the caller.
+                * the callee.
                 */
 #ifndef ENABLE_LLVM
                if (ji->has_arch_eh_info)
@@ -872,7 +872,7 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
                                MonoMethod *method = (*lmf)->method;
                                MonoJitArgumentInfo *arg_info = g_newa (MonoJitArgumentInfo, mono_method_signature (method)->param_count + 1);
 
-                               guint32 stack_to_pop = mono_arch_get_argument_info (mono_method_signature (method), mono_method_signature (method)->param_count, arg_info);
+                               guint32 stack_to_pop = mono_arch_get_argument_info (NULL, mono_method_signature (method), mono_method_signature (method)->param_count, arg_info);
                                new_ctx->esp += stack_to_pop;
                        }
 #endif
index b71b0185d9b1f68ecf5011c953c5aa25f432c158..2ec1c0ab3ff0f314df1f949757c04c5032bfde37 100644 (file)
@@ -2,6 +2,7 @@ using System;
 using System.Reflection;
 using System.Runtime.CompilerServices;
 using System.Collections;
+using System.Threading;
 
 /*
  * Regression tests for the GC support in the JIT
@@ -564,4 +565,22 @@ class Tests {
                liveness_13_inner (ref arr);
                return 0;
        }
+
+       static ThreadLocal<object> tls;
+
+       [MethodImplAttribute (MethodImplOptions.NoInlining)]
+       static void alloc_tls_obj () {
+               tls = new ThreadLocal<object> ();
+               tls.Value = new object ();
+       }
+
+       public static int test_0_thread_local () {
+               alloc_tls_obj ();
+               GC.Collect ();
+               Type t = tls.Value.GetType ();
+               if (t == typeof (object))
+                       return 0;
+               else
+                       return 1;
+       }
 }
\ No newline at end of file
index 9546356d1941c604de22ce5d1b2b97eb891434fd..c4d731d20969ffa66a82f67d41a4075a393caa80 100644 (file)
@@ -5647,14 +5647,8 @@ is_supported_tail_call (MonoCompile *cfg, MonoMethod *method, MonoMethod *cmetho
        /* Debugging support */
 #if 0
        if (supported_tail_call) {
-               static int count = 0;
-               count ++;
-               if (getenv ("COUNT")) {
-                       if (count == atoi (getenv ("COUNT")))
-                               printf ("LAST: %s\n", mono_method_full_name (cmethod, TRUE));
-                       if (count > atoi (getenv ("COUNT")))
-                               supported_tail_call = FALSE;
-               }
+               if (!mono_debug_count ())
+                       supported_tail_call = FALSE;
        }
 #endif
 
index 18b05e07dc67def86911f1288b0e4cc89a947119..908b877f68fc4a54e1c3a4aefc481b11ae669ab3 100644 (file)
@@ -1687,7 +1687,7 @@ emit_call(MonoCompile *cfg, unsigned int *code,
 /*------------------------------------------------------------------*/
 
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig,
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig,
                              int param_count,
                              MonoJitArgumentInfo *arg_info)
 {
index e36875a18379428c84de7e2180e3d940ba080ecd..82598ece91dcfece417ff607a4fc1a2b871341ac 100644 (file)
@@ -171,36 +171,11 @@ mono_arch_xregname (int reg)
                return "unknown";
 }
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (!getenv ("COUNT"))
-               return TRUE;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 static gboolean
 debug_omit_fp (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
@@ -1202,7 +1177,7 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign
  * Returns the size of the argument area on the stack.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k;
        CallInfo *cinfo = get_call_info (NULL, NULL, csig);
index 823761f9f33b7d7c30edb9ca10ddba2584830601..7221fc963135dd9383597d21e0b8aa32e89cdfe3 100644 (file)
@@ -410,7 +410,7 @@ emit_restore_lmf (MonoCompile *cfg, guint8 *code, gint32 lmf_offset)
  * Returns the size of the activation frame.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k, frame_size = 0;
        guint32 size, align, pad;
@@ -1259,36 +1259,11 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign
 
 #ifndef DISABLE_JIT
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (!getenv ("COUNT"))
-               return TRUE;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 static gboolean
 debug_omit_fp (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
index be4b65fcdfa47daa5bf47301cdc1f8602dd0fa84..22d36cf6546b9aa83df0da7b1c4b5af0a139fc2e 100644 (file)
@@ -410,6 +410,53 @@ typedef struct {
 } RegTrack;
 
 #ifndef DISABLE_LOGGING
+
+static const char*
+info_type_to_str (MonoRgctxInfoType type)
+{
+       switch (type) {
+       case MONO_RGCTX_INFO_STATIC_DATA: return "STATIC_DATA";
+       case MONO_RGCTX_INFO_KLASS: return "KLASS";
+       case MONO_RGCTX_INFO_VTABLE: return "VTABLE";
+       case MONO_RGCTX_INFO_TYPE: return "TYPE";
+       case MONO_RGCTX_INFO_REFLECTION_TYPE: return "REFLECTION_TYPE";
+       case MONO_RGCTX_INFO_METHOD: return "METHOD";
+       case MONO_RGCTX_INFO_GENERIC_METHOD_CODE: return "GENERIC_METHOD_CODE";
+       case MONO_RGCTX_INFO_CLASS_FIELD: return "CLASS_FIELD";
+       case MONO_RGCTX_INFO_METHOD_RGCTX: return "METHOD_RGCTX";
+       case MONO_RGCTX_INFO_METHOD_CONTEXT: return "METHOD_CONTEXT";
+       case MONO_RGCTX_INFO_REMOTING_INVOKE_WITH_CHECK: return "REMOTING_INVOKE_WITH_CHECK";
+       case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE: return "METHOD_DELEGATE_CODE";
+       case MONO_RGCTX_INFO_CAST_CACHE: return "CAST_CACHE";
+       default:
+               return "<UNKNOWN RGCTX INFO TYPE>";
+       }
+}
+
+static void
+print_ji (MonoJumpInfo *ji)
+{
+       switch (ji->type) {
+       case MONO_PATCH_INFO_RGCTX_FETCH: {
+               MonoJumpInfoRgctxEntry *entry = ji->data.rgctx_entry;
+
+               printf ("[RGCTX_FETCH ");
+               print_ji (entry->data);
+               printf (" - %s]", info_type_to_str (entry->info_type));
+               break;
+       }
+       case MONO_PATCH_INFO_METHODCONST: {
+               char *s = mono_method_full_name (ji->data.method, TRUE);
+               printf ("[METHODCONST - %s]", s);
+               g_free (s);
+               break;
+       }
+       default:
+               printf ("[%d]", ji->type);
+               break;
+       }
+}
+
 void
 mono_print_ins_index (int i, MonoInst *ins)
 {
@@ -532,6 +579,7 @@ mono_print_ins_index (int i, MonoInst *ins)
        case OP_IAND_IMM:
        case OP_IOR_IMM:
        case OP_IXOR_IMM:
+       case OP_SUB_IMM:
                printf (" [%d]", (int)ins->inst_imm);
                break;
        case OP_ADD_IMM:
@@ -581,6 +629,11 @@ mono_print_ins_index (int i, MonoInst *ins)
                        char *full_name = mono_method_full_name (call->method, TRUE);
                        printf (" [%s]", full_name);
                        g_free (full_name);
+               } else if (call->fptr_is_patch) {
+                       MonoJumpInfo *ji = (MonoJumpInfo*)call->fptr;
+
+                       printf (" ");
+                       print_ji (ji);
                } else if (call->fptr) {
                        MonoJitICallInfo *info = mono_find_jit_icall_by_addr (call->fptr);
                        if (info)
index e12f172d041405d26346cda974512ef8eb9fe9b3..079c88f71f68e3af3a4d3b7e4c37868c5844f0cb 100644 (file)
 
 //#define ALLOW_PARTIAL_SHARING TRUE
 #define ALLOW_PARTIAL_SHARING FALSE
+#if 0
+#define DEBUG(...) __VA_ARGS__
+#else
+#define DEBUG(...)
+#endif
 
 static void
 mono_class_unregister_image_generic_subclasses (MonoImage *image, gpointer user_data);
@@ -114,12 +120,12 @@ mono_class_check_context_used (MonoClass *class)
 /*
  * LOCKING: loader lock
  */
-static MonoRuntimeGenericContextOtherInfoTemplate*
-get_other_info_templates (MonoRuntimeGenericContextTemplate *template, int type_argc)
+static MonoRuntimeGenericContextInfoTemplate*
+get_info_templates (MonoRuntimeGenericContextTemplate *template, int type_argc)
 {
        g_assert (type_argc >= 0);
        if (type_argc == 0)
-               return template->other_infos;
+               return template->infos;
        return g_slist_nth_data (template->method_templates, type_argc - 1);
 }
 
@@ -127,12 +133,12 @@ get_other_info_templates (MonoRuntimeGenericContextTemplate *template, int type_
  * LOCKING: loader lock
  */
 static void
-set_other_info_templates (MonoImage *image, MonoRuntimeGenericContextTemplate *template, int type_argc,
-       MonoRuntimeGenericContextOtherInfoTemplate *oti)
+set_info_templates (MonoImage *image, MonoRuntimeGenericContextTemplate *template, int type_argc,
+       MonoRuntimeGenericContextInfoTemplate *oti)
 {
        g_assert (type_argc >= 0);
        if (type_argc == 0)
-               template->other_infos = oti;
+               template->infos = oti;
        else {
                int length = g_slist_length (template->method_templates);
                GSList *list;
@@ -161,15 +167,15 @@ template_get_max_argc (MonoRuntimeGenericContextTemplate *template)
 /*
  * LOCKING: loader lock
  */
-static MonoRuntimeGenericContextOtherInfoTemplate*
+static MonoRuntimeGenericContextInfoTemplate*
 rgctx_template_get_other_slot (MonoRuntimeGenericContextTemplate *template, int type_argc, int slot)
 {
        int i;
-       MonoRuntimeGenericContextOtherInfoTemplate *oti;
+       MonoRuntimeGenericContextInfoTemplate *oti;
 
        g_assert (slot >= 0);
 
-       for (oti = get_other_info_templates (template, type_argc), i = 0; i < slot; oti = oti->next, ++i) {
+       for (oti = get_info_templates (template, type_argc), i = 0; i < slot; oti = oti->next, ++i) {
                if (!oti)
                        return NULL;
        }
@@ -181,12 +187,12 @@ rgctx_template_get_other_slot (MonoRuntimeGenericContextTemplate *template, int
  * LOCKING: loader lock
  */
 static int
-rgctx_template_num_other_infos (MonoRuntimeGenericContextTemplate *template, int type_argc)
+rgctx_template_num_infos (MonoRuntimeGenericContextTemplate *template, int type_argc)
 {
-       MonoRuntimeGenericContextOtherInfoTemplate *oti;
+       MonoRuntimeGenericContextInfoTemplate *oti;
        int i;
 
-       for (i = 0, oti = get_other_info_templates (template, type_argc); oti; ++i, oti = oti->next)
+       for (i = 0, oti = get_info_templates (template, type_argc); oti; ++i, oti = oti->next)
                ;
 
        return i;
@@ -337,14 +343,14 @@ alloc_template (MonoClass *class)
        return mono_image_alloc0 (class->image, size);
 }
 
-static MonoRuntimeGenericContextOtherInfoTemplate*
+static MonoRuntimeGenericContextInfoTemplate*
 alloc_oti (MonoImage *image)
 {
        static gboolean inited = FALSE;
        static int num_allocted = 0;
        static int num_bytes = 0;
 
-       int size = sizeof (MonoRuntimeGenericContextOtherInfoTemplate);
+       int size = sizeof (MonoRuntimeGenericContextInfoTemplate);
 
        if (!inited) {
                mono_counters_register ("RGCTX oti num allocted", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_allocted);
@@ -366,7 +372,7 @@ alloc_oti (MonoImage *image)
  * Some info types expect that each insert results in a new slot been assigned.
  */
 static int
-other_info_has_identity (MonoRgctxInfoType info_type)
+info_has_identity (MonoRgctxInfoType info_type)
 {
        return info_type != MONO_RGCTX_INFO_CAST_CACHE;
 }
@@ -375,7 +381,7 @@ other_info_has_identity (MonoRgctxInfoType info_type)
  * LOCKING: loader lock
  */
 static void
-rgctx_template_set_other_slot (MonoImage *image, MonoRuntimeGenericContextTemplate *template, int type_argc,
+rgctx_template_set_slot (MonoImage *image, MonoRuntimeGenericContextTemplate *template, int type_argc,
        int slot, gpointer data, MonoRgctxInfoType info_type)
 {
        static gboolean inited = FALSE;
@@ -383,8 +389,8 @@ rgctx_template_set_other_slot (MonoImage *image, MonoRuntimeGenericContextTempla
        static int num_data = 0;
 
        int i;
-       MonoRuntimeGenericContextOtherInfoTemplate *list = get_other_info_templates (template, type_argc);
-       MonoRuntimeGenericContextOtherInfoTemplate **oti = &list;
+       MonoRuntimeGenericContextInfoTemplate *list = get_info_templates (template, type_argc);
+       MonoRuntimeGenericContextInfoTemplate **oti = &list;
 
        if (!inited) {
                mono_counters_register ("RGCTX oti num markers", MONO_COUNTER_GENERICS | MONO_COUNTER_INT, &num_markers);
@@ -408,7 +414,7 @@ rgctx_template_set_other_slot (MonoImage *image, MonoRuntimeGenericContextTempla
        (*oti)->data = data;
        (*oti)->info_type = info_type;
 
-       set_other_info_templates (image, template, type_argc, list);
+       set_info_templates (image, template, type_argc, list);
 
        if (data == MONO_RGCTX_SLOT_USED_MARKER)
                ++num_markers;
@@ -491,8 +497,10 @@ mono_class_get_method_generic (MonoClass *klass, MonoMethod *method)
 }
 
 static gpointer
-inflate_other_data (gpointer data, MonoRgctxInfoType info_type, MonoGenericContext *context, MonoClass *class, gboolean temporary)
+inflate_info (MonoRuntimeGenericContextInfoTemplate *oti, MonoGenericContext *context, MonoClass *class, gboolean temporary)
 {
+       gpointer data = oti->data;
+       MonoRgctxInfoType info_type = oti->info_type;
        MonoError error;
 
        g_assert (data);
@@ -565,13 +573,6 @@ inflate_other_data (gpointer data, MonoRgctxInfoType info_type, MonoGenericConte
        return NULL;
 }
 
-static gpointer
-inflate_other_info (MonoRuntimeGenericContextOtherInfoTemplate *oti,
-       MonoGenericContext *context, MonoClass *class, gboolean temporary)
-{
-       return inflate_other_data (oti->data, oti->info_type, context, class, temporary);
-}
-
 static void
 free_inflated_info (MonoRgctxInfoType info_type, gpointer info)
 {
@@ -592,7 +593,7 @@ free_inflated_info (MonoRgctxInfoType info_type, gpointer info)
        }
 }
 
-static MonoRuntimeGenericContextOtherInfoTemplate
+static MonoRuntimeGenericContextInfoTemplate
 class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean shared, gboolean *do_free);
  
 static MonoClass*
@@ -705,8 +706,8 @@ get_shared_class (MonoClass *class)
  * mono_class_get_runtime_generic_context_template:
  * @class: a class
  *
- * Looks up or constructs, if necessary, the runtime generic context
- * for class.
+ * Looks up or constructs, if necessary, the runtime generic context template for class.
+ * The template is the same for all instantiations of a class.
  */
 static MonoRuntimeGenericContextTemplate*
 mono_class_get_runtime_generic_context_template (MonoClass *class)
@@ -714,6 +715,8 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
        MonoRuntimeGenericContextTemplate *parent_template, *template;
        guint32 i;
 
+       class = get_shared_class (class);
+
        mono_loader_lock ();
        template = class_lookup_rgctx_template (class);
        mono_loader_unlock ();
@@ -728,51 +731,24 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
        mono_loader_lock ();
 
        if (class->parent) {
-               if (class->parent->generic_class) {
-                       guint32 num_entries;
-                       int max_argc, type_argc;
-
-                       parent_template = mono_class_get_runtime_generic_context_template
-                               (class->parent->generic_class->container_class);
-
-                       max_argc = template_get_max_argc (parent_template);
+               guint32 num_entries;
+               int max_argc, type_argc;
 
-                       for (type_argc = 0; type_argc <= max_argc; ++type_argc) {
-                               num_entries = rgctx_template_num_other_infos (parent_template, type_argc);
+               parent_template = mono_class_get_runtime_generic_context_template (class->parent);
+               max_argc = template_get_max_argc (parent_template);
 
-                               /* FIXME: quadratic! */
-                               for (i = 0; i < num_entries; ++i) {
-                                       MonoRuntimeGenericContextOtherInfoTemplate oti;
+               for (type_argc = 0; type_argc <= max_argc; ++type_argc) {
+                       num_entries = rgctx_template_num_infos (parent_template, type_argc);
 
-                                       oti = class_get_rgctx_template_oti (class->parent, type_argc, i, FALSE, FALSE, NULL);
-                                       if (oti.data && oti.data != MONO_RGCTX_SLOT_USED_MARKER) {
-                                               rgctx_template_set_other_slot (class->image, template, type_argc, i,
-                                                       oti.data, oti.info_type);
-                                       }
-                               }
-                       }
-               } else {
-                       guint32 num_entries;
-                       int max_argc, type_argc;
-
-                       parent_template = mono_class_get_runtime_generic_context_template (class->parent);
+                       /* FIXME: quadratic! */
+                       for (i = 0; i < num_entries; ++i) {
+                               MonoRuntimeGenericContextInfoTemplate oti;
 
-                       max_argc = template_get_max_argc (parent_template);
-
-                       for (type_argc = 0; type_argc <= max_argc; ++type_argc) {
-                               num_entries = rgctx_template_num_other_infos (parent_template, type_argc);
-
-                               /* FIXME: quadratic! */
-                               for (i = 0; i < num_entries; ++i) {
-                                       MonoRuntimeGenericContextOtherInfoTemplate oti;
-
-                                       oti = class_get_rgctx_template_oti (class->parent, type_argc, i, FALSE, FALSE, NULL);
-                                       if (oti.data && oti.data != MONO_RGCTX_SLOT_USED_MARKER) {
-                                               rgctx_template_set_other_slot (class->image, template, type_argc, i,
-                                                       oti.data, oti.info_type);
-                                       }
+                               oti = class_get_rgctx_template_oti (class->parent, type_argc, i, FALSE, FALSE, NULL);
+                               if (oti.data && oti.data != MONO_RGCTX_SLOT_USED_MARKER) {
+                                       rgctx_template_set_slot (class->image, template, type_argc, i,
+                                                                                        oti.data, oti.info_type);
                                }
-
                        }
                }
        }
@@ -793,6 +769,9 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
 }
 
 /*
+ * class_get_rgctx_template_oti:
+ *
+ *   Return the info template of CLASS numbered TYPE_ARGC/SLOT.
  * temporary signifies whether the inflated info (oti.data) will be
  * used temporarily, in which case it might be heap-allocated, or
  * permanently, in which case it will be mempool-allocated.  If
@@ -801,20 +780,22 @@ mono_class_get_runtime_generic_context_template (MonoClass *class)
  *
  * LOCKING: loader lock
  */
-static MonoRuntimeGenericContextOtherInfoTemplate
+static MonoRuntimeGenericContextInfoTemplate
 class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gboolean temporary, gboolean shared, gboolean *do_free)
 {
        g_assert ((temporary && do_free) || (!temporary && !do_free));
 
+       DEBUG (printf ("get slot: %s %d\n", mono_type_full_name (&class->byval_arg), slot));
+
        if (class->generic_class && !shared) {
-               MonoRuntimeGenericContextOtherInfoTemplate oti;
+               MonoRuntimeGenericContextInfoTemplate oti;
                gboolean tmp_do_free;
 
                oti = class_get_rgctx_template_oti (class->generic_class->container_class,
                                                                                        type_argc, slot, TRUE, FALSE, &tmp_do_free);
                if (oti.data) {
                        gpointer info = oti.data;
-                       oti.data = inflate_other_info (&oti, &class->generic_class->context, class, temporary);
+                       oti.data = inflate_info (&oti, &class->generic_class->context, class, temporary);
                        if (tmp_do_free)
                                free_inflated_info (oti.info_type, info);
                }
@@ -824,7 +805,7 @@ class_get_rgctx_template_oti (MonoClass *class, int type_argc, guint32 slot, gbo
                return oti;
        } else {
                MonoRuntimeGenericContextTemplate *template;
-               MonoRuntimeGenericContextOtherInfoTemplate *oti;
+               MonoRuntimeGenericContextInfoTemplate *oti;
 
                template = mono_class_get_runtime_generic_context_template (class);
                oti = rgctx_template_get_other_slot (template, type_argc, slot);
@@ -869,7 +850,7 @@ class_type_info (MonoDomain *domain, MonoClass *class, MonoRgctxInfoType info_ty
 }
 
 static gpointer
-instantiate_other_info (MonoDomain *domain, MonoRuntimeGenericContextOtherInfoTemplate *oti,
+instantiate_info (MonoDomain *domain, MonoRuntimeGenericContextInfoTemplate *oti,
        MonoGenericContext *context, MonoClass *class)
 {
        gpointer data;
@@ -889,7 +870,7 @@ instantiate_other_info (MonoDomain *domain, MonoRuntimeGenericContextOtherInfoTe
                temporary = FALSE;
        }
 
-       data = inflate_other_info (oti, context, class, temporary);
+       data = inflate_info (oti, context, class, temporary);
 
        switch (oti->info_type) {
        case MONO_RGCTX_INFO_STATIC_DATA:
@@ -963,7 +944,7 @@ fill_in_rgctx_template_slot (MonoClass *class, int type_argc, int index, gpointe
        MonoRuntimeGenericContextTemplate *template = mono_class_get_runtime_generic_context_template (class);
        MonoClass *subclass;
 
-       rgctx_template_set_other_slot (class->image, template, type_argc, index, data, info_type);
+       rgctx_template_set_slot (class->image, template, type_argc, index, data, info_type);
 
        /* Recurse for all subclasses */
        if (generic_subclass_hash)
@@ -972,7 +953,7 @@ fill_in_rgctx_template_slot (MonoClass *class, int type_argc, int index, gpointe
                subclass = NULL;
 
        while (subclass) {
-               MonoRuntimeGenericContextOtherInfoTemplate subclass_oti;
+               MonoRuntimeGenericContextInfoTemplate subclass_oti;
                MonoRuntimeGenericContextTemplate *subclass_template = class_lookup_rgctx_template (subclass);
 
                g_assert (subclass_template);
@@ -986,30 +967,63 @@ fill_in_rgctx_template_slot (MonoClass *class, int type_argc, int index, gpointe
        }
 }
 
+G_GNUC_UNUSED static const char*
+info_type_to_str (MonoRgctxInfoType type)
+{
+       switch (type) {
+       case MONO_RGCTX_INFO_STATIC_DATA: return "STATIC_DATA";
+       case MONO_RGCTX_INFO_KLASS: return "KLASS";
+       case MONO_RGCTX_INFO_VTABLE: return "VTABLE";
+       case MONO_RGCTX_INFO_TYPE: return "TYPE";
+       case MONO_RGCTX_INFO_REFLECTION_TYPE: return "REFLECTION_TYPE";
+       case MONO_RGCTX_INFO_METHOD: return "METHOD";
+       case MONO_RGCTX_INFO_GENERIC_METHOD_CODE: return "GENERIC_METHOD_CODE";
+       case MONO_RGCTX_INFO_CLASS_FIELD: return "CLASS_FIELD";
+       case MONO_RGCTX_INFO_METHOD_RGCTX: return "METHOD_RGCTX";
+       case MONO_RGCTX_INFO_METHOD_CONTEXT: return "METHOD_CONTEXT";
+       case MONO_RGCTX_INFO_REMOTING_INVOKE_WITH_CHECK: return "REMOTING_INVOKE_WITH_CHECK";
+       case MONO_RGCTX_INFO_METHOD_DELEGATE_CODE: return "METHOD_DELEGATE_CODE";
+       case MONO_RGCTX_INFO_CAST_CACHE: return "CAST_CACHE";
+       default:
+               return "<>";
+       }
+}
+
+G_GNUC_UNUSED static char*
+rgctx_info_to_str (MonoRgctxInfoType info_type, gpointer data)
+{
+       switch (info_type) {
+       case MONO_RGCTX_INFO_VTABLE:
+               return mono_type_full_name ((MonoType*)data);
+       default:
+               return g_strdup_printf ("<%p>", data);
+       }
+}
+
 /*
  * LOCKING: loader lock
  */
 static int
-register_other_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxInfoType info_type)
+register_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxInfoType info_type)
 {
        int i;
        MonoRuntimeGenericContextTemplate *template = mono_class_get_runtime_generic_context_template (class);
        MonoClass *parent;
-       MonoRuntimeGenericContextOtherInfoTemplate *oti;
+       MonoRuntimeGenericContextInfoTemplate *oti;
 
-       for (i = 0, oti = get_other_info_templates (template, type_argc); oti; ++i, oti = oti->next) {
+       for (i = 0, oti = get_info_templates (template, type_argc); oti; ++i, oti = oti->next) {
                if (!oti->data)
                        break;
        }
 
-       //g_print ("template %s . other_infos [%d] = %s\n", mono_type_get_full_name (class), i, mono_type_get_full_name (other_class));
+       DEBUG (printf ("set slot %s, infos [%d] = %s, %s\n", mono_type_get_full_name (class), i, info_type_to_str (info_type), rgctx_info_to_str (info_type, data)));
 
        /* Mark the slot as used in all parent classes (until we find
           a parent class which already has it marked used). */
        parent = class->parent;
        while (parent != NULL) {
                MonoRuntimeGenericContextTemplate *parent_template;
-               MonoRuntimeGenericContextOtherInfoTemplate *oti;
+               MonoRuntimeGenericContextInfoTemplate *oti;
 
                if (parent->generic_class)
                        parent = parent->generic_class->container_class;
@@ -1020,8 +1034,8 @@ register_other_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxIn
                if (oti && oti->data)
                        break;
 
-               rgctx_template_set_other_slot (parent->image, parent_template, type_argc, i,
-                               MONO_RGCTX_SLOT_USED_MARKER, 0);
+               rgctx_template_set_slot (parent->image, parent_template, type_argc, i,
+                                                                MONO_RGCTX_SLOT_USED_MARKER, 0);
 
                parent = parent->parent;
        }
@@ -1034,7 +1048,7 @@ register_other_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxIn
 }
 
 static gboolean
-other_info_equal (gpointer data1, gpointer data2, MonoRgctxInfoType info_type)
+info_equal (gpointer data1, gpointer data2, MonoRgctxInfoType info_type)
 {
        switch (info_type) {
        case MONO_RGCTX_INFO_STATIC_DATA:
@@ -1060,7 +1074,7 @@ other_info_equal (gpointer data1, gpointer data2, MonoRgctxInfoType info_type)
 }
 
 static int
-lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxInfoType info_type,
+lookup_or_register_info (MonoClass *class, int type_argc, gpointer data, MonoRgctxInfoType info_type,
        MonoGenericContext *generic_context)
 {
        static gboolean inited = FALSE;
@@ -1068,13 +1082,15 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, M
 
        MonoRuntimeGenericContextTemplate *rgctx_template =
                mono_class_get_runtime_generic_context_template (class);
-       MonoRuntimeGenericContextOtherInfoTemplate *oti_list, *oti;
+       MonoRuntimeGenericContextInfoTemplate *oti_list, *oti;
        int i;
 
+       class = get_shared_class (class);
+
        mono_loader_lock ();
 
-       if (other_info_has_identity (info_type)) {
-               oti_list = get_other_info_templates (rgctx_template, type_argc);
+       if (info_has_identity (info_type)) {
+               oti_list = get_info_templates (rgctx_template, type_argc);
 
                for (oti = oti_list, i = 0; oti; oti = oti->next, ++i) {
                        gpointer inflated_data;
@@ -1082,9 +1098,9 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, M
                        if (oti->info_type != info_type || !oti->data)
                                continue;
 
-                       inflated_data = inflate_other_info (oti, generic_context, class, TRUE);
+                       inflated_data = inflate_info (oti, generic_context, class, TRUE);
 
-                       if (other_info_equal (data, inflated_data, info_type)) {
+                       if (info_equal (data, inflated_data, info_type)) {
                                free_inflated_info (info_type, inflated_data);
                                mono_loader_unlock ();
                                return i;
@@ -1094,7 +1110,7 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, M
        }
 
        /* We haven't found the info */
-       i = register_other_info (class, type_argc, data, info_type);
+       i = register_info (class, type_argc, data, info_type);
 
        mono_loader_unlock ();
 
@@ -1109,7 +1125,7 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, M
 }
 
 /*
- * mono_method_lookup_or_register_other_info:
+ * mono_method_lookup_or_register_info:
  * @method: a method
  * @in_mrgctx: whether to put the data into the MRGCTX
  * @data: the info data
@@ -1121,7 +1137,7 @@ lookup_or_register_other_info (MonoClass *class, int type_argc, gpointer data, M
  * encoded slot number.
  */
 guint32
-mono_method_lookup_or_register_other_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
+mono_method_lookup_or_register_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
        MonoRgctxInfoType info_type, MonoGenericContext *generic_context)
 {
        MonoClass *class = method->klass;
@@ -1137,7 +1153,7 @@ mono_method_lookup_or_register_other_info (MonoMethod *method, gboolean in_mrgct
                type_argc = 0;
        }
 
-       index = lookup_or_register_other_info (class, type_argc, data, info_type, generic_context);
+       index = lookup_or_register_info (class, type_argc, data, info_type, generic_context);
 
        //g_print ("rgctx item at index %d argc %d\n", index, type_argc);
 
@@ -1210,7 +1226,7 @@ fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContex
        MonoDomain *domain = class_vtable->domain;
        MonoClass *class = class_vtable->klass;
        MonoGenericContext *class_context = class->generic_class ? &class->generic_class->context : NULL;
-       MonoRuntimeGenericContextOtherInfoTemplate oti;
+       MonoRuntimeGenericContextInfoTemplate oti;
        MonoGenericContext context = { class_context ? class_context->class_inst : NULL, method_inst };
        int rgctx_index;
        gboolean do_free;
@@ -1257,7 +1273,7 @@ fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContex
        oti = class_get_rgctx_template_oti (get_shared_class (class),
                                                                                method_inst ? method_inst->type_argc : 0, slot, TRUE, TRUE, &do_free);
        /* This might take the loader lock */
-       info = instantiate_other_info (domain, &oti, &context, class);
+       info = instantiate_info (domain, &oti, &context, class);
 
        /*
        if (method_inst)
@@ -1287,7 +1303,7 @@ fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContex
  * @class_vtable: a vtable
  * @slot: a slot index to be instantiated
  *
- * Instantiates a slot in the RGCTX.
+ * Instantiates a slot in the RGCTX, returning its value.
  */
 gpointer
 mono_class_fill_runtime_generic_context (MonoVTable *class_vtable, guint32 slot)
@@ -1317,6 +1333,8 @@ mono_class_fill_runtime_generic_context (MonoVTable *class_vtable, guint32 slot)
 
        info = fill_runtime_generic_context (class_vtable, rgctx, slot, 0);
 
+       DEBUG (printf ("get rgctx slot: %s %d -> %p\n", mono_type_full_name (&class_vtable->klass->byval_arg), slot, info));
+
        return info;
 }
 
index 3f72c551723e9ab3dfcd7fb2f7c9e2d65b7ee3e6..c410f07dc0c58f4c73de3017d2fa9476a37c4fd9 100644 (file)
@@ -2904,7 +2904,7 @@ mono_arch_get_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethod
  * Returns the size of the activation frame.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k, align;
        CallInfo *cinfo;
index 87c474f2e474275b7f36e8f2e7be14e6833da3ed..c45305e2668a99e960a45797daec97f6011df4a3 100644 (file)
@@ -109,33 +109,11 @@ mono_arch_fregname (int reg)
                return "unknown";
 }
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 static gboolean
 debug_ins_sched (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
@@ -145,7 +123,7 @@ static gboolean
 debug_omit_fp (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
@@ -575,7 +553,7 @@ get_call_info (MonoCompile *cfg, MonoMemPool *mp, MonoMethodSignature *sig, gboo
  * Returns the size of the argument area on the stack.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k;
        CallInfo *cinfo = get_call_info (NULL, NULL, csig, FALSE);
old mode 100755 (executable)
new mode 100644 (file)
index d9a05f2620bab8a7c9b33c9933144f17b252351c..12d17c399a1fd074d5aa99079e52cc79c50c349f 100644 (file)
@@ -495,7 +495,7 @@ emit_memcpy (guint8 *code, int size, int dreg, int doffset, int sreg, int soffse
  * Returns the size of the activation frame.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k, frame_size = 0;
        guint32 size, align, pad;
@@ -1320,36 +1320,11 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign
        return cinfo;
 }
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (!getenv ("COUNT"))
-               return TRUE;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 static gboolean
 debug_omit_fp (void)
 {
 #if 0
-       return debug_count ();
+       return mono_debug_count ();
 #else
        return TRUE;
 #endif
index 53b860e96a03b16d7a5118d6ea9f35dd98d40e56..e779862c46e361dd4b5788d7fd80191b4ff64ef0 100644 (file)
@@ -274,7 +274,7 @@ emit_memcpy (guint8 *code, int size, int dreg, int doffset, int sreg, int soffse
  * Returns the size of the activation frame.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
 #ifdef __mono_ppc64__
        NOT_IMPLEMENTED;
@@ -1277,31 +1277,6 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *sig)
        return cinfo;
 }
 
-G_GNUC_UNUSED static void
-break_count (void)
-{
-}
-
-G_GNUC_UNUSED static gboolean
-debug_count (void)
-{
-       static int count = 0;
-       count ++;
-
-       if (!getenv ("COUNT"))
-               return TRUE;
-
-       if (count == atoi (getenv ("COUNT"))) {
-               break_count ();
-       }
-
-       if (count > atoi (getenv ("COUNT"))) {
-               return FALSE;
-       }
-
-       return TRUE;
-}
-
 gboolean
 mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig)
 {
@@ -1322,7 +1297,7 @@ mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignatu
        }
 
        /*
-       if (!debug_count ())
+       if (!mono_debug_count ())
                res = FALSE;
        */
 
index c5fb2015b432accf6c88987f7def2f0a33d1f0bd..6f2f76a4780a814465a2bbd964ba501c176a8d4f 100644 (file)
@@ -421,7 +421,7 @@ mono_arch_fregname (int reg) {
 /*------------------------------------------------------------------*/
 
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, 
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, 
                             int param_count, 
                             MonoJitArgumentInfo *arg_info)
 {
index e309a2c7ae0c9f441731cb7a7db53d54414f0655..f37b087e49d4f7d356256acf358ea642f768c88e 100644 (file)
@@ -485,7 +485,7 @@ mono_arch_fregname (int reg) {
 /*------------------------------------------------------------------*/
 
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, 
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, 
                             int param_count, 
                             MonoJitArgumentInfo *arg_info)
 {
index d8390f57243a0324b77590db2b26a9216dfaadf2..12150ca1eb6f75ed24be0269957c7b8f4a37cb58 100644 (file)
@@ -4409,7 +4409,7 @@ mono_arch_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMetho
  * Returns the size of the activation frame.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int k, align;
        CallInfo *cinfo;
index 936d1e55a45ebd901f8c0af3675a6c8ece519d22..3901a59449d68d03a6b50a592f3a57a02f2f151c 100644 (file)
@@ -582,7 +582,7 @@ get_call_info (MonoGenericSharingContext *gsctx, MonoMemPool *mp, MonoMethodSign
  * FIXME: The metadata calls might not be signal safe.
  */
 int
-mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
+mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info)
 {
        int len, k, args_size = 0;
        int size, pad;
@@ -595,7 +595,7 @@ mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJit
        cinfo = (CallInfo*)g_newa (guint8*, len);
        memset (cinfo, 0, len);
 
-       cinfo = get_call_info_internal (NULL, cinfo, csig);
+       cinfo = get_call_info_internal (gsctx, cinfo, csig);
 
        arg_info [0].offset = offset;
 
@@ -5441,7 +5441,7 @@ mono_arch_emit_epilog (MonoCompile *cfg)
        if (CALLCONV_IS_STDCALL (sig)) {
                MonoJitArgumentInfo *arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1));
 
-               stack_to_pop = mono_arch_get_argument_info (sig, sig->param_count, arg_info);
+               stack_to_pop = mono_arch_get_argument_info (cfg->generic_sharing_context, sig, sig->param_count, arg_info);
        } else if (MONO_TYPE_ISSTRUCT (mono_method_signature (cfg->method)->ret) && (cinfo->ret.storage == ArgOnStack))
                stack_to_pop = 4;
        else
index 81794f7db748d0d9fcee93c4ee2e634cecaad575..6c7744b94cf5fe6659e2734bc45d116dcb777196 100644 (file)
@@ -601,6 +601,35 @@ mono_tramp_info_free (MonoTrampInfo *info)
        g_free (info);
 }
 
+G_GNUC_UNUSED static void
+break_count (void)
+{
+}
+
+/*
+ * Runtime debugging tool, use if (debug_count ()) <x> else <y> to do <x> the first COUNT times, then do <y> afterwards.
+ * Set a breakpoint in break_count () to break the last time <x> is done.
+ */
+G_GNUC_UNUSED gboolean
+mono_debug_count (void)
+{
+       static int count = 0;
+       count ++;
+
+       if (!getenv ("COUNT"))
+               return TRUE;
+
+       if (count == atoi (getenv ("COUNT"))) {
+               break_count ();
+       }
+
+       if (count > atoi (getenv ("COUNT"))) {
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
 #define MONO_INIT_VARINFO(vi,id) do { \
        (vi)->range.first_use.pos.bid = 0xffff; \
        (vi)->reg = -1; \
@@ -3221,14 +3250,14 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
 
                switch (entry->data->type) {
                case MONO_PATCH_INFO_CLASS:
-                       slot = mono_method_lookup_or_register_other_info (entry->method, entry->in_mrgctx, &entry->data->data.klass->byval_arg, entry->info_type, mono_method_get_context (entry->method));
+                       slot = mono_method_lookup_or_register_info (entry->method, entry->in_mrgctx, &entry->data->data.klass->byval_arg, entry->info_type, mono_method_get_context (entry->method));
                        break;
                case MONO_PATCH_INFO_METHOD:
                case MONO_PATCH_INFO_METHODCONST:
-                       slot = mono_method_lookup_or_register_other_info (entry->method, entry->in_mrgctx, entry->data->data.method, entry->info_type, mono_method_get_context (entry->method));
+                       slot = mono_method_lookup_or_register_info (entry->method, entry->in_mrgctx, entry->data->data.method, entry->info_type, mono_method_get_context (entry->method));
                        break;
                case MONO_PATCH_INFO_FIELD:
-                       slot = mono_method_lookup_or_register_other_info (entry->method, entry->in_mrgctx, entry->data->data.field, entry->info_type, mono_method_get_context (entry->method));
+                       slot = mono_method_lookup_or_register_info (entry->method, entry->in_mrgctx, entry->data->data.field, entry->info_type, mono_method_get_context (entry->method));
                        break;
                default:
                        g_assert_not_reached ();
@@ -3903,7 +3932,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                 * mono_arch_get_argument_info () is not signal safe.
                 */
                arg_info = g_newa (MonoJitArgumentInfo, sig->param_count + 1);
-               stack_size = mono_arch_get_argument_info (sig, sig->param_count, arg_info);
+               stack_size = mono_arch_get_argument_info (cfg->generic_sharing_context, sig, sig->param_count, arg_info);
 
                if (stack_size)
                        arch_eh_info_size = sizeof (MonoArchEHJitInfo);
index d6ac333cefe51e775c0b3576d8785302dcc2fe61..d1d2255c442bd12c42d418c10f5932c6662bfeff 100644 (file)
 #endif
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 83
+#define MONO_AOT_FILE_VERSION 84
 
 //TODO: This is x86/amd64 specific.
 #define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
@@ -1031,15 +1031,15 @@ typedef enum {
        MONO_RGCTX_INFO_CAST_CACHE
 } MonoRgctxInfoType;
 
-typedef struct _MonoRuntimeGenericContextOtherInfoTemplate {
+typedef struct _MonoRuntimeGenericContextInfoTemplate {
        MonoRgctxInfoType info_type;
        gpointer data;
-       struct _MonoRuntimeGenericContextOtherInfoTemplate *next;
-} MonoRuntimeGenericContextOtherInfoTemplate;
+       struct _MonoRuntimeGenericContextInfoTemplate *next;
+} MonoRuntimeGenericContextInfoTemplate;
 
 typedef struct {
        MonoClass *next_subclass;
-       MonoRuntimeGenericContextOtherInfoTemplate *other_infos;
+       MonoRuntimeGenericContextInfoTemplate *infos;
        GSList *method_templates;
 } MonoRuntimeGenericContextTemplate;
 
@@ -1805,6 +1805,7 @@ void      mono_print_bb                     (MonoBasicBlock *bb, const char *msg
 void      mono_print_code                   (MonoCompile *cfg, const char *msg) MONO_INTERNAL;
 void      mono_print_method_from_ip         (void *ip);
 char     *mono_pmip                         (void *ip);
+gboolean  mono_debug_count                  (void) MONO_INTERNAL;
 const char* mono_inst_name                  (int op);
 void      mono_inst_set_src_registers       (MonoInst *ins, int *regs) MONO_INTERNAL;
 int       mono_op_to_op_imm                 (int opcode) MONO_INTERNAL;
@@ -2085,7 +2086,7 @@ void      mono_arch_output_basic_block          (MonoCompile *cfg, MonoBasicBloc
 void      mono_arch_free_jit_tls_data           (MonoJitTlsData *tls) MONO_INTERNAL;
 void      mono_arch_fill_argument_info          (MonoCompile *cfg) MONO_INTERNAL;
 void      mono_arch_allocate_vars               (MonoCompile *m) MONO_INTERNAL;
-int       mono_arch_get_argument_info           (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info) MONO_INTERNAL;
+int       mono_arch_get_argument_info           (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info) MONO_INTERNAL;
 gboolean  mono_arch_print_tree                 (MonoInst *tree, int arity) MONO_INTERNAL;
 void      mono_arch_emit_call                   (MonoCompile *cfg, MonoCallInst *call) MONO_INTERNAL;
 void      mono_arch_emit_outarg_vt              (MonoCompile *cfg, MonoInst *ins, MonoInst *src) MONO_INTERNAL;
@@ -2325,7 +2326,7 @@ int
 mono_class_rgctx_get_array_size (int n, gboolean mrgctx) MONO_INTERNAL;
 
 guint32
-mono_method_lookup_or_register_other_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
+mono_method_lookup_or_register_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
        MonoRgctxInfoType info_type, MonoGenericContext *generic_context) MONO_INTERNAL;
 
 MonoGenericContext
index a75478ef80c38f154574109d63cc735d18f33d9a..43516d87a7a0ca7a0c9270c1f662b01b9b97c9ea 100644 (file)
@@ -392,7 +392,7 @@ mono_trace_enter_method (MonoMethod *method, char *ebp)
 
        arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1));
 
-       mono_arch_get_argument_info (sig, sig->param_count, arg_info);
+       mono_arch_get_argument_info (NULL, sig, sig->param_count, arg_info);
 
        if (MONO_TYPE_ISSTRUCT (mono_method_signature (method)->ret)) {
                g_assert (!mono_method_signature (method)->ret->byref);
index b69fa2ac4370e7ae778ecd788d8def198bcb85a3..f1adabee3d0f7fd56c17c65463710f2e75411c50 100644 (file)
@@ -490,6 +490,7 @@ mono_shared_area_instances_slow (void **array, int count, gboolean cleanup)
        return j;
 }
 
+#if (defined (__MACH__) && defined (TARGET_ARM))
 static int
 mono_shared_area_instances_helper (void **array, int count, gboolean cleanup)
 {
@@ -522,6 +523,9 @@ mono_shared_area_instances_helper (void **array, int count, gboolean cleanup)
        g_dir_close (dir);
        return i;
 }
+#else
+#define mono_shared_area_instances_helper mono_shared_area_instances_slow
+#endif
 
 void*
 mono_shared_area (void)