2009-03-31 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Mon, 30 Mar 2009 22:31:16 +0000 (22:31 -0000)
committerZoltan Varga <vargaz@gmail.com>
Mon, 30 Mar 2009 22:31:16 +0000 (22:31 -0000)
* aot-compiler.c (mono_compile_assembly): Call img_writer_emit_start ()
right before emitting code, not at the start.

* mini.c (mono_postprocess_patches): Extract this into a separate function
from mono_codegen ().

* ssa.c (mono_ssa_compute): Set ins->klass for every PHI node, handle
byref types correctly.

svn path=/trunk/mono/; revision=130585

mono/mini/ChangeLog
mono/mini/aot-compiler.c
mono/mini/mini.c
mono/mini/ssa.c

index e59961f697ffd7f6371a204a704e8c6f8d7c10c0..24803fe6c56508b75a8415854b326503b6b0ea53 100644 (file)
@@ -1,3 +1,14 @@
+2009-03-31  Zoltan Varga  <vargaz@gmail.com>
+
+       * aot-compiler.c (mono_compile_assembly): Call img_writer_emit_start ()
+       right before emitting code, not at the start.
+
+       * mini.c (mono_postprocess_patches): Extract this into a separate function
+       from mono_codegen ().
+
+       * ssa.c (mono_ssa_compute): Set ins->klass for every PHI node, handle
+       byref types correctly.
+
 2009-03-30  Zoltan Varga  <vargaz@gmail.com>
 
        * dwarfwriter.c (mono_dwarf_writer_emit_method): Fix a crash introduced
index c5328b9fbd09595f9595c846cad0985d7f2370b4..22894a76678dd65152e9d8b2cbbddbfffa95bca9 100644 (file)
@@ -4105,8 +4105,6 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        load_profile_files (acfg);
 
-       img_writer_emit_start (acfg->w);
-
        acfg->dwarf = mono_dwarf_writer_create (acfg->w, NULL);
 
        acfg->num_aot_trampolines = acfg->aot_opts.full_aot ? 10240 : 0;
@@ -4215,10 +4213,12 @@ mono_compile_assembly (MonoAssembly *ass, guint32 opts, const char *aot_options)
 
        TV_GETTIME (atv);
 
-       mono_dwarf_writer_emit_base_info (acfg->dwarf, arch_get_cie_program ());
-
        alloc_got_slots (acfg);
 
+       img_writer_emit_start (acfg->w);
+
+       mono_dwarf_writer_emit_base_info (acfg->dwarf, arch_get_cie_program ());
+
        emit_code (acfg);
 
        emit_info (acfg);
index 595e64d753feef9826e2391f18bc745ddd9bb60b..6847fdffac2488faa22f8ba098fa884376670354 100644 (file)
@@ -2800,12 +2800,105 @@ mono_print_code (MonoCompile *cfg, const char* msg)
 
 #ifndef DISABLE_JIT
 
