mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-16 17:10:20 -10:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50d4088349 | ||
|
|
faecc312c9 | ||
|
|
bfa7186158 | ||
|
|
5f246a5889 | ||
|
|
dcc4db5d78 | ||
|
|
433017c011 | ||
|
|
c5fbe7ae03 |
No files matched your search
@@ -37,6 +37,7 @@ namespace Mono.Linker.Steps {
|
||||
public class SweepStep : BaseStep {
|
||||
|
||||
AssemblyDefinition [] assemblies;
|
||||
HashSet<AssemblyDefinition> resolvedTypeReferences;
|
||||
|
||||
protected override void Process ()
|
||||
{
|
||||
@@ -102,21 +103,51 @@ namespace Mono.Linker.Steps {
|
||||
references.RemoveAt (i);
|
||||
// Removing the reference does not mean it will be saved back to disk!
|
||||
// That depends on the AssemblyAction set for the `assembly`
|
||||
if (Annotations.GetAction (assembly) == AssemblyAction.Copy) {
|
||||
switch (Annotations.GetAction (assembly)) {
|
||||
case AssemblyAction.Copy:
|
||||
// Copy means even if "unlinked" we still want that assembly to be saved back
|
||||
// to disk (OutputStep) without the (removed) reference
|
||||
Annotations.SetAction (assembly, AssemblyAction.Save);
|
||||
// note: we only enter here (Copy->Save once) so we nned to do the complete job
|
||||
foreach (TypeReference tr in assembly.MainModule.GetTypeReferences ()) {
|
||||
var td = tr.Resolve ();
|
||||
// at this stage reference might include things that can't be resolved
|
||||
tr.Scope = td == null ? null : assembly.MainModule.Import (td).Scope;
|
||||
}
|
||||
ResolveAllTypeReferences (assembly);
|
||||
break;
|
||||
|
||||
case AssemblyAction.Save:
|
||||
case AssemblyAction.Link:
|
||||
ResolveAllTypeReferences (assembly);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void ResolveAllTypeReferences (AssemblyDefinition assembly)
|
||||
{
|
||||
if (resolvedTypeReferences == null)
|
||||
resolvedTypeReferences = new HashSet<AssemblyDefinition> ();
|
||||
if (resolvedTypeReferences.Contains (assembly))
|
||||
return;
|
||||
resolvedTypeReferences.Add (assembly);
|
||||
|
||||
var hash = new Dictionary<TypeReference,IMetadataScope> ();
|
||||
|
||||
foreach (TypeReference tr in assembly.MainModule.GetTypeReferences ()) {
|
||||
if (hash.ContainsKey (tr))
|
||||
continue;
|
||||
var td = tr.Resolve ();
|
||||
// at this stage reference might include things that can't be resolved
|
||||
var scope = td == null ? null : assembly.MainModule.Import (td).Scope;
|
||||
hash.Add (tr, scope);
|
||||
}
|
||||
|
||||
// Resolve everything first before updating scopes.
|
||||
// If we set the scope to null, then calling Resolve() on any of its
|
||||
// nested types would crash.
|
||||
|
||||
foreach (var e in hash) {
|
||||
e.Key.Scope = e.Value;
|
||||
}
|
||||
}
|
||||
|
||||
void SweepType (TypeDefinition type)
|
||||
{
|
||||
if (type.HasFields)
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Mono.Tuner {
|
||||
|
||||
public abstract SubStepTargets Targets { get; }
|
||||
|
||||
void ISubStep.Initialize (LinkContext context)
|
||||
public virtual void Initialize (LinkContext context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@@ -76,6 +76,7 @@
|
||||
#include <mono/utils/mono-time.h>
|
||||
#include <mono/utils/mono-membar.h>
|
||||
#include <mono/utils/mono-mutex.h>
|
||||
#include <mono/utils/mono-signal-handler.h>
|
||||
|
||||
/* The process' environment strings */
|
||||
#if defined(__APPLE__) && !defined (__arm__)
|
||||
@@ -2828,8 +2829,7 @@ process_close (gpointer handle, gpointer data)
|
||||
}
|
||||
|
||||
#if HAVE_SIGACTION
|
||||
static void
|
||||
mono_sigchld_signal_handler (int _dummy, siginfo_t *info, void *context)
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, mono_sigchld_signal_handler, (int _dummy, siginfo_t *info, void *context))
|
||||
{
|
||||
int status;
|
||||
int pid;
|
||||
@@ -2870,6 +2870,7 @@ mono_sigchld_signal_handler (int _dummy, siginfo_t *info, void *context)
|
||||
fprintf (stdout, "SIG CHILD handler: done looping.");
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static void process_add_sigchld_handler (void)
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <mono/metadata/gc-internal.h>
|
||||
#include <mono/metadata/metadata.h>
|
||||
#include <mono/metadata/threadpool.h>
|
||||
#include <mono/utils/mono-signal-handler.h>
|
||||
|
||||
/* On solaris, curses.h must come before both termios.h and term.h */
|
||||
#ifdef HAVE_CURSES_H
|
||||
@@ -272,8 +273,8 @@ mono_console_handle_async_ops (void)
|
||||
}
|
||||
|
||||
static gboolean in_sigint;
|
||||
static void
|
||||
sigint_handler (int signo)
|
||||
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, sigint_handler, (int signo))
|
||||
{
|
||||
int save_errno;
|
||||
MONO_ARCH_SAVE_REGS;
|
||||
@@ -291,8 +292,7 @@ sigint_handler (int signo)
|
||||
|
||||
static struct sigaction save_sigcont, save_sigint, save_sigwinch;
|
||||
|
||||
static void
|
||||
sigcont_handler (int signo, void *the_siginfo, void *data)
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, sigcont_handler, (int signo, void *the_siginfo, void *data))
|
||||
{
|
||||
int unused;
|
||||
// Ignore error, there is not much we can do in the sigcont handler.
|
||||
@@ -308,8 +308,7 @@ sigcont_handler (int signo, void *the_siginfo, void *data)
|
||||
(*save_sigcont.sa_sigaction) (signo, the_siginfo, data);
|
||||
}
|
||||
|
||||
static void
|
||||
sigwinch_handler (int signo, void *the_siginfo, void *data)
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, sigwinch_handler, (int signo, void *the_siginfo, void *data))
|
||||
{
|
||||
int dims = terminal_get_dimensions ();
|
||||
if (dims != -1)
|
||||
@@ -358,7 +357,7 @@ console_set_signal_handlers ()
|
||||
sigaction (SIGCONT, &sigcont, &save_sigcont);
|
||||
|
||||
// Interrupt handler
|
||||
sigint.sa_handler = sigint_handler;
|
||||
sigint.sa_handler = (void *) sigint_handler;
|
||||
sigint.sa_flags = 0;
|
||||
sigemptyset (&sigint.sa_mask);
|
||||
sigaction (SIGINT, &sigint, &save_sigint);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "metadata/gc-internal.h"
|
||||
#include "metadata/sgen-archdep.h"
|
||||
#include "metadata/object-internals.h"
|
||||
#include "utils/mono-signal-handler.h"
|
||||
|
||||
#if defined(__APPLE__) || defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
const static int suspend_signal_num = SIGXFSZ;
|
||||
@@ -121,8 +122,7 @@ suspend_thread (SgenThreadInfo *info, void *context)
|
||||
}
|
||||
|
||||
/* LOCKING: assumes the GC lock is held (by the stopping thread) */
|
||||
static void
|
||||
suspend_handler (int sig, siginfo_t *siginfo, void *context)
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, suspend_handler, (int sig, siginfo_t *siginfo, void *context))
|
||||
{
|
||||
SgenThreadInfo *info;
|
||||
int old_errno = errno;
|
||||
@@ -133,8 +133,7 @@ suspend_handler (int sig, siginfo_t *siginfo, void *context)
|
||||
errno = old_errno;
|
||||
}
|
||||
|
||||
static void
|
||||
restart_handler (int sig)
|
||||
MONO_SIGNAL_HANDLER_FUNC (static, restart_handler, (int sig))
|
||||
{
|
||||
SgenThreadInfo *info;
|
||||
int old_errno = errno;
|
||||
@@ -219,7 +218,7 @@ sgen_os_init (void)
|
||||
g_error ("failed sigaction");
|
||||
}
|
||||
|
||||
sinfo.sa_handler = restart_handler;
|
||||
sinfo.sa_handler = (void*) restart_handler;
|
||||
if (sigaction (restart_signal_num, &sinfo, NULL) != 0) {
|
||||
g_error ("failed sigaction");
|
||||
}
|
||||
|
||||
@@ -5187,7 +5187,7 @@ emit_exception_debug_info (MonoAotCompile *acfg, MonoCompile *cfg)
|
||||
|
||||
seq_points = cfg->seq_point_info;
|
||||
|
||||
buf_size = header->num_clauses * 256 + debug_info_size + 2048 + (seq_points ? (seq_points->len * 64) : 0) + cfg->gc_map_size;
|
||||
buf_size = header->num_clauses * 256 + debug_info_size + 2048 + (seq_points ? (seq_points->len * 128) : 0) + cfg->gc_map_size;
|
||||
p = buf = g_malloc (buf_size);
|
||||
|
||||
#ifdef MONO_ARCH_HAVE_XP_UNWIND
|
||||
|
||||
@@ -4562,6 +4562,9 @@ process_breakpoint_inner (DebuggerTlsData *tls)
|
||||
SingleStepReq *ss_req = req->info;
|
||||
gboolean hit;
|
||||
|
||||
if (mono_thread_internal_current () != ss_req->thread)
|
||||
continue;
|
||||
|
||||
hit = ss_update (ss_req, ji, sp);
|
||||
if (hit)
|
||||
g_ptr_array_add (ss_reqs, req);
|
||||
|
||||
@@ -6267,15 +6267,15 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI
|
||||
#ifdef USE_JUMP_TABLES
|
||||
code = load_element_with_regbase_cond (code, ARMREG_R1, ARMREG_R2, IMT_METHOD_JTI (i), ARMCOND_AL);
|
||||
ARM_CMP_REG_REG (code, ARMREG_R0, ARMREG_R1);
|
||||
code = load_element_with_regbase_cond (code, ARMREG_R1, ARMREG_R2, JUMP_CODE_JTI (i), ARMCOND_GE);
|
||||
ARM_BX_COND (code, ARMCOND_GE, ARMREG_R1);
|
||||
code = load_element_with_regbase_cond (code, ARMREG_R1, ARMREG_R2, JUMP_CODE_JTI (i), ARMCOND_HS);
|
||||
ARM_BX_COND (code, ARMCOND_HS, ARMREG_R1);
|
||||
item->jmp_code = GUINT_TO_POINTER (JUMP_CODE_JTI (i));
|
||||
#else
|
||||
ARM_LDR_IMM (code, ARMREG_R1, ARMREG_PC, 0);
|
||||
ARM_CMP_REG_REG (code, ARMREG_R0, ARMREG_R1);
|
||||
|
||||
item->jmp_code = (guint8*)code;
|
||||
ARM_B_COND (code, ARMCOND_GE, 0);
|
||||
ARM_B_COND (code, ARMCOND_HS, 0);
|
||||
++extra_space;
|
||||
#endif
|
||||
}
|
||||
|
||||
+8
-12
@@ -54,6 +54,7 @@
|
||||
#include <mono/utils/mono-logger-internal.h>
|
||||
#include <mono/utils/mono-mmap.h>
|
||||
#include <mono/utils/dtrace.h>
|
||||
#include <mono/utils/mono-signal-handler.h>
|
||||
|
||||
#include "mini.h"
|
||||
#include <string.h>
|
||||
@@ -192,8 +193,7 @@ SIG_HANDLER_SIGNATURE (mono_chain_signal)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigabrt_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigabrt_signal_handler)
|
||||
{
|
||||
MonoJitInfo *ji = NULL;
|
||||
GET_CONTEXT;
|
||||
@@ -207,8 +207,7 @@ SIG_HANDLER_SIGNATURE (sigabrt_signal_handler)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigusr1_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigusr1_signal_handler)
|
||||
{
|
||||
gboolean running_managed;
|
||||
MonoException *exc;
|
||||
@@ -281,6 +280,7 @@ SIG_HANDLER_SIGNATURE (sigusr1_signal_handler)
|
||||
mono_arch_handle_exception (ctx, exc);
|
||||
}
|
||||
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
#define FULL_STAT_PROFILER_BACKTRACE 1
|
||||
#define CURRENT_FRAME_GET_BASE_POINTER(f) (* (gpointer*)(f))
|
||||
@@ -298,8 +298,7 @@ SIG_HANDLER_SIGNATURE (sigusr1_signal_handler)
|
||||
|
||||
#if defined(__ia64__) || defined(__sparc__) || defined(sparc) || defined(__s390__) || defined(s390)
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigprof_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigprof_signal_handler)
|
||||
{
|
||||
if (mono_chain_signal (SIG_HANDLER_PARAMS))
|
||||
return;
|
||||
@@ -309,8 +308,7 @@ SIG_HANDLER_SIGNATURE (sigprof_signal_handler)
|
||||
|
||||
#else
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigprof_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigprof_signal_handler)
|
||||
{
|
||||
int call_chain_depth = mono_profiler_stat_get_call_chain_depth ();
|
||||
MonoProfilerCallChainStrategy call_chain_strategy = mono_profiler_stat_get_call_chain_strategy ();
|
||||
@@ -388,8 +386,7 @@ SIG_HANDLER_SIGNATURE (sigprof_signal_handler)
|
||||
|
||||
#endif
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigquit_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigquit_signal_handler)
|
||||
{
|
||||
gboolean res;
|
||||
|
||||
@@ -419,8 +416,7 @@ SIG_HANDLER_SIGNATURE (sigquit_signal_handler)
|
||||
mono_chain_signal (SIG_HANDLER_PARAMS);
|
||||
}
|
||||
|
||||
static void
|
||||
SIG_HANDLER_SIGNATURE (sigusr2_signal_handler)
|
||||
SIG_HANDLER_FUNC (static, sigusr2_signal_handler)
|
||||
{
|
||||
gboolean enabled = mono_trace_is_enabled ();
|
||||
|
||||
|
||||
+5
-8
@@ -58,6 +58,7 @@
|
||||
#include <mono/utils/mono-tls.h>
|
||||
#include <mono/utils/mono-hwcap.h>
|
||||
#include <mono/utils/dtrace.h>
|
||||
#include <mono/utils/mono-signal-handler.h>
|
||||
|
||||
#include "mini.h"
|
||||
#include "mini-llvm.h"
|
||||
@@ -6514,8 +6515,7 @@ mono_jit_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoObjec
|
||||
return runtime_invoke (obj, params, exc, info->compiled_method);
|
||||
}
|
||||
|
||||
void
|
||||
SIG_HANDLER_SIGNATURE (mono_sigfpe_signal_handler)
|
||||
SIG_HANDLER_FUNC (, mono_sigfpe_signal_handler)
|
||||
{
|
||||
MonoException *exc = NULL;
|
||||
MonoJitInfo *ji;
|
||||
@@ -6549,8 +6549,7 @@ SIG_HANDLER_SIGNATURE (mono_sigfpe_signal_handler)
|
||||
mono_arch_handle_exception (ctx, exc);
|
||||
}
|
||||
|
||||
void
|
||||
SIG_HANDLER_SIGNATURE (mono_sigill_signal_handler)
|
||||
SIG_HANDLER_FUNC (, mono_sigill_signal_handler)
|
||||
{
|
||||
MonoException *exc;
|
||||
GET_CONTEXT;
|
||||
@@ -6564,8 +6563,7 @@ SIG_HANDLER_SIGNATURE (mono_sigill_signal_handler)
|
||||
#define HAVE_SIG_INFO
|
||||
#endif
|
||||
|
||||
void
|
||||
SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler)
|
||||
SIG_HANDLER_FUNC (, mono_sigsegv_signal_handler)
|
||||
{
|
||||
MonoJitInfo *ji;
|
||||
MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id);
|
||||
@@ -6644,8 +6642,7 @@ SIG_HANDLER_SIGNATURE (mono_sigsegv_signal_handler)
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
SIG_HANDLER_SIGNATURE (mono_sigint_signal_handler)
|
||||
SIG_HANDLER_FUNC (, mono_sigint_signal_handler)
|
||||
{
|
||||
MonoException *exc;
|
||||
GET_CONTEXT;
|
||||
|
||||
@@ -2734,15 +2734,19 @@ void mono_gdb_render_native_backtraces (pid_t crashed_pid) MONO_INTERNAL;
|
||||
|
||||
#ifdef MONO_ARCH_USE_SIGACTION
|
||||
#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, siginfo_t *info, void *context)
|
||||
#define SIG_HANDLER_FUNC(access, ftn) MONO_SIGNAL_HANDLER_FUNC (access, ftn, (int _dummy, siginfo_t *info, void *context))
|
||||
#define SIG_HANDLER_PARAMS _dummy, info, context
|
||||
#elif defined(HOST_WIN32)
|
||||
#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, EXCEPTION_POINTERS *info, void *context)
|
||||
#define SIG_HANDLER_FUNC(access, ftn) MONO_SIGNAL_HANDLER_FUNC (access, ftn, (int _dummy, EXCEPTION_POINTERS *info, void *context))
|
||||
#define SIG_HANDLER_PARAMS _dummy, info, context
|
||||
#elif defined(__HAIKU__)
|
||||
#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy, void *userData, vregs regs)
|
||||
#define SIG_HANDLER_FUNC(access, ftn) MONO_SIGNAL_HANDLER_FUNC (access, ftn, (int _dummy, void *userData, vregs regs))
|
||||
#define SIG_HANDLER_PARAMS _dummy, userData, regs
|
||||
#else
|
||||
#define SIG_HANDLER_SIGNATURE(ftn) ftn (int _dummy)
|
||||
#define SIG_HANDLER_FUNC(access, ftn) MONO_SIGNAL_HANDLER_FUNC (access, ftn, (int _dummy))
|
||||
#define SIG_HANDLER_PARAMS _dummy
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* mono-signal-handler.h: Handle signal handler differences across platforms
|
||||
*
|
||||
* Copyright (C) 2013 Xamarin Inc
|
||||
*/
|
||||
|
||||
#ifndef __MONO_SIGNAL_HANDLER_H__
|
||||
#define __MONO_SIGNAL_HANDLER_H__
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ENABLE_EXTENSION_MODULE
|
||||
#include "../../../mono-extensions/mono/utils/mono-signal-handler.h"
|
||||
#endif
|
||||
/*
|
||||
Not all platforms support signal handlers in the same way. Some have the same concept but
|
||||
for some weird reason pass different kind of arguments.
|
||||
|
||||
All signal handler helpers should go here so they can be properly shared across the JIT,
|
||||
utils and sgen.
|
||||
|
||||
TODO: Cleanup & move mini's macros to here so they can leveraged by other parts.
|
||||
|
||||
*/
|
||||
#ifndef MONO_SIGNAL_HANDLER_FUNC
|
||||
#define MONO_SIGNAL_HANDLER_FUNC(access, name, arglist) access void name arglist
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user