#include "regalloc.h"
#include "declsec.h"
#include "mini-unwind.h"
+#include "jit.h"
+
+/*
+ * 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.
+ */
+#if defined(HAVE_BOEHM_GC) || defined(HAVE_SGEN_GC)
+#error "The code in mini/ should not depend on these defines."
+#endif
#ifndef G_LIKELY
#define G_LIKELY(a) (a)
#endif
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 82
+#define MONO_AOT_FILE_VERSION 84
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
/* Constants used to encode different types of methods in AOT */
enum {
MONO_AOT_METHODREF_MIN = 240,
+ /* Image index bigger than METHODREF_MIN */
+ MONO_AOT_METHODREF_LARGE_IMAGE_INDEX = 249,
/* Runtime provided methods on arrays */
MONO_AOT_METHODREF_ARRAY = 250,
MONO_AOT_METHODREF_NO_AOT_TRAMPOLINE = 251,
typedef enum {
MONO_AOT_FILE_FLAG_WITH_LLVM = 1,
MONO_AOT_FILE_FLAG_FULL_AOT = 2,
- MONO_AOT_FILE_FLAG_DEBUG = 4
+ MONO_AOT_FILE_FLAG_DEBUG = 4,
+ MONO_AOT_FILE_FLAG_DIRECT_METHOD_ADDRESSES = 8
} MonoAotFileFlags;
/* This structure is stored in the AOT file */
gpointer method_info_offsets;
gpointer ex_info_offsets;
gpointer code_offsets;
+#ifdef MONOTOUCH
+ gpointer method_addresses;
+#endif
gpointer extra_method_info_offsets;
gpointer extra_method_table;
gpointer got_info_offsets;
guint32 flags;
/* Optimization flags used to compile the module */
guint32 opts;
+ /* SIMD flags used to compile the module */
+ guint32 simd_opts;
/* Index of the blob entry holding the GC used by this module */
gint32 gc_name_index;
MonoInst *vret_var;
gconstpointer fptr;
guint stack_usage;
+ guint stack_align_amount;
guint virtual : 1;
guint tail_call : 1;
/* If this is TRUE, 'fptr' points to a MonoJumpInfo instead of an address. */
guint dynamic_imt_arg : 1;
/* Whenever there is an RGCTX argument */
guint32 rgctx_reg : 1;
+ /* Whenever the call will need an unbox trampoline */
+ guint need_unbox_trampoline : 1;
regmask_t used_iregs;
regmask_t used_fregs;
GSList *out_ireg_args;
MONO_RGCTX_INFO_METHOD_CONTEXT,
MONO_RGCTX_INFO_REMOTING_INVOKE_WITH_CHECK,
MONO_RGCTX_INFO_METHOD_DELEGATE_CODE,
- MONO_RGCTX_INFO_CAST_CACHE
+ MONO_RGCTX_INFO_CAST_CACHE,
+ MONO_RGCTX_INFO_ARRAY_ELEMENT_SIZE,
+ MONO_RGCTX_INFO_VALUE_SIZE,
+ MONO_RGCTX_INFO_FIELD_OFFSET
} MonoRgctxInfoType;
-typedef struct _MonoRuntimeGenericContextOtherInfoTemplate {
+typedef struct _MonoRuntimeGenericContextInfoTemplate {
MonoRgctxInfoType info_type;
gpointer data;
- struct _MonoRuntimeGenericContextOtherInfoTemplate *next;
-} MonoRuntimeGenericContextOtherInfoTemplate;
+ struct _MonoRuntimeGenericContextInfoTemplate *next;
+} MonoRuntimeGenericContextInfoTemplate;
typedef struct {
MonoClass *next_subclass;
- MonoRuntimeGenericContextOtherInfoTemplate *other_infos;
+ MonoRuntimeGenericContextInfoTemplate *infos;
GSList *method_templates;
} MonoRuntimeGenericContextTemplate;
MonoGenericSharingContext *generic_sharing_context;
+ /* For native-to-managed wrappers, the saved old domain */
+ MonoInst *orig_domain_var;
+
unsigned char *cil_start;
#ifdef __native_client_codegen__
/* this alloc is not aligned, native_code */
* Whenever to break in the debugger using G_BREAKPOINT on unhandled exceptions.
*/
gboolean break_on_exc;
+ /*
+ * Load AOT JIT info eagerly.
+ */
+ gboolean load_aot_jit_info_eagerly;
} MonoDebugOptions;
enum {
MonoDomain* mini_init (const char *filename, const char *runtime_version) MONO_INTERNAL;
void mini_cleanup (MonoDomain *domain) MONO_INTERNAL;
MonoDebugOptions *mini_get_debug_options (void) MONO_INTERNAL;
-char* mono_get_runtime_build_info (void) MONO_INTERNAL;
/* helper methods */
void mono_disable_optimizations (guint32 opts) MONO_INTERNAL;
void mono_print_code (MonoCompile *cfg, const char *msg) MONO_INTERNAL;
void mono_print_method_from_ip (void *ip);
char *mono_pmip (void *ip);
+gboolean mono_debug_count (void) MONO_INTERNAL;
const char* mono_inst_name (int op);
void mono_inst_set_src_registers (MonoInst *ins, int *regs) MONO_INTERNAL;
int mono_op_to_op_imm (int opcode) MONO_INTERNAL;
MonoLMF * mono_get_lmf (void) MONO_INTERNAL;
MonoLMF** mono_get_lmf_addr (void) MONO_INTERNAL;
void mono_set_lmf (MonoLMF *lmf) MONO_INTERNAL;
-void mono_jit_thread_attach (MonoDomain *domain);
+MonoDomain *mono_jit_thread_attach (MonoDomain *domain);
+void mono_jit_set_domain (MonoDomain *domain);
MonoNativeTlsKey mono_get_jit_tls_key (void) MONO_INTERNAL;
gint32 mono_get_jit_tls_offset (void) MONO_INTERNAL;
gint32 mono_get_lmf_tls_offset (void) MONO_INTERNAL;
MonoInst* mono_get_jit_tls_intrinsic (MonoCompile *cfg) MONO_INTERNAL;
MonoInst* mono_get_domain_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
MonoInst* mono_get_thread_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
+MonoInst* mono_get_lmf_intrinsic (MonoCompile* cfg) MONO_INTERNAL;
GList *mono_varlist_insert_sorted (MonoCompile *cfg, GList *list, MonoMethodVar *mv, int sort_type) MONO_INTERNAL;
GList *mono_varlist_sort (MonoCompile *cfg, GList *list, int sort_type) MONO_INTERNAL;
void mono_analyze_liveness (MonoCompile *cfg) MONO_INTERNAL;
void mono_arch_finish_init (void) MONO_INTERNAL;
void mono_arch_cleanup (void) MONO_INTERNAL;
void mono_arch_cpu_init (void) MONO_INTERNAL;
-guint32 mono_arch_cpu_optimizazions (guint32 *exclude_mask) MONO_INTERNAL;
+guint32 mono_arch_cpu_optimizations (guint32 *exclude_mask) MONO_INTERNAL;
void mono_arch_instrument_mem_needs (MonoMethod *method, int *stack, int *code) MONO_INTERNAL;
void *mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments) MONO_INTERNAL;
void *mono_arch_instrument_epilog (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments) MONO_INTERNAL;
gpointer mono_arch_get_nullified_class_init_trampoline (MonoTrampInfo **info) MONO_INTERNAL;
gpointer mono_arch_create_monitor_enter_trampoline (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
gpointer mono_arch_create_monitor_exit_trampoline (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
+guint8 *mono_arch_create_llvm_native_thunk (MonoDomain *domain, guint8* addr) MONO_LLVM_INTERNAL;
GList *mono_arch_get_allocatable_int_vars (MonoCompile *cfg) MONO_INTERNAL;
GList *mono_arch_get_global_int_regs (MonoCompile *cfg) MONO_INTERNAL;
GList *mono_arch_get_global_fp_regs (MonoCompile *cfg) MONO_INTERNAL;
void mono_arch_free_jit_tls_data (MonoJitTlsData *tls) MONO_INTERNAL;
void mono_arch_fill_argument_info (MonoCompile *cfg) MONO_INTERNAL;
void mono_arch_allocate_vars (MonoCompile *m) MONO_INTERNAL;
-int mono_arch_get_argument_info (MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info) MONO_INTERNAL;
+int mono_arch_get_argument_info (MonoGenericSharingContext *gsctx, MonoMethodSignature *csig, int param_count, MonoJitArgumentInfo *arg_info) MONO_INTERNAL;
gboolean mono_arch_print_tree (MonoInst *tree, int arity) MONO_INTERNAL;
void mono_arch_emit_call (MonoCompile *cfg, MonoCallInst *call) MONO_INTERNAL;
void mono_arch_emit_outarg_vt (MonoCompile *cfg, MonoInst *ins, MonoInst *src) MONO_INTERNAL;
MonoJitInfo * mono_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, MonoJitInfo *res, MonoJitInfo *prev_ji, MonoContext *ctx, MonoContext *new_ctx, char **trace, MonoLMF **lmf, int *native_offset, gboolean *managed) MONO_INTERNAL;
+typedef gboolean (*MonoExceptionFrameWalk) (MonoMethod *method, gpointer ip, size_t native_offset, gboolean managed, gpointer user_data);
+gboolean mono_exception_walk_trace (MonoException *ex, MonoExceptionFrameWalk func, gpointer user_data);
+
gboolean
mono_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls,
MonoJitInfo *prev_ji, MonoContext *ctx,
MonoString *ves_icall_System_Exception_get_trace (MonoException *exc) MONO_INTERNAL;
void mono_set_cast_details (MonoClass *from, MonoClass *to) MONO_INTERNAL;
+/* 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);
+void mono_install_unhandled_exception_hook (MonoUnhandledExceptionFunc func, gpointer user_data);
+void mono_invoke_unhandled_exception_hook (MonoObject *exc);
+
/* Dominator/SSA methods */
void mono_compile_dominator_info (MonoCompile *cfg, int dom_flags) MONO_INTERNAL;
void mono_compute_natural_loops (MonoCompile *cfg) MONO_INTERNAL;
/* Generic sharing */
-
void
mono_set_generic_sharing_supported (gboolean supported) MONO_INTERNAL;
+void
+mono_set_generic_sharing_vt_supported (gboolean supported) MONO_INTERNAL;
+
gboolean
mono_class_generic_sharing_enabled (MonoClass *class) MONO_INTERNAL;
mono_class_rgctx_get_array_size (int n, gboolean mrgctx) MONO_INTERNAL;
guint32
-mono_method_lookup_or_register_other_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
+mono_method_lookup_or_register_info (MonoMethod *method, gboolean in_mrgctx, gpointer data,
MonoRgctxInfoType info_type, MonoGenericContext *generic_context) MONO_INTERNAL;
MonoGenericContext
mono_method_is_generic_sharable_impl (MonoMethod *method, gboolean allow_type_vars) MONO_INTERNAL;
gboolean
-mono_method_is_generic_sharable_impl_full (MonoMethod *method, gboolean allow_type_vars, gboolean allow_partial) MONO_INTERNAL;
+mono_method_is_generic_sharable_impl_full (MonoMethod *method, gboolean allow_type_vars, gboolean allow_partial, gboolean allow_gsharedvt) MONO_INTERNAL;
gboolean
mono_is_partially_sharable_inst (MonoGenericInst *inst) MONO_INTERNAL;
void mono_cfg_set_exception (MonoCompile *cfg, int type) MONO_INTERNAL;
gboolean mini_type_is_reference (MonoCompile *cfg, MonoType *type) MONO_INTERNAL;
-
+gboolean mini_type_var_is_vt (MonoCompile *cfg, MonoType *type) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_klass (MonoCompile *cfg, MonoClass *klass) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_type (MonoCompile *cfg, MonoType *t) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_signature (MonoCompile *cfg, MonoMethodSignature *sig) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_type_gsctx (MonoGenericSharingContext *gsctx, MonoType *t) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_variable_type (MonoCompile *cfg, MonoType *t) MONO_INTERNAL;
+MonoType* mini_get_gsharedvt_alloc_type_for_type (MonoCompile *cfg, MonoType *t) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_sharable_method (MonoMethod *method) MONO_INTERNAL;
+gboolean mini_is_gsharedvt_variable_signature (MonoMethodSignature *sig) MONO_INTERNAL;
+gpointer mini_method_get_rgctx (MonoMethod *m) MONO_INTERNAL;
+void mini_init_gsctx (MonoGenericContext *context, MonoGenericSharingContext *gsctx) MONO_INTERNAL;
/* wapihandles.c */
int mini_wapi_hps (int argc, char **argv) MONO_INTERNAL;