[runtime] Synthesize IList and IReadOnlyList for the element type of enum errays. Fixes #59824
/mono/metadata/threads* @luhenry @kumpera
/mono/metadata/threadpool* @luhenry
/mono/metadata/w32* @luhenry
+/mono/metadata/*-win* @lateralusX @luhenry
/mono/mini @vargaz @kumpera
/mono/mini/*cfgdump* @lewurm
/mono/utils/mono-hwcap* @alexrp
/mono/utils/mono-mem* @alexrp
/mono/utils/mono-threads* @luhenry @kumpera
+/mono/utils/*-win* @lateralusX @kumpera
-/msvc @ntherning
+/msvc @lateralusX
/msvc/*profiler* @alexrp
/msvc/scripts @akoeplinger
return timeout;
}
set {
- if (value != System.Threading.Timeout.InfiniteTimeSpan && value < TimeSpan.Zero)
+ if (value != System.Threading.Timeout.InfiniteTimeSpan && (value <= TimeSpan.Zero || value.Ticks > int.MaxValue))
throw new ArgumentOutOfRangeException ();
timeout = value;
Assert.Fail ("#2");
} catch (ArgumentOutOfRangeException) {
}
+
+ try {
+ client.Timeout = TimeSpan.Zero;
+ Assert.Fail ("#3");
+ } catch (ArgumentOutOfRangeException) {
+ }
+
+ try {
+ client.Timeout = new TimeSpan(int.MaxValue + 1L);
+ Assert.Fail ("#3");
+ } catch (ArgumentOutOfRangeException) {
+ }
}
[Test]
if (current != null) {
cookies.Add (current);
}
- current = new Cookie ();
- int idx = str.IndexOf ('=');
- if (idx > 0) {
- current.Name = str.Substring (0, idx).Trim ();
- current.Value = str.Substring (idx + 1).Trim ();
- } else {
- current.Name = str.Trim ();
- current.Value = String.Empty;
+ try {
+ current = new Cookie ();
+ int idx = str.IndexOf ('=');
+ if (idx > 0) {
+ current.Name = str.Substring (0, idx).Trim ();
+ current.Value = str.Substring (idx + 1).Trim ();
+ } else {
+ current.Name = str.Trim ();
+ current.Value = String.Empty;
+ }
+ current.Version = version;
+ } catch (CookieException) {
+ current = null;
}
- current.Version = version;
}
}
if (current != null) {
var request = (HttpWebRequest)WebRequest.Create (prefix);
var rsp = request.GetResponseAsync ();
Assert.IsFalse (rsp.Wait (1000), "Don't send on empty write");
+ }
+ [Test]
+ public void HttpRequestIgnoreBadCookies ()
+ {
+ var port = NetworkHelpers.FindFreePort ();
+ HttpListener listener = HttpListener2Test.CreateAndStartListener (
+ "http://127.0.0.1:" + port + "/HttpRequestIgnoreBadCookiesTest/");
+ NetworkStream ns = HttpListener2Test.CreateNS (port);
+ HttpListener2Test.Send (ns, "GET /HttpRequestIgnoreBadCookiesTest/?a=b HTTP/1.1\r\nHost: 127.0.0.1\r\nCookie: ELOQUA=GUID=5ca2346347357f4-f877-4eff-96aa-70fe0b677650; ELQSTATUS=OK; WRUID=609099666.123259461695; CommunityServer-UserCookie2101=lv=Thu, 26 Jul 2012 15:25:11 GMT&mra=Mon, 01 Oct 2012 17:40:05 GMT; PHPSESSID=1234dg3opfjb4qafp0oo645; __utma=9761706.1153317537.1357240270.1357240270.1357317902.2; __utmb=9761706.6.10.1357317902; __utmc=9761706; __utmz=9761706.1357240270.1.1.utmcsr=test.testdomain.com|utmccn=(referral)|utmcmd=referral|utmcct=/test/1234\r\n\r\n");
+ HttpListenerContext ctx = listener.GetContext ();
+ HttpListenerRequest request = ctx.Request;
+ Assert.AreEqual ("/HttpRequestIgnoreBadCookiesTest/?a=b", request.Url.PathAndQuery);
listener.Close ();
}
}
using System.Text;
using System.Security.AccessControl;
+using Microsoft.Win32.SafeHandles;
+
namespace System.IO {
[Serializable]
return EnumerateFileSystemInfos (FullPath, searchPattern, searchOption);
}
- static internal IEnumerable<FileSystemInfo> EnumerateFileSystemInfos (string full, string searchPattern, SearchOption searchOption)
+ static internal IEnumerable<FileSystemInfo> EnumerateFileSystemInfos (string basePath, string searchPattern, SearchOption searchOption)
{
- string path_with_pattern = Path.Combine (full, searchPattern);
- IntPtr handle = IntPtr.Zero;
- MonoIOError error;
- FileAttributes rattr;
- bool subdirs = searchOption == SearchOption.AllDirectories;
+ Path.Validate (basePath);
+
+ SafeFindHandle findHandle = null;
- Path.Validate (full);
-
try {
- string s = MonoIO.FindFirst (full, path_with_pattern, out rattr, out error, out handle);
- if (s == null)
+ string filePath;
+ int nativeAttrs;
+
+ string basePathWithPattern = Path.Combine (basePath, searchPattern);
+
+ int nativeError;
+ try {} finally {
+ findHandle = new SafeFindHandle (MonoIO.FindFirstFile (basePathWithPattern, out filePath, out nativeAttrs, out nativeError));
+ }
+
+ if (findHandle.IsInvalid) {
+ MonoIOError error = (MonoIOError) nativeError;
+ if (error != MonoIOError.ERROR_FILE_NOT_FOUND)
+ throw MonoIO.GetException (Path.GetDirectoryName (basePathWithPattern), error);
+
yield break;
- if (error != 0)
- throw MonoIO.GetException (Path.GetDirectoryName (path_with_pattern), (MonoIOError) error);
+ }
do {
- if (((rattr & FileAttributes.ReparsePoint) == 0)){
- if ((rattr & FileAttributes.Directory) != 0)
- yield return new DirectoryInfo (s);
+ if (filePath == null)
+ yield break;
+
+ if (filePath == "." || filePath == "..")
+ continue;
+
+ FileAttributes attrs = (FileAttributes) nativeAttrs;
+
+ string fullPath = Path.Combine (basePath, filePath);
+
+ if ((attrs & FileAttributes.ReparsePoint) == 0) {
+ if ((attrs & FileAttributes.Directory) != 0)
+ yield return new DirectoryInfo (fullPath);
else
- yield return new FileInfo (s);
+ yield return new FileInfo (fullPath);
}
- if (((rattr & FileAttributes.Directory) != 0) && subdirs)
- foreach (FileSystemInfo child in EnumerateFileSystemInfos (s, searchPattern, searchOption))
+ if ((attrs & FileAttributes.Directory) != 0 && searchOption == SearchOption.AllDirectories) {
+ foreach (FileSystemInfo child in EnumerateFileSystemInfos (fullPath, searchPattern, searchOption))
yield return child;
-
- } while ((s = MonoIO.FindNext (handle, out rattr, out error)) != null);
+ }
+ } while (MonoIO.FindNextFile (findHandle.DangerousGetHandle (), out filePath, out nativeAttrs, out int _));
} finally {
- if (handle != IntPtr.Zero)
- MonoIO.FindClose (handle);
+ if (findHandle != null)
+ findHandle.Dispose ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static bool RemoveDirectory (string path, out MonoIOError error);
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static string [] GetFileSystemEntries (string path, string path_with_pattern, int attrs, int mask, out MonoIOError error);
-
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static string GetCurrentDirectory (out MonoIOError error);
//
// Find file methods
//
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static string FindFirst (string path, string pattern, out FileAttributes result_attr, out MonoIOError error, out IntPtr handle);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static string FindNext (IntPtr handle, out FileAttributes result_attr, out MonoIOError error);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static int FindClose (IntPtr handle);
[MethodImplAttribute (MethodImplOptions.InternalCall)]
public extern static IntPtr FindFirstFile (string path_with_pattern, out string fileName, out int fileAttr, out int error);
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private static extern void basic_init (AssemblyBuilder ab);
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ static extern void UpdateNativeCustomAttributes (AssemblyBuilder ab);
+
/* Keep this in sync with codegen.cs in mcs */
private const AssemblyBuilderAccess COMPILER_ACCESS = (AssemblyBuilderAccess) 0x800;
cattrs = new CustomAttributeBuilder [1];
cattrs [0] = customBuilder;
}
+
+ /*
+ Only update the native list of custom attributes if we're adding one that is known to change dynamic execution behavior.
+ */
+ if (customBuilder.Ctor != null && customBuilder.Ctor.DeclaringType == typeof (System.Runtime.CompilerServices.RuntimeCompatibilityAttribute))
+ UpdateNativeCustomAttributes (this);
}
[ComVisible (true)]
invoke (444);
}
+ static Func<int> EmitDelegate (DynamicMethod dm) {
+ ILGenerator il = dm.GetILGenerator ();
+ var ret_val = il.DeclareLocal (typeof (int));
+ var leave_label = il.DefineLabel ();
+
+ //ret = 1;
+ il.Emit (OpCodes.Ldc_I4, 1);
+ il.Emit (OpCodes.Stloc, ret_val);
+
+ // try {
+ il.BeginExceptionBlock ();
+ // throw "hello";
+ il.Emit (OpCodes.Ldstr, "hello");
+ il.Emit (OpCodes.Throw, typeof (string));
+ // ret = 2
+ il.Emit (OpCodes.Ldc_I4, 2);
+ il.Emit (OpCodes.Stloc, ret_val);
+ // }
+ il.Emit (OpCodes.Leave, leave_label);
+ //catch (string)
+ il.BeginCatchBlock (typeof (string));
+ il.Emit (OpCodes.Pop);
+ // ret = 3
+ il.Emit (OpCodes.Ldc_I4, 3);
+ il.Emit (OpCodes.Stloc, ret_val);
+ //}
+ il.Emit (OpCodes.Leave, leave_label);
+ il.EndExceptionBlock ();
+
+ il.MarkLabel (leave_label);
+ //return ret;
+ il.Emit (OpCodes.Ldloc, ret_val);
+ il.Emit (OpCodes.Ret);
+
+ var dele = (Func<int>)dm.CreateDelegate (typeof (Func<int>));
+ return dele;
+ }
+
+ [Test] //see bxc #59334
+ public void ExceptionWrapping ()
+ {
+ AssemblyBuilder ab = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("ehatevfheiw"), AssemblyBuilderAccess.Run);
+ AssemblyBuilder ab2 = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("ddf4234"), AssemblyBuilderAccess.Run);
+ CustomAttributeBuilder cab = new CustomAttributeBuilder (
+ typeof (RuntimeCompatibilityAttribute).GetConstructor (new Type [0]),
+ new object [0],
+ new PropertyInfo[] { typeof (RuntimeCompatibilityAttribute).GetProperty ("WrapNonExceptionThrows") },
+ new object[] { true });
+ ab2.SetCustomAttribute (cab);
+
+ AssemblyBuilder ab3 = AppDomain.CurrentDomain.DefineDynamicAssembly (new AssemblyName ("frfhfher"), AssemblyBuilderAccess.Run);
+ //1 NamedArg. Property name: WrapNonExceptionThrows value: true (0x01)
+ byte[] blob = new byte[] { 0x01, 0x00, 0x01, 0x00, 0x54, 0x02, 0x16, 0x57, 0x72, 0x61, 0x70, 0x4E, 0x6F, 0x6E, 0x45, 0x78,
+ 0x63, 0x65, 0x70, 0x74, 0x69, 0x6F, 0x6E, 0x54, 0x68, 0x72, 0x6F, 0x77, 0x73, 0x01 };
+ ab3.SetCustomAttribute (typeof (RuntimeCompatibilityAttribute).GetConstructor (new Type [0]), blob);
+
+ DynamicMethod invoke_no_module = new DynamicMethod("throw_1", typeof (int), new Type [0]);
+ DynamicMethod invoke_with_module = new DynamicMethod("throw_2", typeof (int), new Type [0], typeof (DynamicMethodTest).Module);
+ DynamicMethod invoke_with_ab = new DynamicMethod("throw_3", typeof (int), new Type [0], ab.ManifestModule);
+ DynamicMethod invoke_with_ab2 = new DynamicMethod("throw_4", typeof (int), new Type [0], ab2.ManifestModule);
+ DynamicMethod invoke_with_ab3 = new DynamicMethod("throw_5", typeof (int), new Type [0], ab3.ManifestModule);
+
+ int result = 0;
+ try {
+ int res = EmitDelegate (invoke_no_module)();
+ Assert.AreEqual (3, res, "invoke_no_module bad return value");
+ } catch (RuntimeWrappedException e) {
+ Assert.Fail ("invoke_no_module threw RWE");
+ }
+
+ try {
+ int res = EmitDelegate (invoke_with_module)();
+ Assert.Fail ("invoke_with_module did not throw RWE");
+ } catch (RuntimeWrappedException e) {
+ }
+
+ try {
+ int res = EmitDelegate (invoke_with_ab)();
+ Assert.AreEqual (3, res, "invoke_with_ab bad return value");
+ } catch (RuntimeWrappedException e) {
+ Assert.Fail ("invoke_with_ab threw RWE");
+ }
+
+ try {
+ int res = EmitDelegate (invoke_with_ab2)();
+ Assert.Fail ("invoke_with_ab2 did not throw RWE");
+ } catch (RuntimeWrappedException e) {
+ }
+
+ try {
+ int res = EmitDelegate (invoke_with_ab3)();
+ Assert.Fail ("invoke_with_a3 did not throw RWE");
+ } catch (RuntimeWrappedException e) {
+ }
+ }
+
#if !MONODROID
// RUNTIME: crash
[Test]
Assert.AreEqual (0x02, il [14]); //typedef
Assert.AreEqual (0x01, il [19]); //typeref
}
+
+ [Test]
+ public void MethodRefTokenSame () {
+ // Get the same non-virtual method from a base and a derived type so
+ // that the MemberInfo:DeclaredType differs but the tokens are the same.
+ //
+ // Regression test for bugzilla #59364
+
+ DefineBasicMethod ();
+
+ var m1 = typeof (object).GetMethod ("GetType");
+ var m2 = typeof (string).GetMethod ("GetType");
+
+ var value_getter = typeof (RuntimeMethodHandle).GetProperty ("Value").GetMethod;
+
+ var il = il_gen;
+
+ var loc = il.DeclareLocal (typeof (RuntimeMethodHandle));
+
+ // return ((int)(RuntimeMethodHandle (m1).Value == RuntimeMethodHandle (m2).Value)).ToString ()
+ il.Emit (OpCodes.Ldtoken, m1);
+ il.Emit (OpCodes.Stloc, loc);
+ il.Emit (OpCodes.Ldloca, loc);
+ il.Emit (OpCodes.Call, value_getter);
+ il.Emit (OpCodes.Ldtoken, m2);
+ il.Emit (OpCodes.Stloc, loc);
+ il.Emit (OpCodes.Ldloca, loc);
+ il.Emit (OpCodes.Call, value_getter);
+ il.Emit (OpCodes.Ceq);
+ il.Emit (OpCodes.Box, typeof (Int32));
+ il.Emit (OpCodes.Callvirt, typeof (object).GetMethod ("ToString"));
+ il.Emit (OpCodes.Ret);
+
+ var baked = tb.CreateType ();
+
+ var x = Activator.CreateInstance (baked);
+ var m = baked.GetMethod ("F");
+
+ var s = m.Invoke (x, null);
+
+ Assert.AreEqual ("1", s);
+
+ }
+
+ public class Base {
+ public int x;
+ }
+
+ public class Derived : Base {
+ }
+
+ [Test]
+ public void FieldRefTokenSame () {
+ DefineBasicMethod ();
+
+ // Get the same field from a base and a derived type so hat
+ // the MemberInfo:DeclaredType differs but the tokens are the same.
+ //
+ // Regression test for bugzilla #59364
+
+ var f1 = typeof (Base).GetField ("x");
+ var f2 = typeof (Derived).GetField ("x");
+
+ var value_getter = typeof (RuntimeFieldHandle).GetProperty("Value").GetMethod;
+
+ var il = il_gen;
+
+ var loc = il.DeclareLocal (typeof (RuntimeFieldHandle));
+
+ il.Emit (OpCodes.Ldtoken, f1);
+ il.Emit (OpCodes.Stloc, loc);
+ il.Emit (OpCodes.Ldloca, loc);
+ il.Emit (OpCodes.Call, value_getter);
+ il.Emit (OpCodes.Ldtoken, f2);
+ il.Emit (OpCodes.Stloc, loc);
+ il.Emit (OpCodes.Ldloca, loc);
+ il.Emit (OpCodes.Call, value_getter);
+ il.Emit (OpCodes.Ceq);
+ il.Emit (OpCodes.Box, typeof (Int32));
+ il.Emit (OpCodes.Callvirt, typeof (object).GetMethod ("ToString"));
+ il.Emit (OpCodes.Ret);
+
+ var baked = tb.CreateType ();
+
+ var x = Activator.CreateInstance (baked);
+ var m = baked.GetMethod ("F");
+
+ var s = m.Invoke (x, null);
+
+ Assert.AreEqual ("1", s);
+ }
+
}
}
typedef struct _MonoMethodWrapper MonoMethodWrapper;
typedef struct _MonoMethodInflated MonoMethodInflated;
typedef struct _MonoMethodPInvoke MonoMethodPInvoke;
+typedef struct _MonoDynamicMethod MonoDynamicMethod;
/* Properties that applies to a group of structs should better use a higher number
* to avoid colision with type specific properties.
void *method_data;
};
+struct _MonoDynamicMethod {
+ MonoMethodWrapper method;
+ MonoAssembly *assembly;
+};
+
struct _MonoMethodPInvoke {
MonoMethod method;
gpointer addr;
image->method_aux_hash = g_hash_table_new (NULL, NULL);
image->vararg_aux_hash = g_hash_table_new (NULL, NULL);
image->handleref = g_hash_table_new (NULL, NULL);
- image->handleref_managed = mono_g_hash_table_new_type ((GHashFunc)mono_object_hash, NULL, MONO_HASH_KEY_GC, MONO_ROOT_SOURCE_REFLECTION, "dynamic module reference-to-token table");
image->tokens = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_REFLECTION, "dynamic module tokens table");
image->generic_def_objects = mono_g_hash_table_new_type (NULL, NULL, MONO_HASH_VALUE_GC, MONO_ROOT_SOURCE_REFLECTION, "dynamic module generic definitions table");
image->typespec = g_hash_table_new ((GHashFunc)mono_metadata_type_hash, (GCompareFunc)mono_metadata_type_equal);
mono_dynamic_image_release_gc_roots (MonoDynamicImage *image)
{
release_hashtable (&image->token_fixups);
- release_hashtable (&image->handleref_managed);
release_hashtable (&image->tokens);
release_hashtable (&image->remapped_tokens);
release_hashtable (&image->generic_def_objects);
g_hash_table_destroy (di->typeref);
if (di->handleref)
g_hash_table_destroy (di->handleref);
- if (di->handleref_managed)
- mono_g_hash_table_destroy (di->handleref_managed);
if (di->tokens)
mono_g_hash_table_destroy (di->tokens);
if (di->remapped_tokens)
#endif /* !PLATFORM_RO_FS */
ICALL(MONOIO_38, "DumpHandles", ves_icall_System_IO_MonoIO_DumpHandles)
ICALL(MONOIO_34, "DuplicateHandle", ves_icall_System_IO_MonoIO_DuplicateHandle)
-ICALL(MONOIO_37, "FindClose", ves_icall_System_IO_MonoIO_FindClose)
ICALL(MONOIO_37a, "FindCloseFile", ves_icall_System_IO_MonoIO_FindCloseFile)
-ICALL(MONOIO_35, "FindFirst", ves_icall_System_IO_MonoIO_FindFirst)
ICALL(MONOIO_35a, "FindFirstFile", ves_icall_System_IO_MonoIO_FindFirstFile)
-ICALL(MONOIO_36, "FindNext", ves_icall_System_IO_MonoIO_FindNext)
ICALL(MONOIO_36a, "FindNextFile", ves_icall_System_IO_MonoIO_FindNextFile)
ICALL(MONOIO_6, "Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush)
ICALL(MONOIO_7, "GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory)
ICALL(MONOIO_8, "GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes)
ICALL(MONOIO_9, "GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat)
-ICALL(MONOIO_10, "GetFileSystemEntries", ves_icall_System_IO_MonoIO_GetFileSystemEntries)
ICALL(MONOIO_11, "GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType)
ICALL(MONOIO_12, "GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength)
#ifndef PLATFORM_RO_FS
ICALL_TYPE(CATTR_DATA, "System.Reflection.CustomAttributeData", CATTR_DATA_1)
ICALL(CATTR_DATA_1, "ResolveArgumentsInternal", ves_icall_System_Reflection_CustomAttributeData_ResolveArgumentsInternal)
-ICALL_TYPE(ASSEMB, "System.Reflection.Emit.AssemblyBuilder", ASSEMB_2)
+ICALL_TYPE(ASSEMB, "System.Reflection.Emit.AssemblyBuilder", ASSEMB_1)
+HANDLES(ICALL(ASSEMB_1, "UpdateNativeCustomAttributes", ves_icall_AssemblyBuilder_UpdateNativeCustomAttributes))
ICALL(ASSEMB_2, "basic_init", ves_icall_AssemblyBuilder_basic_init)
#ifndef DISABLE_REFLECTION_EMIT
GHashTable *typespec;
GHashTable *typeref;
GHashTable *handleref;
- MonoGHashTable *handleref_managed;
MonoGHashTable *tokens;
GHashTable *blob_cache;
GHashTable *standalonesig_cache;
void
ves_icall_AssemblyBuilder_basic_init (MonoReflectionAssemblyBuilder *assemblyb);
-MonoReflectionModule*
-ves_icall_AssemblyBuilder_InternalAddModule (MonoReflectionAssemblyBuilder *ab, MonoString *fileName);
+void
+ves_icall_AssemblyBuilder_UpdateNativeCustomAttributes (MonoReflectionAssemblyBuilderHandle assemblyb, MonoError *error);
MonoArray*
ves_icall_CustomAttributeBuilder_GetBlob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *propValues, MonoArray *fields, MonoArray* fieldValues);
static MonoObject*
mono_runtime_capture_context (MonoDomain *domain, MonoError *error)
{
+#ifdef HOST_WASM
+ return mono_runtime_invoke_checked (mono_get_context_capture_method (), NULL, NULL, error);
+#else
MONO_REQ_GC_UNSAFE_MODE;
RuntimeInvokeFunction runtime_invoke;
runtime_invoke = (RuntimeInvokeFunction)domain->capture_context_runtime_invoke;
return runtime_invoke (NULL, NULL, NULL, domain->capture_context_method);
+#endif
}
/**
* mono_async_result_new:
{
scan_area_arg_start = start_nursery;
scan_area_arg_end = end_nursery;
+#ifdef HOST_WASM
+ //Under WASM we don't scan thread stacks and we can't trust the values we find there either.
+ return;
+#endif
FOREACH_THREAD (info) {
int skip_reason = 0;
#if !defined(MONO_CROSS_COMPILE) && MONO_ARCH_HAS_MONO_CONTEXT
MONO_CONTEXT_GET_CURRENT (info->client_info.ctx);
+#elif defined (HOST_WASM)
+ //nothing
#else
g_error ("Sgen STW requires a working mono-context");
#endif
mono_image_property_insert (image, obj, MONO_PROP_DYNAMIC_CATTR, ainfo);
mono_loader_unlock ();
+}
+#else
+//FIXME some code compiled under DISABLE_REFLECTION_EMIT depends on this function, we should be more aggressively disabling things
+static void
+mono_save_custom_attrs (MonoImage *image, void *obj, MonoArray *cattrs)
+{
}
#endif
#ifndef DISABLE_REFLECTION_EMIT
static guint32
-mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoObjectHandle f, MonoClassField *field)
+mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoClassField *field)
{
MonoType *type;
guint32 token;
g_assert (field);
g_assert (field->parent);
- token = GPOINTER_TO_UINT (mono_g_hash_table_lookup (assembly->handleref_managed, MONO_HANDLE_RAW (f)));
+ token = GPOINTER_TO_UINT (g_hash_table_lookup (assembly->handleref, field));
if (token)
return token;
token = mono_image_get_memberref_token (assembly, &field->parent->byval_arg,
mono_field_get_name (field),
mono_dynimage_encode_fieldref_signature (assembly, field->parent->image, type));
- mono_g_hash_table_insert (assembly->handleref_managed, MONO_HANDLE_RAW (f), GUINT_TO_POINTER(token));
+ g_hash_table_insert (assembly->handleref, field, GUINT_TO_POINTER(token));
return token;
}
gboolean create_open_instance, gboolean register_token,
MonoError *error)
{
+ HANDLE_FUNCTION_ENTER ();
guint32 token = 0;
error_init (error);
MonoClass *klass = mono_handle_class (obj);
+ MonoObjectHandle register_obj = MONO_HANDLE_NEW (MonoObject, NULL);
+ MONO_HANDLE_ASSIGN (register_obj, obj);
/* Check for user defined reflection objects */
/* TypeDelegator is the only corlib type which doesn't look like a MonoReflectionType */
if (klass->image != mono_defaults.corlib || (strcmp (klass->name, "TypeDelegator") == 0)) {
mono_error_set_not_supported (error, "User defined subclasses of System.Type are not yet supported");
- return 0;
+ goto leave;
}
/* This function is called from ModuleBuilder:getToken multiple times for the same objects */
if (strcmp (klass->name, "RuntimeType") == 0) {
MonoType *type = mono_reflection_type_handle_mono_type (MONO_HANDLE_CAST (MonoReflectionType, obj), error);
- return_val_if_nok (error, 0);
+ if (!is_ok (error))
+ goto leave;
MonoClass *mc = mono_class_from_mono_type (type);
token = mono_metadata_token_from_dor (
mono_dynimage_encode_typedef_or_ref_full (assembly, type, !mono_class_is_gtd (mc) || create_open_instance));
how_collide = MONO_DYN_IMAGE_TOK_NEW;
}
} else {
- token = mono_image_get_methodref_token (assembly, method, create_open_instance);
+ guint32 methodref_token = mono_image_get_methodref_token (assembly, method, create_open_instance);
+ /* We need to register a 'canonical' object. The same
+ * MonoMethod could have been reflected via different
+ * classes so the MonoReflectionMethod:reftype could be
+ * different, and the object lookup in
+ * dynamic_image_register_token would assert assert. So
+ * we pick the MonoReflectionMethod object that has the
+ * reflected type as NULL (ie, take the declaring type
+ * of the method) */
+ MonoReflectionMethodHandle canonical_obj =
+ mono_method_get_object_handle (MONO_HANDLE_DOMAIN (obj), method, NULL, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ASSIGN (register_obj, canonical_obj);
+ token = methodref_token;
}
/*g_print ("got token 0x%08x for %s\n", token, m->method->name);*/
} else if (strcmp (klass->name, "MonoField") == 0) {
token = MONO_TOKEN_FIELD_DEF | field_table_idx;
how_collide = MONO_DYN_IMAGE_TOK_NEW;
} else {
- token = mono_image_get_fieldref_token (assembly, obj, field);
+ guint32 fieldref_token = mono_image_get_fieldref_token (assembly, field);
+ /* Same as methodref: get a canonical object to
+ * register with the token. */
+ MonoReflectionFieldHandle canonical_obj =
+ mono_field_get_object_handle (MONO_HANDLE_DOMAIN (obj), field->parent, field, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ASSIGN (register_obj, canonical_obj);
+ token = fieldref_token;
}
/*g_print ("got token 0x%08x for %s\n", token, f->field->name);*/
} else if (strcmp (klass->name, "MonoArrayMethod") == 0) {
MonoReflectionArrayMethodHandle m = MONO_HANDLE_CAST (MonoReflectionArrayMethod, obj);
- token = mono_image_get_array_token (assembly, m, error);
- return_val_if_nok (error, 0);
+ /* always returns a fresh token */
+ guint32 array_token = mono_image_get_array_token (assembly, m, error);
+ if (!is_ok (error))
+ goto leave;
+ token = array_token;
+ how_collide = MONO_DYN_IMAGE_TOK_NEW;
} else if (strcmp (klass->name, "SignatureHelper") == 0) {
MonoReflectionSigHelperHandle s = MONO_HANDLE_CAST (MonoReflectionSigHelper, obj);
- token = MONO_TOKEN_SIGNATURE | mono_image_get_sighelper_token (assembly, s, error);
- return_val_if_nok (error, 0);
+ /* always returns a fresh token */
+ guint32 sig_token = MONO_TOKEN_SIGNATURE | mono_image_get_sighelper_token (assembly, s, error);
+ if (!is_ok (error))
+ goto leave;
+ token = sig_token;
+ how_collide = MONO_DYN_IMAGE_TOK_NEW;
} else {
g_error ("requested token for %s\n", klass->name);
}
if (register_token)
- mono_dynamic_image_register_token (assembly, token, obj, how_collide);
+ mono_dynamic_image_register_token (assembly, token, register_obj, how_collide);
- return token;
+leave:
+ HANDLE_FUNCTION_RETURN_VAL (token);
}
(rmb->iattrs & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
m = (MonoMethod *)image_g_new0 (image, MonoMethodPInvoke, 1);
else
- m = (MonoMethod *)image_g_new0 (image, MonoMethodWrapper, 1);
+ m = (MonoMethod *)image_g_new0 (image, MonoDynamicMethod, 1);
wrapperm = (MonoMethodWrapper*)m;
}
wrapperm->header = header;
+ MonoDynamicMethod *dm = (MonoDynamicMethod*)wrapperm;
+ dm->assembly = klass->image->assembly;
}
if (rmb->generic_params) {
rmb.refs [i + 1] = handle_class;
}
+ MonoAssembly *ass = NULL;
if (mb->owner) {
MonoType *owner_type = mono_reflection_type_get_handle ((MonoReflectionType*)mb->owner, error);
if (!is_ok (error)) {
return FALSE;
}
klass = mono_class_from_mono_type (owner_type);
+ ass = klass->image->assembly;
} else {
klass = mono_defaults.object_class;
+ ass = (mb->module && mb->module->image) ? mb->module->image->assembly : NULL;
}
mb->mhandle = handle = reflection_methodbuilder_to_mono_method (klass, &rmb, sig, error);
+ ((MonoDynamicMethod*)handle)->assembly = ass;
g_free (rmb.refs);
return_val_if_nok (error, FALSE);
mono_reflection_dynimage_basic_init (assemblyb);
}
+void
+ves_icall_AssemblyBuilder_UpdateNativeCustomAttributes (MonoReflectionAssemblyBuilderHandle assemblyb, MonoError *error)
+{
+ MonoArrayHandle cattrs = MONO_HANDLE_NEW_GET (MonoArray, assemblyb, cattrs);
+
+ MonoReflectionAssemblyHandle assembly_handle = MONO_HANDLE_CAST (MonoReflectionAssembly, assemblyb);
+ MonoAssembly *assembly = MONO_HANDLE_GETVAL (assembly_handle, assembly);
+ g_assert (assembly);
+
+ mono_save_custom_attrs (assembly->image, assembly, MONO_HANDLE_RAW (cattrs));
+}
+
void
ves_icall_EnumBuilder_setup_enum_type (MonoReflectionTypeHandle enumtype,
MonoReflectionTypeHandle t,
return(ret);
}
-static gchar *
-get_search_dir (const gunichar2 *pattern)
-{
- gchar *p;
- gchar *result;
-
- p = g_utf16_to_utf8 (pattern, -1, NULL, NULL, NULL);
- result = g_path_get_dirname (p);
- g_free (p);
- return result;
-}
-
-static GPtrArray *
-get_filesystem_entries (const gunichar2 *path,
- const gunichar2 *path_with_pattern,
- gint attrs, gint mask,
- gint32 *error)
-{
- int i;
- WIN32_FIND_DATA data;
- HANDLE find_handle;
- GPtrArray *names = NULL;
- gchar *utf8_path = NULL, *utf8_result, *full_name;
- gint32 attributes;
-
- mask = convert_attrs ((MonoFileAttributes)mask);
- attributes = get_file_attributes (path);
- if (attributes != -1) {
- if ((attributes & FILE_ATTRIBUTE_DIRECTORY) == 0) {
- *error = ERROR_INVALID_NAME;
- goto fail;
- }
- } else {
- *error = mono_w32error_get_last ();
- goto fail;
- }
-
- find_handle = mono_w32file_find_first (path_with_pattern, &data);
- if (find_handle == INVALID_HANDLE_VALUE) {
- gint32 find_error = mono_w32error_get_last ();
-
- if (find_error == ERROR_FILE_NOT_FOUND || find_error == ERROR_NO_MORE_FILES) {
- /* No files, so just return an empty array */
- goto fail;
- }
-
- *error = find_error;
- goto fail;
- }
-
- utf8_path = get_search_dir (path_with_pattern);
- names = g_ptr_array_new ();
-
- do {
- if ((data.cFileName[0] == '.' && data.cFileName[1] == 0) ||
- (data.cFileName[0] == '.' && data.cFileName[1] == '.' && data.cFileName[2] == 0)) {
- continue;
- }
-
- if ((data.dwFileAttributes & mask) == attrs) {
- utf8_result = g_utf16_to_utf8 (data.cFileName, -1, NULL, NULL, NULL);
- if (utf8_result == NULL) {
- continue;
- }
-
- full_name = g_build_filename (utf8_path, utf8_result, NULL);
- g_ptr_array_add (names, full_name);
-
- g_free (utf8_result);
- }
- } while(mono_w32file_find_next (find_handle, &data));
-
- if (mono_w32file_find_close (find_handle) == FALSE) {
- *error = mono_w32error_get_last ();
- goto fail;
- }
-
- g_free (utf8_path);
- return names;
-fail:
- if (names) {
- for (i = 0; i < names->len; i++)
- g_free (g_ptr_array_index (names, i));
- g_ptr_array_free (names, TRUE);
- }
- g_free (utf8_path);
- return FALSE;
-}
-
-
-MonoArray *
-ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
- MonoString *path_with_pattern,
- gint attrs, gint mask,
- gint32 *ioerror)
-{
- MonoError error;
- MonoDomain *domain = mono_domain_get ();
- MonoArray *result;
- int i;
- GPtrArray *names;
-
- *ioerror = ERROR_SUCCESS;
-
- names = get_filesystem_entries (mono_string_chars (path), mono_string_chars (path_with_pattern), attrs, mask, ioerror);
-
- if (!names) {
- // If there's no array and no error, then return an empty array.
- if (*ioerror == ERROR_SUCCESS) {
- MonoArray *arr = mono_array_new_checked (domain, mono_defaults.string_class, 0, &error);
- mono_error_set_pending_exception (&error);
- return arr;
- }
- return NULL;
- }
-
- result = mono_array_new_checked (domain, mono_defaults.string_class, names->len, &error);
- if (mono_error_set_pending_exception (&error))
- goto leave;
- for (i = 0; i < names->len; i++) {
- MonoString *name = mono_string_new_checked (domain, (const char *)g_ptr_array_index (names, i), &error);
- if (mono_error_set_pending_exception (&error))
- goto leave;
- mono_array_setref (result, i, name);
- g_free (g_ptr_array_index (names, i));
- }
-leave:
- g_ptr_array_free (names, TRUE);
- return result;
-}
-
-typedef struct {
- MonoDomain *domain;
- gchar *utf8_path;
- HANDLE find_handle;
-} IncrementalFind;
-
-static gboolean
-incremental_find_check_match (IncrementalFind *handle, WIN32_FIND_DATA *data, MonoString **result, MonoError *error)
-{
- error_init (error);
- gchar *utf8_result;
- gchar *full_name;
-
- if ((data->cFileName[0] == '.' && data->cFileName[1] == 0) || (data->cFileName[0] == '.' && data->cFileName[1] == '.' && data->cFileName[2] == 0))
- return FALSE;
-
- utf8_result = g_utf16_to_utf8 (data->cFileName, -1, NULL, NULL, NULL);
- if (utf8_result == NULL)
- return FALSE;
-
- full_name = g_build_filename (handle->utf8_path, utf8_result, NULL);
- g_free (utf8_result);
- *result = mono_string_new_checked (mono_domain_get (), full_name, error);
- g_free (full_name);
- if (!is_ok (error))
- return FALSE;
-
- return TRUE;
-}
-
HANDLE
ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern, MonoString **file_name, gint32 *file_attr, gint32 *ioerror)
{
return mono_w32file_find_close (hnd);
}
-/* FIXME make gc suspendable */
-MonoString *
-ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
- MonoString *path_with_pattern,
- gint32 *result_attr, gint32 *ioerror,
- gpointer *handle)
-{
- MonoError error;
- WIN32_FIND_DATA data;
- HANDLE find_handle;
- IncrementalFind *ifh;
- MonoString *result;
-
- *ioerror = ERROR_SUCCESS;
-
- find_handle = mono_w32file_find_first (mono_string_chars (path_with_pattern), &data);
-
- if (find_handle == INVALID_HANDLE_VALUE) {
- gint32 find_error = mono_w32error_get_last ();
- *handle = NULL;
-
- if (find_error == ERROR_FILE_NOT_FOUND)
- return NULL;
-
- *ioerror = find_error;
- return NULL;
- }
-
- ifh = g_new (IncrementalFind, 1);
- ifh->find_handle = find_handle;
- ifh->utf8_path = mono_string_to_utf8_checked (path, &error);
- if (mono_error_set_pending_exception (&error)) {
- mono_w32file_find_close (find_handle);
- g_free (ifh);
- return NULL;
- }
- ifh->domain = mono_domain_get ();
- *handle = ifh;
-
- while (incremental_find_check_match (ifh, &data, &result, &error) == 0){
- if (!is_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
- if (mono_w32file_find_next (find_handle, &data) == FALSE){
- int e = mono_w32error_get_last ();
- if (e != ERROR_NO_MORE_FILES)
- *ioerror = e;
- return NULL;
- }
- }
- *result_attr = data.dwFileAttributes;
-
- return result;
-}
-
-/* FIXME make gc suspendable */
-MonoString *
-ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_attr, gint32 *ioerror)
-{
- MonoError error;
- IncrementalFind *ifh = (IncrementalFind *)handle;
- WIN32_FIND_DATA data;
- MonoString *result;
-
- error_init (&error);
- *ioerror = ERROR_SUCCESS;
- do {
- if (!is_ok (&error)) {
- mono_error_set_pending_exception (&error);
- return NULL;
- }
- if (mono_w32file_find_next (ifh->find_handle, &data) == FALSE){
- int e = mono_w32error_get_last ();
- if (e != ERROR_NO_MORE_FILES)
- *ioerror = e;
- return NULL;
- }
- } while (incremental_find_check_match (ifh, &data, &result, &error) == 0);
-
- *result_attr = data.dwFileAttributes;
- return result;
-}
-
-int
-ves_icall_System_IO_MonoIO_FindClose (gpointer handle)
-{
- IncrementalFind *ifh = (IncrementalFind *)handle;
- gint32 error;
-
- if (mono_w32file_find_close (ifh->find_handle) == FALSE){
- error = mono_w32error_get_last ();
- } else
- error = ERROR_SUCCESS;
- g_free (ifh->utf8_path);
- g_free (ifh);
-
- return error;
-}
-
MonoString *
ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *io_error)
{
extern MonoBoolean
ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
-MonoArray *
-ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
- MonoString *path_with_pattern,
- gint mask, gint attrs,
- gint32 *error);
-
extern gpointer
ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern,
MonoString **file_name,
extern MonoBoolean
ves_icall_System_IO_MonoIO_FindCloseFile (gpointer hnd);
-extern MonoString *
-ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
- MonoString *path_with_pattern,
- gint32 *result_mask,
- gint32 *error,
- gpointer *handle);
-extern MonoString *
-ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_mask, gint32 *error);
-
-extern int
-ves_icall_System_IO_MonoIO_FindClose (gpointer handle);
-
extern MonoString *
ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
} pair;
} interp_pair;
+static void
+wasm_invoke_l (void *target_func, InterpMethodArguments *margs)
+{
+ gint64 (*func)(void) = target_func;
+
+ gint64 res = func ();
+ *(gint64*)margs->retval = res;
+}
+
static void
wasm_invoke_ll (void *target_func, InterpMethodArguments *margs)
{
*(float*)&margs->iargs [1]);
}
+static void
+wasm_invoke_ff (void *target_func, InterpMethodArguments *margs)
+{
+ float (*func)(float a) = target_func;
+
+ float res = func (*(float*)&margs->fargs [FIDX (0)]);
+ *(float*)margs->retval = res;
+}
+
static void
wasm_enter_icall_trampoline (void *target_func, InterpMethodArguments *margs)
{
wasm_invoke_iiiii (target_func, margs);
else if (!strcmp ("IIIIII", cookie))
wasm_invoke_iiiiii (target_func, margs);
+ else if (!strcmp ("L", cookie))
+ wasm_invoke_l (target_func, margs);
else if (!strcmp ("LL", cookie))
wasm_invoke_ll (target_func, margs);
else if (!strcmp ("LI", cookie))
wasm_invoke_viffff (target_func, margs);
else if (!strcmp ("VIFFFFFI", cookie))
wasm_invoke_vifffffi (target_func, margs);
+ else if (!strcmp ("FF", cookie))
+ wasm_invoke_ff (target_func, margs);
else {
printf ("CANNOT HANDLE COOKIE %s\n", cookie);
g_assert (0);
public delegate void ArrayDelegate (int[,] arr);
+ [Category ("!WASM")] //Requires a working threadpool
static int test_0_array_delegate_full_aot () {
ArrayDelegate d = delegate (int[,] arr) {
};
[Category ("DYNCALL")]
[Category ("!FULLAOT-AMD64")]
+ [Category ("!INTERPRETER")] //known bug in the interpreter
public static int test_0_dyncall_nullable () {
int? v;
[Category ("DYNCALL")]
[Category ("!FULLAOT-AMD64")]
+ [Category ("!INTERPRETER")] //known bug in the interpreter
public static int test_0_large_nullable_invoke () {
var s = new LargeStruct () { a = 1, b = 2, c = 3, d = 4 };
return 0;
}
+#if !__MOBILE__
public static int Main (String[] args) {
return TestDriver.RunTests (typeof (BuiltinTests), args);
}
+#endif
}
}
-class Tests {
+class DevirtualizationTests {
+#if !__MOBILE__
static int Main (string[] args) {
- return TestDriver.RunTests (typeof (Tests), args);
+ return TestDriver.RunTests (typeof (DevirtualizationTests), args);
}
+#endif
static public int test_0_sealed_class_devirt_right_method () {
SealedFinal x = new SealedFinal ();
return 0;
}
+ [Category ("!WASM")] // reported as https://github.com/kripken/emscripten/issues/5603
public static int test_0_simple_double_casts () {
double d = 0xffffffff;
/*
* Regression tests for the GC support in the JIT
*/
-
-class Tests {
-
- static int Main () {
- return TestDriver.RunTests (typeof (Tests));
- }
+#if __MOBILE__
+class GcTests
+#else
+class Tests
+#endif
+{
+#if !__MOBILE__
+ public static int Main (string[] args) {
+ return TestDriver.RunTests (typeof (Tests), args);
+ }
+#endif
public static int test_36_simple () {
// Overflow the registers
return 0;
}
+ class ObjWithShiftOp {
+ public static ObjWithShiftOp operator >> (ObjWithShiftOp bi1, int shiftVal) {
+ clobber_regs_and_gc ();
+ return bi1;
+ }
+ }
+
// Liveness for spill slots holding managed pointers
public static int test_0_liveness_11 () {
- Tests[] arr = new Tests [10];
+ ObjWithShiftOp[] arr = new ObjWithShiftOp [10];
// This uses an ldelema internally
// FIXME: This doesn't crash if mp-s are not correctly tracked, just writes to
// an old object.
return 0;
}
- public static Tests operator >> (Tests bi1, int shiftVal) {
- clobber_regs_and_gc ();
- return bi1;
- }
[MethodImplAttribute (MethodImplOptions.NoInlining)]
public static void liveness_12_inner (int a, int b, int c, int d, int e, int f, object o, ref string s) {
/* needed on arm64 */
if (isinf (sp [-1].data.f))
sp [-1].data.i = 0;
+ /* needed by wasm */
+ else if (isnan (sp [-1].data.f))
+ sp [-1].data.i = 0;
else
sp [-1].data.i = (guint32)sp [-1].data.f;
++ip;
return;
} else {
/* mheader might not exist if this is a delegate invoc, etc */
- if (mheader && *mheader->code == CEE_RET && called_inited) {
+ gboolean has_vt_arg = FALSE;
+ for (i = 0; i < csignature->param_count; i++)
+ has_vt_arg |= !mini_type_is_reference (csignature->params [i]);
+
+ if (mheader && *mheader->code == CEE_RET && called_inited && !has_vt_arg) {
if (td->verbose_level)
g_print ("Inline (empty) call of %s.%s\n", target_method->klass->name, target_method->name);
for (i = 0; i < csignature->param_count; i++) {
MonoException *
mono_interp_transform_method (InterpMethod *imethod, ThreadContext *context)
{
+ MonoError error;
int i, align, size, offset;
MonoMethod *method = imethod->method;
MonoImage *image = method->klass->image;
MonoDomain *domain = imethod->domain;
// g_printerr ("TRANSFORM(0x%016lx): begin %s::%s\n", mono_thread_current (), method->klass->name, method->name);
- method_class_vt = mono_class_vtable (domain, imethod->method->klass);
+ method_class_vt = mono_class_vtable_full (domain, imethod->method->klass, &error);
+ if (!is_ok (&error))
+ return mono_error_convert_to_exception (&error);
+
if (!method_class_vt->initialized) {
- MonoError error;
jmp_buf env;
InterpFrame *last_env_frame = context->env_frame;
jmp_buf *old_env = context->current_env;
break;
case MonoInlineMethod:
if (method->wrapper_type == MONO_WRAPPER_NONE && *ip != CEE_CALLI) {
- m = mono_get_method_full (image, read32 (ip + 1), NULL, generic_context);
- if (m == NULL) {
+ m = mono_get_method_checked (image, read32 (ip + 1), NULL, generic_context, &error);
+ if (!is_ok (&error)) {
g_free (is_bb_start);
- g_error ("FIXME: where to get method and class string?");
- return NULL;
- // return mono_get_exception_missing_method ();
+ return mono_error_convert_to_exception (&error);
}
mono_class_init (m->klass);
if (!mono_class_is_interface (m->klass))
int i;
gboolean val = FALSE;
+ if (m->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD) {
+ MonoDynamicMethod *dm = (MonoDynamicMethod *)m;
+ if (dm->assembly)
+ ass = dm->assembly;
+ }
g_assert (ass);
if (ass->wrap_non_exception_throws_inited)
return ass->wrap_non_exception_throws;
if (mono_ex->trace_ips) {
GList *trace_ips = NULL;
- gpointer ip = RETURN_ADDRESS ();
+ gpointer ip = MONO_RETURN_ADDRESS ();
size_t upper = mono_array_length (mono_ex->trace_ips);
/* regression test suite */
if (!strcmp ("builtin-types", klass->image->assembly_name))
return TRUE;
+ if (!strcmp ("mini_tests", klass->image->assembly_name))
+ return TRUE;
return FALSE;
}
void
mini_init_delegate (MonoDelegate *del)
{
- if (mono_llvm_only)
- del->extra_arg = mini_get_delegate_arg (del->method, del->method_ptr);
#ifdef ENABLE_INTERPRETER
if (mono_use_interpreter)
mono_interp_init_delegate (del);
+ else
#endif
+ if (mono_llvm_only)
+ del->extra_arg = mini_get_delegate_arg (del->method, del->method_ptr);
}
char*
#if defined (HOST_WASM)
-#define RETURN_ADDRESS_N(N) NULL
-#define RETURN_ADDRESS() RETURN_ADDRESS_N(0)
+#define MONO_RETURN_ADDRESS_N(N) NULL
+#define MONO_RETURN_ADDRESS() MONO_RETURN_ADDRESS_N(0)
#elif defined (__GNUC__)
-#define RETURN_ADDRESS_N(N) (__builtin_extract_return_addr (__builtin_return_address (N)))
-#define RETURN_ADDRESS() RETURN_ADDRESS_N(0)
+#define MONO_RETURN_ADDRESS_N(N) (__builtin_extract_return_addr (__builtin_return_address (N)))
+#define MONO_RETURN_ADDRESS() MONO_RETURN_ADDRESS_N(0)
#elif defined(_MSC_VER)
#include <intrin.h>
#pragma intrinsic(_ReturnAddress)
-#define RETURN_ADDRESS() _ReturnAddress()
-#define RETURN_ADDRESS_N(N) NULL
+#define MONO_RETURN_ADDRESS() _ReturnAddress()
+#define MONO_RETURN_ADDRESS_N(N) NULL
#else
return a;
}
+#if __MOBILE__
+ public static test_2_old_test_suite () {
+ return test1 (1);
+ }
+#else
static int Main() {
if (test1 (1) != 2)
return 1;
return 0;
}
+#endif
}
}
g_free (fname);
if (!ebp) {
- printf (") ip: %p\n", RETURN_ADDRESS_N (1));
+ printf (") ip: %p\n", MONO_RETURN_ADDRESS_N (1));
goto unlock;
}
if (method->is_inflated) {
/* FIXME: Might be better to pass the ji itself */
- MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)RETURN_ADDRESS (), NULL);
+ MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_RETURN_ADDRESS (), NULL);
if (ji) {
gsctx = mono_jit_info_get_generic_sharing_context (ji);
if (gsctx && gsctx->is_gsharedvt) {
if (method->is_inflated) {
/* FIXME: Might be better to pass the ji itself */
- MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)RETURN_ADDRESS (), NULL);
+ MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)MONO_RETURN_ADDRESS (), NULL);
if (ji) {
gsctx = mono_jit_info_get_generic_sharing_context (ji);
if (gsctx && gsctx->is_gsharedvt) {
printf ("(unknown return type %x)", mono_method_signature (method)->ret->type);
}
- //printf (" ip: %p\n", RETURN_ADDRESS_N (1));
+ //printf (" ip: %p\n", MONO_RETURN_ADDRESS_N (1));
printf ("\n");
fflush (stdout);
#endif
#endif
-#if defined (TARGET_WASM)
+#if defined (HOST_WASM)
#define DEFAULT_MAJOR SGEN_MAJOR_SERIAL
#define DEFAULT_SWEEP_MODE SGEN_SWEEP_SERIAL
#elif defined(HAVE_CONC_GC_AS_DEFAULT)
* LOCKING: Assumes the GC lock is held.
*/
void
-sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish, gboolean stw)
+sgen_perform_collection_inner (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish, gboolean stw)
{
TV_DECLARE (gc_total_start);
TV_DECLARE (gc_total_end);
sgen_restart_world (oldest_generation_collected);
}
+#ifdef HOST_WASM
+
+typedef struct {
+ size_t requested_size;
+ int generation_to_collect;
+ const char *reason;
+} SgenGcRequest;
+
+static SgenGcRequest gc_request;
+static gboolean pending_request;
+
+extern void request_gc_cycle (void);
+
+#include <emscripten.h>
+
+EMSCRIPTEN_KEEPALIVE void
+mono_gc_pump_callback (void)
+{
+ if (!pending_request)
+ return;
+ pending_request = FALSE;
+ sgen_perform_collection_inner (gc_request.requested_size, gc_request.generation_to_collect, gc_request.reason, TRUE, TRUE);
+}
+#endif
+
+void
+sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish, gboolean stw)
+{
+#ifdef HOST_WASM
+ g_assert (stw); //can't handle non-stw mode (IE, domain unload)
+ //we ignore wait_to_finish
+ if (!pending_request || gc_request.generation_to_collect <= generation_to_collect) { //no active request or request was for a smaller part of the heap
+ gc_request.requested_size = requested_size;
+ gc_request.generation_to_collect = generation_to_collect;
+ gc_request.reason = reason;
+ if (!pending_request) {
+ request_gc_cycle ();
+ pending_request = TRUE;
+ }
+ }
+
+ degraded_mode = 1; //enable degraded mode so allocation can continue
+#else
+ sgen_perform_collection_inner (requested_size, generation_to_collect, reason, wait_to_finish, stw);
+#endif
+}
/*
* ######################################################################
* ######## Memory allocation from the OS
class MSBuild (GitHubPackage):
def __init__ (self):
GitHubPackage.__init__ (self, 'mono', 'msbuild', '15.4',
- revision = '8b76a1d2b9ffc493349a861962e44540ea14eaac')
+ revision = '5bb588162eadfc68c6af8895397f4f65f8008b24')
def build (self):
self.sh ('./cibuild.sh --scope Compile --target Mono --host Mono --config Release')