Merge pull request #3036 from tritao/windowsbase_zip_datetime
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 25 May 2016 17:28:55 +0000 (19:28 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 25 May 2016 17:28:55 +0000 (19:28 +0200)
[WindowsBase] Fixed System.IO.Packaging creating Zip archive with wrong date time entries

82 files changed:
build-libs.bat [new file with mode: 0644]
build-libs.sh [new file with mode: 0755]
configure.ac
eglib/configure.ac
eglib/src/eglib-config.h.in
eglib/src/eglib-config.hw
eglib/src/glib.h
mcs/class/Commons.Xml.Relaxng/Commons.Xml.Relaxng-net_4_x.csproj
mcs/class/Mono.Data.Sqlite/Mono.Data.Sqlite-net_4_x.csproj
mcs/class/Novell.Directory.Ldap/Novell.Directory.Ldap-net_4_x.csproj
mcs/class/System.ComponentModel.Composition.4.5/System.ComponentModel.Composition-net_4_x.csproj
mcs/class/System.Data.Services.Client/System.Data.Services.Client-net_4_x.csproj
mcs/class/System.Json.Microsoft/System.Json.Microsoft-net_4_x.csproj
mcs/class/System.Net.Http.Formatting/System.Net.Http.Formatting-net_4_x.csproj
mcs/class/System.Net.Http/CFNetworkHandler.cs
mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs
mcs/class/System.Net.Http/Test/System.Net.Http/HttpClientTest.cs
mcs/class/System.Reactive.Core/System.Reactive.Core-net_4_x.csproj
mcs/class/System.Reactive.Linq/System.Reactive.Linq-net_4_x.csproj
mcs/class/System.Reactive.PlatformServices/System.Reactive.PlatformServices-net_4_x.csproj
mcs/class/System.Reactive.Providers/System.Reactive.Providers-net_4_x.csproj
mcs/class/System.Reactive.Windows.Threading/System.Reactive.Windows.Threading-net_4_x.csproj
mcs/class/System.Web.Http/System.Web.Http-net_4_x.csproj
mcs/class/System.Web.Mvc3/System.Web.Mvc3-net_4_x.csproj
mcs/class/System.Web.Razor/System.Web.Razor-net_4_x.csproj
mcs/class/System.Web.WebPages.Deployment/System.Web.WebPages.Deployment-net_4_x.csproj
mcs/class/System.Web.WebPages.Razor/System.Web.WebPages.Razor-net_4_x.csproj
mcs/class/System.Web.WebPages/System.Web.WebPages-net_4_x.csproj
mcs/class/System.Web/System.Web-net_4_x.csproj
mcs/class/System.Web/System.Web-plainweb-net_4_x.csproj
mcs/class/System.Windows.Forms/System.Windows.Forms-net_4_x.csproj
mcs/class/WindowsBase/System.IO.Packaging/Package.cs
mcs/class/WindowsBase/System.IO.Packaging/ZipPackage.cs
mcs/class/WindowsBase/Test/System.IO.Packaging/PackageRelationshipTests.cs
mcs/nunit24/ClientUtilities/util/nunit.util-net_4_x.csproj
mono/metadata/appdomain.c
mono/metadata/class-internals.h
mono/metadata/cominterop.c
mono/metadata/debug-helpers.c
mono/metadata/gc-internals.h
mono/metadata/gc.c
mono/metadata/icall.c
mono/metadata/marshal.c
mono/metadata/monitor.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/metadata/remoting.c
mono/metadata/threadpool-ms-io.c
mono/metadata/threadpool-ms.c
mono/metadata/threadpool-ms.h
mono/metadata/threads-types.h
mono/metadata/threads.c
mono/metadata/threads.h
mono/mini/Makefile.am.in
mono/mini/aot-runtime.c
mono/mini/cfgdump.c
mono/mini/debugger-agent.c
mono/mini/driver.c
mono/mini/jit-icalls.c
mono/mini/jit.h
mono/mini/method-to-ir.c
mono/mini/mini-amd64-gsharedvt.c
mono/mini/mini-amd64.h
mono/mini/mini-arm.c
mono/mini/mini-generic-sharing.c
mono/mini/mini-ia64.c
mono/mini/mini-llvm.c
mono/mini/mini-mips.c
mono/mini/mini-ppc.c
mono/mini/mini-runtime.c
mono/mini/mini-s390x.c
mono/mini/mini-sparc.c
mono/mini/mini-trampolines.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/tramp-amd64.c
mono/profiler/mono-profiler-iomap.c
mono/tests/libtest.c
mono/utils/mono-io-portability.c
msvc/scripts/Commons.Xml.Relaxng.pre [new file with mode: 0644]
msvc/scripts/genproj.cs
msvc/scripts/prepare.cs

diff --git a/build-libs.bat b/build-libs.bat
new file mode 100644 (file)
index 0000000..df0d978
--- /dev/null
@@ -0,0 +1,4 @@
+@echo off
+cd mcs\jay
+vcbuild jay.vcxproj
+msbuild net_4_x.sln
diff --git a/build-libs.sh b/build-libs.sh
new file mode 100755 (executable)
index 0000000..17b2e16
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+(cd mcs/jay; make)
+msbuild net_4_x.sln
index 59107bef5755e06e5703d90ef0992c1b5ed6011f..cff61275963b3e8a01df250650ea8cd0d47666b5 100644 (file)
@@ -2906,6 +2906,7 @@ case "$host" in
                TARGET=ARM64
                arch_target=arm64
                boehm_supported=false
+               AOT_SUPPORTED="yes"
                ;;
        s390x-*-linux*)
                TARGET=S390X;
index 21cf8c49276dce652845a68bea80371fb2c24779..7622701ef455e81d8ce977db10503d84da267ba9 100644 (file)
@@ -193,10 +193,6 @@ if test $ac_cv_sizeof_void_p = $ac_cv_sizeof_int; then
    GUINT_TO_POINTER="((gpointer) (v))"
    GSIZE="int"
    GSIZE_FORMAT='"u"'
-   G_GUINT64_FORMAT='"llu"'
-   G_GINT64_FORMAT='"lld"'
-   G_GUINT32_FORMAT='"lu"'
-   G_GINT32_FORMAT='"ld"'
 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
    GPOINTER_TO_INT="((gint)(long) (ptr))"
    GPOINTER_TO_UINT="((guint)(long) (ptr))"
@@ -204,10 +200,6 @@ elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long; then
    GUINT_TO_POINTER="((gpointer)(gulong) (v))"
    GSIZE="long"
    GSIZE_FORMAT='"lu"'
-   G_GUINT64_FORMAT='"lu"'
-   G_GINT64_FORMAT='"ld"'
-   G_GUINT32_FORMAT='"u"'
-   G_GINT32_FORMAT='"d"'
 elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
    GPOINTER_TO_INT="((gint)(long long) (ptr))"
    GPOINTER_TO_UINT="((guint)(unsigned long long) (ptr))"
@@ -215,10 +207,6 @@ elif test $ac_cv_sizeof_void_p = $ac_cv_sizeof_long_long; then
    GUINT_TO_POINTER="((gpointer)(unsigned long long) (v))"
    GSIZE="long long"
    GSIZE_FORMAT='"I64u"'
-   G_GUINT64_FORMAT='"I64u"'
-   G_GINT64_FORMAT='"I64i"'
-   G_GUINT32_FORMAT='"I32u"'
-   G_GINT32_FORMAT='"I32i"'
 else
    AC_MSG_ERROR([unsupported pointer size])
 fi
index 8f5a245cfebac07514f809750e28dd8210685183..ae7b6d45337183fb48d52b2593f26b7d0c0de28f 100644 (file)
@@ -27,10 +27,6 @@ typedef unsigned @GSIZE@ gsize;
 typedef signed   @GSIZE@ gssize;
 
 #define G_GSIZE_FORMAT   @GSIZE_FORMAT@
-#define G_GUINT64_FORMAT @G_GUINT64_FORMAT@
-#define G_GINT64_FORMAT @G_GINT64_FORMAT@
-#define G_GUINT32_FORMAT @G_GUINT32_FORMAT@
-#define G_GINT32_FORMAT @G_GINT32_FORMAT@
 
 #if @G_HAVE_ISO_VARARGS@ == 1
 #define G_HAVE_ISO_VARARGS
index 192d39367b60c1a7c2433fb19b5f095c6fcb1881..cc7bd44a8ca25c8938a2d7a28b7335a24c5fda72 100644 (file)
@@ -26,27 +26,14 @@ typedef int pid_t;
 #define G_SEARCHPATH_SEPARATOR_S ";"
 #define G_SEARCHPATH_SEPARATOR   ';'
 #define G_GSIZE_FORMAT   "d"
-#define G_GUINT64_FORMAT "d"
-#define G_GINT64_FORMAT "d"
 #define GPOINTER_TO_INT(ptr)   ((gint)(intptr_t) (ptr))
 #define GPOINTER_TO_UINT(ptr)  ((guint)(intptr_t) (ptr))
 #define GINT_TO_POINTER(v)     ((gpointer)(intptr_t) (v))
 #define GUINT_TO_POINTER(v)    ((gpointer)(intptr_t) (v))
 
-/* VS 2010 and later have stdint.h */
-#if defined(_MSC_VER) && _MSC_VER < 1600
-#define INT32_MAX 2147483647
-#define INT32_MIN (~ INT32_MAX)
-#define INT64_MAX 9223372036854775807i64
-#define INT64_MIN (~INT64_MAX)
-#define UINT32_MAX 0xffffffffU
-#define UINT64_MAX 0xffffffffffffffffULL
-#endif
-
 #define STDOUT_FILENO (int)(intptr_t)stdout
 #define STDERR_FILENO (int)(intptr_t)stderr
 
-
 /* FIXME: what should this be ?*/
 #define X_OK 4 /* This is really read */
 #define WNOHANG 1
index f5473bd2a5c0ee172cffe5de50d491768dfaa498..72770b2f44fab3fae7b0a5312b83d802df98524e 100644 (file)
 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
 #endif
 
-/* VS 2010 and later have stdint.h */
-#if defined(_MSC_VER) && _MSC_VER < 1600
-#else
 #include <stdint.h>
-#endif
 
 #include <eglib-config.h>
 #ifndef EGLIB_NO_REMAP
@@ -63,21 +59,6 @@ typedef const void *   gconstpointer;
 typedef char           gchar;
 typedef unsigned char  guchar;
 
-#if !G_TYPES_DEFINED
-/* VS 2010 and later have stdint.h */
-#if defined(_MSC_VER) && _MSC_VER < 1600
-typedef __int8                 gint8;
-typedef unsigned __int8                guint8;
-typedef __int16                        gint16;
-typedef unsigned __int16       guint16;
-typedef __int32                        gint32;
-typedef unsigned __int32       guint32;
-typedef __int64                        gint64;
-typedef unsigned __int64       guint64;
-typedef float                  gfloat;
-typedef double                 gdouble;
-typedef int                    gboolean;
-#else
 /* Types defined in terms of the stdint.h */
 typedef int8_t         gint8;
 typedef uint8_t        guint8;
@@ -90,8 +71,6 @@ typedef uint64_t       guint64;
 typedef float          gfloat;
 typedef double         gdouble;
 typedef int32_t        gboolean;
-#endif
-#endif
 
 typedef guint16 gunichar2;
 typedef guint32 gunichar;
@@ -135,6 +114,11 @@ typedef guint32 gunichar;
 
 #define G_CONST_RETURN const
 
+#define G_GUINT64_FORMAT PRIu64
+#define G_GINT64_FORMAT PRIi64
+#define G_GUINT32_FORMAT PRIu32
+#define G_GINT32_FORMAT PRIi32
+
 /*
  * Allocation
  */
index 3b0863d250127098bde4ac814aaa9a8cd7a80ff0..77b7e2ba8a3d69c0b41cec92c595300d6fcbdbfd 100644 (file)
   -->\r
   <PropertyGroup>\r
     <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+$(ProjectDir)\..\..\jay\jay -ct &lt; $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.jay > $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.cs
 
     </PreBuildEvent>\r
     <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">\r
+$(ProjectDir)\..\..\jay\jay.exe -ct &lt; $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.jay > $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.cs
 \r
     </PreBuildEvent>\r
 \r
index 9b5e7d736ab0d0040f4eb5d5c4d6240129125861..a5ea5e1483dbe2fb90905b1cb95fb81e5a734511 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="resources/SR.resources">\r
+    <EmbeddedResource Include="resources/SR.resx">\r
       <LogicalName>SR.resources</LogicalName>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="resources/SQLiteCommand.bmp">\r
index 096323d61e7327d62a23dc12797b0fa167827c47..a5ddfedcf19c40211cfe5c9edb631690504058d8 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Novell.Directory.Ldap.Utilclass/ResultCodeMessages.resources">\r
+    <EmbeddedResource Include="Novell.Directory.Ldap.Utilclass/ResultCodeMessages.resx">\r
       <LogicalName>ResultCodeMessages.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 8ae3cfccffd8ad7aaf56793aa8528ee6490a716b..bf63d7a400bde6bc2651cb8dc4ff8658b6eb2286 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Microsoft.Internal.Strings.resources">\r
+    <EmbeddedResource Include="Microsoft.Internal.Strings.resx">\r
       <LogicalName>Microsoft.Internal.Strings.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 3d0f0ea86a53a47c4c7d96a1713b86e9287e80ec..840cebb9105a47ec08497e4471468339da6da5fc 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Client/System.Data.Services.Client.resources">\r
+    <EmbeddedResource Include="Client/System.Data.Services.Client.resx">\r
       <LogicalName>System.Data.Services.Client.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 08caf0b68652349aeb8d60b0db49784dc7b68f54..9ae3c0813a12f97e79406e2ed6bfc9fac61f9e46 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Json.Properties.Resources.resources">\r
+    <EmbeddedResource Include="System.Json.Properties.Resources.resx">\r
       <LogicalName>System.Json.Properties.Resources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 78ccedb9aa29d1c884734ae8049d5f1e9cabdeaf..b3e1c9cb5089420cc2662b97ee028b2ab3ed679e 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Net.Http.Properties.CommonWebApiResources.resources">\r
+    <EmbeddedResource Include="System.Net.Http.Properties.CommonWebApiResources.resx">\r
       <LogicalName>System.Net.Http.Properties.CommonWebApiResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Net.Http.Properties.Resources.resources">\r
+    <EmbeddedResource Include="System.Net.Http.Properties.Resources.resx">\r
       <LogicalName>System.Net.Http.Properties.Resources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 5723acb0b1cce0f3d80837d87010b6e2f01769a3..2b9a54d7fdc0000eddd99e1658c42c983ed26a63 100644 (file)
@@ -61,7 +61,9 @@ namespace System.Net.Http
                        public void Close ()
                        {
                                CancellationTokenRegistration.Dispose ();
-                               ContentStream.Close ();
+                                if (ContentStream != null) {
+                                    ContentStream.Close ();
+                                }
                        }
                }
 
index 37833bc67086e6b96cbf74f99025feb188174496..94ad2ffb2742945f1914a1a127bd8542367a395e 100644 (file)
@@ -245,8 +245,6 @@ namespace System.Net.Http
                                wr.KeepAlive = request.Headers.ConnectionClose != true;
                        }
 
-                       wr.ServicePoint.Expect100Continue = request.Headers.ExpectContinue == true;
-
                        if (allowAutoRedirect) {
                                wr.AllowAutoRedirect = true;
                                wr.MaximumAutomaticRedirections = maxAutomaticRedirections;
@@ -270,8 +268,13 @@ namespace System.Net.Http
 
                        if (useProxy) {
                                wr.Proxy = proxy;
+                       } else {
+                               // Disables default WebRequest.DefaultWebProxy value
+                               wr.Proxy = null;
                        }
 
+                       wr.ServicePoint.Expect100Continue = request.Headers.ExpectContinue == true;
+
                        // Add request headers
                        var headers = wr.Headers;
                        foreach (var header in request.Headers) {
index 4d9265a6ac76f8e3640e82e2e75e1fa6189b8ee6..aa678a036e6d2f8219e3d89a55695dba90dfdffa 100644 (file)
@@ -150,6 +150,29 @@ namespace MonoTests.System.Net.Http
                        }
                }
 
+               class ThrowOnlyProxy : IWebProxy
+               {
+                       public ICredentials Credentials {
+                               get {
+                                       throw new NotImplementedException ();
+                               }
+
+                               set {
+                                       throw new NotImplementedException ();
+                               }
+                       }
+
+                       public Uri GetProxy (Uri destination)
+                       {
+                               throw new NotImplementedException ();
+                       }
+
+                       public bool IsBypassed (Uri host)
+                       {
+                               throw new NotImplementedException ();
+                       }
+               }
+
                const int WaitTimeout = 5000;
 
                string TestHost, LocalServer;
@@ -297,6 +320,25 @@ namespace MonoTests.System.Net.Http
                        }
                }
 