+static void
+mono_postprocess_patches (MonoCompile *cfg)
+{
+       MonoJumpInfo *patch_info;
+       int i;
+
+       for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
+               switch (patch_info->type) {
+               case MONO_PATCH_INFO_ABS: {
+                       MonoJitICallInfo *info = mono_find_jit_icall_by_addr (patch_info->data.target);
+
+                       /*
+                        * Change patches of type MONO_PATCH_INFO_ABS into patches describing the 
+                        * absolute address.
+                        */
+                       if (info) {
+                               //printf ("TEST %s %p\n", info->name, patch_info->data.target);
+                               // FIXME: CLEAN UP THIS MESS.
+                               if ((cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) && 
+                                       strstr (cfg->method->name, info->name)) {
+                                       /*
+                                        * This is an icall wrapper, and this is a call to the
+                                        * wrapped function.
+                                        */
+                                       if (cfg->compile_aot) {
+                                               patch_info->type = MONO_PATCH_INFO_JIT_ICALL_ADDR;
+                                               patch_info->data.name = info->name;
+                                       }
+                               } else {
+                                       /* for these array methods we currently register the same function pointer
+                                        * since it's a vararg function. But this means that mono_find_jit_icall_by_addr ()
+                                        * will return the incorrect one depending on the order they are registered.
+                                        * See tests/test-arr.cs
+                                        */
+                                       if (strstr (info->name, "ves_array_new_va_") == NULL && strstr (info->name, "ves_array_element_address_") == NULL) {
+                                               patch_info->type = MONO_PATCH_INFO_INTERNAL_METHOD;
+                                               patch_info->data.name = info->name;
+                                       }
+                               }
+                       }
+
+                       if (patch_info->type == MONO_PATCH_INFO_ABS) {
+                               if (cfg->abs_patches) {
+                                       MonoJumpInfo *abs_ji = g_hash_table_lookup (cfg->abs_patches, patch_info->data.target);
+                                       if (abs_ji) {
+                                               patch_info->type = abs_ji->type;
+                                               patch_info->data.target = abs_ji->data.target;
+                                       }
+                               }
+                       }
+
+                       break;
+               }
+               case MONO_PATCH_INFO_SWITCH: {
+                       gpointer *table;
+                       if (cfg->method->dynamic) {
+                               table = mono_code_manager_reserve (cfg->dynamic_info->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
+                       } else {
+                               table = mono_domain_code_reserve (cfg->domain, sizeof (gpointer) * patch_info->data.table->table_size);
+                       }
+
+                       for (i = 0; i < patch_info->data.table->table_size; i++) {
+                               /* Might be NULL if the switch is eliminated */
+                               if (patch_info->data.table->table [i]) {
+                                       g_assert (patch_info->data.table->table [i]->native_offset);
+                                       table [i] = GINT_TO_POINTER (patch_info->data.table->table [i]->native_offset);
+                               } else {
+                                       table [i] = NULL;
+                               }
+                       }
+                       patch_info->data.table->table = (MonoBasicBlock**)table;
+                       break;
+               }
+               case MONO_PATCH_INFO_METHOD_JUMP: {
+                       GSList *list;
+                       MonoDomain *domain = cfg->domain;
+                       unsigned char *ip = cfg->native_code + patch_info->ip.i;
+
+                       mono_domain_lock (domain);
+                       if (!domain_jit_info (domain)->jump_target_hash)
+                               domain_jit_info (domain)->jump_target_hash = g_hash_table_new (NULL, NULL);
+                       list = g_hash_table_lookup (domain_jit_info (domain)->jump_target_hash, patch_info->data.method);
+                       list = g_slist_prepend (list, ip);
+                       g_hash_table_insert (domain_jit_info (domain)->jump_target_hash, patch_info->data.method, list);
+                       mono_domain_unlock (domain);
+                       break;
+               }
+               default:
+                       /* do nothing */
+                       break;
+               }
+       }
+}
+
 void
 mono_codegen (MonoCompile *cfg)
 {
-       MonoJumpInfo *patch_info;
        MonoBasicBlock *bb;
-       int i, max_epilog_size;
+       int max_epilog_size;
        guint8 *code;
 
        for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
@@ -2895,92 +2988,7 @@ mono_codegen (MonoCompile *cfg)
        code = cfg->native_code + cfg->code_len;
   
        /* g_assert (((int)cfg->native_code & (MONO_ARCH_CODE_ALIGNMENT - 1)) == 0); */
-       for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) {
-               switch (patch_info->type) {
-               case MONO_PATCH_INFO_ABS: {
-                       MonoJitICallInfo *info = mono_find_jit_icall_by_addr (patch_info->data.target);
-
-                       /*
-                        * Change patches of type MONO_PATCH_INFO_ABS into patches describing the 
-                        * absolute address.
-                        */
-                       if (info) {
-                               //printf ("TEST %s %p\n", info->name, patch_info->data.target);
-                               // FIXME: CLEAN UP THIS MESS.
-                               if ((cfg->method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE) && 
-                                       strstr (cfg->method->name, info->name)) {
-                                       /*
-                                        * This is an icall wrapper, and this is a call to the
-                                        * wrapped function.
-                                        */
-                                       if (cfg->compile_aot) {
-                                               patch_info->type = MONO_PATCH_INFO_JIT_ICALL_ADDR;
-                                               patch_info->data.name = info->name;
-                                       }
-                               } else {
-                                       /* for these array methods we currently register the same function pointer
-                                        * since it's a vararg function. But this means that mono_find_jit_icall_by_addr ()
-                                        * will return the incorrect one depending on the order they are registered.
-                                        * See tests/test-arr.cs
-                                        */
-                                       if (strstr (info->name, "ves_array_new_va_") == NULL && strstr (info->name, "ves_array_element_address_") == NULL) {
-                                               patch_info->type = MONO_PATCH_INFO_INTERNAL_METHOD;
-                                               patch_info->data.name = info->name;
-                                       }
-                               }
-                       }
-
-                       if (patch_info->type == MONO_PATCH_INFO_ABS) {
-                               if (cfg->abs_patches) {
-                                       MonoJumpInfo *abs_ji = g_hash_table_lookup (cfg->abs_patches, patch_info->data.target);
-                                       if (abs_ji) {
-                                               patch_info->type = abs_ji->type;
-                                               patch_info->data.target = abs_ji->data.target;
-                                       }
-                               }
-                       }
-
-                       break;
-               }
-               case MONO_PATCH_INFO_SWITCH: {
-                       gpointer *table;
-                       if (cfg->method->dynamic) {
-                               table = mono_code_manager_reserve (cfg->dynamic_info->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
-                       } else {
-                               table = mono_domain_code_reserve (cfg->domain, sizeof (gpointer) * patch_info->data.table->table_size);
-                       }
-
-                       for (i = 0; i < patch_info->data.table->table_size; i++) {
-                               /* Might be NULL if the switch is eliminated */
-                               if (patch_info->data.table->table [i]) {
-                                       g_assert (patch_info->data.table->table [i]->native_offset);
-                                       table [i] = GINT_TO_POINTER (patch_info->data.table->table [i]->native_offset);
-                               } else {
-                                       table [i] = NULL;
-                               }
-                       }
-                       patch_info->data.table->table = (MonoBasicBlock**)table;
-                       break;
-               }
-               case MONO_PATCH_INFO_METHOD_JUMP: {
-                       GSList *list;
-                       MonoDomain *domain = cfg->domain;
-                       unsigned char *ip = cfg->native_code + patch_info->ip.i;
-
-                       mono_domain_lock (domain);
-                       if (!domain_jit_info (domain)->jump_target_hash)
-                               domain_jit_info (domain)->jump_target_hash = g_hash_table_new (NULL, NULL);
-                       list = g_hash_table_lookup (domain_jit_info (domain)->jump_target_hash, patch_info->data.method);
-                       list = g_slist_prepend (list, ip);
-                       g_hash_table_insert (domain_jit_info (domain)->jump_target_hash, patch_info->data.method, list);
-                       mono_domain_unlock (domain);
-                       break;
-               }
-               default:
-                       /* do nothing */
-                       break;
-               }
-       }
+       mono_postprocess_patches (cfg);
 
 #ifdef VALGRIND_JIT_REGISTER_MAP
 if (valgrind_register){
index 25bc360bcab93864c78dd834aa573ff5e3f35068..00cf17ab25dfc8d9dff5bf1f2368eb3361c6421c 100644 (file)
@@ -430,10 +430,14 @@ mono_ssa_compute (MonoCompile *cfg)
                                break;
                        case STACK_VTYPE:
                                ins->opcode = MONO_CLASS_IS_SIMD (cfg, var->klass) ? OP_XPHI : OP_VPHI;
-                               ins->klass = var->klass;
                                break;
                        }
 
+                       if (var->inst_vtype->byref)
+                               ins->klass = mono_defaults.int_class;
+                       else
+                               ins->klass = var->klass;
+
                        ins->inst_phi_args =  mono_mempool_alloc0 (cfg->mempool, sizeof (int) * (cfg->bblocks [idx]->in_count + 1));
                        ins->inst_phi_args [0] = cfg->bblocks [idx]->in_count;