[WindowsBase] Fixed System.IO.Packaging creating Zip archive with wrong date time entries
--- /dev/null
+@echo off
+cd mcs\jay
+vcbuild jay.vcxproj
+msbuild net_4_x.sln
--- /dev/null
+#!/bin/sh
+(cd mcs/jay; make)
+msbuild net_4_x.sln
TARGET=ARM64
arch_target=arm64
boehm_supported=false
+ AOT_SUPPORTED="yes"
;;
s390x-*-linux*)
TARGET=S390X;
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))"
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))"
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
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
#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
#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
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;
typedef float gfloat;
typedef double gdouble;
typedef int32_t gboolean;
-#endif
-#endif
typedef guint16 gunichar2;
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
*/
-->\r
<PropertyGroup>\r
<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+$(ProjectDir)\..\..\jay\jay -ct < $(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 < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.jay > $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.cs
\r
</PreBuildEvent>\r
\r
<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
<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
<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
<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
<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
<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
public void Close ()
{
CancellationTokenRegistration.Dispose ();
- ContentStream.Close ();
+ if (ContentStream != null) {
+ ContentStream.Close ();
+ }
}
}
wr.KeepAlive = request.Headers.ConnectionClose != true;
}
- wr.ServicePoint.Expect100Continue = request.Headers.ExpectContinue == true;
-
if (allowAutoRedirect) {
wr.AllowAutoRedirect = true;
wr.MaximumAutomaticRedirections = maxAutomaticRedirections;
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) {
}
}
+ 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;
}
}
+ [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 ()
{
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
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);
{
// 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;
// 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);
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
<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
/* 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));
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);
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);
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)
/* 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);
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);
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;
#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);
/* 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;
}
}
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),
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);
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);
* 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;
*
*/
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);
}
/**
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
* 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
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;
}
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;
}
#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)
{
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);
} 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) {
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) {
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);
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);
#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;
* 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;
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;
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);
method_count += mono_class_num_methods (ic);
}
g_ptr_array_free (ifaces, TRUE);
+ ifaces = NULL;
}
extra_interface_vtsize += method_count * sizeof (gpointer);
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;
}
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;
+ }
}
}
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);
}
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 */
}
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) {
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);
* @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;
MonoRemoteClass *remote_class;
gboolean redo_vtable;
+ mono_error_init (error);
mono_loader_lock (); /*FIXME mono_remote_class_vtable requires it.*/
mono_domain_lock (domain);
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 */
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;
}
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;
}
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;
}
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;
}
#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;
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;
}
}
/* 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)
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 {
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;
}
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 */
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);
}
}
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);
}
}
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);
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);
}
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);
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;
}
} 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);
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);
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);
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);
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);
#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 *);
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);
}
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);
}
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);
}
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);
/* 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
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);
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;
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);
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);
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 */
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);
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;
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;
MonoThread *
mono_thread_current (void)
{
- MonoError error;
MonoDomain *domain = mono_domain_get ();
MonoInternalThread *internal = mono_thread_internal_current ();
MonoThread **current_thread_ptr;
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;
}
static MonoThread *
mono_thread_current_for_thread (MonoInternalThread *internal)
{
- MonoError error;
MonoDomain *domain = mono_domain_get ();
MonoThread **current_thread_ptr;
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;
}
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);
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;
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;
gint32 ves_icall_System_Threading_WaitHandle_WaitAll_internal(MonoArray *mono_handles, gint32 ms)
{
+ MonoError error;
HANDLE *handles;
guint32 numhandles;
guint32 ret;
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);
}
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;
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);
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 ();
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
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);
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)
}
}
-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;
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);
(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;
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
return found;
}
-void mono_thread_internal_stop (MonoInternalThread *thread)
+static gboolean
+request_thread_stop (MonoInternalThread *thread)
{
LOCK_THREAD (thread);
(thread->state & ThreadState_Stopped) != 0)
{
UNLOCK_THREAD (thread);
- return;
+ return FALSE;
}
/* Make sure the thread is awake */
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
}
/* 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];
MonoDebugSourceLocation *location;
int tindex, nthreads;
- mono_error_init (&error);
+ mono_error_init (error);
*out_threads = NULL;
*out_stack_frames = NULL;
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) {
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;
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);
leave:
g_free (ud.frames);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return is_ok (error);
}
/**
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
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)
{
}
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 {
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);
}
/*
gpointer
mono_threads_attach_coop (MonoDomain *domain, gpointer *dummy)
{
- MonoError error;
MonoDomain *orig;
gboolean fresh_thread;
}
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);
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);
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 = \
}
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;
MethodRef ref;
gboolean res;
+ mono_error_init (error);
+
if (MONO_CLASS_IS_INTERFACE (klass) || klass->rank || !amodule)
return NULL;
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)
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
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);
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;
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;
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);
}
/*
* 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);
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;
}
/*
* 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];
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> */
((!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];
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)
* 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 */
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;
}
}
}
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;
}
* 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;
}
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)
{
}
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;
}
}
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;
}
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;
}
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;
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);
/*
* 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.
*/
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;
}
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
/* 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);
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
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)) {
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);
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);
}
#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
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);
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;
}
}
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;
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);
#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
}
}
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;
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
/* 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;
}
#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) {
* 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
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:
}
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:
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
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;
MonoMethod *method = NULL;
gpointer addr;
guint8 *plt_entry;
+ MonoError error;
trampoline_calls ++;
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);
}
}
#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) {
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
}
}
/* 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);
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);
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);
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)
{
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 ("");
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)
{
EmptyStruct s;
+ memset (&s, 0, sizeof (s));
+
g_assert (a == 42);
return s;
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 ("");
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)
--- /dev/null
+$(ProjectDir)\..\..\jay\jay.exe -ct < $(ProjectDir)\..\..\jay\skeleton.cs $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.jay > $(ProjectDir)\Commons.Xml.Relaxng.Rnc\RncParser.cs
}
//
// Prebuild code, might be in inputs, check:
- // inputs/LIBRARY-PROFILE.pre
// inputs/LIBRARY.pre
//
string prebuild = Load (library + ".pre");
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");
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 =
}
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 ();
}
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);
}
}
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",