+               [Test]
+               public void Proxy_Disabled ()
+               {
+                       var pp = WebRequest.DefaultWebProxy;
+
+                       try {
+                               WebRequest.DefaultWebProxy = new ThrowOnlyProxy ();
+
+                               var request = new HttpClientHandler {
+                                       UseProxy = false
+                               };
+
+                               var client = new HttpClient (request);
+                               Assert.IsTrue (client.GetAsync ("http://google.com").Wait (5000), "needs internet access");
+                       } finally {
+                               WebRequest.DefaultWebProxy = pp;
+                       }
+               }
+
                [Test]
                public void Send ()
                {
index ebdde2de08b82c530025f7b770d7ede01177ca19..270278e73392ad1f38bfd4fa75159efae35a8d1d 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Strings_Core.resources">\r
+    <EmbeddedResource Include="Strings_Core.resx">\r
       <LogicalName>System.Reactive.Strings_Core.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index b4ea1eed3cf1eab2db7f5f145e41d05b6f0eb0d5..b13bf98e82b35447d38d666213053dbb57414104 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Strings_Linq.resources">\r
+    <EmbeddedResource Include="Strings_Linq.resx">\r
       <LogicalName>System.Reactive.Strings_Linq.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 64ed969e3c7745224246000839aeca28f51f2bc2..5e1435c3dfbff4b1e16f32bb99b9f0157bc1a608 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Strings_PlatformServices.resources">\r
+    <EmbeddedResource Include="Strings_PlatformServices.resx">\r
       <LogicalName>System.Reactive.Strings_PlatformServices.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 6edf8555781cc195fdd1ab8bf2e2f1813225ad2d..2dee913e1134e6ecadf4a426ea7487fbad370342 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Strings_Providers.resources">\r
+    <EmbeddedResource Include="Strings_Providers.resx">\r
       <LogicalName>System.Reactive.Strings_Providers.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 8f7843093771312d715ee553f2a07fa6704523ee..d8eb8de10da4d91c597f913770b3c4f8b3872ae5 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Strings_WindowsThreading.resources">\r
+    <EmbeddedResource Include="Strings_WindowsThreading.resx">\r
       <LogicalName>System.Reactive.Strings_WindowsThreading.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 31e60bb0b175dccb9e57e732bc7f044cb7871da6..4cfba6d759e295079f4a192c1bf8976c6ae30158 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Web.Http.Properties.CommonWebApiResources.resources">\r
+    <EmbeddedResource Include="System.Web.Http.Properties.CommonWebApiResources.resx">\r
       <LogicalName>System.Web.Http.Properties.CommonWebApiResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Web.Http.Properties.SRResources.resources">\r
+    <EmbeddedResource Include="System.Web.Http.Properties.SRResources.resx">\r
       <LogicalName>System.Web.Http.Properties.SRResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 73d5328f89889d7098f5c1cd053d01167dcd82b7..3bed8a7d326fb33e7d2c5e2f9ae98d038076022b 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Mvc/Resources/MvcResources.resources">\r
+    <EmbeddedResource Include="Mvc/Resources/MvcResources.resx">\r
       <LogicalName>System.Web.Mvc.Resources.MvcResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index fd459922df14da9f76e268815a902093cb905d1f..23422a60b2c4e9ebdda370a42faaaede7642d33a 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Web.Razor.Resources.RazorResources.resources">\r
+    <EmbeddedResource Include="System.Web.Razor.Resources.RazorResources.resx">\r
       <LogicalName>System.Web.Razor.Resources.RazorResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Web.Razor.Common.CommonResources.resources">\r
+    <EmbeddedResource Include="System.Web.Razor.Common.CommonResources.resx">\r
       <LogicalName>System.Web.Razor.Common.CommonResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 16282251ad42b04695d57660ea952730d9d13a46..0aba08155ed3148ea38f47f329a5a9845b5f7022 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Web.WebPages.Deployment.Common.CommonResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Deployment.Common.CommonResources.resx">\r
       <LogicalName>System.Web.WebPages.Deployment.Common.CommonResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Web.WebPages.Deployment.Resources.ConfigurationResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Deployment.Resources.ConfigurationResources.resx">\r
       <LogicalName>System.Web.WebPages.Deployment.Resources.ConfigurationResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 6df147742b1dcbf6d98c3574feafbeae524a9a2e..72b548bd2189a2aac937b533cdb5e7a77eeef71d 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Web.WebPages.Razor.Resources.RazorWebResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Razor.Resources.RazorWebResources.resx">\r
       <LogicalName>System.Web.WebPages.Razor.Resources.RazorWebResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Web.WebPages.Razor.Common.CommonResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Razor.Common.CommonResources.resx">\r
       <LogicalName>System.Web.WebPages.Razor.Common.CommonResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 6bb28d4513fa8413a8b17c41a96ac9d6d3669ea5..05b00144488613f0ce51aeb6258c64411a8db6f4 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="System.Web.WebPages.Resources.WebPageResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Resources.WebPageResources.resx">\r
       <LogicalName>System.Web.WebPages.Resources.WebPageResources.resources</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="System.Web.WebPages.Common.CommonResources.resources">\r
+    <EmbeddedResource Include="System.Web.WebPages.Common.CommonResources.resx">\r
       <LogicalName>System.Web.WebPages.Common.CommonResources.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 1c4ef9bb5bf6c4f34a26ed2a04943558763ef7a7..0b2f0ba3ea7c1e9e12091f34646cabbf94273f31 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="resources/TranslationResources.resources">\r
+    <EmbeddedResource Include="resources/TranslationResources.resx">\r
       <LogicalName>TranslationResources.resources</LogicalName>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="resources/WebUIValidation.js">\r
index 52bfd6d852c655d1b4546896475619cf393ef8bf..6d65c01cc378bbd0ec0b79b4a8a8311e76988f83 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="resources/TranslationResources.resources">\r
+    <EmbeddedResource Include="resources/TranslationResources.resx">\r
       <LogicalName>TranslationResources.resources</LogicalName>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="resources/WebUIValidation.js">\r
index c3ca632b42c9c75b5022255e99e282910c6748bb..9e5f97d26276b74d20c3c77c217f01d1faf33e09 100644 (file)
     <EmbeddedResource Include="resources/DnDMove.cur">\r
       <LogicalName>System.Windows.Forms.DnDMove.cur</LogicalName>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="resources/keyboards.resources">\r
+    <EmbeddedResource Include="resources/keyboards.resx">\r
       <LogicalName>keyboards.resources</LogicalName>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="resources/16_computer.png">\r
index 96ea9a5403b45bdae370068ca187d7763be6b3d8..e4b4ae11d2a1633aea6487a63fab392315db1c22 100644 (file)
@@ -457,6 +457,8 @@ namespace System.IO.Packaging {
 
                internal static void WriteRelationships (Dictionary <string, PackageRelationship> relationships, Stream stream)
                {
+                       stream.SetLength(0);
+
                        XmlDocument doc = new XmlDocument ();
                        XmlNamespaceManager manager = new XmlNamespaceManager (doc.NameTable);
                        manager.AddNamespace ("rel", RelationshipNamespace);
index 435e1d5ab7cfe656c637725b4d4c9739d3f5dfa3..783350b09344a6943326be5ae5eafa28a5e589b3 100644 (file)
@@ -95,8 +95,10 @@ namespace System.IO.Packaging {
                {
                        // Ensure that all the data has been read out of the package
                        // stream already. Otherwise we'll lose data when we recreate the zip
-                       foreach (ZipPackagePart part in Parts.Values)
-                               part.GetStream ().Dispose ();
+                       foreach (ZipPackagePart part in Parts.Values) {
+                               if (part.Package != null)
+                                       part.GetStream ().Dispose ();
+                       }
                        
                        // Empty the package stream
                        PackageStream.Position = 0;
@@ -107,6 +109,9 @@ namespace System.IO.Packaging {
 
                                // Write all the part streams
                                foreach (ZipPackagePart part in Parts.Values) {
+                                       if (part.Package == null)
+                                               continue;
+
                                        Stream partStream = part.GetStream ();
                                        partStream.Seek (0, SeekOrigin.Begin);
                                        
index 6ce92d31e57dddeea54db7eac175339197aa5b64..ade937eea58027764bfe61d863d9054b68346adf 100644 (file)
@@ -184,5 +184,33 @@ namespace MonoTests.System.IO.Packaging {
                                                         d.RelationshipType == node.Attributes["Type"].InnerText));\r
             }\r
         }\r
+\r
+        [Test]\r
+        public void CheckRelationshipDeletion ()\r
+        {\r
+            AddThreeRelationShips ();\r
+            package.Flush ();\r
+\r
+            foreach (PackageRelationship p in new List<PackageRelationship> (package.GetRelationships ()).Skip(1))\r
+                package.DeleteRelationship (p.Id);\r
+\r
+            PackagePart part = package.GetPart (new Uri ("/_rels/.rels", UriKind.Relative));\r
+            Assert.IsNotNull (package.GetPart (new Uri ("/_RELS/.RELS", UriKind.Relative)), "#0");\r
+            package.Flush ();\r
+            Assert.IsNotNull (part, "#1");\r
+\r
+            Stream stream = part.GetStream ();\r
+            Assert.IsTrue (stream.Length > 0, "#2a");\r
+\r
+            XmlDocument doc = new XmlDocument ();\r
+            XmlNamespaceManager manager = new XmlNamespaceManager (doc.NameTable);\r
+            manager.AddNamespace("rel", "http://schemas.openxmlformats.org/package/2006/relationships");\r
+            doc.Load (new StreamReader (stream));\r
+\r
+            Assert.IsNotNull (doc.SelectSingleNode ("/rel:Relationships", manager), "#2b");\r
+\r
+            XmlNodeList list = doc.SelectNodes ("/rel:Relationships/*", manager);\r
+            Assert.AreEqual (1, list.Count);\r
+        }\r
     }\r
 }\r
index 92c8f57f6f221950a8892cad3244819fc2aa6369..c56737e4394a42767e16c8815bec8e03e304a2ca 100644 (file)
     <Folder Include="Properties\" />\r
   </ItemGroup>\r
   <ItemGroup>\r
-    <EmbeddedResource Include="Transform.resources">\r
+    <EmbeddedResource Include="Transform.resx">\r
       <LogicalName>NUnit.Util.Transform.resources</LogicalName>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
index 774151fa5b94ec1f68243e0de603818e873a8064..3155861850469b91e0902c7dc8c015dc59b091d9 100644 (file)
@@ -2439,12 +2439,8 @@ unload_thread_main (void *arg)
 
        /* Have to attach to the runtime so shutdown can wait for this thread */
        /* Force it to be attached to avoid racing during shutdown. */
-       thread = mono_thread_attach_full (mono_get_root_domain (), TRUE, &error);
-       if (!is_ok (&error)) {
-               data->failure_reason = g_strdup (mono_error_get_message (&error));
-               mono_error_cleanup (&error);
-               goto failure;
-       }
+       thread = mono_thread_attach_full (mono_get_root_domain (), TRUE);
+
        mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Domain unloader"), TRUE, &error);
        if (!is_ok (&error)) {
                data->failure_reason = g_strdup (mono_error_get_message (&error));
index 1e7404d4e0ca4f35fa84f5ce47c475a9b3694ef0..dcd856692c28b2d71ab285e5d336f2118cffd8be 100644 (file)
@@ -905,7 +905,7 @@ typedef struct {
 
 extern MonoStats mono_stats;
 
-typedef gpointer (*MonoRemotingTrampoline)       (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target);
+typedef gpointer (*MonoRemotingTrampoline)       (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target, MonoError *error);
 typedef gpointer (*MonoDelegateTrampoline)       (MonoDomain *domain, MonoClass *klass);
 
 typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass, MonoCachedClassInfo *res);
index d500fb626ce2a66029d2687aa1ffbd3888ed6f88..889c19ece4f786221a020fc365cebe41983b7734 100644 (file)
@@ -1984,8 +1984,7 @@ cominterop_get_ccw_checked (MonoObject* object, MonoClass* itf, MonoError *error
                g_hash_table_insert (ccw_hash, GINT_TO_POINTER (mono_object_hash (object)), ccw_list);
                mono_cominterop_unlock ();
                /* register for finalization to clean up ccw */
-               mono_object_register_finalizer (object, error);
-               return_val_if_nok (error, NULL);
+               mono_object_register_finalizer (object);
        }
 
        cinfo = mono_custom_attrs_from_class_checked (itf, error);
index baf79f6be9709502aa442df5fe76f9570e73719a..f8cbb0744a2d5c19af1ba8eb8cb70219e71b372c 100644 (file)
@@ -444,10 +444,6 @@ mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method)
        gboolean name_match;
 
        name_match = strcmp (desc->name, method->name) == 0;
-#ifndef _EGLIB_MAJOR
-       if (!name_match && desc->name_glob)
-               name_match = g_pattern_match_simple (desc->name, method->name);
-#endif
        if (!name_match)
                return FALSE;
        if (!desc->args)
index 52d950d8cca7b8469db99a3f95dcd751d6a24f4b..ff44969a81de215b72e081ea7567b8a3fdcda1f7 100644 (file)
@@ -66,7 +66,7 @@
 /* useful until we keep track of gc-references in corlib etc. */
 #define IS_GC_REFERENCE(class,t) (mono_gc_is_moving () ? FALSE : ((t)->type == MONO_TYPE_U && (class)->image == mono_defaults.corlib))
 
-void   mono_object_register_finalizer               (MonoObject  *obj, MonoError *error);
+void   mono_object_register_finalizer               (MonoObject  *obj);
 void   ves_icall_System_GC_InternalCollect          (int          generation);
 gint64 ves_icall_System_GC_GetTotalMemory           (MonoBoolean  forceCollection);
 void   ves_icall_System_GC_KeepAlive                (MonoObject  *obj);
index 51b9306fc67c984693ab0f09f7a2499ef55ca3a6..79293d97b9910f8440b5d69e627551a27a031c2a 100644 (file)
@@ -73,7 +73,7 @@ static MonoCoopCond exited_cond;
 
 static MonoInternalThread *gc_thread;
 
-static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*), MonoError *error);
+static void object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*));
 
 static void reference_queue_proccess_all (void);
 static void mono_reference_queue_cleanup (void);
@@ -92,16 +92,16 @@ guarded_wait (HANDLE handle, guint32 timeout, gboolean alertable)
        return result;
 }
 
-static void
-add_thread_to_finalize (MonoInternalThread *thread)
+static gboolean
+add_thread_to_finalize (MonoInternalThread *thread, MonoError *error)
 {
-       MonoError error;
+       mono_error_init (error);
        mono_finalizer_lock ();
        if (!threads_to_finalize)
                MONO_GC_REGISTER_ROOT_SINGLE (threads_to_finalize, MONO_ROOT_SOURCE_FINALIZER_QUEUE, "finalizable threads list");
-       threads_to_finalize = mono_mlist_append_checked (threads_to_finalize, (MonoObject*)thread, &error);
+       threads_to_finalize = mono_mlist_append_checked (threads_to_finalize, (MonoObject*)thread, error);
        mono_finalizer_unlock ();
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       return is_ok (error);
 }
 
 static gboolean suspend_finalizers = FALSE;
@@ -166,8 +166,7 @@ mono_gc_run_finalize (void *obj, void *data)
 #endif
 
        /* make sure the finalizer is not called again if the object is resurrected */
-       object_register_finalizer ((MonoObject *)obj, NULL, &error);
-       mono_error_assert_ok (&error); /* FIXME don't swallow the error */
+       object_register_finalizer ((MonoObject *)obj, NULL);
 
        if (log_finalizers)
                g_log ("mono-gc-finalizers", G_LOG_LEVEL_MESSAGE, "<%s at %p> Registered finalizer as processed.", o->vtable->klass->name, o);
@@ -183,7 +182,8 @@ mono_gc_run_finalize (void *obj, void *data)
                        /* Don't finalize threadpool threads when
                           shutting down - they're finalized when the
                           threadpool shuts down. */
-                       add_thread_to_finalize (t);
+                       if (!add_thread_to_finalize (t, &error))
+                               goto unhandled_error;
                        return;
                }
        }
