#include <mono/metadata/profiler-private.h>
#include <mono/metadata/debug-helpers.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/mono-machine.h>
+#include <mono/utils/mono-stack-unwinding.h>
#define MONO_BREAKPOINT_ARRAY_SIZE 64
-/* C type matching the size of a machine register. Not always the same as 'int' */
-/* Note that member 'p' of MonoInst must be the same type, as OP_PCONST is defined
- * as one of the OP_ICONST types, so inst_c0 must be the same as inst_p0
- */
-#if SIZEOF_REGISTER == 4
-typedef gint32 mgreg_t;
-#elif SIZEOF_REGISTER == 8
-typedef gint64 mgreg_t;
-#endif
-
#include "mini-arch.h"
#include "regalloc.h"
#include "declsec.h"
} MonoDynCallInfo;
/*
- * Possible frame types returned by the stack walker.
+ * Information about a stack frame.
+ * FIXME This typedef exists only to avoid tons of code rewriting
*/
-typedef enum {
- /* Normal managed frames */
- FRAME_TYPE_MANAGED = 0,
- /* Pseudo frame marking the start of a method invocation done by the soft debugger */
- FRAME_TYPE_DEBUGGER_INVOKE = 1,
- /* Frame for transitioning to native code */
- FRAME_TYPE_MANAGED_TO_NATIVE = 2,
- FRAME_TYPE_SENTINEL = 3
-} StackFrameType;
-
-/*
- * Information about a stack frame
- */
-typedef struct {
- StackFrameType type;
- /*
- * For FRAME_TYPE_MANAGED, otherwise NULL.
- */
- MonoJitInfo *ji;
- /*
- * Same as ji->method.
- */
- MonoMethod *method;
- /*
- * If ji->method is a gshared method, this is the actual method instance.
- */
- MonoMethod *actual_method;
- /* The domain containing the code executed by this frame */
- MonoDomain *domain;
- gboolean managed;
- int native_offset;
- int il_offset;
- gpointer lmf;
- guint32 unwind_info_len;
- guint8 *unwind_info;
-} StackFrameInfo;
+typedef MonoStackFrameInfo StackFrameInfo;
typedef struct {
int il_offset, native_offset;
MONO_INST_NORANGECHECK = 16,
/* On loads, the source address can be null */
MONO_INST_FAULT = 32,
+ /*
+ * On variables, identifies LMF variables. These variables have a dummy type (int), but
+ * require stack space for a MonoLMF struct.
+ */
+ MONO_INST_LMF = 32,
/* On loads, the source address points to a constant value */
MONO_INST_CONSTANT_LOAD = 64,
/* On variables, the variable needs GC tracking */
*/
guint8 *gc_map;
guint32 gc_map_size;
+
+ /* Stats */
+ int stat_allocate_var;
+ int stat_locals_stack_size;
+ int stat_basic_blocks;
+ int stat_cil_code_size;
+ int stat_n_regvars;
+ int stat_inlineable_methods;
+ int stat_inlined_methods;
+ int stat_cas_demand_generation;
+ int stat_code_reallocs;
} MonoCompile;
typedef enum {
} MonoCompileFlags;
typedef struct {
- gulong methods_compiled;
- gulong methods_aot;
- gulong methods_lookups;
- gulong allocate_var;
- gulong cil_code_size;
- gulong native_code_size;
- gulong code_reallocs;
- gulong max_code_size_ratio;
- gulong biggest_method_size;
- gulong allocated_code_size;
- gulong inlineable_methods;
- gulong inlined_methods;
- gulong basic_blocks;
- gulong max_basic_blocks;
- gulong locals_stack_size;
- gulong regvars;
- gulong cas_declsec_check;
- gulong cas_linkdemand_icall;
- gulong cas_linkdemand_pinvoke;
- gulong cas_linkdemand_aptc;
- gulong cas_linkdemand;
- gulong cas_demand_generation;
- gulong generic_virtual_invocations;
- int methods_with_llvm;
+ gint32 methods_compiled;
+ gint32 methods_aot;
+ gint32 methods_lookups;
+ gint32 allocate_var;
+ gint32 cil_code_size;
+ gint32 native_code_size;
+ gint32 code_reallocs;
+ gint32 max_code_size_ratio;
+ gint32 biggest_method_size;
+ gint32 allocated_code_size;
+ gint32 inlineable_methods;
+ gint32 inlined_methods;
+ gint32 basic_blocks;
+ gint32 max_basic_blocks;
+ gint32 locals_stack_size;
+ gint32 regvars;
+ gint32 cas_declsec_check;
+ gint32 cas_linkdemand_icall;
+ gint32 cas_linkdemand_pinvoke;
+ gint32 cas_linkdemand_aptc;
+ gint32 cas_linkdemand;
+ gint32 cas_demand_generation;
+ gint32 generic_virtual_invocations;
+ int methods_with_llvm;
int methods_without_llvm;
char *max_ratio_method;
char *biggest_method;
void mono_global_codeman_commit(void *data, int size, int newsize) MONO_INTERNAL;
void nacl_global_codeman_validate(guint8 **buf_base, int buf_size, guint8 **code_end) MONO_INTERNAL;
const char *mono_regname_full (int reg, int bank) MONO_INTERNAL;
-gint32* mono_allocate_stack_slots_full (MonoCompile *cfg, gboolean backward, guint32 *stack_size, guint32 *stack_align) MONO_INTERNAL;
-gint32* mono_allocate_stack_slots (MonoCompile *cfg, guint32 *stack_size, guint32 *stack_align) MONO_INTERNAL;
+gint32* mono_allocate_stack_slots (MonoCompile *cfg, gboolean backward, guint32 *stack_size, guint32 *stack_align) MONO_INTERNAL;
void mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb) MONO_INTERNAL;
MonoInst *mono_branch_optimize_exception_target (MonoCompile *cfg, MonoBasicBlock *bb, const char * exname) MONO_INTERNAL;
void mono_remove_critical_edges (MonoCompile *cfg) MONO_INTERNAL;
gpointer mono_arch_ip_from_context (void *sigctx) MONO_INTERNAL;
void mono_arch_sigctx_to_monoctx (void *sigctx, MonoContext *ctx) MONO_INTERNAL;
void mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *ctx) MONO_INTERNAL;
-gpointer mono_arch_context_get_int_reg (MonoContext *ctx, int reg) MONO_INTERNAL;
+mgreg_t mono_arch_context_get_int_reg (MonoContext *ctx, int reg) MONO_INTERNAL;
+void mono_arch_context_set_int_reg (MonoContext *ctx, int reg, mgreg_t val) MONO_INTERNAL;
void mono_arch_flush_register_windows (void) MONO_INTERNAL;
gboolean mono_arch_is_inst_imm (gint64 imm) MONO_INTERNAL;
MonoInst* mono_arch_get_domain_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
gboolean mono_install_handler_block_guard (MonoInternalThread *thread, MonoContext *ctx) MONO_INTERNAL;
/* Exception handling */
-
-typedef enum {
- MONO_UNWIND_NONE = 0x0,
- MONO_UNWIND_LOOKUP_IL_OFFSET = 0x1,
- MONO_UNWIND_LOOKUP_ACTUAL_METHOD = 0x2,
- MONO_UNWIND_DEFAULT = MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
- MONO_UNWIND_SIGNAL_SAFE = MONO_UNWIND_NONE,
- MONO_UNWIND_LOOKUP_ALL = MONO_UNWIND_LOOKUP_IL_OFFSET | MONO_UNWIND_LOOKUP_ACTUAL_METHOD,
-} MonoUnwindOptions;
-
typedef gboolean (*MonoJitStackWalk) (StackFrameInfo *frame, MonoContext *ctx, gpointer data);
void mono_exceptions_init (void) MONO_INTERNAL;
void mono_handle_native_sigsegv (int signal, void *sigctx) MONO_INTERNAL;
void mono_print_thread_dump (void *sigctx);
void mono_print_thread_dump_from_ctx (MonoContext *ctx);
-void mono_jit_walk_stack (MonoStackWalk func, gboolean do_il_offset, gpointer user_data) MONO_INTERNAL;
-void mono_jit_walk_stack_from_ctx (MonoStackWalk func, MonoContext *ctx, MonoUnwindOptions unwind_options, gpointer user_data) MONO_INTERNAL;
-void mono_walk_stack (MonoJitStackWalk func, MonoDomain *domain, MonoContext *start_ctx, MonoUnwindOptions unwind_options, MonoInternalThread *thread, MonoLMF *lmf, gpointer user_data) MONO_INTERNAL;
+void mono_walk_stack_with_ctx (MonoJitStackWalk func, MonoContext *start_ctx, MonoUnwindOptions unwind_options, void *user_data) MONO_INTERNAL;
+void mono_walk_stack_with_state (MonoJitStackWalk func, MonoThreadUnwindState *state, MonoUnwindOptions unwind_options, void *user_data) MONO_INTERNAL;
+void mono_walk_stack (MonoJitStackWalk func, MonoUnwindOptions options, void *user_data) MONO_INTERNAL;
+gboolean mono_thread_state_init_from_sigctx (MonoThreadUnwindState *ctx, void *sigctx) MONO_INTERNAL;
+gboolean mono_thread_state_init_from_current (MonoThreadUnwindState *ctx) MONO_INTERNAL;
+gboolean mono_thread_state_init_from_monoctx (MonoThreadUnwindState *ctx, MonoContext *mctx) MONO_INTERNAL;
+
void mono_setup_altstack (MonoJitTlsData *tls) MONO_INTERNAL;
void mono_free_altstack (MonoJitTlsData *tls) MONO_INTERNAL;
gpointer mono_altstack_restore_prot (mgreg_t *regs, guint8 *code, gpointer *tramp_data, guint8* tramp) MONO_INTERNAL;
void mono_cfg_add_try_hole (MonoCompile *cfg, MonoExceptionClause *clause, guint8 *start, MonoBasicBlock *bb) MONO_INTERNAL;
void mono_cfg_set_exception (MonoCompile *cfg, int type) MONO_INTERNAL;
+gboolean mini_type_is_reference (MonoCompile *cfg, MonoType *type) MONO_INTERNAL;
+
/* wapihandles.c */
int mini_wapi_hps (int argc, char **argv) MONO_INTERNAL;
#define SIG_HANDLER_SIGNATURE(ftn) 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_RECORD *info, void *context)
+#define SIG_HANDLER_SIGNATURE(ftn) 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)