mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 11:21:39 -10:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cd89eeb84 | ||
|
|
9e9897b9d6 | ||
|
|
8aa227c28e | ||
|
|
38fa35562f | ||
|
|
b990032df2 | ||
|
|
71e9335b8f | ||
|
|
20ee5d06e9 | ||
|
|
e67542745f | ||
|
|
a4d906fa47 | ||
|
|
28d2644a8f | ||
|
|
98a94ddca9 |
No files matched your search
@@ -3020,6 +3020,7 @@ if test "x$host" != "x$target"; then
|
||||
arch_target=amd64;
|
||||
AC_DEFINE(TARGET_AMD64, 1, [...])
|
||||
AC_DEFINE(TARGET_PS4, 1, [...])
|
||||
AC_DEFINE(DISABLE_HW_TRAPS, 1, [...])
|
||||
CPPFLAGS="$CPPFLAGS"
|
||||
# Can't use tls, since it depends on the runtime detection of tls offsets
|
||||
# in mono-compiler.h
|
||||
@@ -3299,6 +3300,11 @@ if test "x$icall_tables" = "xno"; then
|
||||
AC_DEFINE(DISABLE_ICALL_TABLES, 1, [Icall tables disabled])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(division-check,[ --enable-division-check Generate manual checks for division errors rather than relying on signals], division_check=$enableval, division_check=no)
|
||||
if test "x$division_check" = "xyes"; then
|
||||
AC_DEFINE(MONO_ARCH_NEED_DIV_CHECK, 1, [Manual division check generation enabled])
|
||||
fi
|
||||
|
||||
if test "x$with_tls" = "x__thread"; then
|
||||
AC_DEFINE(HAVE_KW_THREAD, 1, [Have __thread keyword])
|
||||
# Pass the information to libgc
|
||||
|
||||
@@ -90,14 +90,14 @@ namespace System
|
||||
*/
|
||||
private List<KeyValuePair<DateTime, TimeType>> transitions;
|
||||
|
||||
private static bool libcNotFound;
|
||||
private static bool readlinkNotFound;
|
||||
|
||||
[DllImport ("libc")]
|
||||
private static extern int readlink (string path, byte[] buffer, int buflen);
|
||||
|
||||
private static string readlink (string path)
|
||||
{
|
||||
if (libcNotFound)
|
||||
if (readlinkNotFound)
|
||||
return null;
|
||||
|
||||
byte[] buf = new byte [512];
|
||||
@@ -106,7 +106,10 @@ namespace System
|
||||
try {
|
||||
ret = readlink (path, buf, buf.Length);
|
||||
} catch (DllNotFoundException e) {
|
||||
libcNotFound = true;
|
||||
readlinkNotFound = true;
|
||||
return null;
|
||||
} catch (EntryPointNotFoundException e) {
|
||||
readlinkNotFound = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
+36
-8
@@ -4853,8 +4853,8 @@ emit_marshal_vtype (EmitMarshalContext *m, int argnum, MonoType *t,
|
||||
}
|
||||
|
||||
/* load pointer to returned value type */
|
||||
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
|
||||
mono_mb_emit_byte (mb, CEE_MONO_VTADDR);
|
||||
mono_mb_emit_byte (mb, CEE_POP);
|
||||
mono_mb_emit_ldloc_addr (mb, 3);
|
||||
/* store the address of the source into local variable 0 */
|
||||
mono_mb_emit_stloc (mb, 0);
|
||||
/* set dst_ptr */
|
||||
@@ -7128,10 +7128,12 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
EmitMarshalContext m;
|
||||
MonoMethodSignature *csig;
|
||||
MonoClass *klass;
|
||||
MonoExceptionClause *clause;
|
||||
int i, argnum, *tmp_locals;
|
||||
int type, param_shift = 0;
|
||||
static MonoMethodSignature *get_last_error_sig = NULL;
|
||||
int coop_gc_stack_dummy, coop_gc_var;
|
||||
int leave_pos;
|
||||
|
||||
memset (&m, 0, sizeof (m));
|
||||
m.mb = mb;
|
||||
@@ -7174,6 +7176,9 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
coop_gc_stack_dummy = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
|
||||
/* local 5, the local to be used when calling the suspend funcs */
|
||||
coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
|
||||
|
||||
clause = (MonoExceptionClause *)mono_image_alloc0 (image, sizeof (MonoExceptionClause));
|
||||
clause->flags = MONO_EXCEPTION_CLAUSE_FINALLY;
|
||||
}
|
||||
|
||||
if (mspecs [0] && mspecs [0]->native == MONO_NATIVE_CUSTOM) {
|
||||
@@ -7194,6 +7199,14 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
tmp_locals [i] = emit_marshal (&m, i + param_shift, sig->params [i], mspecs [i + 1], 0, &csig->params [i], MARSHAL_ACTION_CONV_IN);
|
||||
}
|
||||
|
||||
if (mono_threads_is_coop_enabled ()) {
|
||||
clause->try_offset = mono_mb_get_label (mb);
|
||||
|
||||
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
|
||||
mono_mb_emit_icall (mb, mono_threads_prepare_blocking);
|
||||
mono_mb_emit_stloc (mb, coop_gc_var);
|
||||
}
|
||||
|
||||
/* push all arguments */
|
||||
|
||||
if (sig->hasthis)
|
||||
@@ -7203,12 +7216,6 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
emit_marshal (&m, i + param_shift, sig->params [i], mspecs [i + 1], tmp_locals [i], NULL, MARSHAL_ACTION_PUSH);
|
||||
}
|
||||
|
||||
if (mono_threads_is_coop_enabled ()) {
|
||||
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
|
||||
mono_mb_emit_icall (mb, mono_threads_prepare_blocking);
|
||||
mono_mb_emit_stloc (mb, coop_gc_var);
|
||||
}
|
||||
|
||||
/* call the native method */
|
||||
if (func_param) {
|
||||
mono_mb_emit_byte (mb, CEE_LDARG_0);
|
||||
@@ -7233,6 +7240,9 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
}
|
||||
}
|
||||
|
||||
if (!MONO_TYPE_IS_VOID (sig->ret))
|
||||
mono_mb_emit_stloc (mb, 3);
|
||||
|
||||
/* Set LastError if needed */
|
||||
if (piinfo->piflags & PINVOKE_ATTRIBUTE_SUPPORTS_LAST_ERROR) {
|
||||
if (!get_last_error_sig) {
|
||||
@@ -7254,11 +7264,25 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
}
|
||||
|
||||
if (mono_threads_is_coop_enabled ()) {
|
||||
leave_pos = mono_mb_emit_branch (mb, CEE_LEAVE);
|
||||
|
||||
clause->try_len = mono_mb_get_label (mb) - clause->try_offset;
|
||||
clause->handler_offset = mono_mb_get_label (mb);
|
||||
|
||||
mono_mb_emit_ldloc (mb, coop_gc_var);
|
||||
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
|
||||
mono_mb_emit_icall (mb, mono_threads_finish_blocking);
|
||||
|
||||
mono_mb_emit_byte (mb, CEE_ENDFINALLY);
|
||||
|
||||
clause->handler_len = mono_mb_get_pos (mb) - clause->handler_offset;
|
||||
|
||||
mono_mb_patch_branch (mb, leave_pos);
|
||||
}
|
||||
|
||||
if (!MONO_TYPE_IS_VOID (sig->ret))
|
||||
mono_mb_emit_ldloc (mb, 3);
|
||||
|
||||
/* convert the result */
|
||||
if (!sig->ret->byref) {
|
||||
MonoMarshalSpec *spec = mspecs [0];
|
||||
@@ -7351,6 +7375,10 @@ mono_marshal_emit_native_wrapper (MonoImage *image, MonoMethodBuilder *mb, MonoM
|
||||
mono_mb_emit_ldloc (mb, 3);
|
||||
|
||||
mono_mb_emit_byte (mb, CEE_RET);
|
||||
|
||||
if (mono_threads_is_coop_enabled ()) {
|
||||
mono_mb_set_clauses (mb, 1, clause);
|
||||
}
|
||||
}
|
||||
#endif /* DISABLE_JIT */
|
||||
|
||||
|
||||
@@ -471,6 +471,66 @@ mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins)
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_LDIV:
|
||||
case OP_LREM:
|
||||
case OP_LDIV_UN:
|
||||
case OP_LREM_UN:
|
||||
if (cfg->backend->emulate_div && mono_arch_opcode_needs_emulation (cfg, ins->opcode))
|
||||
emulate = TRUE;
|
||||
if (!emulate) {
|
||||
if (cfg->backend->need_div_check) {
|
||||
int reg1 = alloc_ireg (cfg);
|
||||
int reg2 = alloc_ireg (cfg);
|
||||
int reg3 = alloc_ireg (cfg);
|
||||
/* b == 0 */
|
||||
MONO_EMIT_NEW_LCOMPARE_IMM (cfg, ins->sreg2, 0);
|
||||
MONO_EMIT_NEW_COND_EXC (cfg, IEQ, "DivideByZeroException");
|
||||
if (ins->opcode == OP_LDIV || ins->opcode == OP_LREM) {
|
||||
/* b == -1 && a == 0x80000000 */
|
||||
MONO_EMIT_NEW_I8CONST (cfg, reg3, -1);
|
||||
MONO_EMIT_NEW_BIALU (cfg, OP_LCOMPARE, -1, ins->sreg2, reg3);
|
||||
MONO_EMIT_NEW_UNALU (cfg, OP_LCEQ, reg1, -1);
|
||||
MONO_EMIT_NEW_I8CONST (cfg, reg3, 0x8000000000000000L);
|
||||
MONO_EMIT_NEW_BIALU (cfg, OP_LCOMPARE, -1, ins->sreg1, reg3);
|
||||
MONO_EMIT_NEW_UNALU (cfg, OP_LCEQ, reg2, -1);
|
||||
MONO_EMIT_NEW_BIALU (cfg, OP_IAND, reg1, reg1, reg2);
|
||||
MONO_EMIT_NEW_ICOMPARE_IMM (cfg, reg1, 1);
|
||||
MONO_EMIT_NEW_COND_EXC (cfg, IEQ, "OverflowException");
|
||||
}
|
||||
}
|
||||
MONO_EMIT_NEW_BIALU (cfg, ins->opcode, ins->dreg, ins->sreg1, ins->sreg2);
|
||||
NULLIFY_INS (ins);
|
||||
}
|
||||
break;
|
||||
|
||||
case OP_DIV_IMM:
|
||||
case OP_REM_IMM:
|
||||
case OP_IDIV_IMM:
|
||||
case OP_IREM_IMM:
|
||||
case OP_IDIV_UN_IMM:
|
||||
case OP_IREM_UN_IMM:
|
||||
if (cfg->backend->need_div_check) {
|
||||
int reg1 = alloc_ireg (cfg);
|
||||
/* b == 0 */
|
||||
if (ins->inst_imm == 0) {
|
||||
// FIXME: Optimize this
|
||||
MONO_EMIT_NEW_ICONST (cfg, reg1, 0);
|
||||
MONO_EMIT_NEW_ICOMPARE_IMM (cfg, reg1, 0);
|
||||
MONO_EMIT_NEW_COND_EXC (cfg, IEQ, "DivideByZeroException");
|
||||
}
|
||||
if ((ins->opcode == OP_DIV_IMM || ins->opcode == OP_IDIV_IMM || ins->opcode == OP_REM_IMM || ins->opcode == OP_IREM_IMM) &&
|
||||
(ins->inst_imm == -1)) {
|
||||
/* b == -1 && a == 0x80000000 */
|
||||
MONO_EMIT_NEW_ICOMPARE_IMM (cfg, ins->sreg1, 0x80000000);
|
||||
MONO_EMIT_NEW_COND_EXC (cfg, IEQ, "OverflowException");
|
||||
}
|
||||
MONO_EMIT_NEW_BIALU_IMM (cfg, ins->opcode, ins->dreg, ins->sreg1, ins->inst_imm);
|
||||
NULLIFY_INS (ins);
|
||||
} else {
|
||||
emulate = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
emulate = TRUE;
|
||||
break;
|
||||
|
||||
@@ -1928,6 +1928,14 @@ mono_main (int argc, char* argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DISABLE_HW_TRAPS
|
||||
// Signal handlers not available
|
||||
do {
|
||||
MonoDebugOptions *opt = mini_get_debug_options ();
|
||||
opt->explicit_null_checks = TRUE;
|
||||
} while (0);
|
||||
#endif
|
||||
|
||||
if (!argv [i]) {
|
||||
mini_usage ();
|
||||
return 1;
|
||||
|
||||
@@ -3116,6 +3116,11 @@ void mono_cross_helpers_run (void);
|
||||
* Signal handling
|
||||
*/
|
||||
|
||||
#ifdef DISABLE_HW_TRAPS
|
||||
// Signal handlers not available
|
||||
#define MONO_ARCH_NEED_DIV_CHECK 1
|
||||
#endif
|
||||
|
||||
void MONO_SIG_HANDLER_SIGNATURE (mono_sigfpe_signal_handler) ;
|
||||
void MONO_SIG_HANDLER_SIGNATURE (mono_sigill_signal_handler) ;
|
||||
void MONO_SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
public class Test {
|
||||
public class ThreadPoolTest
|
||||
{
|
||||
|
||||
static int csum = 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user