@@ -251,7 +251,8 @@ mono_gc_run_finalize (void *obj, void *data)
        runtime_invoke = (RuntimeInvokeFunction)domain->finalize_runtime_invoke;
 
        mono_runtime_class_init_full (o->vtable, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       if (!is_ok (&error))
+               goto unhandled_error;
 
        if (G_UNLIKELY (MONO_GC_FINALIZE_INVOKE_ENABLED ())) {
                MONO_GC_FINALIZE_INVOKE ((unsigned long)o, mono_object_get_size (o),
@@ -266,6 +267,9 @@ mono_gc_run_finalize (void *obj, void *data)
        if (log_finalizers)
                g_log ("mono-gc-finalizers", G_LOG_LEVEL_MESSAGE, "<%s at %p> Returned from finalizer.", o->vtable->klass->name, o);
 
+unhandled_error:
+       if (!is_ok (&error))
+               exc = (MonoObject*)mono_error_convert_to_exception (&error);
        if (exc)
                mono_thread_internal_unhandled_exception (exc);
 
@@ -275,14 +279,12 @@ mono_gc_run_finalize (void *obj, void *data)
 void
 mono_gc_finalize_threadpool_threads (void)
 {
-       MonoError error;
        while (threads_to_finalize) {
                MonoInternalThread *thread = (MonoInternalThread*) mono_mlist_get_data (threads_to_finalize);
 
                /* Force finalization of the thread. */
                thread->threadpool_thread = FALSE;
-               mono_object_register_finalizer ((MonoObject*)thread, &error);
-               mono_error_assert_ok (&error); /* FIXME don't swallow the error */
+               mono_object_register_finalizer ((MonoObject*)thread);
 
                mono_gc_run_finalize (thread, NULL);
 
@@ -312,16 +314,11 @@ mono_gc_out_of_memory (size_t size)
  * since that, too, can cause the underlying pointer to be offset.
  */
 static void
-object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*), MonoError *error)
+object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*))
 {
        MonoDomain *domain;
 
-       mono_error_init (error);
-
-       if (obj == NULL) {
-               mono_error_set_argument_null (error, "obj", "");
-               return;
-       }
+       g_assert (obj != NULL);
 
        domain = obj->vtable->domain;
 
@@ -363,10 +360,10 @@ object_register_finalizer (MonoObject *obj, void (*callback)(void *, void*), Mon
  * 
  */
 void
-mono_object_register_finalizer (MonoObject *obj, MonoError *error)
+mono_object_register_finalizer (MonoObject *obj)
 {
        /* g_print ("Registered finalizer on %p %s.%s\n", obj, mono_object_class (obj)->name_space, mono_object_class (obj)->name); */
-       object_register_finalizer (obj, mono_gc_run_finalize, error);
+       object_register_finalizer (obj, mono_gc_run_finalize);
 }
 
 /**
@@ -486,19 +483,14 @@ ves_icall_System_GC_KeepAlive (MonoObject *obj)
 void
 ves_icall_System_GC_ReRegisterForFinalize (MonoObject *obj)
 {
-       MonoError error;
-
        MONO_CHECK_ARG_NULL (obj,);
 
-       object_register_finalizer (obj, mono_gc_run_finalize, &error);
-       mono_error_set_pending_exception (&error);
+       object_register_finalizer (obj, mono_gc_run_finalize);
 }
 
 void
 ves_icall_System_GC_SuppressFinalize (MonoObject *obj)
 {
-       MonoError error;
-
        MONO_CHECK_ARG_NULL (obj,);
 
        /* delegates have no finalizers, but we register them to deal with the
@@ -512,8 +504,7 @@ ves_icall_System_GC_SuppressFinalize (MonoObject *obj)
         * generated for it that needs cleaned up, but user wants to suppress
         * their derived object finalizer. */
 
-       object_register_finalizer (obj, NULL, &error);
-       mono_error_set_pending_exception (&error);
+       object_register_finalizer (obj, NULL);
 }
 
 void
@@ -1122,18 +1113,18 @@ mono_gc_reference_queue_new (mono_reference_queue_callback callback)
 gboolean
 mono_gc_reference_queue_add (MonoReferenceQueue *queue, MonoObject *obj, void *user_data)
 {
-       MonoError error;
        RefQueueEntry *entry;
        if (queue->should_be_deleted)
                return FALSE;
 
+       g_assert (obj != NULL);
+
        entry = g_new0 (RefQueueEntry, 1);
        entry->user_data = user_data;
        entry->domain = mono_object_domain (obj);
 
        entry->gchandle = mono_gchandle_new_weakref (obj, TRUE);
-       mono_object_register_finalizer (obj, &error);
-       mono_error_assert_ok (&error);
+       mono_object_register_finalizer (obj);
 
        ref_list_push (&queue->queue, entry);
        return TRUE;
index e60d9b3b27e47902c30d162e3c08e9c429dfdaca..8d13d5c5d53f9ee22aa857169c83b67b156711e5 100644 (file)
@@ -6733,17 +6733,15 @@ ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this_obj, MonoStri
        }
 
        tp->custom_type_info = (mono_object_isinst_checked (this_obj, mono_defaults.iremotingtypeinfo_class, &error) != NULL);
-       if (!is_ok (&error)) {
-               mono_error_set_pending_exception (&error);
+       if (mono_error_set_pending_exception (&error))
                return NULL;
-       }
        tp->remote_class = mono_remote_class (domain, class_name, klass, &error);
-       if (!is_ok (&error)) {
-               mono_error_set_pending_exception (&error);
+       if (mono_error_set_pending_exception (&error))
                return NULL;
-       }
 
-       res->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tp->remote_class, rp);
+       res->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tp->remote_class, rp, &error);
+       if (mono_error_set_pending_exception (&error))
+               return NULL;
        return res;
 }
 
@@ -7011,14 +7009,6 @@ ves_icall_System_Environment_GetEnvironmentVariableNames (void)
 #endif
 }
 
-/*
- * If your platform lacks setenv/unsetenv, you must upgrade your glib.
- */
-#if !GLIB_CHECK_VERSION(2,4,0)
-#define g_setenv(a,b,c)   setenv(a,b,c)
-#define g_unsetenv(a) unsetenv(a)
-#endif
-
 ICALL_EXPORT void
 ves_icall_System_Environment_InternalSetEnvironmentVariable (MonoString *name, MonoString *value)
 {
index 4e734a7a5f93854d490d34f231098109a19aa0f7..91fc1d62ac0bc0c1b17df7835eaec559d6f44f31 100644 (file)
@@ -407,14 +407,10 @@ mono_delegate_to_ftnptr (MonoDelegate *delegate)
        delegate_hash_table_add (delegate);
 
        /* when the object is collected, collect the dynamic method, too */
-       mono_object_register_finalizer ((MonoObject*)delegate, &error);
-       if (!is_ok (&error))
-               goto fail2;
+       mono_object_register_finalizer ((MonoObject*)delegate);
 
        return delegate->delegate_trampoline;
 
-fail2:
-       delegate_hash_table_remove (delegate);
 fail:
        mono_gchandle_free (target_handle);
        mono_error_set_pending_exception (&error);
@@ -3009,7 +3005,9 @@ mono_delegate_end_invoke (MonoDelegate *delegate, gpointer *params)
        } else
 #endif
        {
-               res = mono_threadpool_ms_end_invoke (ares, &out_args, &exc);
+               res = mono_threadpool_ms_end_invoke (ares, &out_args, &exc, &error);
+               if (mono_error_set_pending_exception (&error))
+                       return NULL;
        }
 
        if (exc) {
index 6cf9691777ea783631f39c7cac24c239cd180a7f..b9a305121641975286467b84392ceba8856a4111 100644 (file)
@@ -1250,7 +1250,8 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        mon = lock_word_get_inflated_lock (lw);
 
        /* Do this WaitSleepJoin check before creating the event handle */
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return FALSE;
        
        event = CreateEvent (NULL, FALSE, FALSE, NULL);
        if (event == NULL) {
@@ -1260,7 +1261,11 @@ ves_icall_System_Threading_Monitor_Monitor_wait (MonoObject *obj, guint32 ms)
        
        LOCK_DEBUG (g_message ("%s: (%d) queuing handle %p", __func__, mono_thread_info_get_small_id (), event));
 
-       mono_thread_current_check_pending_interrupt ();
+       /* This looks superfluous */
+       if (mono_thread_current_check_pending_interrupt ()) {
+               CloseHandle (event);
+               return FALSE;
+       }
        
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
 
index 659bd648289bce6e49f27ff059b02e2462019ee5..8c727448a2d5449c4b960f2f586c79ba7efc753e 100644 (file)
@@ -1447,10 +1447,10 @@ MonoObject *
 mono_remoting_invoke (MonoObject *real_proxy, MonoMethodMessage *msg, MonoObject **exc, MonoArray **out_args, MonoError *error);
 
 gpointer
-mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy);
+mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *real_proxy, MonoError *error);
 
-void
-mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass);
+gboolean
+mono_upgrade_remote_class (MonoDomain *domain, MonoObject *tproxy, MonoClass *klass, MonoError *error);
 
 void*
 mono_load_remote_field_checked (MonoObject *this_obj, MonoClass *klass, MonoClassField *field, void **res, MonoError *error);
index c5fa20e1bb1e83f5c4010016c514e5ba4de3fe46..00d225552b6fac77c2070bbf59232d4139b4eea6 100644 (file)
@@ -541,7 +541,7 @@ mono_release_type_locks (MonoInternalThread *thread)
 #ifndef DISABLE_REMOTING
 
 static gpointer
-default_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target)
+default_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target, MonoError *error)
 {
        g_error ("remoting not installed");
        return NULL;
@@ -2305,25 +2305,27 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *klass, MonoErro
  * mono_class_proxy_vtable:
  * @domain: the application domain
  * @remove_class: the remote class
+ * @error: set on error
  *
  * Creates a vtable for transparent proxies. It is basically
  * a copy of the real vtable of the class wrapped in @remote_class,
  * but all function pointers invoke the remoting functions, and
  * vtable->klass points to the transparent proxy class, and not to @class.
+ *
+ * On failure returns NULL and sets @error
  */
 static MonoVTable *
-mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRemotingTarget target_type)
+mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRemotingTarget target_type, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
-       MonoError error;
        MonoVTable *vt, *pvt;
        int i, j, vtsize, max_interface_id, extra_interface_vtsize = 0;
        MonoClass *k;
        GSList *extra_interfaces = NULL;
        MonoClass *klass = remote_class->proxy_class;
        gpointer *interface_offsets;
-       uint8_t *bitmap;
+       uint8_t *bitmap = NULL;
        int bsize;
        size_t imt_table_bytes;
        
@@ -2331,6 +2333,8 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        int bcsize;
 #endif
 
+       mono_error_init (error);
+
        vt = mono_class_vtable (domain, klass);
        g_assert (vt); /*FIXME property handle failure*/
        max_interface_id = vt->max_interface_id;
@@ -2351,8 +2355,9 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                
                method_count = mono_class_num_methods (iclass);
        
-               ifaces = mono_class_get_implemented_interfaces (iclass, &error);
-               g_assert (mono_error_ok (&error)); /*FIXME do proper error handling*/
+               ifaces = mono_class_get_implemented_interfaces (iclass, error);
+               if (!is_ok (error))
+                       goto failure;
                if (ifaces) {
                        for (i = 0; i < ifaces->len; ++i) {
                                MonoClass *ic = (MonoClass *)g_ptr_array_index (ifaces, i);
@@ -2365,6 +2370,7 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                                method_count += mono_class_num_methods (ic);
                        }
                        g_ptr_array_free (ifaces, TRUE);
+                       ifaces = NULL;
                }
 
                extra_interface_vtsize += method_count * sizeof (gpointer);
@@ -2394,9 +2400,11 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        for (i = 0; i < klass->vtable_size; ++i) {
                MonoMethod *cm;
                    
-               if ((cm = klass->vtable [i]))
-                       pvt->vtable [i] = arch_create_remoting_trampoline (domain, cm, target_type);
-               else
+               if ((cm = klass->vtable [i])) {
+                       pvt->vtable [i] = arch_create_remoting_trampoline (domain, cm, target_type, error);
+                       if (!is_ok (error))
+                               goto failure;
+               } else
                        pvt->vtable [i] = NULL;
        }
 
@@ -2406,8 +2414,11 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                        MonoMethod* m;
                        gpointer iter = NULL;
                        while ((m = mono_class_get_methods (k, &iter)))
-                               if (!pvt->vtable [m->slot])
-                                       pvt->vtable [m->slot] = arch_create_remoting_trampoline (domain, m, target_type);
+                               if (!pvt->vtable [m->slot]) {
+                                       pvt->vtable [m->slot] = arch_create_remoting_trampoline (domain, m, target_type, error);
+                                       if (!is_ok (error))
+                                               goto failure;
+                               }
                }
        }
 
@@ -2439,8 +2450,11 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
 
                        iter = NULL;
                        j = 0;
-                       while ((cm = mono_class_get_methods (interf, &iter)))
-                               pvt->vtable [slot + j++] = arch_create_remoting_trampoline (domain, cm, target_type);
+                       while ((cm = mono_class_get_methods (interf, &iter))) {
+                               pvt->vtable [slot + j++] = arch_create_remoting_trampoline (domain, cm, target_type, error);
+                               if (!is_ok (error))
+                                       goto failure;
+                       }
                        
                        slot += mono_class_num_methods (interf);
                }
@@ -2461,6 +2475,13 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        pvt->interface_bitmap = bitmap;
 #endif
        return pvt;
+failure:
+       if (extra_interfaces)
+               g_slist_free (extra_interfaces);
+#ifdef COMPRESSED_INTERFACE_BITMAP
+       g_free (bitmap);
+#endif
+       return NULL;
 }
 
 #endif /* DISABLE_REMOTING */
@@ -2726,17 +2747,20 @@ clone_remote_class (MonoDomain *domain, MonoRemoteClass* remote_class, MonoClass
 }
 
 gpointer
-mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *rp)
+mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *rp, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
+       mono_error_init (error);
+
        mono_loader_lock (); /*FIXME mono_class_from_mono_type and mono_class_proxy_vtable take it*/
        mono_domain_lock (domain);
        if (rp->target_domain_id != -1) {
                if (remote_class->xdomain_vtable == NULL)
-                       remote_class->xdomain_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_APPDOMAIN);
+                       remote_class->xdomain_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_APPDOMAIN, error);
                mono_domain_unlock (domain);
                mono_loader_unlock ();
+               return_val_if_nok (error, NULL);
                return remote_class->xdomain_vtable;
        }
        if (remote_class->default_vtable == NULL) {
@@ -2746,10 +2770,16 @@ mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mon
                klass = mono_class_from_mono_type (type);
 #ifndef DISABLE_COM
                if ((mono_class_is_com_object (klass) || (mono_class_get_com_object_class () && klass == mono_class_get_com_object_class ())) && !mono_vtable_is_remote (mono_class_vtable (mono_domain_get (), klass)))
-                       remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_COMINTEROP);
+                       remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_COMINTEROP, error);
                else
 #endif
-                       remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_UNKNOWN);
+                       remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_UNKNOWN, error);
+               /* N.B. both branches of the if modify error */
+               if (!is_ok (error)) {
+                       mono_domain_unlock (domain);
+                       mono_loader_unlock ();
+                       return NULL;
+               }
        }
        
        mono_domain_unlock (domain);
@@ -2762,13 +2792,14 @@ mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mon
  * @domain: the application domain
  * @tproxy: the proxy whose remote class has to be upgraded.
  * @klass: class to which the remote class can be casted.
+ * @error: set on error
  *
  * Updates the vtable of the remote class by adding the necessary method slots
  * and interface offsets so it can be safely casted to klass. klass can be a
- * class or an interface.
+ * class or an interface.  On success returns TRUE, on failure returns FALSE and sets @error.
  */
-void
-mono_upgrade_remote_class (MonoDomain *domain, MonoObject *proxy_object, MonoClass *klass)
+gboolean
+mono_upgrade_remote_class (MonoDomain *domain, MonoObject *proxy_object, MonoClass *klass, MonoError *error)
 {
        MONO_REQ_GC_UNSAFE_MODE;
 
@@ -2776,6 +2807,7 @@ mono_upgrade_remote_class (MonoDomain *domain, MonoObject *proxy_object, MonoCla
        MonoRemoteClass *remote_class;
        gboolean redo_vtable;
 
+       mono_error_init (error);
        mono_loader_lock (); /*FIXME mono_remote_class_vtable requires it.*/
        mono_domain_lock (domain);
 
@@ -2795,11 +2827,15 @@ mono_upgrade_remote_class (MonoDomain *domain, MonoObject *proxy_object, MonoCla
 
        if (redo_vtable) {
                tproxy->remote_class = clone_remote_class (domain, remote_class, klass);
-               proxy_object->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tproxy->remote_class, tproxy->rp);
+               proxy_object->vtable = (MonoVTable *)mono_remote_class_vtable (domain, tproxy->remote_class, tproxy->rp, error);
+               if (!is_ok (error))
+                       goto leave;
        }
        
+leave:
        mono_domain_unlock (domain);
        mono_loader_unlock ();
+       return is_ok (error);
 }
 #endif /* DISABLE_REMOTING */
 
@@ -5156,7 +5192,7 @@ mono_object_new_pinned (MonoDomain *domain, MonoClass *klass, MonoError *error)
        if (G_UNLIKELY (!o))
                mono_error_set_out_of_memory (error, "Could not allocate %i bytes", mono_class_instance_size (klass));
        else if (G_UNLIKELY (vtable->klass->has_finalize))
-               mono_object_register_finalizer (o, error);
+               mono_object_register_finalizer (o);
 
        return o;
 }
