Skip to content

Commit

Permalink
[mono] Avoid checking for exceptions after calls to Math icalls. (#77347
Browse files Browse the repository at this point in the history
)

* [mono] Avoid checking for exceptions after calls to Math icalls.

Also add a way to turn off exception checking for arbitrary icalls.

* Fix wasm support.
  • Loading branch information
vargaz committed Oct 25, 2022
1 parent 94c9d02 commit 8ace754
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 103 deletions.
2 changes: 2 additions & 0 deletions src/mono/mono/metadata/icall-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef enum {
#include "icall-table.h"

#define NOHANDLES(inner) inner
#define NOHANDLES_FLAGS(inner,flags) inner
#define HANDLES_REUSE_WRAPPER(...) /* nothing */

// Generate prototypes for coop icall wrappers and coop icalls.
Expand All @@ -53,6 +54,7 @@ typedef enum {
#undef HANDLES
#undef HANDLES_REUSE_WRAPPER
#undef NOHANDLES
#undef NOHANDLES_FLAGS
#undef MONO_HANDLE_REGISTER_ICALL

// This is sorted.
Expand Down
102 changes: 51 additions & 51 deletions src/mono/mono/metadata/icall-def.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,59 +221,59 @@ HANDLES(STREAM_1, "HasOverriddenBeginEndRead", ves_icall_System_IO_Stream_HasOve
HANDLES(STREAM_2, "HasOverriddenBeginEndWrite", ves_icall_System_IO_Stream_HasOverriddenBeginEndWrite, MonoBoolean, 1, (MonoObject))

ICALL_TYPE(MATH, "System.Math", MATH_1)
NOHANDLES(ICALL(MATH_1, "Acos", ves_icall_System_Math_Acos))
NOHANDLES(ICALL(MATH_1a, "Acosh", ves_icall_System_Math_Acosh))
NOHANDLES(ICALL(MATH_2, "Asin", ves_icall_System_Math_Asin))
NOHANDLES(ICALL(MATH_2a, "Asinh", ves_icall_System_Math_Asinh))
NOHANDLES(ICALL(MATH_3, "Atan", ves_icall_System_Math_Atan))
NOHANDLES(ICALL(MATH_4, "Atan2", ves_icall_System_Math_Atan2))
NOHANDLES(ICALL(MATH_4a, "Atanh", ves_icall_System_Math_Atanh))
NOHANDLES(ICALL(MATH_4b, "Cbrt", ves_icall_System_Math_Cbrt))
NOHANDLES(ICALL(MATH_21, "Ceiling", ves_icall_System_Math_Ceiling))
NOHANDLES(ICALL(MATH_5, "Cos", ves_icall_System_Math_Cos))
NOHANDLES(ICALL(MATH_6, "Cosh", ves_icall_System_Math_Cosh))
NOHANDLES(ICALL(MATH_7, "Exp", ves_icall_System_Math_Exp))
NOHANDLES(ICALL(MATH_7a, "FMod", ves_icall_System_Math_FMod))
NOHANDLES(ICALL(MATH_8, "Floor", ves_icall_System_Math_Floor))
NOHANDLES(ICALL(MATH_22, "FusedMultiplyAdd", ves_icall_System_Math_FusedMultiplyAdd))
NOHANDLES(ICALL(MATH_9, "Log", ves_icall_System_Math_Log))
NOHANDLES(ICALL(MATH_10, "Log10", ves_icall_System_Math_Log10))
NOHANDLES(ICALL(MATH_24, "Log2", ves_icall_System_Math_Log2))
NOHANDLES(ICALL(MATH_10a, "ModF", ves_icall_System_Math_ModF))
NOHANDLES(ICALL(MATH_11, "Pow", ves_icall_System_Math_Pow))
NOHANDLES(ICALL(MATH_12, "Round", ves_icall_System_Math_Round))
NOHANDLES(ICALL(MATH_14, "Sin", ves_icall_System_Math_Sin))
NOHANDLES(ICALL(MATH_15, "Sinh", ves_icall_System_Math_Sinh))
NOHANDLES(ICALL(MATH_16, "Sqrt", ves_icall_System_Math_Sqrt))
NOHANDLES(ICALL(MATH_17, "Tan", ves_icall_System_Math_Tan))
NOHANDLES(ICALL(MATH_18, "Tanh", ves_icall_System_Math_Tanh))
NOHANDLES_FLAGS(ICALL(MATH_1, "Acos", ves_icall_System_Math_Acos), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_1a, "Acosh", ves_icall_System_Math_Acosh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_2, "Asin", ves_icall_System_Math_Asin), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_2a, "Asinh", ves_icall_System_Math_Asinh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_3, "Atan", ves_icall_System_Math_Atan), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_4, "Atan2", ves_icall_System_Math_Atan2), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_4a, "Atanh", ves_icall_System_Math_Atanh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_4b, "Cbrt", ves_icall_System_Math_Cbrt), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_21, "Ceiling", ves_icall_System_Math_Ceiling), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_5, "Cos", ves_icall_System_Math_Cos), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_6, "Cosh", ves_icall_System_Math_Cosh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_7, "Exp", ves_icall_System_Math_Exp), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_7a, "FMod", ves_icall_System_Math_FMod), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_8, "Floor", ves_icall_System_Math_Floor), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_22, "FusedMultiplyAdd", ves_icall_System_Math_FusedMultiplyAdd), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_9, "Log", ves_icall_System_Math_Log), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_10, "Log10", ves_icall_System_Math_Log10), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_24, "Log2", ves_icall_System_Math_Log2), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_10a, "ModF", ves_icall_System_Math_ModF), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_11, "Pow", ves_icall_System_Math_Pow), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_12, "Round", ves_icall_System_Math_Round), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_14, "Sin", ves_icall_System_Math_Sin), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_15, "Sinh", ves_icall_System_Math_Sinh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_16, "Sqrt", ves_icall_System_Math_Sqrt), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_17, "Tan", ves_icall_System_Math_Tan), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATH_18, "Tanh", ves_icall_System_Math_Tanh), MONO_ICALL_FLAGS_NO_EXCEPTION)

