-/*
+/**
+ * \file
* Copyright 2002-2003 Ximian Inc
* Copyright 2003-2011 Novell Inc
* Copyright 2011 Xamarin Inc
#include "jit.h"
#include "cfgdump.h"
-#include "mono/metadata/class-internals.h"
-#include "mono/metadata/domain-internals.h"
-#include "mono/metadata/object.h"
#include "mono/metadata/tabledefs.h"
#include "mono/metadata/marshal.h"
#include "mono/metadata/security-manager.h"
#include "mono/metadata/exception.h"
-#include "mono/utils/mono-compiler.h"
-
-#ifdef __native_client_codegen__
-#include <nacl/nacl_dyncode.h>
-#endif
-
/*
* The mini code should not have any compile time dependencies on the GC being used, so the same object file from mini/
#define MINI_DEBUG(level,limit,code) do {if (G_UNLIKELY ((level) >= (limit))) code} while (0)
#endif
-#if !defined(DISABLE_TASKLETS) && defined(MONO_ARCH_SUPPORT_TASKLETS) && defined(__GNUC__)
+#if !defined(DISABLE_TASKLETS) && defined(MONO_ARCH_SUPPORT_TASKLETS)
+#if defined(__GNUC__)
+#define MONO_SUPPORT_TASKLETS 1
+#elif defined(HOST_WIN32)
#define MONO_SUPPORT_TASKLETS 1
+// Replace some gnu intrinsics needed for tasklets with MSVC equivalents.
+#define __builtin_extract_return_addr(x) x
+#define __builtin_return_address(x) _ReturnAddress()
+#define __builtin_frame_address(x) _AddressOfReturnAddress()
+#endif
#endif
#if ENABLE_LLVM
#endif
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 133
+#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))
typedef enum {
MONO_AOT_TRAMP_SPECIFIC = 0,
MONO_AOT_TRAMP_STATIC_RGCTX = 1,
- MONO_AOT_TRAMP_IMT_THUNK = 2,
+ MONO_AOT_TRAMP_IMT = 2,
MONO_AOT_TRAMP_GSHAREDVT_ARG = 3,
MONO_AOT_TRAMP_NUM = 4
} MonoAotTrampoline;
/* Blocks of various kinds of trampolines */
gpointer specific_trampolines;
gpointer static_rgctx_trampolines;
- gpointer imt_thunks;
+ gpointer imt_trampolines;
gpointer gsharedvt_arg_trampolines;
/* In static mode, points to a table of global symbols for trampolines etc */
gpointer globals;
guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
/* The offset where the trampolines begin on a trampoline page */
guint32 tramp_page_code_offsets [MONO_AOT_TRAMP_NUM];
+ /* GUID of aot compilation */
+ guint8 aotid[16];
} MonoAotFileInfo;
/* Number of symbols in the MonoAotFileInfo structure */
gpointer llvm_module;
/* Maps MonoMethod -> GSlist of addresses */
GHashTable *llvm_jit_callees;
+ /* Maps MonoMethod -> RuntimeMethod */
+ MonoInternalHashTable interp_code_hash;
} MonoJitDomainInfo;
typedef struct {
#define MONO_IS_SETCC(ins) ((((ins)->opcode >= OP_CEQ) && ((ins)->opcode <= OP_CLT_UN)) || (((ins)->opcode >= OP_ICEQ) && ((ins)->opcode <= OP_ICLE_UN)) || (((ins)->opcode >= OP_LCEQ) && ((ins)->opcode <= OP_LCLT_UN)) || (((ins)->opcode >= OP_FCEQ) && ((ins)->opcode <= OP_FCLT_UN)))
+#define MONO_HAS_CUSTOM_EMULATION(ins) (((ins)->opcode >= OP_FBEQ && (ins)->opcode <= OP_FBLT_UN) || ((ins)->opcode >= OP_FCEQ && (ins)->opcode <= OP_FCLT_UN))
#define MONO_IS_LOAD_MEMBASE(ins) (((ins)->opcode >= OP_LOAD_MEMBASE && (ins)->opcode <= OP_LOADV_MEMBASE) || ((ins)->opcode >= OP_ATOMIC_LOAD_I1 && (ins)->opcode <= OP_ATOMIC_LOAD_R8))
#define MONO_IS_STORE_MEMBASE(ins) (((ins)->opcode >= OP_STORE_MEMBASE_REG && (ins)->opcode <= OP_STOREV_MEMBASE) || ((ins)->opcode >= OP_ATOMIC_STORE_I1 && (ins)->opcode <= OP_ATOMIC_STORE_R8))
/* FIXME: Add more instructions */
/* INEG sets the condition codes, and the OP_LNEG decomposition depends on this on x86 */
-#define MONO_INS_HAS_NO_SIDE_EFFECT(ins) (MONO_IS_MOVE (ins) || (ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || MONO_IS_ZERO (ins) || (ins->opcode == OP_ADD_IMM) || (ins->opcode == OP_R8CONST) || (ins->opcode == OP_LADD_IMM) || (ins->opcode == OP_ISUB_IMM) || (ins->opcode == OP_IADD_IMM) || (ins->opcode == OP_LNEG) || (ins->opcode == OP_ISUB) || (ins->opcode == OP_CMOV_IGE) || (ins->opcode == OP_ISHL_IMM) || (ins->opcode == OP_ISHR_IMM) || (ins->opcode == OP_ISHR_UN_IMM) || (ins->opcode == OP_IAND_IMM) || (ins->opcode == OP_ICONV_TO_U1) || (ins->opcode == OP_ICONV_TO_I1) || (ins->opcode == OP_SEXT_I4) || (ins->opcode == OP_LCONV_TO_U1) || (ins->opcode == OP_ICONV_TO_U2) || (ins->opcode == OP_ICONV_TO_I2) || (ins->opcode == OP_LCONV_TO_I2) || (ins->opcode == OP_LDADDR) || (ins->opcode == OP_PHI) || (ins->opcode == OP_NOP) || (ins->opcode == OP_ZEXT_I4) || (ins->opcode == OP_NOT_NULL) || (ins->opcode == OP_IL_SEQ_POINT))
+#define MONO_INS_HAS_NO_SIDE_EFFECT(ins) (MONO_IS_MOVE (ins) || (ins->opcode == OP_ICONST) || (ins->opcode == OP_I8CONST) || MONO_IS_ZERO (ins) || (ins->opcode == OP_ADD_IMM) || (ins->opcode == OP_R8CONST) || (ins->opcode == OP_LADD_IMM) || (ins->opcode == OP_ISUB_IMM) || (ins->opcode == OP_IADD_IMM) || (ins->opcode == OP_LNEG) || (ins->opcode == OP_ISUB) || (ins->opcode == OP_CMOV_IGE) || (ins->opcode == OP_ISHL_IMM) || (ins->opcode == OP_ISHR_IMM) || (ins->opcode == OP_ISHR_UN_IMM) || (ins->opcode == OP_IAND_IMM) || (ins->opcode == OP_ICONV_TO_U1) || (ins->opcode == OP_ICONV_TO_I1) || (ins->opcode == OP_SEXT_I4) || (ins->opcode == OP_LCONV_TO_U1) || (ins->opcode == OP_ICONV_TO_U2) || (ins->opcode == OP_ICONV_TO_I2) || (ins->opcode == OP_LCONV_TO_I2) || (ins->opcode == OP_LDADDR) || (ins->opcode == OP_PHI) || (ins->opcode == OP_NOP) || (ins->opcode == OP_ZEXT_I4) || (ins->opcode == OP_NOT_NULL) || (ins->opcode == OP_IL_SEQ_POINT) || (ins->opcode == OP_XZERO))
-#define MONO_METHOD_IS_FINAL(m) (((m)->flags & METHOD_ATTRIBUTE_FINAL) || ((m)->klass && ((m)->klass->flags & TYPE_ATTRIBUTE_SEALED)))
+#define MONO_INS_IS_PCONST_NULL(ins) ((ins)->opcode == OP_PCONST && (ins)->inst_p0 == 0)
+
+#define MONO_METHOD_IS_FINAL(m) (((m)->flags & METHOD_ATTRIBUTE_FINAL) || ((m)->klass && (mono_class_get_flags ((m)->klass) & TYPE_ATTRIBUTE_SEALED)))
#ifdef MONO_ARCH_SIMD_INTRINSICS
typedef struct MonoSpillInfo MonoSpillInfo;
typedef struct MonoTraceSpec MonoTraceSpec;
-extern MonoNativeTlsKey mono_jit_tls_id;
extern MonoTraceSpec *mono_jit_trace_calls;
extern gboolean mono_break_on_exc;
extern int mono_exc_esp_offset;
extern gboolean mono_do_signal_chaining;
extern gboolean mono_do_crash_chaining;
extern MONO_API gboolean mono_use_llvm;
+extern MONO_API gboolean mono_use_interpreter;
extern gboolean mono_do_single_method_regression;
extern guint32 mono_single_method_regression_opt;
extern MonoMethod *mono_current_single_method;
extern gboolean mono_using_xdebug;
extern int mini_verbose;
extern int valgrind_register;
+extern GList* mono_aot_paths;
#define INS_INFO(opcode) (&ins_info [((opcode) - OP_START - 1) * 4])
#define MONO_BB_FOR_EACH_INS_SAFE(bb, n, ins) for ((ins) = (bb)->code, n = (ins) ? (ins)->next : NULL; (ins); (ins) = (n), (n) = (ins) ? (ins)->next : NULL)
+#define MONO_BB_FOR_EACH_INS_REVERSE(bb, ins) for ((ins) = (bb)->last_ins; (ins); (ins) = (ins)->prev)
+
#define MONO_BB_FOR_EACH_INS_REVERSE_SAFE(bb, p, ins) for ((ins) = (bb)->last_ins, p = (ins) ? (ins)->prev : NULL; (ins); (ins) = (p), (p) = (ins) ? (ins)->prev : NULL)
#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;
};
guint real_offset;
GSList *seq_points;
+
+ // The MonoInst of the last sequence point for the current basic block.
MonoInst *last_seq_point;
+
+ // This will hold a list of last sequence points of incoming basic blocks
+ MonoInst **pred_seq_points;
+ guint num_pred_seq_points;
GSList *spill_slot_defs;
/* 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.
* 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;
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;
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;
* The current exception in flight
*/
guint32 thrown_exc;
+ /*
+ * If the current exception is not a subclass of Exception,
+ * the original exception.
+ */
+ guint32 thrown_non_exc;
/*
* The calling assembly in llvmonly mode.
*/
MonoImage *calling_image;
+
+ /*
+ * The stack frame "high water mark" for ThreadAbortExceptions.
+ * We will rethrow the exception upon exiting a catch clause that's
+ * in a function stack frame above the water mark(isn't being called by
+ * 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;
/*
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 */
* 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 {
MONO_TRAMPOLINE_RESTORE_STACK_PROT,
MONO_TRAMPOLINE_GENERIC_VIRTUAL_REMOTING,
MONO_TRAMPOLINE_VCALL,
- MONO_TRAMPOLINE_HANDLER_BLOCK_GUARD,
MONO_TRAMPOLINE_NUM
} MonoTrampolineType;
/* 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,
guint emulate_div : 1;
guint emulate_long_shift_opts : 1;
guint have_objc_get_selector : 1;
- guint have_generalized_imt_thunk : 1;
- guint have_tls_get : 1;
- guint have_tls_get_reg : 1;
+ guint have_generalized_imt_trampoline : 1;
guint have_liverange_ops: 1;
guint have_op_tail_call : 1;
guint have_dummy_init : 1;
guint need_got_var : 1;
guint need_div_check : 1;
guint no_unaligned_access : 1;
+ guint disable_div_with_mul : 1;
int monitor_enter_adjustment;
int dyn_call_param_area;
} MonoBackend;
JIT_FLAG_FULL_AOT = (1 << 2),
/* Whenever to compile with LLVM */
JIT_FLAG_LLVM = (1 << 3),
- /* Whenever to disable direct calls to direct calls to icall functions */
+ /* Whenever to disable direct calls to icall functions */
JIT_FLAG_NO_DIRECT_ICALLS = (1 << 4),
/* Emit explicit null checks */
JIT_FLAG_EXPLICIT_NULL_CHECKS = (1 << 5),
/* Whenever to compile in llvm-only mode */
JIT_FLAG_LLVM_ONLY = (1 << 6),
+ /* Whenever calls to pinvoke functions are made directly */
+ JIT_FLAG_DIRECT_PINVOKE = (1 << 7),
+ /* Whenever this is a compile-all run and the result should be discarded */
+ JIT_FLAG_DISCARD_RESULTS = (1 << 8),
} JitFlags;
/* Bit-fields in the MonoBasicBlock.region */
MonoMethod *current_method; /* The method currently processed by method_to_ir () */
MonoMethod *method_to_register; /* The method to register in JIT info tables */
MonoGenericContext *generic_context;
+ MonoInst *this_arg;
MonoBackend *backend;
/* 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 */
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;
guint epilog_end;
regmask_t used_int_regs;
guint32 opt;
- guint32 prof_options;
guint32 flags;
guint32 comp_done;
guint32 verbose_level;
guint disable_out_of_line_bblocks : 1;
guint disable_direct_icalls : 1;
guint disable_gc_safe_points : 1;
+ guint direct_pinvoke : 1;
guint create_lmf_var : 1;
/*
* When this is set, the code to push/pop the LMF from the LMF stack is generated as IR
* 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;
gpointer debug_info;
guint32 lmf_offset;
guint16 *intvars;
- MonoProfileCoverageInfo *coverage_info;
+ MonoProfilerCoverageInfo *coverage_info;
GHashTable *token_info_hash;
MonoCompileArch arch;
guint32 inline_depth;
guint8 *thunks;
/* Offset between the start of code and the thunks area */
int thunks_offset;
- guint32 exception_type; /* MONO_EXCEPTION_* */
+ MonoExceptionType exception_type; /* MONO_EXCEPTION_* */
guint32 exception_data;
char* exception_message;
gpointer exception_ptr;
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,
gint32 alias_removed;
gint32 loads_eliminated;
gint32 stores_eliminated;
+ gint32 optimized_divisions;
int methods_with_llvm;
int methods_without_llvm;
char *max_ratio_method;
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)
gboolean better_cast_details;
gboolean mdb_optimizations;
gboolean no_gdb_backtrace;
- gboolean suspend_on_sigsegv;
+ gboolean suspend_on_native_crash;
gboolean suspend_on_exception;
gboolean suspend_on_unhandled;
gboolean dyn_runtime_invoke;
gboolean gdb;
- gboolean arm_use_fallback_tls;
+ gboolean lldb;
+ gboolean use_fallback_tls;
/*
* Whenever data such as next sequence points and flags is required.
* Next sequence points and flags are required by the debugger agent.
*/
gboolean gen_sdb_seq_points;
- gboolean gen_seq_points_compact_data;
+ gboolean no_seq_points_compact_data;
/*
* Setting single_imm_size should guarantee that each time managed code is compiled
* the same instructions and registers are used, regardless of the size of used values.
*/
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);
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_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);
void mono_optimize_branches (MonoCompile *cfg);
void mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom);
-const char*mono_ji_type_to_string (MonoJumpInfoType type);
+const char*mono_ji_type_to_string (MonoJumpInfoType type) MONO_LLVM_INTERNAL;
void mono_print_ji (const MonoJumpInfo *ji);
void mono_print_ins_index (int i, MonoInst *ins);
GString *mono_print_ins_index_strbuf (int i, MonoInst *ins);
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);
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);
-gint32 mono_get_jit_tls_offset (void);
-gint32 mono_get_lmf_tls_offset (void);
-gint32 mono_get_lmf_addr_tls_offset (void);
-int mini_get_tls_offset (MonoTlsKey key);
-gboolean mini_tls_get_supported (MonoCompile *cfg, MonoTlsKey key);
MonoInst* mono_create_tls_get (MonoCompile *cfg, MonoTlsKey key);
-MonoInst* mono_get_jit_tls_intrinsic (MonoCompile *cfg);
-MonoInst* mono_get_domain_intrinsic (MonoCompile* cfg);
-MonoInst* mono_get_thread_intrinsic (MonoCompile* cfg);
-MonoInst* mono_get_lmf_intrinsic (MonoCompile* cfg);
-MonoInst* mono_get_lmf_addr_intrinsic (MonoCompile* cfg);
GList *mono_varlist_insert_sorted (MonoCompile *cfg, GList *list, MonoMethodVar *mv, int sort_type);
GList *mono_varlist_sort (MonoCompile *cfg, GList *list, int sort_type);
void mono_analyze_liveness (MonoCompile *cfg);
void mono_create_jump_table (MonoCompile *cfg, MonoInst *label, MonoBasicBlock **bbs, int num_blocks);
MonoCompile *mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFlags flags, int parts, int aot_method_index);
void mono_destroy_compile (MonoCompile *cfg);
+void mono_empty_compile (MonoCompile *cfg);
MonoJitICallInfo *mono_find_jit_opcode_emulation (int opcode);
void mono_print_ins_index (int i, MonoInst *ins);
void mono_print_ins (MonoInst *ins);
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);
/* 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*
gpointer mono_aot_get_unbox_trampoline (MonoMethod *method);
gpointer mono_aot_get_lazy_fetch_trampoline (guint32 slot);
gpointer mono_aot_get_static_rgctx_trampoline (gpointer ctx, gpointer addr);
-gpointer mono_aot_get_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
+gpointer mono_aot_get_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
gpointer mono_aot_get_gsharedvt_arg_trampoline(gpointer arg, gpointer addr);
guint8* mono_aot_get_unwind_info (MonoJitInfo *ji, guint32 *unwind_info_len);
guint32 mono_aot_method_hash (MonoMethod *method);
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);
gboolean mono_running_on_valgrind (void);
void* mono_global_codeman_reserve (int size);
+void mono_global_codeman_foreach (MonoCodeManagerFunc func, void *user_data);
const char *mono_regname_full (int reg, int bank);
gint32* mono_allocate_stack_slots (MonoCompile *cfg, gboolean backward, guint32 *stack_size, guint32 *stack_align);
void mono_local_regalloc (MonoCompile *cfg, MonoBasicBlock *bb);
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);
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;
MonoInst *return_var, MonoInst **inline_args,
guint inline_offset, gboolean is_virtual_call);
+//the following methods could just be renamed/moved from method-to-ir.c
+int mini_inline_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **sp, guchar *ip,
+ guint real_offset, gboolean inline_always);
+
+MonoInst* mini_emit_get_rgctx_klass (MonoCompile *cfg, int context_used, MonoClass *klass, MonoRgctxInfoType rgctx_type);
+MonoInst* mini_emit_runtime_constant (MonoCompile *cfg, MonoJumpInfoType patch_type, gpointer data);
+void mini_save_cast_details (MonoCompile *cfg, MonoClass *klass, int obj_reg, gboolean null_check);
+void mini_reset_cast_details (MonoCompile *cfg);
+void mini_emit_class_check (MonoCompile *cfg, int klass_reg, MonoClass *klass);
+
+gboolean mini_class_has_reference_variant_generic_argument (MonoCompile *cfg, MonoClass *klass, int context_used);
+
+
MonoInst *mono_decompose_opcode (MonoCompile *cfg, MonoInst *ins);
void mono_decompose_long_opts (MonoCompile *cfg);
void mono_decompose_vtype_opts (MonoCompile *cfg);
void mono_allocate_gsharedvt_vars (MonoCompile *cfg);
void mono_if_conversion (MonoCompile *cfg);
+
+
/* Delegates */
gpointer mini_get_delegate_arg (MonoMethod *method, gpointer method_ptr);
void mini_init_delegate (MonoDelegate *del);
+char* mono_get_delegate_virtual_invoke_impl_name (gboolean load_imt_reg, int offset);
gpointer mono_get_delegate_virtual_invoke_impl (MonoMethodSignature *sig, MonoMethod *method);
/* methods that must be provided by the arch-specific port */
gpointer mono_arch_create_monitor_enter_trampoline (MonoTrampInfo **info, gboolean is_v4, gboolean aot);
gpointer mono_arch_create_monitor_exit_trampoline (MonoTrampInfo **info, gboolean aot);
guint8 *mono_arch_create_llvm_native_thunk (MonoDomain *domain, guint8* addr) MONO_LLVM_INTERNAL;
+gpointer mono_arch_get_get_tls_tramp (void);
GList *mono_arch_get_allocatable_int_vars (MonoCompile *cfg);
GList *mono_arch_get_global_int_regs (MonoCompile *cfg);
GList *mono_arch_get_global_fp_regs (MonoCompile *cfg);
int mono_arch_translate_tls_offset (int offset);
gboolean mono_arch_opcode_supported (int opcode);
void mono_arch_setup_resume_sighandler_ctx (MonoContext *ctx, gpointer func);
+gboolean mono_arch_have_fast_tls (void);
#ifdef MONO_ARCH_SOFT_FLOAT_FALLBACK
gboolean mono_arch_is_soft_float (void);
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
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);
gpointer mono_arch_create_specific_trampoline (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
MonoMethod* mono_arch_find_imt_method (mgreg_t *regs, guint8 *code);
MonoVTable* mono_arch_find_static_call_vtable (mgreg_t *regs, guint8 *code);
-gpointer mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
+gpointer mono_arch_build_imt_trampoline (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckItem **imt_entries, int count, gpointer fail_tramp);
void mono_arch_notify_pending_exc (MonoThreadInfo *info);
guint8* mono_arch_get_call_target (guint8 *code);
guint32 mono_arch_get_plt_info_offset (guint8 *plt_entry, mgreg_t *regs, guint8 *code);
GSList *mono_arch_get_trampolines (gboolean aot);
-
-/* 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);
+gpointer mono_arch_get_enter_icall_trampoline (MonoTrampInfo **info);
/*New interruption machinery */
void
void mono_exceptions_init (void);
gboolean mono_handle_exception (MonoContext *ctx, MonoObject *obj);
-void mono_handle_native_sigsegv (int signal, void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo);
+void mono_handle_native_crash (const char *signal, void *sigctx, MONO_SIG_HANDLER_INFO_TYPE *siginfo);
MONO_API void mono_print_thread_dump (void *sigctx);
MONO_API void mono_print_thread_dump_from_ctx (MonoContext *ctx);
void mono_walk_stack_with_ctx (MonoJitStackWalk func, MonoContext *start_ctx, MonoUnwindOptions unwind_options, void *user_data);
MonoString **file, gint32 *line, gint32 *column);
void mono_set_cast_details (MonoClass *from, MonoClass *to);
-/* Installs a function which is called when the runtime encounters an unhandled exception.
- * This hook isn't expected to return.
- * If no hook has been installed, the runtime will print a message before aborting.
- */
-typedef void (*MonoUnhandledExceptionFunc) (MonoObject *exc, gpointer user_data);
-MONO_API void mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data);
-void mono_invoke_unhandled_exception_hook (MonoObject *exc);
-
void mono_decompose_typechecks (MonoCompile *cfg);
/* Dominator/SSA methods */
void mono_compile_dominator_info (MonoCompile *cfg, int dom_flags);
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);
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 */
const char *mono_arch_xregname (int reg);
void mono_simd_simplify_indirection (MonoCompile *cfg);
MonoInst* mono_emit_simd_intrinsics (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args);
+MonoInst* mono_emit_simd_field_load (MonoCompile *cfg, MonoClassField *field, MonoInst *addr);
guint32 mono_arch_cpu_enumerate_simd_versions (void);
void mono_simd_intrinsics_init (void);
* Per-OS implementation functions.
*/
void mono_runtime_install_handlers (void);
+gboolean mono_runtime_install_custom_handlers (const char *handlers);
+void mono_runtime_install_custom_handlers_usage (void);
void mono_runtime_cleanup_handlers (void);
void mono_runtime_setup_stat_profiler (void);
void mono_runtime_shutdown_stat_profiler (void);
void mono_runtime_posix_install_handlers (void);
-pid_t mono_runtime_syscall_fork (void);
void mono_gdb_render_native_backtraces (pid_t crashed_pid);
void mono_cross_helpers_run (void);
void MONO_SIG_HANDLER_SIGNATURE (mono_sigint_signal_handler) ;
gboolean MONO_SIG_HANDLER_SIGNATURE (mono_chain_signal);
-#ifndef MONO_ARCH_HAVE_TLS_GET
-#define MONO_ARCH_HAVE_TLS_GET 0
-#endif
-
#ifdef MONO_ARCH_VARARG_ICALLS
#define ARCH_VARARG_ICALLS 1
#else
#define ARCH_VARARG_ICALLS 0
#endif
-/*
- * Native unwinder integration
- */
-void mono_exception_native_unwind (void *ctx, MONO_SIG_HANDLER_INFO_TYPE *info);
-
/*
* Coop support for trampolines
*/