@@ -5286,7 +5322,7 @@ mono_object_new_alloc_specific_checked (MonoVTable *vtable, MonoError *error)
        if (G_UNLIKELY (!o))
                mono_error_set_out_of_memory (error, "Could not allocate %i bytes", vtable->klass->instance_size);
        else if (G_UNLIKELY (vtable->klass->has_finalize))
-               mono_object_register_finalizer (o, error);
+               mono_object_register_finalizer (o);
 
        return o;
 }
@@ -5374,7 +5410,7 @@ mono_object_new_mature (MonoVTable *vtable, MonoError *error)
        if (G_UNLIKELY (!o))
                mono_error_set_out_of_memory (error, "Could not allocate %i bytes", vtable->klass->instance_size);
        else if (G_UNLIKELY (vtable->klass->has_finalize))
-               mono_object_register_finalizer (o, error);
+               mono_object_register_finalizer (o);
 
        return o;
 }
@@ -5489,7 +5525,7 @@ mono_object_clone_checked (MonoObject *obj, MonoError *error)
        mono_gc_wbarrier_object_copy (o, obj);
 
        if (obj->vtable->klass->has_finalize)
-               mono_object_register_finalizer (o, error);
+               mono_object_register_finalizer (o);
        return o;
 }
 
@@ -6264,7 +6300,7 @@ mono_value_box_checked (MonoDomain *domain, MonoClass *klass, gpointer value, Mo
 #endif
 #endif
        if (klass->has_finalize) {
-               mono_object_register_finalizer (res, error);
+               mono_object_register_finalizer (res);
                return_val_if_nok (error, NULL);
        }
        return res;
@@ -6505,7 +6541,8 @@ mono_object_isinst_mbyref_checked (MonoObject *obj, MonoClass *klass, MonoError
 
                if (*(MonoBoolean *) mono_object_unbox(res)) {
                        /* Update the vtable of the remote type, so it can safely cast to this new type */
-                       mono_upgrade_remote_class (domain, obj, klass);
+                       mono_upgrade_remote_class (domain, obj, klass, error);
+                       return_val_if_nok (error, NULL);
                        return obj;
                }
        }
index e36eed07e37a50b15e863bfdc8808af2cdb19f8c..0afdec6960aa7987fbb77a2c5dc26d6cb18aeb6e 100644 (file)
@@ -504,6 +504,8 @@ mono_marshal_get_remoting_invoke (MonoMethod *method)
 /* mono_marshal_xdomain_copy_out_value()
  * Copies the contents of the src instance into the dst instance. src and dst
  * must have the same type, and if they are arrays, the same size.
+ *
+ * This is an icall, it may use mono_error_set_pending_exception
  */
 static void
 mono_marshal_xdomain_copy_out_value (MonoObject *src, MonoObject *dst)
@@ -523,7 +525,8 @@ mono_marshal_xdomain_copy_out_value (MonoObject *src, MonoObject *dst)
                        for (i = 0; i < len; i++) {
                                MonoObject *item = (MonoObject *)mono_array_get ((MonoArray *)src, gpointer, i);
                                MonoObject *item_copy = mono_marshal_xdomain_copy_value (item, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               if (mono_error_set_pending_exception (&error))
+                                       return;
                                mono_array_setref ((MonoArray *)dst, i, item_copy);
                        }
                } else {
@@ -1259,7 +1262,7 @@ mono_marshal_load_remoting_wrapper (MonoRealProxy *rp, MonoMethod *method)
        else
                marshal_method = mono_marshal_get_remoting_invoke (method);
        gpointer compiled_ptr = mono_compile_method_checked (marshal_method, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       mono_error_assert_ok (&error);
        return compiled_ptr;
 }
 
@@ -1964,10 +1967,12 @@ mono_marshal_get_proxy_cancast (MonoClass *klass)
 void
 mono_upgrade_remote_class_wrapper (MonoReflectionType *rtype, MonoTransparentProxy *tproxy)
 {
+       MonoError error;
        MonoClass *klass;
        MonoDomain *domain = ((MonoObject*)tproxy)->vtable->domain;
        klass = mono_class_from_mono_type (rtype->type);
-       mono_upgrade_remote_class (domain, (MonoObject*)tproxy, klass);
+       mono_upgrade_remote_class (domain, (MonoObject*)tproxy, klass, &error);
+       mono_error_set_pending_exception (&error);
 }
 
 #else /* DISABLE_REMOTING */
index 1840ac45699797f617d7c851eecee2b8fd168825..b78ca83b28551282d59395dba3d132807871f8c8 100644 (file)
@@ -273,7 +273,7 @@ wait_callback (gint fd, gint events, gpointer user_data)
                        MonoIOSelectorJob *job = get_job_for_event (&list, EVENT_IN);
                        if (job) {
                                mono_threadpool_ms_enqueue_work_item (((MonoObject*) job)->vtable->domain, (MonoObject*) job, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               mono_error_assert_ok (&error);
                        }
 
                }
@@ -281,7 +281,7 @@ wait_callback (gint fd, gint events, gpointer user_data)
                        MonoIOSelectorJob *job = get_job_for_event (&list, EVENT_OUT);
                        if (job) {
                                mono_threadpool_ms_enqueue_work_item (((MonoObject*) job)->vtable->domain, (MonoObject*) job, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               mono_error_assert_ok (&error);
                        }
                }
 
@@ -348,7 +348,7 @@ selector_thread (gpointer data)
 
                                exists = mono_g_hash_table_lookup_extended (states, GINT_TO_POINTER (fd), &k, (gpointer*) &list);
                                list = mono_mlist_append_checked (list, (MonoObject*) job, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               mono_error_assert_ok (&error);
                                mono_g_hash_table_replace (states, GINT_TO_POINTER (fd), list);
 
                                operations = get_operations_for_jobs (list);
@@ -379,7 +379,7 @@ selector_thread (gpointer data)
 
                                        for (; list; list = mono_mlist_remove_item (list, list)) {
                                                mono_threadpool_ms_enqueue_work_item (mono_object_domain (mono_mlist_get_data (list)), mono_mlist_get_data (list), &error);
-                                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                                               mono_error_assert_ok (&error);
                                        }
 
                                        mono_trace (G_LOG_LEVEL_DEBUG, MONO_TRACE_IO_THREADPOOL, "io threadpool: del fd %3d", fd);
index 4cda0e814d52d17bb32ba12f4bc0abc5816b1a85..9e18e8c3eff9a66a2d5a06c22805a3a17e8d56ea 100644 (file)
@@ -1366,11 +1366,11 @@ mono_threadpool_ms_begin_invoke (MonoDomain *domain, MonoObject *target, MonoMet
 }
 
 MonoObject *
-mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc)
+mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc, MonoError *error)
 {
-       MonoError error;
        MonoAsyncCall *ac;
 
+       mono_error_init (error);
        g_assert (exc);
        g_assert (out_args);
 
@@ -1381,7 +1381,7 @@ mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, Mono
        mono_monitor_enter ((MonoObject*) ares);
 
        if (ares->endinvoke_called) {
-               *exc = (MonoObject*) mono_get_exception_invalid_operation (NULL);
+               mono_error_set_invalid_operation(error, "Delegate EndInvoke method called more than once");
                mono_monitor_exit ((MonoObject*) ares);
                return NULL;
        }
@@ -1398,8 +1398,11 @@ mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, Mono
                } else {
                        wait_event = CreateEvent (NULL, TRUE, FALSE, NULL);
                        g_assert(wait_event);
-                       MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, &error);
-                       mono_error_raise_exception (&error); /* FIXME don't raise here */
+                       MonoWaitHandle *wait_handle = mono_wait_handle_new (mono_object_domain (ares), wait_event, error);
+                       if (!is_ok (error)) {
+                               CloseHandle (wait_event);
+                               return NULL;
+                       }
                        MONO_OBJECT_SETREF (ares, handle, (MonoObject*) wait_handle);
                }
                mono_monitor_exit ((MonoObject*) ares);
index 9812ee57ba2a989617ac1b96f54997a3cc3c0b58..1603e3a15d998d18b152aa88eb104ec6e4ee1e03 100644 (file)
@@ -17,7 +17,7 @@ mono_threadpool_ms_cleanup (void);
 MonoAsyncResult *
 mono_threadpool_ms_begin_invoke (MonoDomain *domain, MonoObject *target, MonoMethod *method, gpointer *params, MonoError *error);
 MonoObject *
-mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc);
+mono_threadpool_ms_end_invoke (MonoAsyncResult *ares, MonoArray **out_args, MonoObject **exc, MonoError *error);
 
 gboolean
 mono_threadpool_ms_remove_domain_jobs (MonoDomain *domain, int timeout);
index 3face85f7794f472c4cb1a4e93ba1e3d05173911..68f8ec7851c3e1a13fa19f43c8aae37e285c6454 100644 (file)
@@ -193,6 +193,7 @@ MonoInternalThread *mono_thread_internal_current (void);
 void mono_thread_internal_check_for_interruption_critical (MonoInternalThread *thread);
 
 void mono_thread_internal_stop (MonoInternalThread *thread);
+void mono_thread_internal_abort (MonoInternalThread *thread);
 
 gboolean mono_thread_internal_has_appdomain_ref (MonoInternalThread *thread, MonoDomain *domain);
 
@@ -201,7 +202,7 @@ void mono_thread_internal_reset_abort (MonoInternalThread *thread);
 void mono_thread_internal_unhandled_exception (MonoObject* exc);
 
 void mono_alloc_special_static_data_free (GHashTable *special_static_fields);
-void mono_thread_current_check_pending_interrupt (void);
+gboolean mono_thread_current_check_pending_interrupt (void);
 
 void mono_thread_set_state (MonoInternalThread *thread, MonoThreadState state);
 void mono_thread_clr_state (MonoInternalThread *thread, MonoThreadState state);
@@ -247,7 +248,7 @@ gboolean
 mono_thread_create_checked (MonoDomain *domain, gpointer func, gpointer arg, MonoError *error);
 
 MonoThread *
-mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *error);
+mono_thread_attach_full (MonoDomain *domain, gboolean force_attach);
 
 void mono_thread_init_tls (void);
 
index be914f427e81390e4fbe6115fe001e12e0ca939d..cc6bbad33f8a8cf735194172a87deda93ebc1002 100644 (file)
@@ -81,15 +81,6 @@ extern int tkill (pid_t tid, int signal);
 #define LOCK_THREAD(thread) lock_thread((thread))
 #define UNLOCK_THREAD(thread) unlock_thread((thread))
 
-/* Provide this for systems with glib < 2.6 */
-#ifndef G_GSIZE_FORMAT
-#   if GLIB_SIZEOF_LONG == 8
-#       define G_GSIZE_FORMAT "lu"
-#   else
-#       define G_GSIZE_FORMAT "u"
-#   endif
-#endif
-
 typedef struct
 {
        guint32 (*func)(void *);
@@ -206,7 +197,7 @@ static void mono_init_static_data_info (StaticDataInfo *static_data);
 static guint32 mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align);
 static gboolean mono_thread_resume (MonoInternalThread* thread);
 static void async_abort_internal (MonoInternalThread *thread, gboolean install_async_abort);
-static void self_abort_internal (void);
+static void self_abort_internal (MonoError *error);
 static void async_suspend_internal (MonoInternalThread *thread, gboolean interrupt);
 static void self_suspend_internal (void);
 
@@ -583,21 +574,22 @@ set_current_thread_for_domain (MonoDomain *domain, MonoInternalThread *thread, M
 }
 
 static MonoThread*
-create_thread_object (MonoDomain *domain, MonoError *error)
+create_thread_object (MonoDomain *domain)
 {
+       MonoError error;
        MonoVTable *vt = mono_class_vtable (domain, mono_defaults.thread_class);
-       MonoThread *t = (MonoThread*)mono_object_new_mature (vt, error);
+       MonoThread *t = (MonoThread*)mono_object_new_mature (vt, &error);
+       /* only possible failure mode is OOM, from which we don't expect to recover. */
+       mono_error_assert_ok (&error);
        return t;
 }
 
 static MonoThread*
