X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini.h;h=7d681122d43c3b3aa212a18cc74e77f265966a02;hb=f9ae98ab88f522219cd6be6fd282ef30adbc5365;hp=d55825ed383013e36b052235d3fdc49848cd78db;hpb=4281399ba4b7c44a30fa2c2a314a470260bb3eb1;p=mono.git diff --git a/mono/mini/mini.h b/mono/mini/mini.h index d55825ed383..7d681122d43 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -1,4 +1,5 @@ -/* +/** + * \file * Copyright 2002-2003 Ximian Inc * Copyright 2003-2011 Novell Inc * Copyright 2011 Xamarin Inc @@ -48,11 +49,6 @@ #include "mono/metadata/security-manager.h" #include "mono/metadata/exception.h" -#ifdef __native_client_codegen__ -#include -#endif - - /* * The mini code should not have any compile time dependencies on the GC being used, so the same object file from mini/ * can be linked into both mono and mono-sgen. @@ -121,7 +117,7 @@ #endif /* Version number of the AOT file format */ -#define MONO_AOT_FILE_VERSION 139 +#define MONO_AOT_FILE_VERSION 140 //TODO: This is x86/amd64 specific. #define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6)) @@ -365,6 +361,8 @@ typedef struct gpointer llvm_module; /* Maps MonoMethod -> GSlist of addresses */ GHashTable *llvm_jit_callees; + /* Maps MonoMethod -> RuntimeMethod */ + MonoInternalHashTable interp_code_hash; } MonoJitDomainInfo; typedef struct { @@ -592,6 +590,20 @@ extern const gint8 ins_sreg_counts []; #define mono_bb_first_ins(bb) (bb)->code +/* + * Iterate through all used registers in the instruction. + * Relies on the existing order of the MONO_INST enum: MONO_INST_{DREG,SREG1,SREG2,SREG3,LEN} + * INS is the instruction, IDX is the register index, REG is the pointer to a register. + */ +#define MONO_INS_FOR_EACH_REG(ins, idx, reg) for ((idx) = INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ' ? MONO_INST_DEST : \ + (mono_inst_get_num_src_registers (ins) ? MONO_INST_SRC1 : MONO_INST_LEN); \ + (reg) = (idx) == MONO_INST_DEST ? &(ins)->dreg : \ + ((idx) == MONO_INST_SRC1 ? &(ins)->sreg1 : \ + ((idx) == MONO_INST_SRC2 ? &(ins)->sreg2 : \ + ((idx) == MONO_INST_SRC3 ? &(ins)->sreg3 : NULL))), \ + idx < MONO_INST_LEN; \ + (idx) = (idx) > mono_inst_get_num_src_registers (ins) + (INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ') ? MONO_INST_LEN : (idx) + 1) + struct MonoSpillInfo { int offset; }; @@ -743,6 +755,9 @@ struct MonoBasicBlock { /* List of call sites in this bblock sorted by pc_offset */ GSList *gc_callsites; + /* If this is not null, the basic block is a try hole for this clause */ + MonoExceptionClause *clause_hole; + /* * The region encodes whether the basic block is inside * a finally, catch, filter or none of these. @@ -826,7 +841,7 @@ typedef struct { * in the structure. */ int nslots; - /* Only if storage == LLVMArgAsFpArgs/LLVMArgFpStruct (4/8) */ + /* Only if storage == LLVMArgAsIArgs/LLVMArgAsFpArgs/LLVMArgFpStruct (4/8) */ int esize; /* Parameter index in the LLVM signature */ int pindex; @@ -1138,7 +1153,6 @@ typedef struct { typedef struct { gpointer end_of_stack; guint32 stack_size; - /* !defined(HAVE_KW_THREAD) || !defined(MONO_ARCH_ENABLE_MONO_LMF_VAR) */ MonoLMF *lmf; MonoLMF *first_lmf; gpointer restore_stack_prot; @@ -1156,10 +1170,6 @@ typedef struct { MonoContext ex_ctx; ResumeState resume_state; - /*Variabled use to implement handler blocks (finally/catch/etc) guards during interruption*/ - /* handler block return address */ - gpointer handler_block_return_address; - /* handler block been guarded. It's safe to store this even for dynamic methods since there is an activation on stack making sure it will remain alive.*/ MonoJitExceptionInfo *handler_block; @@ -1200,6 +1210,13 @@ typedef struct { * the catch block that caught the ThreadAbortException). */ gpointer abort_exc_stack_threshold; + + /* + * List of methods being JIT'd in the current thread. + */ + int active_jit_methods; + + gpointer interp_context; } MonoJitTlsData; /* @@ -1208,7 +1225,10 @@ typedef struct { typedef struct { struct MonoLMF lmf; gboolean debugger_invoke; + gboolean interp_exit; MonoContext ctx; /* if debugger_invoke is TRUE */ + /* If interp_exit is TRUE */ + gpointer interp_exit_data; } MonoLMFExt; /* Generic sharing */ @@ -1277,6 +1297,8 @@ typedef enum { * which implements the method. */ MONO_RGCTX_INFO_VIRT_METHOD_BOX_TYPE, + /* Resolve to 2 (TRUE) or 1 (FALSE) */ + MONO_RGCTX_INFO_CLASS_IS_REF_OR_CONTAINS_REFS } MonoRgctxInfoType; typedef struct _MonoRuntimeGenericContextInfoTemplate { @@ -1463,7 +1485,6 @@ typedef enum { MONO_TRAMPOLINE_RESTORE_STACK_PROT, MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING, MONO_TRAMPOLINE_VCALL, - MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD, MONO_TRAMPOLINE_NUM } MonoTrampolineType; @@ -1474,7 +1495,7 @@ typedef enum { /* These trampolines receive an argument directly in a register */ #define MONO_TRAMPOLINE_TYPE_HAS_ARG(t) \ - ((t) == MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD) + (FALSE) /* optimization flags */ #define OPTFLAG(id,shift,name,descr) MONO_OPT_ ## id = 1 << shift, @@ -1612,10 +1633,18 @@ typedef struct { /* A hashtable of region ID-> SP var mappings */ /* An SP var is a place to store the stack pointer (used by handlers)*/ + /* + * FIXME We can potentially get rid of this, since it was mainly used + * for hijacking return address for handler. + */ GHashTable *spvars; - /* A hashtable of region ID -> EX var mappings */ - /* An EX var stores the exception object passed to catch/filter blocks */ + /* + * A hashtable of region ID -> EX var mappings + * An EX var stores the exception object passed to catch/filter blocks + * For finally blocks, it is set to TRUE if we should throw an abort + * once the execution of the finally block is over. + */ GHashTable *exvars; GList *ldstr_list; /* used by AOT */ @@ -1651,11 +1680,6 @@ typedef struct { MonoInst *stack_inbalance_var; unsigned char *cil_start; -#ifdef __native_client_codegen__ - /* this alloc is not aligned, native_code */ - /* is the 32-byte aligned version of this */ - unsigned char *native_code_alloc; -#endif unsigned char *native_code; guint code_size; guint code_len; @@ -1664,7 +1688,6 @@ typedef struct { guint epilog_end; regmask_t used_int_regs; guint32 opt; - guint32 prof_options; guint32 flags; guint32 comp_done; guint32 verbose_level; @@ -1709,7 +1732,6 @@ typedef struct { * Whenever to use the mono_lmf TLS variable instead of indirection through the * mono_lmf_addr TLS variable. */ - guint lmf_ir_mono_lmf : 1; guint gen_write_barriers : 1; guint init_ref_vars : 1; guint extend_live_ranges : 1; @@ -1744,7 +1766,7 @@ typedef struct { gpointer debug_info; guint32 lmf_offset; guint16 *intvars; - MonoProfileCoverageInfo *coverage_info; + MonoProfilerCoverageInfo *coverage_info; GHashTable *token_info_hash; MonoCompileArch arch; guint32 inline_depth; @@ -1894,8 +1916,13 @@ typedef struct { int stat_inlineable_methods; int stat_inlined_methods; int stat_code_reallocs; + + MonoProfilerCallInstrumentationFlags prof_flags; } MonoCompile; +#define MONO_CFG_PROFILE_CALL_CONTEXT(cfg) \ + ((cfg)->prof_flags & (MONO_PROFILER_CALL_INSTRUMENTATION_PROLOGUE_CONTEXT | MONO_PROFILER_CALL_INSTRUMENTATION_EPILOGUE_CONTEXT)) + typedef enum { MONO_CFG_HAS_ALLOCA = 1 << 0, MONO_CFG_HAS_CALLS = 1 << 1, @@ -2085,12 +2112,6 @@ typedef struct { int type; } StackSlot; -#if HAVE_ARRAY_ELEM_INIT -extern const guint8 mono_burg_arity []; -#else -extern guint8 mono_burg_arity []; -#endif - extern const char MONO_ARCH_CPU_SPEC []; #define MONO_ARCH_CPU_SPEC_IDX_COMBINE(a) a ## _idx #define MONO_ARCH_CPU_SPEC_IDX(a) MONO_ARCH_CPU_SPEC_IDX_COMBINE(a) @@ -2260,6 +2281,8 @@ enum { */ guint8 *uw_info; guint32 uw_info_len; + /* Whenever uw_info is owned by this structure */ + gboolean owns_uw_info; } MonoTrampInfo; typedef void (*MonoInstFunc) (MonoInst *tree, gpointer data); @@ -2334,7 +2357,14 @@ MonoDomain* mini_init (const char *filename, const char *ru void mini_cleanup (MonoDomain *domain); MONO_API MonoDebugOptions *mini_get_debug_options (void); MONO_API gboolean mini_parse_debug_option (const char *option); -void mini_profiler_enable_with_options (const char *profile_options); +void mini_add_profiler_argument (const char *desc); +void mini_profiler_emit_instrumentation_call (MonoCompile *cfg, void *func, gboolean entry, MonoInst **ret, MonoType *rtype); +void mini_profiler_context_enable (void); +gpointer mini_profiler_context_get_this (MonoProfilerCallContext *ctx); +gpointer mini_profiler_context_get_argument (MonoProfilerCallContext *ctx, guint32 pos); +gpointer mini_profiler_context_get_local (MonoProfilerCallContext *ctx, guint32 pos); +gpointer mini_profiler_context_get_result (MonoProfilerCallContext *ctx); +void mini_profiler_context_free_buffer (gpointer buffer); /* graph dumping */ void mono_cfg_dump_create_context (MonoCompile *cfg); @@ -2404,7 +2434,7 @@ void mono_print_code (MonoCompile *cfg, const char *msg); MONO_API void mono_print_method_from_ip (void *ip); MONO_API char *mono_pmip (void *ip); gboolean mono_debug_count (void); -MONO_API const char* mono_inst_name (int op); +MONO_LLVM_INTERNAL const char* mono_inst_name (int op); int mono_op_to_op_imm (int opcode); int mono_op_imm_to_op (int opcode); int mono_load_membase_to_load_mem (int opcode); @@ -2425,10 +2455,13 @@ gpointer mono_resolve_patch_target (MonoMethod *method, MonoDomain *dom gpointer mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji); gpointer mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method); gpointer mono_jit_compile_method (MonoMethod *method, MonoError *error); +gpointer mono_jit_compile_method_jit_only (MonoMethod *method, MonoError *error); gpointer mono_jit_compile_method_inner (MonoMethod *method, MonoDomain *target_domain, int opt, MonoError *error); MonoLMF * mono_get_lmf (void); MonoLMF** mono_get_lmf_addr (void); void mono_set_lmf (MonoLMF *lmf); +void mono_push_lmf (MonoLMFExt *ext); +void mono_pop_lmf (MonoLMF *lmf); MonoJitTlsData* mono_get_jit_tls (void); MONO_API MonoDomain* mono_jit_thread_attach (MonoDomain *domain); MONO_API void mono_jit_set_domain (MonoDomain *domain); @@ -2455,6 +2488,8 @@ MonoInst* mono_emit_jit_icall (MonoCompile *cfg, gconstpointer func, MonoInst ** MonoInst* mono_emit_jit_icall_by_info (MonoCompile *cfg, int il_offset, MonoJitICallInfo *info, MonoInst **args); MonoInst* mono_emit_method_call (MonoCompile *cfg, MonoMethod *method, MonoInst **args, MonoInst *this_ins); void mono_create_helper_signatures (void); +MonoInst* mono_emit_native_call (MonoCompile *cfg, gconstpointer func, MonoMethodSignature *sig, MonoInst **args); +gboolean mini_should_insert_breakpoint (MonoMethod *method); gboolean mini_class_is_system_array (MonoClass *klass); MonoMethodSignature *mono_get_element_address_signature (int arity); @@ -2472,12 +2507,6 @@ void mono_liveness_handle_exception_clauses (MonoCompile *cfg); /* Native Client functions */ gpointer mono_realloc_native_code(MonoCompile *cfg); -#if defined(__native_client__) || defined(__native_client_codegen__) -extern volatile int __nacl_thread_suspension_needed; -void __nacl_suspend_thread_if_needed(void); -void mono_nacl_gc(void); -#endif - extern MonoDebugOptions debug_options; static inline MonoMethod* @@ -2549,7 +2578,7 @@ void mono_draw_graph (MonoCompile *cfg, MonoGraphOptions void mono_add_ins_to_end (MonoBasicBlock *bb, MonoInst *inst); gpointer mono_create_ftnptr (MonoDomain *domain, gpointer addr); -MONO_API void mono_replace_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst **prev, MonoBasicBlock *first_bb, MonoBasicBlock *last_bb); +void mono_replace_ins (MonoCompile *cfg, MonoBasicBlock *bb, MonoInst *ins, MonoInst **prev, MonoBasicBlock *first_bb, MonoBasicBlock *last_bb); int mono_find_method_opcode (MonoMethod *method); MonoJitICallInfo *mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save); @@ -2618,9 +2647,25 @@ MonoInst *mono_branch_optimize_exception_target (MonoCompile *cfg, MonoB void mono_remove_critical_edges (MonoCompile *cfg); gboolean mono_is_regsize_var (MonoType *t); void mini_emit_memcpy (MonoCompile *cfg, int destreg, int doffset, int srcreg, int soffset, int size, int align); +void mini_emit_memset (MonoCompile *cfg, int destreg, int offset, int size, int val, int align); void mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native); void mini_emit_initobj (MonoCompile *cfg, MonoInst *dest, const guchar *ip, MonoClass *klass); MonoInst* mini_emit_ldelema_1_ins (MonoCompile *cfg, MonoClass *klass, MonoInst *arr, MonoInst *index, gboolean bcheck); +MonoInst* mini_emit_get_gsharedvt_info_klass (MonoCompile *cfg, MonoClass *klass, MonoRgctxInfoType rgctx_type); +MonoInst* mini_emit_calli (MonoCompile *cfg, MonoMethodSignature *sig, MonoInst **args, MonoInst *addr, MonoInst *imt_arg, MonoInst *rgctx_arg); +MonoInst* mini_emit_memory_barrier (MonoCompile *cfg, int kind); +void mini_emit_write_barrier (MonoCompile *cfg, MonoInst *ptr, MonoInst *value); +MonoInst* mini_emit_memory_load (MonoCompile *cfg, MonoType *type, MonoInst *src, int offset, int ins_flag); +void mini_emit_memory_store (MonoCompile *cfg, MonoType *type, MonoInst *dest, MonoInst *value, int ins_flag); +void mini_emit_memory_copy_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoInst *size, int ins_flag); +void mini_emit_memory_init_bytes (MonoCompile *cfg, MonoInst *dest, MonoInst *value, MonoInst *size, int ins_flag); +void mini_emit_memory_copy (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native, int ins_flag); + +MonoMethod* mini_get_memcpy_method (void); +MonoMethod* mini_get_memset_method (void); +int mini_class_check_context_used (MonoCompile *cfg, MonoClass *klass); + + CompRelation mono_opcode_to_cond (int opcode) MONO_LLVM_INTERNAL; CompType mono_opcode_to_type (int opcode, int cmp_opcode); CompRelation mono_negate_cond (CompRelation cond); @@ -2635,6 +2680,7 @@ void mono_emit_unwind_op (MonoCompile *cfg, int when, int val); MonoTrampInfo* mono_tramp_info_create (const char *name, guint8 *code, guint32 code_size, MonoJumpInfo *ji, GSList *unwind_ops); void mono_tramp_info_free (MonoTrampInfo *info); +void mono_aot_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain); void mono_tramp_info_register (MonoTrampInfo *info, MonoDomain *domain); int mini_exception_id_by_name (const char *name); gboolean mini_type_is_hfa (MonoType *t, int *out_nfields, int *out_esize) MONO_LLVM_INTERNAL; @@ -2769,6 +2815,9 @@ gboolean mono_arch_is_breakpoint_event (void *info, void *sigctx); void mono_arch_skip_breakpoint (MonoContext *ctx, MonoJitInfo *ji); void mono_arch_skip_single_step (MonoContext *ctx); gpointer mono_arch_get_seq_point_info (MonoDomain *domain, guint8 *code); +#endif + +#ifdef MONO_ARCH_HAVE_INIT_LMF_EXT void mono_arch_init_lmf_ext (MonoLMFExt *ext, gpointer prev_lmf); #endif @@ -2802,7 +2851,7 @@ void mono_arch_create_vars (MonoCompile *cfg) MONO_LLVM_INT void mono_arch_save_unwind_info (MonoCompile *cfg); void mono_arch_register_lowlevel_calls (void); gpointer mono_arch_get_unbox_trampoline (MonoMethod *m, gpointer addr); -gpointer mono_arch_get_static_rgctx_trampoline (MonoMethod *m, MonoMethodRuntimeGenericContext *mrgctx, gpointer addr); +gpointer mono_arch_get_static_rgctx_trampoline (gpointer arg, gpointer addr); gpointer mono_arch_get_llvm_imt_trampoline (MonoDomain *domain, MonoMethod *method, int vt_offset); gpointer mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer arg, gpointer addr); void mono_arch_patch_callsite (guint8 *method_start, guint8 *code, guint8 *addr); @@ -2822,12 +2871,6 @@ guint32 mono_arch_get_plt_info_offset (guint8 *plt_entry, mgreg_t *reg GSList *mono_arch_get_trampolines (gboolean aot); gpointer mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info); -/* Handle block guard */ -gpointer mono_arch_install_handler_block_guard (MonoJitInfo *ji, MonoJitExceptionInfo *clause, MonoContext *ctx, gpointer new_value); -gpointer mono_arch_create_handler_block_trampoline (MonoTrampInfo **info, gboolean aot); -gpointer mono_create_handler_block_trampoline (void); -gboolean mono_install_handler_block_guard (MonoThreadUnwindState *ctx); - /*New interruption machinery */ void mono_setup_async_callback (MonoContext *ctx, void (*async_cb)(void *fun), gpointer user_data); @@ -3053,6 +3096,7 @@ MonoGenericContext* mini_class_get_context (MonoClass *klass); MonoType* mini_get_underlying_type (MonoType *type) MONO_LLVM_INTERNAL; MonoType* mini_type_get_underlying_type (MonoType *type); +MonoClass* mini_get_class (MonoMethod *method, guint32 token, MonoGenericContext *context); MonoMethod* mini_get_shared_method (MonoMethod *method); MonoMethod* mini_get_shared_method_to_register (MonoMethod *method); MonoMethod* mini_get_shared_method_full (MonoMethod *method, gboolean all_vt, gboolean is_gsharedvt); @@ -3101,6 +3145,7 @@ MonoMethod* mini_get_gsharedvt_in_sig_wrapper (MonoMethodSignature *sig); MonoMethod* mini_get_gsharedvt_out_sig_wrapper (MonoMethodSignature *sig); MonoMethodSignature* mini_get_gsharedvt_out_sig_wrapper_signature (gboolean has_this, gboolean has_ret, int param_count); gboolean mini_gsharedvt_runtime_invoke_supported (MonoMethodSignature *sig); +MonoMethod* mini_get_interp_in_wrapper (MonoMethodSignature *sig); /* SIMD support */