#include <mono/metadata/opcodes.h>
#include <mono/metadata/tabledefs.h>
#include <mono/metadata/profiler-private.h>
-#include "regalloc.h"
-/* fixme: configure should set this */
-#define SIZEOF_VOID_P 4
+#include "mini-arch.h"
+#include "regalloc.h"
#define MONO_USE_AOT_COMPILER
+/* Version number of the AOT file format */
+#define MONO_AOT_FILE_VERSION "6"
+
#if 1
#define mono_bitset_test_fast(set,n) (((guint32*)set)[2+(n)/32] & (1 << ((n) % 32)))
#else
typedef struct MonoBasicBlock MonoBasicBlock;
typedef struct MonoLMF MonoLMF;
typedef struct MonoSpillInfo MonoSpillInfo;
+typedef struct MonoTraceSpec MonoTraceSpec;
extern guint32 mono_jit_tls_id;
-extern gboolean mono_jit_trace_calls;
+extern MonoTraceSpec *mono_jit_trace_calls;
extern gboolean mono_break_on_exc;
extern int mono_exc_esp_offset;
extern gboolean mono_compile_aot;
union {
MonoInst *src;
MonoMethodVar *var;
- gint32 const_val;
+ gssize const_val;
gpointer p;
MonoMethod *method;
MonoMethodSignature *signature;
MonoInst *out_args;
gconstpointer fptr;
guint stack_usage;
- guint32 used_iregs;
- guint32 used_fregs;
+ regmask_t used_iregs;
+ regmask_t used_fregs;
};
/*
MONO_PATCH_INFO_LABEL,
MONO_PATCH_INFO_METHOD,
MONO_PATCH_INFO_METHOD_JUMP,
+ MONO_PATCH_INFO_METHOD_REL,
MONO_PATCH_INFO_METHODCONST,
MONO_PATCH_INFO_INTERNAL_METHOD,
MONO_PATCH_INFO_SWITCH,
MONO_PATCH_INFO_EXC,
+ MONO_PATCH_INFO_EXC_NAME,
MONO_PATCH_INFO_CLASS,
- MONO_PATCH_INFO_IMAGE,
- MONO_PATCH_INFO_FIELD,
- MONO_PATCH_INFO_R4,
+ MONO_PATCH_INFO_IMAGE,
+ MONO_PATCH_INFO_FIELD,
+ MONO_PATCH_INFO_VTABLE,
+ MONO_PATCH_INFO_CLASS_INIT,
+ MONO_PATCH_INFO_SFLDA,
+ MONO_PATCH_INFO_LDSTR,
+ MONO_PATCH_INFO_LDTOKEN,
+ MONO_PATCH_INFO_TYPE_FROM_HANDLE,
+ MONO_PATCH_INFO_R4,
MONO_PATCH_INFO_R8,
- MONO_PATCH_INFO_IP
+ MONO_PATCH_INFO_IP,
+ MONO_PATCH_INFO_IID,
+ MONO_PATCH_INFO_WRAPPER
} MonoJumpInfoType;
+/*
+ * We need to store the image which the token refers to along with the token,
+ * since the image might not be the same as the image of the method which
+ * contains the relocation, because of inlining.
+ */
+typedef struct MonoJumpInfoToken {
+ MonoImage *image;
+ guint32 token;
+} MonoJumpInfoToken;
+
typedef struct MonoJumpInfo MonoJumpInfo;
struct MonoJumpInfo {
MonoJumpInfo *next;
MonoClass *klass;
MonoClassField *field;
MonoImage *image;
+ MonoVTable *vtable;
const char *name;
+ MonoJumpInfoToken *token;
} data;
int table_size; /* use by switch */
};
-/* optimization flags: keep up to date with the name array in mini.c */
+/* optimization flags: keep up to date with the name array in driver.c */
enum {
MONO_OPT_PEEPHOLE = 1 << 0,
MONO_OPT_BRANCH = 1 << 1,
MONO_OPT_TAILC = 1 << 12,
MONO_OPT_LOOP = 1 << 13,
MONO_OPT_FCMOV = 1 << 14,
- MONO_OPT_LEAF = 1 << 15
+ MONO_OPT_LEAF = 1 << 15,
+ MONO_OPT_AOT = 1 << 16,
+ MONO_OPT_PRECOMP = 1 << 17
};
#define MONO_REGION_FINALLY 16
MonoBasicBlock *cbb; /* used by instruction selection */
MonoInst *prev_ins; /* in decompose */
MonoJumpInfo *patch_info;
+ MonoJitInfo *jit_info;
guint num_bblocks;
guint locals_start;
guint num_varinfo; /* used items in varinfo */
MonoInst *exvar; /* the exception object passed to catch/filter blocks */
MonoInst *domainvar; /* a cache for the current domain */
- MonoInst *spvar; /* a place to store the stack pointer (used by handlers) */
+ /* A hashtable of region ID-> SP var mappings */
+ /* An SP var is a place to store the stack pointer (used by handlers) */
+ GHashTable *spvars;
GList *ldstr_list; /* used by AOT */
guint code_len;
guint prolog_end;
guint epilog_begin;
- guint32 used_int_regs;
+ regmask_t used_int_regs;
guint32 opt;
guint32 prof_options;
guint32 flags;
gpointer debug_info;
guint16 *intvars;
MonoProfileCoverageInfo *coverage_info;
+#ifdef __ia64
+ guint8 ins, locals, outs; /* reg stack region sizes */
+#endif /* __ia64 */
} MonoCompile;
typedef enum {
void mini_cleanup (MonoDomain *domain);
/* helper methods */
+MonoJumpInfoToken * mono_jump_info_token_new (MonoMemPool *mp, MonoImage *image, guint32 token);
+MonoInst* mono_find_spvar_for_region (MonoCompile *cfg, int region);
+void mono_precompile_assemblies (void);
int mono_parse_default_optimizations (const char* p);
void mono_bblock_add_inst (MonoBasicBlock *bb, MonoInst *inst);
void mono_constant_fold (MonoCompile *cfg);
MonoInst* mono_compile_create_var (MonoCompile *cfg, MonoType *type, int opcode);
void mono_blockset_print (MonoCompile *cfg, MonoBitSet *set, const char *name, guint idom);
void mono_print_tree (MonoInst *tree);
+void mono_print_tree_nl (MonoInst *tree);
+void mono_print_code (MonoCompile *cfg);
int mono_spillvar_offset (MonoCompile *cfg, int spillvar);
void mono_select_instructions (MonoCompile *cfg);
const char* mono_inst_name (int op);
gpointer mono_get_lmf_addr (void);
GList *mono_varlist_insert_sorted (MonoCompile *cfg, GList *list, MonoMethodVar *mv, gboolean sort_end);
void mono_analyze_liveness (MonoCompile *cfg);
-void mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, guint32 *used_mask);
+void mono_linear_scan (MonoCompile *cfg, GList *vars, GList *regs, regmask_t *used_mask);
void mono_create_jump_table (MonoCompile *cfg, MonoInst *label, MonoBasicBlock **bbs, int num_blocks);
int mono_compile_assembly (MonoAssembly *ass, guint32 opts);
MonoCompile *mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, int parts);
void mono_destroy_compile (MonoCompile *cfg);
-gpointer mono_aot_get_method (MonoMethod *method);
+void mono_aot_init (void);
+MonoJitInfo* mono_aot_get_method (MonoDomain *domain,
+ MonoMethod *method);
gboolean mono_method_blittable (MonoMethod *method);
+gboolean mono_method_same_domain (MonoJitInfo *caller, MonoJitInfo *callee);
void mono_register_opcode_emulation (int opcode, const char* name, MonoMethodSignature *sig, gpointer func, gboolean no_throw);
void mono_arch_register_lowlevel_calls (void);
void mono_draw_graph (MonoCompile *cfg, MonoGraphOptions draw_options);
MonoJitICallInfo *mono_register_jit_icall (gconstpointer func, const char *name, MonoMethodSignature *sig, gboolean is_save);
gconstpointer mono_icall_get_wrapper (MonoJitICallInfo* callinfo);
+gpointer mono_create_class_init_trampoline (MonoVTable *vtable);
+MonoVTable* mono_find_class_init_trampoline_by_addr (gconstpointer addr);
+
/* methods that must be provided by the arch-specific port */
void mono_arch_cpu_init (void);
guint32 mono_arch_cpu_optimizazions (guint32 *exclude_mask);
gpointer mono_arch_get_throw_exception_by_name (void);
gpointer mono_arch_create_jit_trampoline (MonoMethod *method);
gpointer mono_arch_create_jump_trampoline (MonoMethod *method);
+gpointer mono_arch_create_class_init_trampoline(MonoVTable *vtable);
GList *mono_arch_get_allocatable_int_vars (MonoCompile *cfg);
GList *mono_arch_get_global_int_regs (MonoCompile *cfg);
void mono_arch_patch_code (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *ji);
void mono_debug_open_block (MonoCompile *cfg, MonoBasicBlock *bb, guint32 address);
void mono_debug_record_line_number (MonoCompile *cfg, MonoInst *ins, guint32 address);
+
+/* Tracing */
+MonoTraceSpec *mono_trace_parse_options (MonoAssembly *assembly, char *options);
+gboolean mono_trace_eval (MonoMethod *method);
+
#endif /* __MONO_MINI_H__ */