-new_thread_with_internal (MonoDomain *domain, MonoInternalThread *internal, MonoError *error)
+new_thread_with_internal (MonoDomain *domain, MonoInternalThread *internal)
 {
        MonoThread *thread;
 
-       thread = create_thread_object (domain, error);
-       if (!mono_error_ok (error))
-               return NULL;
+       thread = create_thread_object (domain);
 
        MONO_OBJECT_SETREF (thread, internal_thread, internal);
 
@@ -605,15 +597,16 @@ new_thread_with_internal (MonoDomain *domain, MonoInternalThread *internal, Mono
 }
 
 static MonoInternalThread*
-create_internal_thread (MonoError *error)
+create_internal_thread (void)
 {
+       MonoError error;
        MonoInternalThread *thread;
        MonoVTable *vt;
 
        vt = mono_class_vtable (mono_get_root_domain (), mono_defaults.internal_thread_class);
-       thread = (MonoInternalThread*) mono_object_new_mature (vt, error);
-       if (!mono_error_ok (error))
-               return NULL;
+       thread = (MonoInternalThread*) mono_object_new_mature (vt, &error);
+       /* only possible failure mode is OOM, from which we don't exect to recover */
+       mono_error_assert_ok (&error);
 
        thread->synch_cs = g_new0 (MonoCoopMutex, 1);
        mono_coop_mutex_init_recursive (thread->synch_cs);
@@ -629,14 +622,12 @@ create_internal_thread (MonoError *error)
 }
 
 static gboolean
-init_root_domain_thread (MonoInternalThread *thread, MonoThread *candidate, MonoError *error)
+init_root_domain_thread (MonoInternalThread *thread, MonoThread *candidate)
 {
        MonoDomain *domain = mono_get_root_domain ();
 
-       mono_error_init (error);
        if (!candidate || candidate->obj.vtable->domain != domain) {
-               candidate = new_thread_with_internal (domain, thread, error);
-               return_val_if_nok (error, FALSE);
+               candidate = new_thread_with_internal (domain, thread);
        }
        set_current_thread_for_domain (domain, thread, candidate);
        g_assert (!thread->root_domain_thread);
@@ -695,8 +686,7 @@ static guint32 WINAPI start_wrapper_internal(void *data)
        /* We have to do this here because mono_thread_new_init()
           requires that root_domain_thread is set up. */
        thread_adjust_static_data (internal);
-       init_root_domain_thread (internal, start_info->obj, &error);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       init_root_domain_thread (internal, start_info->obj);
 
        /* This MUST be called before any managed code can be
         * executed, as it calls the callback function that (for the
@@ -936,11 +926,9 @@ mono_thread_create_internal (MonoDomain *domain, gpointer func, gpointer arg, gb
 
        mono_error_init (error);
 
-       thread = create_thread_object (domain, error);
-       return_val_if_nok (error, NULL);
+       thread = create_thread_object (domain);
 
-       internal = create_internal_thread (error);
-       return_val_if_nok (error, NULL);
+       internal = create_internal_thread ();
 
        MONO_OBJECT_SETREF (thread, internal_thread, internal);
 
@@ -978,15 +966,13 @@ mono_thread_create_checked (MonoDomain *domain, gpointer func, gpointer arg, Mon
 MonoThread *
 mono_thread_attach (MonoDomain *domain)
 {
-       MonoError error;
-       MonoThread *thread = mono_thread_attach_full (domain, FALSE, &error);
-       mono_error_raise_exception (&error);
+       MonoThread *thread = mono_thread_attach_full (domain, FALSE);
 
        return thread;
 }
 
 MonoThread *
-mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *error)
+mono_thread_attach_full (MonoDomain *domain, gboolean force_attach)
 {
        MonoThreadInfo *info;
        MonoInternalThread *thread;
@@ -994,8 +980,6 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *e
        HANDLE thread_handle;
        MonoNativeThreadId tid;
 
-       mono_error_init (error);
-
        if ((thread = mono_thread_internal_current ())) {
                if (domain != mono_domain_get ())
                        mono_domain_set (domain, TRUE);
@@ -1007,9 +991,7 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *e
                g_error ("Thread %"G_GSIZE_FORMAT" calling into managed code is not registered with the GC. On UNIX, this can be fixed by #include-ing <gc.h> before <pthread.h> in the file containing the thread creation code.", mono_native_thread_id_get ());
        }
 
-       thread = create_internal_thread (error);
-       if (!mono_error_ok (error))
-               return NULL;
+       thread = create_internal_thread ();
 
        thread_handle = mono_thread_info_open_handle ();
        g_assert (thread_handle);
@@ -1027,9 +1009,7 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *e
        thread->thread_info = info;
        thread->small_id = info->small_id;
 
-       current_thread = new_thread_with_internal (domain, thread, error);
-       if (!mono_error_ok (error))
-               return NULL;
+       current_thread = new_thread_with_internal (domain, thread);
 
        if (!handle_store (current_thread, force_attach)) {
                /* Mono is shutting down, so just wait for the end */
@@ -1044,8 +1024,7 @@ mono_thread_attach_full (MonoDomain *domain, gboolean force_attach, MonoError *e
 
        thread_adjust_static_data (thread);
 
-       init_root_domain_thread (thread, current_thread, error);
-       return_val_if_nok (error, NULL);
+       init_root_domain_thread (thread, current_thread);
 
        if (domain != mono_get_root_domain ())
                set_current_thread_for_domain (domain, thread, current_thread);
@@ -1137,12 +1116,9 @@ mono_thread_exit ()
 void
 ves_icall_System_Threading_Thread_ConstructInternalThread (MonoThread *this_obj)
 {
-       MonoError error;
        MonoInternalThread *internal;
 
-       internal = create_internal_thread (&error);
-       if (mono_error_set_pending_exception (&error))
-               return;
+       internal = create_internal_thread ();
 
        internal->state = ThreadState_Unstarted;
 
@@ -1237,7 +1213,8 @@ ves_icall_System_Threading_Thread_Sleep_internal(gint32 ms)
 
        THREAD_DEBUG (g_message ("%s: Sleeping for %d ms", __func__, ms));
 
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return;
 
        while (TRUE) {
                gboolean alerted = FALSE;
@@ -1500,7 +1477,6 @@ ves_icall_System_Threading_Thread_ByteArrayToCurrentDomain (MonoArray *arr)
 MonoThread *
 mono_thread_current (void)
 {
-       MonoError error;
        MonoDomain *domain = mono_domain_get ();
        MonoInternalThread *internal = mono_thread_internal_current ();
        MonoThread **current_thread_ptr;
@@ -1510,8 +1486,7 @@ mono_thread_current (void)
 
        if (!*current_thread_ptr) {
                g_assert (domain != mono_get_root_domain ());
-               *current_thread_ptr = new_thread_with_internal (domain, internal, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
+               *current_thread_ptr = new_thread_with_internal (domain, internal);
        }
        return *current_thread_ptr;
 }
@@ -1520,7 +1495,6 @@ mono_thread_current (void)
 static MonoThread *
 mono_thread_current_for_thread (MonoInternalThread *internal)
 {
-       MonoError error;
        MonoDomain *domain = mono_domain_get ();
        MonoThread **current_thread_ptr;
 
@@ -1529,8 +1503,7 @@ mono_thread_current_for_thread (MonoInternalThread *internal)
 
        if (!*current_thread_ptr) {
                g_assert (domain != mono_get_root_domain ());
-               *current_thread_ptr = new_thread_with_internal (domain, internal, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
+               *current_thread_ptr = new_thread_with_internal (domain, internal);
        }
        return *current_thread_ptr;
 }
@@ -1551,7 +1524,8 @@ ves_icall_System_Threading_Thread_Join_internal(MonoThread *this_obj, int ms)
        MonoInternalThread *cur_thread = mono_thread_internal_current ();
        gboolean ret;
 
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return FALSE;
 
        LOCK_THREAD (thread);
        
@@ -1588,8 +1562,17 @@ ves_icall_System_Threading_Thread_Join_internal(MonoThread *this_obj, int ms)
        return(FALSE);
 }
 
+#define MANAGED_WAIT_FAILED 0x7fffffff
+
 static gint32
-mono_wait_uninterrupted (MonoInternalThread *thread, gboolean multiple, guint32 numhandles, gpointer *handles, gboolean waitall, gint32 ms, gboolean alertable)
+map_native_wait_result_to_managed (gint32 val)
+{
+       /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
+       return val == WAIT_FAILED ? MANAGED_WAIT_FAILED : val;
+}
+
+static gint32
+mono_wait_uninterrupted (MonoInternalThread *thread, guint32 numhandles, gpointer *handles, gboolean waitall, gint32 ms, MonoError *error)
 {
        MonoException *exc;
        guint32 ret;
@@ -1597,21 +1580,25 @@ mono_wait_uninterrupted (MonoInternalThread *thread, gboolean multiple, guint32
        gint32 diff_ms;
        gint32 wait = ms;
 
+       mono_error_init (error);
+
        start = (ms == -1) ? 0 : mono_100ns_ticks ();
        do {
                MONO_ENTER_GC_SAFE;
-                       if (multiple)
-                       ret = WaitForMultipleObjectsEx (numhandles, handles, waitall, wait, alertable);
+               if (numhandles != 1)
+                       ret = WaitForMultipleObjectsEx (numhandles, handles, waitall, wait, TRUE);
                else
-                       ret = WaitForSingleObjectEx (handles [0], ms, alertable);
+                       ret = WaitForSingleObjectEx (handles [0], ms, TRUE);
                MONO_EXIT_GC_SAFE;
 
                if (ret != WAIT_IO_COMPLETION)
                        break;
 
                exc = mono_thread_execute_interruption ();
-               if (exc)
-                       mono_raise_exception (exc);
+               if (exc) {
+                       mono_error_set_exception_instance (error, exc);
+                       break;
+               }
 
                if (ms == -1)
                        continue;
@@ -1630,6 +1617,7 @@ mono_wait_uninterrupted (MonoInternalThread *thread, gboolean multiple, guint32
 
 gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms)
 {
+       MonoError error;
        HANDLE *handles;
        guint32 numhandles;
        guint32 ret;
@@ -1638,7 +1626,8 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_ha
        MonoInternalThread *thread = mono_thread_internal_current ();
 
        /* Do this WaitSleepJoin check before creating objects */
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return map_native_wait_result_to_managed (WAIT_FAILED);
 
        /* We fail in managed if the array has more than 64 elements */
        numhandles = (guint32)mono_array_length(mono_handles);
@@ -1654,19 +1643,22 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_ha
        }
 
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
-       
-       ret = mono_wait_uninterrupted (thread, TRUE, numhandles, handles, TRUE, ms, TRUE);
+
+       ret = mono_wait_uninterrupted (thread, numhandles, handles, TRUE, ms, &error);
 
        mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
 
        g_free(handles);
 
+       mono_error_set_pending_exception (&error);
+
        /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
-       return ret == WAIT_FAILED ? 0x7fffffff : ret;
+       return map_native_wait_result_to_managed (ret);
 }
 
 gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_handles, gint32 ms)
 {
+       MonoError error;
        HANDLE handles [MAXIMUM_WAIT_OBJECTS];
        uintptr_t numhandles;
        guint32 ret;
@@ -1675,11 +1667,12 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
        MonoInternalThread *thread = mono_thread_internal_current ();
 
        /* Do this WaitSleepJoin check before creating objects */
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return map_native_wait_result_to_managed (WAIT_FAILED);
 
        numhandles = mono_array_length(mono_handles);
        if (numhandles > MAXIMUM_WAIT_OBJECTS)
-               return WAIT_FAILED;
+               return map_native_wait_result_to_managed (WAIT_FAILED);
 
        for(i = 0; i < numhandles; i++) {       
                waitHandle = mono_array_get(mono_handles, MonoObject*, i);
@@ -1692,29 +1685,31 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitAny_internal(MonoArray *mono_ha
 
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
 
-       ret = mono_wait_uninterrupted (thread, TRUE, numhandles, handles, FALSE, ms, TRUE);
+       ret = mono_wait_uninterrupted (thread, numhandles, handles, FALSE, ms, &error);
 
        mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
 
        THREAD_WAIT_DEBUG (g_message ("%s: (%"G_GSIZE_FORMAT") returning %d", __func__, mono_native_thread_id_get (), ret));
 
+       mono_error_set_pending_exception (&error);
        /*
         * These need to be here.  See MSDN dos on WaitForMultipleObjects.
         */
        if (ret >= WAIT_OBJECT_0 && ret <= WAIT_OBJECT_0 + numhandles - 1) {
-               return ret - WAIT_OBJECT_0;
+               return map_native_wait_result_to_managed (ret - WAIT_OBJECT_0);
        }
        else if (ret >= WAIT_ABANDONED_0 && ret <= WAIT_ABANDONED_0 + numhandles - 1) {
-               return ret - WAIT_ABANDONED_0;
+               return map_native_wait_result_to_managed (ret - WAIT_ABANDONED_0);
        }
        else {
                /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
-               return ret == WAIT_FAILED ? 0x7fffffff : ret;
+               return map_native_wait_result_to_managed (ret);
        }
 }
 
 gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gint32 ms)
 {
+       MonoError error;
        guint32 ret;
        MonoInternalThread *thread = mono_thread_internal_current ();
 
@@ -1724,16 +1719,17 @@ gint32 ves_icall_System_Threading_WaitHandle_WaitOne_internal(HANDLE handle, gin
                ms=INFINITE;
        }
        
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return map_native_wait_result_to_managed (WAIT_FAILED);
 
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
        
-       ret = mono_wait_uninterrupted (thread, FALSE, 1, &handle, FALSE, ms, TRUE);
+       ret = mono_wait_uninterrupted (thread, 1, &handle, FALSE, ms, &error);
        
        mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
-       
-       /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
-       return ret == WAIT_FAILED ? 0x7fffffff : ret;
+
+       mono_error_set_pending_exception (&error);
+       return map_native_wait_result_to_managed (ret);
 }
 
 gint32
@@ -1745,7 +1741,8 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, H
        if (ms == -1)
                ms = INFINITE;
 
-       mono_thread_current_check_pending_interrupt ();
+       if (mono_thread_current_check_pending_interrupt ())
+               return map_native_wait_result_to_managed (WAIT_FAILED);
 
        mono_thread_set_state (thread, ThreadState_WaitSleepJoin);
        
@@ -1755,8 +1752,7 @@ ves_icall_System_Threading_WaitHandle_SignalAndWait_Internal (HANDLE toSignal, H
        
        mono_thread_clr_state (thread, ThreadState_WaitSleepJoin);
 
-       /* WAIT_FAILED in waithandle.cs is different from WAIT_FAILED in Win32 API */
-       return ret == WAIT_FAILED ? 0x7fffffff : ret;
+       return map_native_wait_result_to_managed (ret);
 }
 
 HANDLE ves_icall_System_Threading_Mutex_CreateMutex_internal (MonoBoolean owned, MonoString *name, MonoBoolean *created)
@@ -2187,7 +2183,15 @@ void ves_icall_System_Threading_Thread_Interrupt_internal (MonoThread *this_obj)
        }
 }
 
-void mono_thread_current_check_pending_interrupt ()
+/**
+ * mono_thread_current_check_pending_interrupt:
+ *
+ * Checks if there's a interruption request and set the pending exception if so.
+ *
+ * @returns true if a pending exception was set
+ */
+gboolean
+mono_thread_current_check_pending_interrupt (void)
 {
        MonoInternalThread *thread = mono_thread_internal_current ();
        gboolean throw_ = FALSE;
@@ -2201,13 +2205,13 @@ void mono_thread_current_check_pending_interrupt ()
        
        UNLOCK_THREAD (thread);
 
-       if (throw_) {
-               mono_raise_exception (mono_get_exception_thread_interrupted ());
-       }
+       if (throw_)
+               mono_set_pending_exception (mono_get_exception_thread_interrupted ());
+       return throw_;
 }
 
-void
-ves_icall_System_Threading_Thread_Abort (MonoInternalThread *thread, MonoObject *state)
+static gboolean
+request_thread_abort (MonoInternalThread *thread, MonoObject *state)
 {
        LOCK_THREAD (thread);
        
@@ -2216,13 +2220,13 @@ ves_icall_System_Threading_Thread_Abort (MonoInternalThread *thread, MonoObject
                (thread->state & ThreadState_Stopped) != 0)
        {
                UNLOCK_THREAD (thread);
-               return;
+               return FALSE;
        }
 
        if ((thread->state & ThreadState_Unstarted) != 0) {
                thread->state |= ThreadState_Aborted;
                UNLOCK_THREAD (thread);
-               return;
+               return FALSE;
        }
 
        thread->state |= ThreadState_AbortRequested;
@@ -2244,11 +2248,39 @@ ves_icall_System_Threading_Thread_Abort (MonoInternalThread *thread, MonoObject
                mono_thread_resume (thread);
 
        UNLOCK_THREAD (thread);
+       return TRUE;
+}
 
-       if (thread == mono_thread_internal_current ())
-               self_abort_internal ();
-       else
+void
+ves_icall_System_Threading_Thread_Abort (MonoInternalThread *thread, MonoObject *state)
+{
+       if (!request_thread_abort (thread, state))
+               return;
+
+       if (thread == mono_thread_internal_current ()) {
+               MonoError error;
+               self_abort_internal (&error);
+               mono_error_set_pending_exception (&error);
+       } else {
                async_abort_internal (thread, TRUE);
+       }
+}
+
+/**
+ * mono_thread_internal_abort:
+ *
+ * Request thread @thread to be aborted.
+ *
+ * @thread MUST NOT be the current thread.
+ */
+void
+mono_thread_internal_abort (MonoInternalThread *thread)
+{
+       g_assert (thread != mono_thread_internal_current ());
+
+       if (!request_thread_abort (thread, NULL))
+               return;
+       async_abort_internal (thread, TRUE);
 }
 
 void
@@ -2448,7 +2480,8 @@ is_running_protected_wrapper (void)
        return found;
 }
 
-void mono_thread_internal_stop (MonoInternalThread *thread)
+static gboolean
+request_thread_stop (MonoInternalThread *thread)
 {
        LOCK_THREAD (thread);
 
@@ -2456,7 +2489,7 @@ void mono_thread_internal_stop (MonoInternalThread *thread)
                (thread->state & ThreadState_Stopped) != 0)
        {
                UNLOCK_THREAD (thread);
-               return;
+               return FALSE;
        }
        
        /* Make sure the thread is awake */
@@ -2466,16 +2499,45 @@ void mono_thread_internal_stop (MonoInternalThread *thread)
        thread->state &= ~ThreadState_AbortRequested;
        
        UNLOCK_THREAD (thread);
+       return TRUE;
+}
+
+/**
+ * mono_thread_internal_stop:
+ *
+ * Request thread @thread to stop.
+ *
+ * @thread MUST NOT be the current thread.
+ */
+void
+mono_thread_internal_stop (MonoInternalThread *thread)
+{
+       g_assert (thread != mono_thread_internal_current ());
+
+       if (!request_thread_stop (thread))
+               return;
        
-       if (thread == mono_thread_internal_current ())
-               self_abort_internal ();
-       else
-               async_abort_internal (thread, TRUE);
+       async_abort_internal (thread, TRUE);
 }
 
 void mono_thread_stop (MonoThread *thread)
 {
-       mono_thread_internal_stop (thread->internal_thread);
+       MonoInternalThread *internal = thread->internal_thread;
+
+       if (!request_thread_stop (internal))
+               return;
+       
+       if (internal == mono_thread_internal_current ()) {
+               MonoError error;
+               self_abort_internal (&error);
+               /*
+               This function is part of the embeding API and has no way to return the exception
+               to be thrown. So what we do is keep the old behavior and raise the exception.
+               */
+               mono_error_raise_exception (&error);
+       } else {
+               async_abort_internal (internal, TRUE);
+       }
 }
 
 gint8
@@ -3534,10 +3596,9 @@ mono_threads_perform_thread_dump (void)
 }
 
 /* Obtain the thread dump of all threads */
-static void
-mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_frames)
+static gboolean
+mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_frames, MonoError *error)
 {
-       MonoError error;
 
        ThreadDumpUserData ud;
        MonoInternalThread *thread_array [128];
@@ -3545,7 +3606,7 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra
        MonoDebugSourceLocation *location;
        int tindex, nthreads;
 
-       mono_error_init (&error);
+       mono_error_init (error);
        
        *out_threads = NULL;
        *out_stack_frames = NULL;
@@ -3557,11 +3618,11 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra
        ud.frames = g_new0 (MonoStackFrameInfo, 256);
        ud.max_frames = 256;
 
-       *out_threads = mono_array_new_checked (domain, mono_defaults.thread_class, nthreads, &error);
-       if (!is_ok (&error))
+       *out_threads = mono_array_new_checked (domain, mono_defaults.thread_class, nthreads, error);
+       if (!is_ok (error))
                goto leave;
-       *out_stack_frames = mono_array_new_checked (domain, mono_defaults.array_class, nthreads, &error);
-       if (!is_ok (&error))
+       *out_stack_frames = mono_array_new_checked (domain, mono_defaults.array_class, nthreads, error);
+       if (!is_ok (error))
                goto leave;
 
        for (tindex = 0; tindex < nthreads; ++tindex) {
@@ -3581,16 +3642,16 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra
 
                mono_array_setref_fast (*out_threads, tindex, mono_thread_current_for_thread (thread));
 
-               thread_frames = mono_array_new_checked (domain, mono_defaults.stack_frame_class, ud.nframes, &error);
-               if (!is_ok (&error))
+               thread_frames = mono_array_new_checked (domain, mono_defaults.stack_frame_class, ud.nframes, error);
+               if (!is_ok (error))
                        goto leave;
                mono_array_setref_fast (*out_stack_frames, tindex, thread_frames);
 
                for (i = 0; i < ud.nframes; ++i) {
                        MonoStackFrameInfo *frame = &ud.frames [i];
                        MonoMethod *method = NULL;
-                       MonoStackFrame *sf = (MonoStackFrame *)mono_object_new_checked (domain, mono_defaults.stack_frame_class, &error);
-                       if (!mono_error_ok (&error))
+                       MonoStackFrame *sf = (MonoStackFrame *)mono_object_new_checked (domain, mono_defaults.stack_frame_class, error);
+                       if (!is_ok (error))
                                goto leave;
 
                        sf->native_offset = frame->native_offset;
@@ -3601,8 +3662,9 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra
                        if (method) {
                                sf->method_address = (gsize) frame->ji->code_start;
 
-                               MonoReflectionMethod *rm = mono_method_get_object_checked (domain, method, NULL, &error);
-                               mono_error_raise_exception (&error); /* FIXME don't raise here */
+                               MonoReflectionMethod *rm = mono_method_get_object_checked (domain, method, NULL, error);
+                               if (!is_ok (error))
+                                       goto leave;
                                MONO_OBJECT_SETREF (sf, method, rm);
 
                                location = mono_debug_lookup_source_location (method, frame->native_offset, domain);
@@ -3625,7 +3687,7 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra
 
 leave:
        g_free (ud.frames);
-       mono_error_raise_exception (&error); /* FIXME don't raise here */
+       return is_ok (error);
 }
 
 /**
@@ -3823,7 +3885,7 @@ mono_threads_abort_appdomain_threads (MonoDomain *domain, int timeout)
                if (user_data.wait.num > 0) {
                        /* Abort the threads outside the threads lock */
                        for (i = 0; i < user_data.wait.num; ++i)
-                               ves_icall_System_Threading_Thread_Abort (user_data.wait.threads [i], NULL);
+                               mono_thread_internal_abort (user_data.wait.threads [i]);
 
                        /*
                         * We should wait for the threads either to abort, or to leave the
@@ -4341,17 +4403,6 @@ mono_alloc_special_static_data_free (GHashTable *special_static_fields)
        mono_threads_unlock ();
 }
 
-static void
-mono_special_static_data_free_slot (guint32 offset, guint32 size)
-{
-       /* Only ever called for ThreadLocal instances */
-       g_assert (ACCESS_SPECIAL_STATIC_OFFSET (offset, type) == SPECIAL_STATIC_OFFSET_TYPE_THREAD);
-
-       mono_threads_lock ();
-       do_free_special_slot (offset, size);
-       mono_threads_unlock ();
-}
-
 #ifdef HOST_WIN32
 static void CALLBACK dummy_apc (ULONG_PTR param)
 {
@@ -4780,18 +4831,20 @@ async_abort_internal (MonoInternalThread *thread, gboolean install_async_abort)
 }
 
 static void
-self_abort_internal (void)
+self_abort_internal (MonoError *error)
 {
        MonoException *exc;
 
+       mono_error_init (error);
+
        /* FIXME this is insanely broken, it doesn't cause interruption to happen synchronously
         * since passing FALSE to mono_thread_request_interruption makes sure it returns NULL */
 
        exc = mono_thread_request_interruption (TRUE);
        if (exc)
-               mono_raise_exception (exc);
-
-       mono_thread_info_self_interrupt ();
+               mono_error_set_exception_instance (error, exc);
+       else
+               mono_thread_info_self_interrupt ();
 }
 
 typedef struct {
@@ -5014,7 +5067,9 @@ mono_thread_internal_unhandled_exception (MonoObject* exc)
 void
 ves_icall_System_Threading_Thread_GetStackTraces (MonoArray **out_threads, MonoArray **out_stack_traces)
 {
-       mono_threads_get_thread_dump (out_threads, out_stack_traces);
+       MonoError error;
+       mono_threads_get_thread_dump (out_threads, out_stack_traces, &error);
+       mono_error_set_pending_exception (&error);
 }
 
 /*
@@ -5031,7 +5086,6 @@ ves_icall_System_Threading_Thread_GetStackTraces (MonoArray **out_threads, MonoA
 gpointer
 mono_threads_attach_coop (MonoDomain *domain, gpointer *dummy)
 {
-       MonoError error;
        MonoDomain *orig;
        gboolean fresh_thread;
 
@@ -5052,8 +5106,7 @@ mono_threads_attach_coop (MonoDomain *domain, gpointer *dummy)
        }
 
        if (!mono_thread_internal_current ()) {
-               mono_thread_attach_full (domain, FALSE, &error);
-               mono_error_assert_ok (&error);
+               mono_thread_attach_full (domain, FALSE);
 
                // #678164
                mono_thread_set_state (mono_thread_internal_current (), ThreadState_Background);
index 5a0c79c7cca732b1ffeff80292a6ad943d1114e5..b72072f3246ca5e69329de13afb80229699d5699 100644 (file)
@@ -30,7 +30,7 @@ extern MONO_API MonoThread *mono_thread_current (void);
 extern MONO_API void        mono_thread_set_main (MonoThread *thread);
 extern MONO_API MonoThread *mono_thread_get_main (void);
 
-extern MONO_API void mono_thread_stop (MonoThread *thread);
+extern MONO_RT_EXTERNAL_ONLY MONO_API void mono_thread_stop (MonoThread *thread);
 
 extern MONO_API void mono_thread_new_init (intptr_t tid, void* stack_start,
                                  void* func);
index 7099579a80c67359b63b32a82a427629cd9b82f4..a2fe45610180ce45a684bc2640412d090339bda5 100755 (executable)
@@ -49,7 +49,7 @@ MINI_RUNTIME = MONO_PATH=$(CLASS) $(RUNTIME_EXECUTABLE)
 RUNTIME_AOTCHECK = MONO_PATH="$(CLASS)$(PLATFORM_PATH_SEPARATOR)." $(RUNTIME_EXECUTABLE)
 
 CSC = $(mcs_topdir)/class/lib/build/mcs.exe
-MCS = CSC_SDK_PATH_DISABLED= $(MINI_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll
+MCS = CSC_SDK_PATH_DISABLED= $(MINI_RUNTIME) $(CSC) -unsafe -nowarn:0162 -nologo -noconfig -r:$(CLASS)/mscorlib.dll -r:$(CLASS)/System.dll -r:$(CLASS)/System.Core.dll
 ILASM = $(MINI_RUNTIME) $(CLASS)/ilasm.exe
 
 AM_CFLAGS = \
index 2078e8ef8543dc8da7291bd9306b1f8021552522..2ebae1f232242f94400f0dba9350a546e639be73 100644 (file)
@@ -2400,9 +2400,8 @@ decode_cached_class_info (MonoAotModule *module, MonoCachedClassInfo *info, guin
 }      
 
 gpointer
-mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot)
+mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot, MonoError *error)
 {
-       MonoError error;
        int i;
        MonoClass *klass = vtable->klass;
        MonoAotModule *amodule = (MonoAotModule *)klass->image->aot_module;
@@ -2412,6 +2411,8 @@ mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int sl
        MethodRef ref;
        gboolean res;
 
+       mono_error_init (error);
+
        if (MONO_CLASS_IS_INTERFACE (klass) || klass->rank || !amodule)
                return NULL;
 
@@ -2423,12 +2424,12 @@ mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int sl
                return NULL;
 
        for (i = 0; i < slot; ++i) {
-               decode_method_ref (amodule, &ref, p, &p, &error);
-               mono_error_cleanup (&error); /* FIXME don't swallow the error */
+               decode_method_ref (amodule, &ref, p, &p, error);
+               mono_error_cleanup (error); /* FIXME don't swallow the error */
        }
 
-       res = decode_method_ref (amodule, &ref, p, &p, &error);
-       mono_error_cleanup (&error); /* FIXME don't swallow the error */
+       res = decode_method_ref (amodule, &ref, p, &p, error);
+       mono_error_cleanup (error); /* FIXME don't swallow the error */
        if (!res)
                return NULL;
        if (ref.no_aot_trampoline)
@@ -2437,7 +2438,7 @@ mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int sl
        if (mono_metadata_token_index (ref.token) == 0 || mono_metadata_token_table (ref.token) != MONO_TABLE_METHOD)
                return NULL;
 
-       return mono_aot_get_method_from_token (domain, ref.image, ref.token);
+       return mono_aot_get_method_from_token (domain, ref.image, ref.token, error);
 }
 
 gboolean
@@ -4254,28 +4255,36 @@ init_method (MonoAotModule *amodule, guint32 method_index, MonoMethod *method, M
        return FALSE;
 }
 
-void
-mono_aot_init_llvm_method (gpointer aot_module, guint32 method_index)
+static void
+init_llvmonly_method (MonoAotModule *amodule, guint32 method_index, MonoMethod *method, MonoClass *init_class, MonoGenericContext *context)
 {
-       MonoAotModule *amodule = (MonoAotModule *)aot_module;
        gboolean res;
        MonoError error;
 
-       res = init_method (amodule, method_index, NULL, NULL, NULL, &error);
-       // FIXME: Pass the exception up to the caller ?
+       res = init_method (amodule, method_index, method, init_class, context, &error);
        /* Its okay to raise in llvmonly mode */
-       mono_error_raise_exception (&error);
+       if (!is_ok (&error)) {
+               MonoException *ex = mono_error_convert_to_exception (&error);
+               if (ex)
+                       mono_llvm_throw_exception ((MonoObject*)ex);
+       }
+}
+
+void
+mono_aot_init_llvm_method (gpointer aot_module, guint32 method_index)
+{
+       MonoAotModule *amodule = (MonoAotModule *)aot_module;
+
+       init_llvmonly_method (amodule, method_index, NULL, NULL, NULL);
 }
 
 void
 mono_aot_init_gshared_method_this (gpointer aot_module, guint32 method_index, MonoObject *this_obj)
 {
        MonoAotModule *amodule = (MonoAotModule *)aot_module;
-       gboolean res;
        MonoClass *klass;
        MonoGenericContext *context;
        MonoMethod *method;
-       MonoError error;
 
        // FIXME:
        g_assert (this_obj);
@@ -4289,19 +4298,15 @@ mono_aot_init_gshared_method_this (gpointer aot_module, guint32 method_index, Mo
        context = mono_method_get_context (method);
        g_assert (context);
 
-       res = init_method (amodule, method_index, NULL, klass, context, &error);
-       /* Its okay to raise in llvmonly mode */
-       mono_error_raise_exception (&error);
+       init_llvmonly_method (amodule, method_index, NULL, klass, context);
 }
 
 void
 mono_aot_init_gshared_method_mrgctx (gpointer aot_module, guint32 method_index, MonoMethodRuntimeGenericContext *rgctx)
 {
        MonoAotModule *amodule = (MonoAotModule *)aot_module;
-       gboolean res;
        MonoGenericContext context = { NULL, NULL };
        MonoClass *klass = rgctx->class_vtable->klass;
-       MonoError error;
 
        if (klass->generic_class)
                context.class_inst = klass->generic_class->context.class_inst;
@@ -4309,20 +4314,16 @@ mono_aot_init_gshared_method_mrgctx (gpointer aot_module, guint32 method_index,
                context.class_inst = klass->generic_container->context.class_inst;
        context.method_inst = rgctx->method_inst;
 
-       res = init_method (amodule, method_index, NULL, rgctx->class_vtable->klass, &context, &error);
-       /* Its okay to raise in llvmonly mode */
-       mono_error_raise_exception (&error);
+       init_llvmonly_method (amodule, method_index, NULL, rgctx->class_vtable->klass, &context);
 }
 
 void
 mono_aot_init_gshared_method_vtable (gpointer aot_module, guint32 method_index, MonoVTable *vtable)
 {
        MonoAotModule *amodule = (MonoAotModule *)aot_module;
-       gboolean res;
        MonoClass *klass;
        MonoGenericContext *context;
        MonoMethod *method;
-       MonoError error;
 
        klass = vtable->klass;
 
@@ -4334,9 +4335,7 @@ mono_aot_init_gshared_method_vtable (gpointer aot_module, guint32 method_index,
        context = mono_method_get_context (method);
        g_assert (context);
 
-       res = init_method (amodule, method_index, NULL, klass, context, &error);
-       /* Its okay to raise in llvmonly mode */
-       mono_error_raise_exception (&error);
+       init_llvmonly_method (amodule, method_index, NULL, klass, context);
 }
 
 /*
@@ -4389,7 +4388,7 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
         * remoting.
         */
        if (mono_aot_only && method->wrapper_type == MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK)
-               return mono_aot_get_method (domain, mono_marshal_method_from_wrapper (method));
+               return mono_aot_get_method_checked (domain, mono_marshal_method_from_wrapper (method), error);
 
        g_assert (klass->inited);
 
@@ -4429,9 +4428,11 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                if (method_index == 0xffffff && method->wrapper_type == MONO_WRAPPER_MANAGED_TO_MANAGED && method->klass->rank && strstr (method->name, "System.Collections.Generic")) {
                        MonoMethod *m = mono_aot_get_array_helper_from_wrapper (method);
 
-                       code = (guint8 *)mono_aot_get_method (domain, m);
+                       code = (guint8 *)mono_aot_get_method_checked (domain, m, error);
                        if (code)
                                return code;
+                       if (!is_ok (error))
+                               return NULL;
                }
 
                /*
@@ -4440,7 +4441,6 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                 * an out parameter, so the managed-to-native wrappers can share the same code.
                 */
                if (method_index == 0xffffff && method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE && method->klass == mono_defaults.array_class && !strcmp (method->name, "GetGenericValueImpl")) {
-                       MonoError error;
                        MonoMethod *m;
                        MonoGenericContext ctx;
                        MonoType *args [16];
@@ -4456,17 +4456,19 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                        args [0] = &mono_defaults.object_class->byval_arg;
                        ctx.method_inst = mono_metadata_get_generic_inst (1, args);
 
-                       m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, &error), TRUE, TRUE);
+                       m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, error), TRUE, TRUE);
                        if (!m)
-                               g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+                               g_error ("AOT runtime could not load method due to %s", mono_error_get_message (error)); /* FIXME don't swallow the error */
 
                        /* 
                         * Get the code for the <object> instantiation which should be emitted into
                         * the mscorlib aot image by the AOT compiler.
                         */
-                       code = (guint8 *)mono_aot_get_method (domain, m);
+                       code = (guint8 *)mono_aot_get_method_checked (domain, m, error);
                        if (code)
                                return code;
+                       if (!is_ok (error))
+                               return NULL;
                }
 
                /* Same for CompareExchange<T> and Exchange<T> */
@@ -4475,7 +4477,6 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                        ((!strcmp (method->klass->name_space, "System.Threading") && !strcmp (method->klass->name, "Interlocked") && (!strcmp (method->name, "CompareExchange") || !strcmp (method->name, "Exchange")) && MONO_TYPE_IS_REFERENCE (mini_type_get_underlying_type (mono_method_signature (method)->params [1]))) ||
                         (!strcmp (method->klass->name_space, "System.Threading") && !strcmp (method->klass->name, "Volatile") && (!strcmp (method->name, "Read") && MONO_TYPE_IS_REFERENCE (mini_type_get_underlying_type (mono_method_signature (method)->ret)))) ||
                         (!strcmp (method->klass->name_space, "System.Threading") && !strcmp (method->klass->name, "Volatile") && (!strcmp (method->name, "Write") && MONO_TYPE_IS_REFERENCE (mini_type_get_underlying_type (mono_method_signature (method)->params [1])))))) {
-                       MonoError error;
                        MonoMethod *m;
                        MonoGenericContext ctx;
                        MonoType *args [16];
@@ -4491,9 +4492,9 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                        args [0] = &mono_defaults.object_class->byval_arg;
                        ctx.method_inst = mono_metadata_get_generic_inst (1, args);
 
-                       m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, &error), TRUE, TRUE);
+                       m = mono_marshal_get_native_wrapper (mono_class_inflate_generic_method_checked (m, &ctx, error), TRUE, TRUE);
                        if (!m)