ICALL_TYPE(MATHF, "System.MathF", MATHF_1)
NOHANDLES(ICALL(MATHF_1, "Acos", ves_icall_System_MathF_Acos))
NOHANDLES(ICALL(MATHF_2, "Acosh", ves_icall_System_MathF_Acosh))
NOHANDLES(ICALL(MATHF_3, "Asin", ves_icall_System_MathF_Asin))
NOHANDLES(ICALL(MATHF_4, "Asinh", ves_icall_System_MathF_Asinh))
NOHANDLES(ICALL(MATHF_5, "Atan", ves_icall_System_MathF_Atan))
NOHANDLES(ICALL(MATHF_6, "Atan2", ves_icall_System_MathF_Atan2))
NOHANDLES(ICALL(MATHF_7, "Atanh", ves_icall_System_MathF_Atanh))
NOHANDLES(ICALL(MATHF_8, "Cbrt", ves_icall_System_MathF_Cbrt))
NOHANDLES(ICALL(MATHF_9, "Ceiling", ves_icall_System_MathF_Ceiling))
NOHANDLES(ICALL(MATHF_10, "Cos", ves_icall_System_MathF_Cos))
NOHANDLES(ICALL(MATHF_11, "Cosh", ves_icall_System_MathF_Cosh))
NOHANDLES(ICALL(MATHF_12, "Exp", ves_icall_System_MathF_Exp))
NOHANDLES(ICALL(MATHF_22, "FMod", ves_icall_System_MathF_FMod))
NOHANDLES(ICALL(MATHF_13, "Floor", ves_icall_System_MathF_Floor))
NOHANDLES(ICALL(MATHF_24, "FusedMultiplyAdd", ves_icall_System_MathF_FusedMultiplyAdd))
NOHANDLES(ICALL(MATHF_14, "Log", ves_icall_System_MathF_Log))
NOHANDLES(ICALL(MATHF_15, "Log10", ves_icall_System_MathF_Log10))
NOHANDLES(ICALL(MATHF_26, "Log2", ves_icall_System_MathF_Log2))
NOHANDLES(ICALL(MATHF_23, "ModF(single,single*)", ves_icall_System_MathF_ModF))
NOHANDLES(ICALL(MATHF_16, "Pow", ves_icall_System_MathF_Pow))
NOHANDLES(ICALL(MATHF_17, "Sin", ves_icall_System_MathF_Sin))
NOHANDLES(ICALL(MATHF_18, "Sinh", ves_icall_System_MathF_Sinh))
NOHANDLES(ICALL(MATHF_19, "Sqrt", ves_icall_System_MathF_Sqrt))
NOHANDLES(ICALL(MATHF_20, "Tan", ves_icall_System_MathF_Tan))
NOHANDLES(ICALL(MATHF_21, "Tanh", ves_icall_System_MathF_Tanh))
NOHANDLES_FLAGS(ICALL(MATHF_1, "Acos", ves_icall_System_MathF_Acos), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_2, "Acosh", ves_icall_System_MathF_Acosh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_3, "Asin", ves_icall_System_MathF_Asin), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_4, "Asinh", ves_icall_System_MathF_Asinh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_5, "Atan", ves_icall_System_MathF_Atan), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_6, "Atan2", ves_icall_System_MathF_Atan2), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_7, "Atanh", ves_icall_System_MathF_Atanh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_8, "Cbrt", ves_icall_System_MathF_Cbrt), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_9, "Ceiling", ves_icall_System_MathF_Ceiling), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_10, "Cos", ves_icall_System_MathF_Cos), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_11, "Cosh", ves_icall_System_MathF_Cosh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_12, "Exp", ves_icall_System_MathF_Exp), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_22, "FMod", ves_icall_System_MathF_FMod), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_13, "Floor", ves_icall_System_MathF_Floor), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_24, "FusedMultiplyAdd", ves_icall_System_MathF_FusedMultiplyAdd), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_14, "Log", ves_icall_System_MathF_Log), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_15, "Log10", ves_icall_System_MathF_Log10), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_26, "Log2", ves_icall_System_MathF_Log2), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_23, "ModF(single,single*)", ves_icall_System_MathF_ModF), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_16, "Pow", ves_icall_System_MathF_Pow), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_17, "Sin", ves_icall_System_MathF_Sin), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_18, "Sinh", ves_icall_System_MathF_Sinh), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_19, "Sqrt", ves_icall_System_MathF_Sqrt), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_20, "Tan", ves_icall_System_MathF_Tan), MONO_ICALL_FLAGS_NO_EXCEPTION)
NOHANDLES_FLAGS(ICALL(MATHF_21, "Tanh", ves_icall_System_MathF_Tanh), MONO_ICALL_FLAGS_NO_EXCEPTION)

