2006-06-04 Zoltan Varga <vargaz@gmail.com>
[mono.git] / mono / mini / mini.h
index 0414004938b87482c2dc2aa57b980c746069f4f2..81d75262b92c817fd572ce94c3488cace20b75dc 100644 (file)
@@ -50,7 +50,7 @@
 #endif
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION "25"
+#define MONO_AOT_FILE_VERSION "27"
 
 #if 0
 #define mono_bitset_foreach_bit(set,b,n) \
@@ -133,7 +133,9 @@ struct MonoEdge {
 };
 
 struct MonoSpillInfo {
+#ifndef MONO_ARCH_HAS_XP_REGALLOC
        MonoSpillInfo *next;
+#endif
        int offset;
 };
 
@@ -167,6 +169,7 @@ struct MonoBasicBlock {
        gint32 dfn;
 
        /* Basic blocks: incoming and outgoing counts and pointers */
+       /* Each bb should only appear once in each array */
        gint16 out_count, in_count;
        MonoBasicBlock **in_bb;
        MonoBasicBlock **out_bb;
@@ -205,9 +208,9 @@ struct MonoBasicBlock {
         * Whenever the bblock is rarely executed so it should be emitted after
         * the function epilog.
         */
-       gboolean out_of_line : 1;
+       guint out_of_line : 1;
        /* Caches the result of uselessness calculation during optimize_branches */
-       gboolean not_useless : 1;
+       guint not_useless : 1;
 
        /* use for liveness analysis */
        MonoBitSet *gen_set;
@@ -294,7 +297,7 @@ struct MonoCallInst {
        gboolean virtual;
        regmask_t used_iregs;
        regmask_t used_fregs;
-#if defined(MONO_ARCH_HAS_XP_LOCAL_REGALLOC) || defined(__x86_64__)
+#if defined(MONO_ARCH_HAS_XP_LOCAL_REGALLOC)
        GSList *out_ireg_args;
        GSList *out_freg_args;
 #endif
@@ -436,6 +439,7 @@ typedef enum {
        MONO_PATCH_INFO_R8,
        MONO_PATCH_INFO_IP,
        MONO_PATCH_INFO_IID,
+       MONO_PATCH_INFO_ADJUSTED_IID,
        MONO_PATCH_INFO_BB_OVF,
        MONO_PATCH_INFO_EXC_OVF,
        MONO_PATCH_INFO_WRAPPER,
@@ -494,6 +498,7 @@ typedef enum {
        MONO_TRAMPOLINE_JUMP,
        MONO_TRAMPOLINE_CLASS_INIT,
        MONO_TRAMPOLINE_AOT,
+       MONO_TRAMPOLINE_AOT_PLT,
        MONO_TRAMPOLINE_DELEGATE,
        MONO_TRAMPOLINE_NUM
 } MonoTrampolineType;
@@ -521,7 +526,8 @@ enum {
        MONO_OPT_ABCREM   = 1 << 18,
        MONO_OPT_SSAPRE   = 1 << 19,
        MONO_OPT_EXCEPTION= 1 << 20,
-       MONO_OPT_SSA      = 1 << 21
+       MONO_OPT_SSA      = 1 << 21,
+       MONO_OPT_TREEPROP = 1 << 22
 };
 
 /* Bit-fields in the MonoBasicBlock.region */
@@ -563,6 +569,7 @@ typedef struct {
        MonoSpillInfo   *spill_info; /* machine register spills */
        MonoSpillInfo   *spill_info_float; /* fp register spills */
        gint             spill_count;
+       gint             spill_info_len, spill_info_float_len;
        /* unsigned char   *cil_code; */
        MonoMethod      *inlined_method; /* the method which is currently inlined */
        MonoInst        *domainvar; /* a cache for the current domain */
@@ -597,13 +604,13 @@ typedef struct {
        guint32          param_area;
        guint32          frame_reg;
        gint32           sig_cookie;
-       gboolean         disable_aot;
-       gboolean         disable_ssa;
-       gboolean         run_cctors;
-       gboolean         need_lmf_area;
-       gboolean         compile_aot;
-       gboolean         got_var_allocated;
-       gboolean         ret_var_is_local;
+       guint            disable_aot : 1;
+       guint            disable_ssa : 1;
+       guint            run_cctors : 1;
+       guint            need_lmf_area : 1;
+       guint            compile_aot : 1;
+       guint            got_var_allocated : 1;
+       guint            ret_var_is_local : 1;
        gpointer         debug_info;
        guint32          lmf_offset;
        guint16          *intvars;
@@ -612,9 +619,13 @@ typedef struct {
        guint32          exception_type;        /* MONO_EXCEPTION_* */
        guint32          exception_data;
        char*            exception_message;
-#ifdef __ia64
-       guint8           ins, locals, outs; /* reg stack region sizes */
-#endif /* __ia64 */
+
+       /* Fields used by the local reg allocator */
+       void*            reginfo;
+       void*            reginfof;
+       void*            reverse_inst_list;
+       int              reginfo_len, reginfof_len;
+       int              reverse_inst_list_len;
 } MonoCompile;
 
 typedef enum {
@@ -814,7 +825,6 @@ void      mono_compile_make_var_load        (MonoCompile *cfg, MonoInst *dest, g
 MonoInst* mono_compile_create_var_load      (MonoCompile *cfg, gssize var_index);
 MonoInst* mono_compile_create_var_store     (MonoCompile *cfg, gssize var_index, MonoInst *value);
 MonoType* mono_type_from_stack_type         (MonoInst *ins);
-void      mono_unlink_bblock                (MonoCompile *cfg, MonoBasicBlock *from, MonoBasicBlock* to);
 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);
@@ -825,8 +835,6 @@ void      mono_select_instructions          (MonoCompile *cfg);
 const char* mono_inst_name                  (int op);
 void      mono_inst_foreach                 (MonoInst *tree, MonoInstFunc func, gpointer data);
 void      mono_disassemble_code             (MonoCompile *cfg, guint8 *code, int size, char *id);
-guint     mono_type_to_ldind                (MonoType *t);
-guint     mono_type_to_stind                (MonoType *t);
 void      mono_add_patch_info               (MonoCompile *cfg, int ip, MonoJumpInfoType type, gconstpointer target);
 void      mono_remove_patch_info            (MonoCompile *cfg, int ip);
 gpointer  mono_resolve_patch_target         (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors);
@@ -842,12 +850,15 @@ void      mono_create_jump_table            (MonoCompile *cfg, MonoInst *label,
 int       mono_compile_assembly             (MonoAssembly *ass, guint32 opts, const char *aot_options);
 MonoCompile *mini_method_compile            (MonoMethod *method, guint32 opts, MonoDomain *domain, gboolean run_cctors, gboolean compile_aot, int parts);
 void      mono_destroy_compile              (MonoCompile *cfg);
+MonoJitICallInfo *mono_find_jit_opcode_emulation (int opcode);
+
 
 void      mono_aot_init                     (void);
 MonoJitInfo*  mono_aot_get_method           (MonoDomain *domain,
                                                                                         MonoMethod *method);
 gpointer  mono_aot_get_method_from_token    (MonoDomain *domain, MonoImage *image, guint32 token);
 gboolean  mono_aot_is_got_entry             (guint8 *code, guint8 *addr);
+guint8*   mono_aot_get_plt_entry            (guint8 *code);
 gboolean  mono_aot_init_vtable              (MonoVTable *vtable);
 gboolean  mono_aot_get_cached_class_info    (MonoClass *klass, MonoCachedClassInfo *res);
 MonoJitInfo* mono_aot_find_jit_info         (MonoDomain *domain, MonoImage *image, gpointer addr);
@@ -855,6 +866,7 @@ void mono_aot_set_make_unreadable           (gboolean unreadable);
 gboolean mono_aot_is_pagefault              (void *ptr);
 void mono_aot_handle_pagefault              (void *ptr);
 guint32 mono_aot_get_n_pagefaults           (void);
+gpointer mono_aot_plt_resolve               (gpointer aot_module, guint32 plt_info_offset, guint8 *code);
 
 gboolean  mono_method_blittable             (MonoMethod *method);
 gboolean  mono_method_same_domain           (MonoJitInfo *caller, MonoJitInfo *callee);
@@ -883,6 +895,8 @@ gpointer          mono_magic_trampoline (gssize *regs, guint8 *code, MonoMethod
 gpointer          mono_delegate_trampoline (gssize *regs, guint8 *code, MonoMethod *m, guint8* tramp);
 gpointer          mono_aot_trampoline (gssize *regs, guint8 *code, guint8 *token_info, 
                                                                           guint8* tramp);
+gpointer          mono_aot_plt_trampoline (gssize *regs, guint8 *code, guint8 *token_info, 
+                                                                                  guint8* tramp);
 void              mono_class_init_trampoline (gssize *regs, guint8 *code, MonoVTable *vtable, guint8 *tramp);
 
 gboolean          mono_running_on_valgrind (void);
@@ -900,9 +914,9 @@ void      mono_arch_instrument_mem_needs        (MonoMethod *method, int *stack,
 void     *mono_arch_instrument_prolog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
 void     *mono_arch_instrument_epilog           (MonoCompile *cfg, void *func, void *p, gboolean enable_arguments);
 MonoCallInst *mono_arch_call_opcode             (MonoCompile *cfg, MonoBasicBlock* bb, MonoCallInst *call, int is_virtual);
-MonoInst *mono_arch_get_inst_for_method       (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args);
+MonoInst *mono_arch_get_inst_for_method         (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsig, MonoInst **args);
 void      mono_codegen                          (MonoCompile *cfg);
-void      mono_call_inst_add_outarg_reg         (MonoCallInst *call, int vreg, int hreg, gboolean fp);
+void      mono_call_inst_add_outarg_reg         (MonoCompile *cfg, MonoCallInst *call, int vreg, int hreg, gboolean fp);
 const char *mono_arch_regname                   (int reg);
 const char *mono_arch_fregname                  (int reg);
 gpointer  mono_arch_get_throw_exception         (void);
@@ -913,7 +927,6 @@ guchar*   mono_arch_create_trampoline_code      (MonoTrampolineType tramp_type);
 gpointer  mono_arch_create_jit_trampoline       (MonoMethod *method);
 MonoJitInfo *mono_arch_create_jump_trampoline      (MonoMethod *method);
 gpointer  mono_arch_create_class_init_trampoline(MonoVTable *vtable);
-gpointer  mono_create_delegate_trampoline       (MonoMethod *method, gpointer addr);
 GList    *mono_arch_get_allocatable_int_vars    (MonoCompile *cfg);
 GList    *mono_arch_get_global_int_regs         (MonoCompile *cfg);
 guint32   mono_arch_regalloc_cost               (MonoCompile *cfg, MonoMethodVar *vmv);
@@ -962,14 +975,16 @@ 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);
 void     mono_arch_patch_callsite               (guint8 *code, guint8 *addr);
+void     mono_arch_patch_plt_entry              (guint8 *code, guint8 *addr);
 void     mono_arch_nullify_class_init_trampoline(guint8 *code, gssize *regs);
+void     mono_arch_nullify_plt_entry            (guint8 *code);
 void     mono_arch_patch_delegate_trampoline    (guint8 *code, guint8 *tramp, gssize *regs, guint8 *addr);
 gpointer mono_arch_create_specific_trampoline   (gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len);
 
 /* Exception handling */
 gboolean mono_handle_exception                  (MonoContext *ctx, gpointer obj,
                                                 gpointer original_ip, gboolean test_only);
-void     mono_handle_native_sigsegv             (void *sigctx);
+void     mono_handle_native_sigsegv             (int signal, void *sigctx);
 void     mono_print_thread_dump                 (void *sigctx);
 void     mono_jit_walk_stack                    (MonoStackWalk func, gboolean do_il_offset, gpointer user_data);
 void     mono_jit_walk_stack_from_ctx           (MonoStackWalk func, MonoContext *ctx, gboolean do_il_offset, gpointer user_data);
@@ -1026,6 +1041,8 @@ extern void
 mono_perform_abc_removal (MonoCompile *cfg);
 extern void
 mono_perform_ssapre (MonoCompile *cfg);
+extern void
+mono_local_cprop (MonoCompile *cfg);
 
 /* CAS - stack walk */
 MonoSecurityFrame* ves_icall_System_Security_SecurityFrame_GetSecurityFrame (gint32 skip);