-                               g_error ("AOT runtime could not load method due to %s", mono_error_get_message (&error)); /* FIXME don't swallow the error */
+                               g_error ("AOT runtime could not load method due to %s", mono_error_get_message (error)); /* FIXME don't swallow the error */
 
                        /* Avoid recursion */
                        if (method == m)
@@ -4503,9 +4504,11 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
                         * Get the code for the <object> instantiation which should be emitted into
                         * the mscorlib aot image by the AOT compiler.
                         */
-                       code = (guint8 *)mono_aot_get_method (domain, m);
+                       code = (guint8 *)mono_aot_get_method_checked (domain, m, error);
                        if (code)
                                return code;
+                       if (!is_ok (error))
+                               return NULL;
                }
 
                /* For ARRAY_ACCESSOR wrappers with reference types, use the <object> instantiation saved in corlib */
@@ -4521,9 +4524,11 @@ mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *
 
                                        m = mono_marshal_get_array_accessor_wrapper (m);
                                        if (m != method) {
-                                               code = (guint8 *)mono_aot_get_method (domain, m);
+                                               code = (guint8 *)mono_aot_get_method_checked (domain, m, error);
                                                if (code)
                                                        return code;
+                                               if (!is_ok (error))
+                                                       return NULL;
                                        }
                                }
                        }
