Extract the code to emit a memory barrier. Add a memory_barrier_kind field to MonoIns...
[mono.git] / mono / mini / mini.h
index 52676ea76f3512c566b724c3bf7b1ad265c7508d..e3d5e54e1c5c93095f291c11dc86554977c7e7a5 100644 (file)
@@ -22,6 +22,7 @@
 #include <mono/utils/mono-compiler.h>
 #include <mono/utils/mono-machine.h>
 #include <mono/utils/mono-stack-unwinding.h>
+#include <mono/utils/mono-threads.h>
 
 #define MONO_BREAKPOINT_ARRAY_SIZE 64
 
@@ -734,6 +735,7 @@ struct MonoInst {
                MonoInst *spill_var; /* for OP_ICONV_TO_R8_RAW and OP_FCONV_TO_R8_X */
                guint16 source_opcode; /*OP_XCONV_R8_TO_I4 needs to know which op was used to do proper widening*/
                int pc_offset; /* OP_GC_LIVERANGE_START/END */
+               int memory_barrier_kind; /* see mono-memory-model.h for valid values */
        } backend;
        
        MonoClass *klass;
@@ -1241,6 +1243,7 @@ typedef struct {
        guint            gen_seq_points : 1;
        guint            explicit_null_checks : 1;
        guint            compute_gc_maps : 1;
+       guint            soft_breakpoints : 1;
        gpointer         debug_info;
        guint32          lmf_offset;
     guint16          *intvars;
@@ -1355,6 +1358,17 @@ typedef struct {
         */
        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 {
@@ -1370,30 +1384,30 @@ 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;
@@ -1558,6 +1572,14 @@ typedef struct {
         * debugging of the stack marking code in the GC.
         */
        gboolean init_stacks;
+
+       /*
+        * Whenever to implement single stepping and breakpoints without signals in the
+        * soft debugger. This is useful on platforms without signals, like the ps3, or during
+        * runtime debugging, since it avoids SIGSEGVs when a single step location or breakpoint
+        * is hit.
+        */
+       gboolean soft_breakpoints;
 } MonoDebugOptions;
 
 enum {
@@ -2021,7 +2043,8 @@ void     mono_handle_hard_stack_ovf             (MonoJitTlsData *jit_tls, MonoJi
 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;
@@ -2056,7 +2079,18 @@ GSList *mono_arch_get_trampolines               (gboolean aot) MONO_INTERNAL;
 gpointer mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value) MONO_INTERNAL;
 gpointer mono_arch_create_handler_block_trampoline (void) MONO_INTERNAL;
 gpointer mono_create_handler_block_trampoline (void) MONO_INTERNAL;
-gboolean mono_install_handler_block_guard (MonoInternalThread *thread, MonoContext *ctx) MONO_INTERNAL;
+gboolean mono_install_handler_block_guard (MonoThreadUnwindState *ctx) MONO_INTERNAL;
+
+/*New interruption machinery */
+void
+mono_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data) MONO_INTERNAL;
+
+void
+mono_arch_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data) MONO_INTERNAL;
+
+gboolean
+mono_thread_state_init_from_handle (MonoThreadUnwindState *tctx, MonoNativeThreadId thread_id, MonoNativeThreadHandle thread_handle) MONO_INTERNAL;
+
 
 /* Exception handling */
 typedef gboolean (*MonoJitStackWalk)            (StackFrameInfo *frame, MonoContext *ctx, gpointer data);
@@ -2394,12 +2428,14 @@ gboolean SIG_HANDLER_SIGNATURE (mono_chain_signal) MONO_INTERNAL;
 
 /* for MONO_WRAPPER_UNKNOWN/MANAGED_TO_MANAGED subtypes */
 enum {
-       MONO_AOT_WRAPPER_MONO_ENTER,
-       MONO_AOT_WRAPPER_MONO_EXIT,
+       MONO_AOT_WRAPPER_MONITOR_ENTER,
+       MONO_AOT_WRAPPER_MONITOR_EXIT,
        MONO_AOT_WRAPPER_ELEMENT_ADDR,
        MONO_AOT_WRAPPER_PTR_TO_STRUCTURE,
        MONO_AOT_WRAPPER_STRUCTURE_TO_PTR,
        MONO_AOT_WRAPPER_CASTCLASS_WITH_CACHE,
+       MONO_AOT_WRAPPER_ISINST_WITH_CACHE,
+       MONO_AOT_WRAPPER_MONITOR_ENTER_V4,
        MONO_AOT_WRAPPER_LAST
 };