#endif
/* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION "71"
+#define MONO_AOT_FILE_VERSION 72
//TODO: This is x86/amd64 specific.
#define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))
/* This structure is stored in the AOT file */
typedef struct MonoAotFileInfo
{
+ /* The version number of the AOT file format, should match MONO_AOT_FILE_VERSION */
+ guint32 version;
+ /* For alignment */
+ guint32 dummy;
+
+ /* All the pointers should be at the start to avoid alignment problems */
+
+ /* Mono's Global Offset Table */
+ gpointer got;
+ /* Compiled code for methods */
+ gpointer methods;
+ /* Mono EH Frame created by llc when using LLVM */
+ gpointer mono_eh_frame;
+ /* Data blob */
+ gpointer blob;
+ gpointer class_name_table;
+ gpointer class_info_offsets;
+ gpointer method_info_offsets;
+ gpointer ex_info_offsets;
+ gpointer code_offsets;
+ gpointer extra_method_info_offsets;
+ gpointer extra_method_table;
+ gpointer got_info_offsets;
+ gpointer methods_end;
+ gpointer unwind_info;
+ gpointer mem_end;
+ gpointer image_table;
+ /* Start of Mono's Program Linkage Table */
+ gpointer plt;
+ /* End of Mono's Program Linkage Table */
+ gpointer plt_end;
+ /* The GUID of the assembly which the AOT image was generated from */
+ gpointer assembly_guid;
+ /*
+ * The runtime version string for AOT images generated using 'bind-to-runtime-version',
+ * NULL otherwise.
+ */
+ gpointer runtime_version;
+ /* Blocks of various kinds of trampolines */
+ gpointer specific_trampolines;
+ gpointer static_rgctx_trampolines;
+ gpointer imt_thunks;
+ /*
+ * The end of LLVM generated thumb code, or NULL.
+ */
+ gpointer thumb_end;
+
+ /* The index of the first GOT slot used by the PLT */
guint32 plt_got_offset_base;
+ /* Number of entries in the GOT */
guint32 got_size;
+ /* Number of entries in the PLT */
guint32 plt_size;
+ /* Number of methods */
guint32 nmethods;
+ /* A union of MonoAotFileFlags */
guint32 flags;
/* Optimization flags used to compile the module */
guint32 opts;
/* Index of the blob entry holding the GC used by this module */
gint32 gc_name_index;
+ /* Number of trampolines */
guint32 num_trampolines [MONO_AOT_TRAMP_NUM];
+ /* The indexes of the first GOT slots used by the trampolines */
guint32 trampoline_got_offset_base [MONO_AOT_TRAMP_NUM];
+ /* The size of one trampoline */
guint32 trampoline_size [MONO_AOT_TRAMP_NUM];
} MonoAotFileInfo;
int native_offset;
int il_offset;
gpointer lmf;
+ guint32 unwind_info_len;
+ guint8 *unwind_info;
} StackFrameInfo;
typedef struct {
int offset;
};
+/*
+ * Information about a call site for the GC map creation code
+ */
+typedef struct {
+ /* The next offset after the call instruction */
+ int pc_offset;
+ /* The basic block containing the call site */
+ MonoBasicBlock *bb;
+ /*
+ * The set of variables live at the call site.
+ * Has length cfg->num_varinfo in bits.
+ */
+ guint8 *liveness;
+ /*
+ * List of OP_GC_PARAM_SLOT_LIVENESS_DEF instructions defining the param slots
+ * used by this call.
+ */
+ GSList *param_slots;
+} GCCallSite;
+
/*
* The IR-level extended basic block.
*
GSList *seq_points;
MonoInst *last_seq_point;
+ GSList *spill_slot_defs;
+
+ /* List of call sites in this bblock sorted by pc_offset */
+ GSList *gc_callsites;
+
/*
* The region encodes whether the basic block is inside
* a finally, catch, filter or none of these.
/* On loads, the source address points to a constant value */
MONO_INST_CONSTANT_LOAD = 64,
/* On variables, the variable needs GC tracking */
- MONO_INST_GC_TRACK = 128
+ MONO_INST_GC_TRACK = 128,
+ /*
+ * Set on instructions during code emission which make calls, i.e. OP_CALL, OP_THROW.
+ * backend.pc_offset will be set to the pc offset at the end of the native call instructions.
+ */
+ MONO_INST_GC_CALLSITE = 128
};
#define inst_c0 data.op[0].const_val
guint idx; /* inside cfg->varinfo, cfg->vars */
MonoLiveRange range; /* generated by liveness analysis */
MonoLiveInterval *interval; /* generated by liveness analysis */
-#ifdef HAVE_SGEN_GC
- MonoLiveInterval *gc_interval; /* generated by mono_analyze_liveness_gc () */
-#endif
int reg; /* != -1 if allocated into a register */
int spill_costs;
MonoBitSet *def_in; /* used by SSA */
/* Stores state needed by handler block with a guard */
MonoContext ex_ctx;
ResumeState resume_state;
- /* handle block return address */
+
+ /*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 */
+
+ /* 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;
+ /* context to be used by the guard trampoline when resuming interruption.*/
+ MonoContext handler_block_context;
/*
* Stores the state at the exception throw site to be used by mono_stack_walk ()
* when it is called from profiler functions during exception handling.
#ifdef HAVE_SGEN_GC
#define vreg_is_ref(cfg, vreg) ((vreg) < (cfg)->vreg_is_ref_len ? (cfg)->vreg_is_ref [(vreg)] : 0)
+#define vreg_is_mp(cfg, vreg) ((vreg) < (cfg)->vreg_is_mp_len ? (cfg)->vreg_is_mp [(vreg)] : 0)
#else
#define vreg_is_ref(cfg, vreg) FALSE
+#define vreg_is_mp(cfg, vreg) FALSE
#endif
/*
/* Size of above array */
guint32 vreg_is_ref_len;
+ /* Marks vregs which hold a managed pointer */
+ /* FIXME: Use a bitmap */
+ gboolean *vreg_is_mp;
+
+ /* Size of above array */
+ guint32 vreg_is_mp_len;
+
/*
* The original method to compile, differs from 'method' when doing generic
* sharing.
/* Points to a MonoCompileGC */
gpointer gc_info;
+
+ /*
+ * The encoded GC map along with its size. This contains binary data so it can be saved in an AOT
+ * image etc, but it requires a 4 byte alignment.
+ */
+ guint8 *gc_map;
+ guint32 gc_map_size;
} MonoCompile;
typedef enum {
#endif
/* Opcodes to load/store regsize quantities */
-#ifdef __mono_ilp32__
+#if defined (__mono_ilp32__)
#define OP_LOADR_MEMBASE OP_LOADI8_MEMBASE
#define OP_STORER_MEMBASE_REG OP_STOREI8_MEMBASE_REG
#else
guint32 mono_alloc_preg (MonoCompile *cfg) MONO_LLVM_INTERNAL;
guint32 mono_alloc_dreg (MonoCompile *cfg, MonoStackType stack_type) MONO_INTERNAL;
guint32 mono_alloc_ireg_ref (MonoCompile *cfg) MONO_LLVM_INTERNAL;
+guint32 mono_alloc_ireg_mp (MonoCompile *cfg) MONO_LLVM_INTERNAL;
+guint32 mono_alloc_ireg_copy (MonoCompile *cfg, guint32 vreg) MONO_LLVM_INTERNAL;
void mono_mark_vreg_as_ref (MonoCompile *cfg, int vreg) MONO_INTERNAL;
+void mono_mark_vreg_as_mp (MonoCompile *cfg, int vreg) MONO_INTERNAL;
void mono_link_bblock (MonoCompile *cfg, MonoBasicBlock *from, MonoBasicBlock* to) MONO_INTERNAL;
void mono_unlink_bblock (MonoCompile *cfg, MonoBasicBlock *from, MonoBasicBlock* to) MONO_INTERNAL;
void mono_liveness_handle_exception_clauses (MonoCompile *cfg) MONO_INTERNAL;
/* Native Client functions */
+gpointer mono_realloc_native_code(MonoCompile *cfg);
#ifdef __native_client_codegen__
void mono_nacl_align_inst(guint8 **pcode, int instlen);
void mono_nacl_align_call(guint8 **start, guint8 **pcode);
guint8 *mono_arch_nacl_pad(guint8 *code, int pad);
guint8 *mono_arch_nacl_skip_nops(guint8 *code);
+extern const guint kNaClAlignment;
+extern const guint kNaClAlignmentMask;
+#endif
+
+#if defined(__native_client__) || defined(__native_client_codegen__)
+void mono_nacl_gc();
+#endif
+
+#if defined(__native_client_codegen__) || defined(__native_client__)
+#define NACL_SIZE(a, b) (b)
+#else
+#define NACL_SIZE(a, b) (a)
#endif
/* AOT */
gboolean mono_running_on_valgrind (void) MONO_INTERNAL;
void* mono_global_codeman_reserve (int size) MONO_INTERNAL;
+void* nacl_global_codeman_get_dest(void *data) MONO_INTERNAL;
+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;
gboolean
mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls,
MonoJitInfo *ji, MonoContext *ctx,
- MonoContext *new_ctx, MonoLMF **lmf,
+ MonoContext *new_ctx, MonoLMF **lmf,
+ mgreg_t **save_locations,
StackFrameInfo *frame_info) MONO_INTERNAL;
gpointer mono_arch_get_throw_exception_by_name (void) MONO_INTERNAL;
gpointer mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) MONO_INTERNAL;
mono_find_jit_info_ext (MonoDomain *domain, MonoJitTlsData *jit_tls,
MonoJitInfo *prev_ji, MonoContext *ctx,
MonoContext *new_ctx, char **trace, MonoLMF **lmf,
+ mgreg_t **save_locations,
StackFrameInfo *frame) MONO_INTERNAL;
gpointer mono_get_throw_exception (void) MONO_INTERNAL;