@@ -4596,6 +4601,7 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
        MonoError error;
 
        gpointer res = mono_aot_get_method_checked (domain, method, &error);
+       /* This is a public api function so it can raise exceptions */
        mono_error_raise_exception (&error);
        return res;
 }
@@ -4605,20 +4611,20 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
  * method.
  */
 gpointer
-mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 token)
+mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 token, MonoError *error)
 {
        MonoAotModule *aot_module = (MonoAotModule *)image->aot_module;
        int method_index;
-       MonoError error;
        gpointer res;
 
+       mono_error_init (error);
+
        if (!aot_module)
                return NULL;
 
        method_index = mono_metadata_token_index (token) - 1;
 
-       res = load_method (domain, aot_module, image, NULL, token, method_index, &error);
-       mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+       res = load_method (domain, aot_module, image, NULL, token, method_index, error);
        return res;
 }
 
@@ -5825,6 +5831,12 @@ mono_aot_get_method (MonoDomain *domain, MonoMethod *method)
        return NULL;
 }
 
+gpointer
+mono_aot_get_method_checked (MonoDomain *domain, MonoMethod *method, MonoError *error)
+{
+       return NULL;
+}
+
 gboolean
 mono_aot_is_got_entry (guint8 *code, guint8 *addr)
 {
@@ -5850,7 +5862,7 @@ mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr)
 }
 
 gpointer
-mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 token)
+mono_aot_get_method_from_token (MonoDomain *domain, MonoImage *image, guint32 token, MonoError *error)
 {
        return NULL;
 }
@@ -5873,7 +5885,7 @@ mono_aot_patch_plt_entry (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_
 }
 
 gpointer
-mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot)
+mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot, MonoError *error)
 {
        return NULL;
 }
index 7b9cfd320ab60e682c2356632b61a48507850c7a..fb4f06fb9bed0356940ade628058ec623d250af1 100644 (file)
@@ -401,9 +401,9 @@ instruction_hash (MonoInst *insn)
        res ^= insn->sreg1  << 0x10;
        res ^= insn->sreg2  << 0x14;
        res ^= insn->sreg3  << 0x18;
-       res ^= (guint) insn->next;
-       res ^= (guint) insn->prev;
-       res ^= (guint) insn;
+       res ^= (gsize) insn->next;
+       res ^= (gsize) insn->prev;
+       res ^= (gsize) insn;
        return res;
 }
 
index 60126395bc67b2d304de82b975dd777989858ccd..f0a4f49dd7fce66daa38936e06948b3896b1ca6b 100644 (file)
@@ -2678,7 +2678,7 @@ notify_thread (gpointer key, gpointer value, gpointer user_data)
 
        DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
 
-       /* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
+       /* This is _not_ equivalent to mono_thread_internal_abort () */
        InterruptData interrupt_data = { 0 };
        interrupt_data.tls = tls;
 
@@ -4320,8 +4320,10 @@ set_bp_in_method (MonoDomain *domain, MonoMethod *method, MonoSeqPointInfo *seq_
 
        code = mono_jit_find_compiled_method_with_jit_info (domain, method, &ji);
        if (!code) {
+               MonoError error;
+
                /* Might be AOTed code */
-               code = mono_aot_get_method (domain, method);
+               code = mono_aot_get_method_checked (domain, method, &error);
                g_assert (code);
                ji = mono_jit_info_table_find (domain, (char *)code);
                g_assert (ji);
@@ -6802,7 +6804,7 @@ invoke_method (void)
        /*
         * Take the loader lock to avoid race conditions with CMD_VM_ABORT_INVOKE:
         *
-        * It is possible that ves_icall_System_Threading_Thread_Abort () was called
+        * It is possible that mono_thread_internal_abort () was called
         * after the mono_runtime_invoke_checked() already returned, but it doesn't matter
         * because we reset the abort here.
         */
@@ -7114,7 +7116,7 @@ vm_commands (int command, int id, guint8 *p, guint8 *end, Buffer *buf)
 
                tls->abort_requested = TRUE;
 
-               ves_icall_System_Threading_Thread_Abort (THREAD_TO_INTERNAL (thread), NULL);
+               mono_thread_internal_abort (THREAD_TO_INTERNAL (thread));
                mono_loader_unlock ();
                break;
        }
index aa80289292431607f3c68cb9b344b3e5fa7fea28..7b37da2a67705dae962975399db081541af1392f 100644 (file)
@@ -399,7 +399,7 @@ mini_regression_step (MonoImage *image, int verbose, int *total_run, int *total,
                                if (verbose >= 2)
                                        g_print ("Running '%s' ...\n", method->name);
 #ifdef MONO_USE_AOT_COMPILER
-                               if ((func = (TestMethod)mono_aot_get_method (mono_get_root_domain (), method)))
+                               if ((func = (TestMethod)mono_aot_get_method_checked (mono_get_root_domain (), method, &error)))
                                        ;
                                else
 #endif
index 1c365d577b8fac4b4cc97e16d56318a771b19f99..5852061fcd8c4a649bd8a6dbb8e1097eb24bbcc1 100644 (file)
@@ -1576,7 +1576,8 @@ resolve_vcall (MonoVTable *vt, int slot, MonoMethod *imt_method, gpointer *out_a
        /* Same as in common_call_trampoline () */
 
        /* Avoid loading metadata or creating a generic vtable if possible */
-       addr = mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, slot);
+       addr = mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, slot, &error);
+       mono_error_assert_ok (&error); /* FIXME don't swallow the error */
        if (addr && !vt->klass->valuetype)
                return mono_create_ftnptr (mono_domain_get (), addr);
 
index f2dc914e374aaf959ca6cbb97336efe5bb72ab6c..6d528eb651c88b7375f6521083809f624422006d 100644 (file)
@@ -88,7 +88,7 @@ MONO_API char*       mono_get_runtime_build_info    (void);
 MONO_API MonoJitInfo *
 mono_get_jit_info_from_method (MonoDomain *domain, MonoMethod *method);
 
-MONO_API void *
+MONO_RT_EXTERNAL_ONLY MONO_API void *
 mono_aot_get_method (MonoDomain *domain, MonoMethod *method);
 
 MONO_END_DECLS
index 4017d42b6df005c735e688aea0d9193dff4dcb1e..b7bb7790fac84a7154b274e145c43cdb53d9c68d 100644 (file)
@@ -4527,6 +4527,9 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, guint8 *ip,
        int context_used;
        MonoInst *klass_inst = NULL, *res;
 
+       if (src->opcode == OP_PCONST && src->inst_p0 == 0)
+               return src;
+
        context_used = mini_class_check_context_used (cfg, klass);
 
        if (!context_used && mini_class_has_reference_variant_generic_argument (cfg, klass, context_used)) {
@@ -4558,7 +4561,7 @@ handle_castclass (MonoCompile *cfg, MonoClass *klass, MonoInst *src, guint8 *ip,
        if (context_used) {
                MonoInst *args [3];
 
-               if(mini_class_has_reference_variant_generic_argument (cfg, klass, context_used) || is_complex_isinst (klass)) {
+               if (mini_class_has_reference_variant_generic_argument (cfg, klass, context_used) || is_complex_isinst (klass)) {
                        MonoInst *cache_ins;
 
                        cache_ins = emit_get_rgctx_klass (cfg, context_used, klass, MONO_RGCTX_INFO_CAST_CACHE);
index dffa9370f27024990fe7e52ab6a01d3128ca4498..2930a31e58526064279b25364aa023b29e8e6acb 100644 (file)
@@ -441,7 +441,10 @@ mono_arch_get_gsharedvt_call_info (gpointer addr, MonoMethodSignature *normal_si
                                case MONO_TYPE_I8:
                                        info->ret_marshal = GSHAREDVT_RET_I8;
                                        break;
-
+                               case MONO_TYPE_GENERICINST:
+                                       g_assert (!mono_type_generic_inst_is_valuetype (ret));
+                                       info->ret_marshal = GSHAREDVT_RET_I8;
+                                       break;
                                default:
                                        g_error ("Gsharedvt can't handle dst type [%d]", (int)sig->ret->type);
                                }
index 33c815d75762d6a97121fb703e0660b844fa6c2d..753c091a3b7963720f010b2f1797b7f6255fa95c 100644 (file)
@@ -402,6 +402,7 @@ typedef struct {
 #define MONO_ARCH_HAVE_SDB_TRAMPOLINES 1
 #define MONO_ARCH_HAVE_PATCH_CODE_NEW 1
 #define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
+#define MONO_ARCH_HAVE_GENERAL_RGCTX_LAZY_FETCH_TRAMPOLINE 1
 
 #if defined(TARGET_OSX) || defined(__linux__)
 #define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1
index 93edb0fdafb6aa21b2b374bb62ccc65b3eef1751..8e7e351b08070e417be7b1524e85581d2797af8e 100644 (file)
@@ -6067,13 +6067,8 @@ mono_arch_emit_prolog (MonoCompile *cfg)
                                reg_offset += 4;
                        }
                }
-               if (iphone_abi) {
-                       mono_emit_unwind_op_offset (cfg, code, ARMREG_LR, -4);
-                       mini_gc_set_slot_type_from_cfa (cfg, -4, SLOT_NOREF);
-               } else {
-                       mono_emit_unwind_op_offset (cfg, code, ARMREG_LR, -4);
-                       mini_gc_set_slot_type_from_cfa (cfg, -4, SLOT_NOREF);
-               }
+               mono_emit_unwind_op_offset (cfg, code, ARMREG_LR, -4);
+               mini_gc_set_slot_type_from_cfa (cfg, -4, SLOT_NOREF);
        } else {
                ARM_MOV_REG_REG (code, ARMREG_IP, ARMREG_SP);
                ARM_PUSH (code, 0x5ff0);
index e778f7561ff100d127adfcd475e76a941fda020b..564c0de7d03b271a30f1663277095a4afb6fa0c5 100644 (file)
@@ -1440,7 +1440,7 @@ mini_get_gsharedvt_wrapper (gboolean gsharedvt_in, gpointer addr, MonoMethodSign
                else
                        wrapper = mini_get_gsharedvt_out_sig_wrapper (normal_sig);
                res = mono_compile_method_checked (wrapper, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
+               mono_error_assert_ok (&error);
                return res;
        }
 
index 8a8a7e35d6308c4e2d014b5c715ea8d799eef6b7..d88a6c99a8f362bb690424ace4462d58f3d913d9 100644 (file)
@@ -3777,17 +3777,18 @@ ia64_patch (unsigned char* code, gpointer target)
 }
 
 void
-mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors, MonoError *error)
 {
        MonoJumpInfo *patch_info;
 
+       mono_error_init (error);
+
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
                const unsigned char *target;
-               MonoError error;
 
-               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, &error);
-               mono_error_raise_exception (&error); /* FIXME: don't raise here */
+               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, error);
+               return_if_nok (error);
 
                if (patch_info->type == MONO_PATCH_INFO_NONE)
                        continue;
index b7f5ec5a3ebf31a1932c6dc1ebdc45cb2cb10914..8f33bb655a977867a859c49f0f616e8c627083e6 100644 (file)
@@ -3201,8 +3201,12 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
                                        target =
                                                mono_create_jit_trampoline (mono_domain_get (),
                                                                                                        call->method, &error);
-                                       if (!mono_error_ok (&error))
-                                               mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+                                       if (!is_ok (&error)) {
+                                               set_failure (ctx, mono_error_get_message (&error));
+                                               mono_error_cleanup (&error);
+                                               return;
+                                       }
+
                                        tramp_var = LLVMAddGlobal (ctx->lmodule, LLVMPointerType (llvm_sig, 0), name);
                                        LLVMSetInitializer (tramp_var, LLVMConstIntToPtr (LLVMConstInt (LLVMInt64Type (), (guint64)(size_t)target, FALSE), LLVMPointerType (llvm_sig, 0)));
                                        LLVMSetLinkage (tramp_var, LLVMExternalLinkage);
@@ -3212,15 +3216,17 @@ process_call (EmitContext *ctx, MonoBasicBlock *bb, LLVMBuilderRef *builder_ref,
 #else
                                target =
                                        mono_create_jit_trampoline (mono_domain_get (),
-                                                                                               call->method, &error);
-                               if (!mono_error_ok (&error))
-                                       mono_error_raise_exception (&error); /* FIXME: Don't raise here */
+                                                                   call->method, &error);
+                               if (!is_ok (&error)) {
+                                       g_free (name);
+                                       set_failure (ctx, mono_error_get_message (&error));
+                                       mono_error_cleanup (&error);
+                                       return;
+                               }
 
                                callee = LLVMAddFunction (ctx->lmodule, name, llvm_sig);
                                g_free (name);
 
-                               if (!mono_error_ok (&error))
-                                       mono_error_raise_exception (&error); /* FIXME: Don't raise here */
                                LLVMAddGlobalMapping (ctx->module->ee, callee, target);
 #endif
                        }
index 773bd20087c95e56a17e2f811f227a5b38e7867e..5d6ebc7b6bc126975df54bdc38c29d247d5ca8d0 100644 (file)
@@ -4671,10 +4671,11 @@ mono_arch_register_lowlevel_calls (void)
 }
 
 void
-mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors, MonoError *error)
 {
        MonoJumpInfo *patch_info;
-       MonoError error;
+
+       mono_error_init (error);
 
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
@@ -4708,8 +4709,9 @@ mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain,
                case MONO_PATCH_INFO_R4:
                case MONO_PATCH_INFO_R8:
                        /* from OP_AOTCONST : lui + addiu */
-                       target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, &error);
-                       mono_error_raise_exception (&error); /* FIXME: don't raise here */
+                       target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, error);
+                       return_if_nok (error);
+
                        patch_lui_addiu ((guint32 *)(void *)ip, (guint32)target);
                        continue;
 #if 0
@@ -4722,8 +4724,9 @@ mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain,
                        /* everything is dealt with at epilog output time */
                        continue;
                default:
-                       target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, &error);
-                       mono_error_raise_exception (&error); /* FIXME: don't raise here */
+                       target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, error);
+                       return_if_nok (error);
+
                        mips_patch ((guint32 *)(void *)ip, (guint32)target);
                        break;
                }
index c9116ff46e1e6a974f1e5391de97731bc38bd90e..3089a8546b1d3a4d605535a775c1f57d27eb793f 100644 (file)
@@ -4743,19 +4743,20 @@ mono_arch_register_lowlevel_calls (void)
 
 #ifndef DISABLE_JIT
 void
-mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors, MonoError *error)
 {
        MonoJumpInfo *patch_info;
        gboolean compile_aot = !run_cctors;
-       MonoError error;
+
+       mono_error_init (error);
 
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
                unsigned char *target;
                gboolean is_fd = FALSE;
 
-               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, &error);
-               mono_error_raise_exception (&error); /* FIXME: don't raise here */
+               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, error);
+               return_if_nok (error);
 
                if (compile_aot) {
                        switch (patch_info->type) {
index 717e97f0669f7fb7fdb47b5f9c0cfa9ce3c38d63..b1cb79734d5b607f96df20034f6f866da27c07d9 100644 (file)
@@ -2890,27 +2890,25 @@ MONO_SIG_HANDLER_FUNC (, mono_sigint_signal_handler)
  * Returns: a pointer to the newly created code
  */
 static gpointer
-mono_jit_create_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target)
+mono_jit_create_remoting_trampoline (MonoDomain *domain, MonoMethod *method, MonoRemotingTarget target, MonoError *error)
 {
-       MonoError error;
        MonoMethod *nm;
        guint8 *addr = NULL;
 
+       mono_error_init (error);
+
        if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) && mono_method_signature (method)->generic_param_count) {
                return mono_create_specific_trampoline (method, MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING,
                        domain, NULL);
        }
 
        if ((method->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
-           (mono_method_signature (method)->hasthis && (mono_class_is_marshalbyref (method->klass) || method->klass == mono_defaults.object_class))) {
+           (mono_method_signature (method)->hasthis && (mono_class_is_marshalbyref (method->klass) || method->klass == mono_defaults.object_class)))
                nm = mono_marshal_get_remoting_invoke_for_target (method, target);
-               addr = (guint8 *)mono_compile_method_checked (nm, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
-       } else
-       {
-               addr = (guint8 *)mono_compile_method_checked (method, &error);
-               mono_error_raise_exception (&error); /* FIXME don't raise here */
-       }
+       else
+               nm = method;
+       addr = (guint8 *)mono_compile_method_checked (nm, error);
+       return_val_if_nok (error, NULL);
        return mono_get_addr_from_ftnptr (addr);
 }
 #endif