ICALL_TYPE(OBJ, "System.Object", OBJ_3)
HANDLES(OBJ_3, "MemberwiseClone", ves_icall_System_Object_MemberwiseClone, MonoObject, 1, (MonoObject))
Expand Down
8 changes: 0 additions & 8 deletions src/mono/mono/metadata/icall-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ mono_add_internal_call_internal (const char *name, gconstpointer method);
MonoAssembly*
mono_runtime_get_caller_from_stack_mark (MonoStackCrawlMark *stack_mark);

typedef enum {
MONO_ICALL_FLAGS_NONE = 0,
MONO_ICALL_FLAGS_FOREIGN = 1 << 1,
MONO_ICALL_FLAGS_USES_HANDLES = 1 << 2,
MONO_ICALL_FLAGS_COOPERATIVE = 1 << 3,
MONO_ICALL_FLAGS_NO_WRAPPER = 1 << 4
} MonoInternalCallFlags;

gconstpointer
mono_lookup_internal_call_full_with_flags (MonoMethod *method, gboolean warn_on_missing, guint32 *flags);

Expand Down
31 changes: 18 additions & 13 deletions src/mono/mono/metadata/icall-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

// These definitions are used for multiple includes of icall-def.h and eventually undefined.
#define NOHANDLES(inner) inner
#define NOHANDLES_FLAGS(inner,flags) inner
#define HANDLES(id, name, func, ...) ICALL (id, name, func ## _raw)
#define HANDLES_REUSE_WRAPPER HANDLES
#define MONO_HANDLE_REGISTER_ICALL(...) /* nothing */
Expand Down Expand Up @@ -156,12 +157,14 @@ static const MonoICallFunction icall_functions [] = {

#undef HANDLES
#undef NOHANDLES
#undef NOHANDLES_FLAGS

static const guchar icall_uses_handles [] = {
static const guchar icall_flags [] = {
#define ICALL_TYPE(id,name,first) /* nothing */
#define ICALL(id,name,func) 0,
#define HANDLES(...) 1,
#define HANDLES(...) MONO_ICALL_FLAGS_USES_HANDLES,
#define NOHANDLES(inner) 0,
#define NOHANDLES_FLAGS(inner,flags) flags,
#include "metadata/icall-def.h"
#undef ICALL_TYPE
#undef ICALL
Expand All @@ -170,6 +173,7 @@ static const guchar icall_uses_handles [] = {
#undef HANDLES
#undef HANDLES_REUSE_WRAPPER
#undef NOHANDLES
#undef NOHANDLES_FLAGS
#undef MONO_HANDLE_REGISTER_ICALL

static int
Expand All @@ -188,13 +192,13 @@ find_slot_icall (const IcallTypeDesc *imap, const char *name)
return (nameslot - &icall_names_idx [0]);
}

static gboolean
find_uses_handles_icall (const IcallTypeDesc *imap, const char *name)
static MonoInternalCallFlags
find_icall_flags (const IcallTypeDesc *imap, const char *name)
{
const gssize slotnum = find_slot_icall (imap, name);
if (slotnum == -1)
return FALSE;
return (gboolean)icall_uses_handles [slotnum];
return 0;
return (MonoInternalCallFlags)icall_flags [slotnum];
}

static gpointer
Expand Down Expand Up @@ -223,31 +227,32 @@ find_class_icalls (const char *name)
}

static gpointer
icall_table_lookup (MonoMethod *method, char *classname, char *methodname, char *sigstart, gboolean *uses_handles)
icall_table_lookup (MonoMethod *method, char *classname, char *methodname, char *sigstart, MonoInternalCallFlags *out_flags)
{
const IcallTypeDesc *imap = NULL;
gpointer res;

imap = find_class_icalls (classname);

if (out_flags)
*out_flags = 0;

/* it wasn't found in the static call tables */
if (!imap) {
if (uses_handles)
*uses_handles = FALSE;
return NULL;
}
res = find_method_icall (imap, methodname);
if (res) {
if (uses_handles)
*uses_handles = find_uses_handles_icall (imap, methodname);
if (out_flags)
*out_flags = find_icall_flags (imap, methodname);
return res;
}
/* try _with_ signature */
*sigstart = '(';
res = find_method_icall (imap, methodname);
if (res) {
if (uses_handles)
*uses_handles = find_uses_handles_icall (imap, methodname);
if (out_flags)
*out_flags = find_icall_flags (imap, methodname);
return res;
}
return NULL;
Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/icall-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include "marshal.h"
#include "icalls.h"

#define MONO_ICALL_TABLE_CALLBACKS_VERSION 2
#define MONO_ICALL_TABLE_CALLBACKS_VERSION 3

typedef struct {
int version;
gpointer (*lookup) (MonoMethod *method, char *classname, char *methodname, char *sigstart, gboolean *uses_handles);
gpointer (*lookup) (MonoMethod *method, char *classname, char *methodname, char *sigstart, MonoInternalCallFlags *out_flags);
const char* (*lookup_icall_symbol) (gpointer func);
} MonoIcallTableCallbacks;

Expand Down
10 changes: 6 additions & 4 deletions src/mono/mono/metadata/icall.c
Original file line number Diff line number Diff line change
Expand Up @@ -6901,11 +6901,11 @@ mono_lookup_internal_call_full_with_flags (MonoMethod *method, gboolean warn_on_
res = (gconstpointer)no_icall_table;
goto exit;
} else {
gboolean uses_handles = FALSE;
MonoInternalCallFlags icall_flags;
g_assert (icall_table->lookup);
res = icall_table->lookup (method, classname, sigstart - mlen, sigstart, &uses_handles);
if (res && flags && uses_handles)
*flags = *flags | MONO_ICALL_FLAGS_USES_HANDLES;
res = icall_table->lookup (method, classname, sigstart - mlen, sigstart, &icall_flags);
if (res && flags)
*flags = *flags | icall_flags;
mono_icall_unlock ();
locked = FALSE;

Expand Down Expand Up @@ -7191,6 +7191,7 @@ ves_icall_System_Environment_get_ProcessorCount (void)
#define ICALL_TYPE(id,name,first) /* nothing */
#define ICALL(id,name,func) /* nothing */
#define NOHANDLES(inner) /* nothing */
#define NOHANDLES_FLAGS(inner,flags) /* nothing */

#define MONO_HANDLE_REGISTER_ICALL(func, ret, nargs, argtypes) MONO_HANDLE_REGISTER_ICALL_IMPLEMENT (func, ret, nargs, argtypes)

Expand All @@ -7212,4 +7213,5 @@ ves_icall_System_Environment_get_ProcessorCount (void)
#undef ICALL_TYPE
#undef ICALL
#undef NOHANDLES
#undef NOHANDLES_FLAGS
#undef MONO_HANDLE_REGISTER_ICALL
9 changes: 9 additions & 0 deletions src/mono/mono/metadata/icalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@

#include <mono/utils/mono-publib.h>

typedef enum {
MONO_ICALL_FLAGS_NONE = 0,
MONO_ICALL_FLAGS_FOREIGN = 1 << 1,
MONO_ICALL_FLAGS_USES_HANDLES = 1 << 2,
MONO_ICALL_FLAGS_COOPERATIVE = 1 << 3,
MONO_ICALL_FLAGS_NO_WRAPPER = 1 << 4,
MONO_ICALL_FLAGS_NO_EXCEPTION = 1 << 5,
} MonoInternalCallFlags;

#ifdef ENABLE_ICALL_EXPORT
#define ICALL_EXPORT MONO_API
#define ICALL_EXTERN_C G_EXTERN_C
Expand Down
11 changes: 9 additions & 2 deletions src/mono/mono/metadata/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ MONO_PRAGMA_WARNING_POP()
#include "mono/metadata/custom-attrs-internals.h"
#include "mono/metadata/loader-internals.h"
#include "mono/metadata/jit-info.h"
#include "mono/metadata/icall-internals.h"
#include "mono/utils/mono-counters.h"
#include "mono/utils/mono-tls.h"
#include "mono/utils/mono-memory-model.h"
Expand Down Expand Up @@ -3382,8 +3383,6 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
ERROR_DECL (emitted_error);
WrapperInfo *info;



g_assert (method != NULL);
g_assertf (mono_method_signature_internal (method)->pinvoke, "%s flags:%X iflags:%X param_count:%X",
method->name, method->flags, method->iflags, mono_method_signature_internal (method)->param_count);
Expand All @@ -3409,6 +3408,14 @@ mono_marshal_get_native_wrapper (MonoMethod *method, gboolean check_exceptions,
if ((res = mono_marshal_find_in_cache (cache, method)))
return res;

if (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) {
guint32 icall_flags = 0;
if (mono_lookup_internal_call_full_with_flags (method, FALSE, &icall_flags)) {
if (icall_flags & MONO_ICALL_FLAGS_NO_EXCEPTION)
check_exceptions = FALSE;
}
}

if (MONO_CLASS_IS_IMPORT (method->klass)) {
/* The COM code is not AOT compatible, it calls mono_custom_attrs_get_attr_checked () */
if (aot)
Expand Down
5 changes: 3 additions & 2 deletions src/mono/mono/mini/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -2021,11 +2021,12 @@ print_icall_table (void)

printf ("[\n{ \"klass\": \"\", \"icalls\": [");
#define NOHANDLES(inner) inner
#define HANDLES(id, name, func, ...) printf ("\t,{ \"name\": \"%s\", \"func\": \"%s_raw\", \"handles\": true }\n", name, #func);
#define NOHANDLES_FLAGS(inner,flags) inner
#define HANDLES(id, name, func, ...) printf ("\t,{ \"name\": \"%s\", \"func\": \"%s_raw\", \"handles\": true, \"flags\": \"%d\" }\n", name, #func, MONO_ICALL_FLAGS_USES_HANDLES);
#define HANDLES_REUSE_WRAPPER HANDLES
#define MONO_HANDLE_REGISTER_ICALL(...) /* nothing */
#define ICALL_TYPE(id,name,first) printf ("]},\n { \"klass\":\"%s\", \"icalls\": [{} ", name);
#define ICALL(id,name,func) printf ("\t,{ \"name\": \"%s\", \"func\": \"%s\", \"handles\": false }\n", name, #func);
#define ICALL(id,name,func) printf ("\t,{ \"name\": \"%s\", \"func\": \"%s\", \"handles\": false, \"flags\": \"0\" }\n", name, #func);
#include <mono/metadata/icall-def.h>

printf ("]}\n]\n");
Expand Down

0 comments on commit 8ace754

Please sign in to comment.