index e593e3b350102a00c7a020e36042b5fbdce771ed..9cecc8b84458e8a66d02370fa66c521c24867e0c 100644 (file)
@@ -5386,18 +5386,20 @@ mono_arch_register_lowlevel_calls (void)
 
 void
 mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, 
-                     guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+                     guint8 *code, MonoJumpInfo *ji, gboolean run_cctors,
+                     MonoError *error)
 {
        MonoJumpInfo *patch_info;
-       MonoError error;
+
+       mono_error_init (error);
 
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
                gconstpointer target = NULL;
 
                target = mono_resolve_patch_target (method, domain, code, 
-                                                                                       patch_info, run_cctors, &error);
-               mono_error_raise_exception (&error); /* FIXME: don't raise here */
+                                                                                       patch_info, run_cctors, error);
+               return_if_nok (error);
 
                switch (patch_info->type) {
                        case MONO_PATCH_INFO_IP:
index b29563dcb0ac480f6e6f93651ebd654b5e3c3466..022f8a5e790b8ea9334d4fa61bb7f92c99229c9f 100644 (file)
@@ -3672,18 +3672,19 @@ mono_arch_register_lowlevel_calls (void)
 }
 
 void
-mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors)
+mono_arch_patch_code (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors, MonoError *error)
 {
-       MonoError error;
        MonoJumpInfo *patch_info;
 
+       mono_error_init (error);
+
        /* FIXME: Move part of this to arch independent code */
        for (patch_info = ji; patch_info; patch_info = patch_info->next) {
                unsigned char *ip = patch_info->ip.i + code;
                gpointer target;
 
-               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, &error);
-               mono_error_raise_exception (&error); /* FIXME: don't raise here */
+               target = mono_resolve_patch_target (method, domain, code, patch_info, run_cctors, error);
+               return_if_nok (error);
 
                switch (patch_info->type) {
                case MONO_PATCH_INFO_NONE:
index 9a71893c239fa4137906d382c43df066c9b1ebde..69a76c19afec5f1c9f865649b3451dec0f345c80 100644 (file)
@@ -203,11 +203,14 @@ mini_resolve_imt_method (MonoVTable *vt, gpointer *vtable_slot, MonoMethod *imt_
                impl = mono_class_inflate_generic_method_checked (impl, &context, &error);
                g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
        } else {
+               MonoError error;
                /* Avoid loading metadata or creating a generic vtable if possible */
-               if (lookup_aot && !vt->klass->valuetype)
-                       aot_addr = (guint8 *)mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, interface_offset + mono_method_get_vtable_slot (imt_method));
-               else
+               if (lookup_aot && !vt->klass->valuetype) {
+                       aot_addr = (guint8 *)mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, interface_offset + mono_method_get_vtable_slot (imt_method), &error);
+                       g_assert (mono_error_ok (&error)); /* FIXME don't swallow the error */
+               } else {
                        aot_addr = NULL;
+               }
                if (aot_addr)
                        impl = NULL;
                else
@@ -870,7 +873,11 @@ mono_vcall_trampoline (mgreg_t *regs, guint8 *code, int slot, guint8 *tramp)
                vtable_slot = &(vt->vtable [slot]);
 
                /* Avoid loading metadata or creating a generic vtable if possible */
-               addr = mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, slot);
+               addr = mono_aot_get_method_from_vt_slot (mono_domain_get (), vt, slot, &error);
+               if (!is_ok (&error)) {
+                       mono_error_set_pending_exception (&error);
+                       return NULL;
+               }
                if (addr && !vt->klass->valuetype) {
                        if (mono_domain_owns_vtable_slot (mono_domain_get (), vtable_slot))
                                *vtable_slot = addr;
@@ -968,6 +975,7 @@ mono_aot_trampoline (mgreg_t *regs, guint8 *code, guint8 *token_info,
        MonoMethod *method = NULL;
        gpointer addr;
        guint8 *plt_entry;
+       MonoError error;
 
        trampoline_calls ++;
 
@@ -975,12 +983,13 @@ mono_aot_trampoline (mgreg_t *regs, guint8 *code, guint8 *token_info,
        token_info += sizeof (gpointer);
        token = *(guint32*)(gpointer)token_info;
 
-       addr = mono_aot_get_method_from_token (mono_domain_get (), image, token);
+       addr = mono_aot_get_method_from_token (mono_domain_get (), image, token, &error);
        if (!addr) {
-               MonoError error;
+               if (!is_ok (&error))
+                       g_error ("Could not load AOT method due to %s", mono_error_get_message (&error));
                method = mono_get_method_checked (image, token, NULL, NULL, &error);
                if (!method)
-                       g_error ("Could not load AOT trampoline due to %s", mono_error_get_message (&error));
+                       g_error ("Could not load AOT method due to %s", mono_error_get_message (&error));
 
                /* Use the generic code */
                return mono_magic_trampoline (regs, code, method, tramp);
index 1f4711425eced29efa18bcf86c2b4738b9a52fac..0dcda64a378eafd968056c96d79fe1c67b70f84c 100644 (file)
@@ -2419,7 +2419,11 @@ mono_codegen (MonoCompile *cfg)
                }
        }
 #else
-       mono_arch_patch_code (cfg, cfg->method, cfg->domain, cfg->native_code, cfg->patch_info, cfg->run_cctors);
+       mono_arch_patch_code (cfg, cfg->method, cfg->domain, cfg->native_code, cfg->patch_info, cfg->run_cctors, &cfg->error);
+       if (!is_ok (&cfg->error)) {
+               mono_cfg_set_exception (cfg, MONO_EXCEPTION_MONO_ERROR);
+               return;
+       }
 #endif
 
        if (cfg->method->dynamic) {
@@ -4291,8 +4295,11 @@ mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, in
                                mono_arch_patch_code_new (NULL, target_domain, (guint8 *)tmp->data, &patch_info, target);
                        }
 #else
-                       for (tmp = jlist->list; tmp; tmp = tmp->next)
-                               mono_arch_patch_code (NULL, NULL, target_domain, tmp->data, &patch_info, TRUE);
+                       for (tmp = jlist->list; tmp; tmp = tmp->next) {
+                               mono_arch_patch_code (NULL, NULL, target_domain, tmp->data, &patch_info, TRUE, error);
+                               if (!is_ok (error))
+                                       break;
+                       }
 #endif
                }
        }
index e53a39a8cbc5419df12881b84b44710d7129d1a8..1f2d43208115b5dd6122a86d26abc944861961d7 100644 (file)
@@ -2455,11 +2455,9 @@ jinfo_get_method (MonoJitInfo *ji)
 /* AOT */
 void      mono_aot_init                     (void);
 void      mono_aot_cleanup                  (void);
-gpointer  mono_aot_get_method               (MonoDomain *domain,
-                                                                                        MonoMethod *method);
 gpointer  mono_aot_get_method_checked       (MonoDomain *domain,
                                                                                         MonoMethod *method, MonoError *error);
-gpointer  mono_aot_get_method_from_token    (MonoDomain *domain, MonoImage *image, guint32 token);
+gpointer  mono_aot_get_method_from_token    (MonoDomain *domain, MonoImage *image, guint32 token, MonoError *error);
 gboolean  mono_aot_is_got_entry             (guint8 *code, guint8 *addr);
 guint8*   mono_aot_get_plt_entry            (guint8 *code);
 guint32   mono_aot_get_plt_info_offset      (mgreg_t *regs, guint8 *code);
@@ -2468,7 +2466,7 @@ gboolean  mono_aot_get_class_from_name      (MonoImage *image, const char *name_
 MonoJitInfo* mono_aot_find_jit_info         (MonoDomain *domain, MonoImage *image, gpointer addr);
 gpointer mono_aot_plt_resolve               (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error);
 void     mono_aot_patch_plt_entry           (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_t *regs, guint8 *addr);
-gpointer mono_aot_get_method_from_vt_slot   (MonoDomain *domain, MonoVTable *vtable, int slot);
+gpointer mono_aot_get_method_from_vt_slot   (MonoDomain *domain, MonoVTable *vtable, int slot, MonoError *error);
 gpointer mono_aot_create_specific_trampoline   (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
 gpointer mono_aot_get_trampoline            (const char *name);
 gpointer mono_aot_get_trampoline_full       (const char *name, MonoTrampInfo **out_tinfo);
@@ -2654,7 +2652,7 @@ GList    *mono_arch_get_global_fp_regs          (MonoCompile *cfg);
 GList    *mono_arch_get_iregs_clobbered_by_call (MonoCallInst *call);
 GList    *mono_arch_get_fregs_clobbered_by_call (MonoCallInst *call);
 guint32   mono_arch_regalloc_cost               (MonoCompile *cfg, MonoMethodVar *vmv);
-void      mono_arch_patch_code                  (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors);
+void      mono_arch_patch_code                  (MonoCompile *cfg, MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gboolean run_cctors, MonoError *error);
 void      mono_arch_patch_code_new              (MonoCompile *cfg, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji, gpointer target);
 void      mono_arch_flush_icache                (guint8 *code, gint size);
 int       mono_arch_max_epilog_size             (MonoCompile *cfg);
index a8df3065dd80910322b0f6f21a7732acc94c043d..d9737fb8c52e948339da1868b78630a3a2005c34 100644 (file)
@@ -709,6 +709,41 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info
        return buf;
 }
 
+gpointer
+mono_arch_create_general_rgctx_lazy_fetch_trampoline (MonoTrampInfo **info, gboolean aot)
+{
+       guint8 *code, *buf;
+       int tramp_size;
+       MonoJumpInfo *ji = NULL;
+       GSList *unwind_ops;
+
+       g_assert (aot);
+       tramp_size = 64;
+
+       code = buf = (guint8 *)mono_global_codeman_reserve (tramp_size);
+
+       unwind_ops = mono_arch_get_cie_program ();
+
+       // FIXME: Currently, we always go to the slow path.
+       /* This receives a <slot, trampoline> in the rgctx arg reg. */
+       /* Load trampoline addr */
+       amd64_mov_reg_membase (code, AMD64_R11, MONO_ARCH_RGCTX_REG, 8, 8);
+       /* move the rgctx pointer to the VTABLE register */
+       amd64_mov_reg_reg (code, MONO_ARCH_VTABLE_REG, AMD64_ARG_REG1, sizeof(gpointer));
+       /* Jump to the trampoline */
+       amd64_jump_reg (code, AMD64_R11);
+
+       mono_arch_flush_icache (buf, code - buf);
+       mono_profiler_code_buffer_new (buf, code - buf, MONO_PROFILER_CODE_BUFFER_GENERICS_TRAMPOLINE, NULL);
+
+       g_assert (code - buf <= tramp_size);
+
+       if (info)
+               *info = mono_tramp_info_create ("rgctx_fetch_trampoline_general", buf, code - buf, ji, unwind_ops);
+
+       return buf;
+}
+
 void
 mono_arch_invalidate_method (MonoJitInfo *ji, void *func, gpointer func_arg)
 {
index e658bf9777b6b78e81c6851a74b41a6fc44ec53a..e9983a3b0697dd01c5e6dbb8153c406c769287eb 100644 (file)
@@ -212,7 +212,6 @@ static inline void print_report (const gchar *format, ...)
 
 static inline void append_report (GString **report, const gchar *format, ...)
 {
-#if defined (_EGLIB_MAJOR) || GLIB_CHECK_VERSION(2,14,0)
        va_list ap;
        if (!*report)
                *report = g_string_new ("");
@@ -220,9 +219,6 @@ static inline void append_report (GString **report, const gchar *format, ...)
        va_start (ap, format);
        g_string_append_vprintf (*report, format, ap);
        va_end (ap);
-#else
-       g_assert_not_reached ();
-#endif
 }
 
 static gboolean saved_strings_find_func (gpointer key, gpointer value, gpointer user_data)
index dbd2e9ad1cc108d8ee2ebbb383738f9b84999af4..650e7716e583d8af4318a59a900c7ad8b742780c 100644 (file)
@@ -1339,6 +1339,8 @@ mono_test_return_empty_struct (int a)
 {
        EmptyStruct s;
 
+       memset (&s, 0, sizeof (s));
+
        g_assert (a == 42);
 
        return s;
index 740db4c7543cb72bc2b8f1d6c68775849bb35cbd..54c6320d2b6f6a08bc8fc2fe249f315bbde8cac8 100644 (file)
@@ -93,7 +93,6 @@ static gchar *find_in_dir (DIR *current, const gchar *name)
 
 static inline void append_report (GString **report, const gchar *format, ...)
 {
-#if defined (_EGLIB_MAJOR) || GLIB_CHECK_VERSION(2,14,0)
        va_list ap;
        if (!*report)
                *report = g_string_new ("");
@@ -101,9 +100,6 @@ static inline void append_report (GString **report, const gchar *format, ...)
        va_start (ap, format);
        g_string_append_vprintf (*report, format, ap);
        va_end (ap);
-#else
-       g_assert_not_reached ();
-#endif
 }
 
 static inline void do_mono_profiler_iomap (GString **report, const char *pathname, const char *new_pathname)
diff --git a/msvc/scripts/Commons.Xml.Relaxng.pre b/msvc/scripts/Commons.Xml.Relaxng.pre
new file mode 100644 (file)
index 0000000..55520b7
--- /dev/null
@@ -0,0 +1 @@
+$(ProjectDir)\..\..\jay\jay.exe -ct &lt; $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.jay > $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.cs
index 60c66680b662b862af21bb86fa01597a91e7d203..ccaa3b3149c9059691926e96e6a17433c2ee84b8 100644 (file)
@@ -696,7 +696,6 @@ class MsbuildGenerator {
                }
                //
                // Prebuild code, might be in inputs, check:
-               //  inputs/LIBRARY-PROFILE.pre
                //  inputs/LIBRARY.pre
                //
                string prebuild = Load (library + ".pre");
@@ -705,7 +704,7 @@ class MsbuildGenerator {
                int q = library.IndexOf ("-");
                if (q != -1)
                        prebuild = prebuild + Load (library.Substring (0, q) + ".pre");
-
+               
                if (prebuild.IndexOf ("@MONO@") != -1){
                        prebuild_unix = prebuild.Replace ("@MONO@", "mono").Replace ("@CAT@", "cat");
                        prebuild_windows = prebuild.Replace ("@MONO@", "").Replace ("@CAT@", "type");
@@ -713,7 +712,6 @@ class MsbuildGenerator {
                        prebuild_unix = prebuild.Replace ("jay.exe", "jay");
                        prebuild_windows = prebuild;
                }
-               
                const string condition_unix    = "Condition=\" '$(OS)' != 'Windows_NT' \"";
                const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \"";
                prebuild =
@@ -752,7 +750,6 @@ class MsbuildGenerator {
                }
 
                string [] source_files;
-               //Console.WriteLine ("Base: {0} res: {1}", base_dir, response);
                using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))) {
                        source_files = reader.ReadToEnd ().Split ();
                }
@@ -812,7 +809,11 @@ class MsbuildGenerator {
                if (embedded_resources.Count > 0) {
                        resources.AppendFormat ("  <ItemGroup>" + NewLine);
                        foreach (var dk in embedded_resources) {
-                               resources.AppendFormat ("    <EmbeddedResource Include=\"{0}\">" + NewLine, dk.Key);
+                               var source = dk.Key;
+                               if (source.EndsWith (".resources"))
+                                       source = source.Replace (".resources", ".resx");
+                               Console.WriteLine ("Got {0} -> {1}", dk.Key, source);
+                               resources.AppendFormat ("    <EmbeddedResource Include=\"{0}\">" + NewLine, source);
                                resources.AppendFormat ("      <LogicalName>{0}</LogicalName>" + NewLine, dk.Value);
                                resources.AppendFormat ("    </EmbeddedResource>" + NewLine);
                        }
index 1d220e23fac778114dc662ab284b6103385f7bbe..fba952f0701f56e37bebc921a4bd5de1510f0c88 100644 (file)
@@ -28,12 +28,6 @@ class Prepare {
                }
 
                switch (args [1]){
-               case "xml":
-                       Filter (bdir + "/class/System.XML/System.Xml.XPath/Parser.jay",
-                               bdir + "/class/System.XML/Mono.Xml.Xsl/PatternParser.jay",
-                               (i, o) => o.Write (i.ReadToEnd ().Replace ("%start Expr", "%start Pattern")));
-                       break;
-
                case "core":
                        Filter (bdir + "/build/common/Consts.cs.in",
                                bdir + "/build/common/Consts.cs",