Merge pull request #1708 from alexanderkyte/always_use_imt
authorZoltan Varga <vargaz@gmail.com>
Mon, 13 Apr 2015 18:48:35 +0000 (14:48 -0400)
committerZoltan Varga <vargaz@gmail.com>
Mon, 13 Apr 2015 18:48:35 +0000 (14:48 -0400)
[runtime] Remove checks for mono_use_imt because always true.

mono/metadata/object.c
mono/mini/method-to-ir.c
mono/mini/mini-runtime.c
mono/mini/mini.h

index 76460f4d2c3f68f6801fafd3a15969fdde26a1b2..e380ed043c8c84eba896f22f6356cf941e35ba24 100644 (file)
@@ -530,8 +530,7 @@ default_delegate_trampoline (MonoDomain *domain, MonoClass *klass)
 static MonoTrampoline arch_create_jit_trampoline = default_trampoline;
 static MonoJumpTrampoline arch_create_jump_trampoline = default_jump_trampoline;
 static MonoDelegateTrampoline arch_create_delegate_trampoline = default_delegate_trampoline;
-static MonoImtThunkBuilder imt_thunk_builder = NULL;
-#define ARCH_USE_IMT (imt_thunk_builder != NULL)
+static MonoImtThunkBuilder imt_thunk_builder;
 #if (MONO_IMT_SIZE > 32)
 #error "MONO_IMT_SIZE cannot be larger than 32"
 #endif
@@ -1965,16 +1964,12 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
        if (class_size)
                vtable_slots++;
 
-       if (ARCH_USE_IMT) {
-               if (class->interface_offsets_count) {
-                       imt_table_bytes = sizeof (gpointer) * (MONO_IMT_SIZE);
-                       mono_stats.imt_number_of_tables++;
-                       mono_stats.imt_tables_size += imt_table_bytes;
-               } else {
-                       imt_table_bytes = 0;
-               }
+       if (class->interface_offsets_count) {
+               imt_table_bytes = sizeof (gpointer) * (MONO_IMT_SIZE);
+               mono_stats.imt_number_of_tables++;
+               mono_stats.imt_tables_size += imt_table_bytes;
        } else {
-               imt_table_bytes = sizeof (gpointer) * (class->max_interface_id + 1);
+               imt_table_bytes = 0;
        }
 
        vtable_size = imt_table_bytes + MONO_SIZEOF_VTABLE + vtable_slots * sizeof (gpointer);
@@ -2107,13 +2102,11 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
        //printf ("Initializing VT for class %s (interface_offsets_count = %d)\n",
        //              class->name, class->interface_offsets_count);
        
-       if (! ARCH_USE_IMT) {
-               /* initialize interface offsets */
-               for (i = 0; i < class->interface_offsets_count; ++i) {
-                       int interface_id = class->interfaces_packed [i]->interface_id;
-                       int slot = class->interface_offsets_packed [i];
-                       interface_offsets [class->max_interface_id - interface_id] = &(vt->vtable [slot]);
-               }
+       /* initialize interface offsets */
+       for (i = 0; i < class->interface_offsets_count; ++i) {
+               int interface_id = class->interfaces_packed [i]->interface_id;
+               int slot = class->interface_offsets_packed [i];
+               interface_offsets [class->max_interface_id - interface_id] = &(vt->vtable [slot]);
        }
 
        /* Initialize vtable */
@@ -2133,7 +2126,7 @@ mono_class_create_runtime_vtable (MonoDomain *domain, MonoClass *class, gboolean
                }
        }
 
-       if (ARCH_USE_IMT && imt_table_bytes) {
+       if (imt_table_bytes) {
                /* Now that the vtable is full, we can actually fill up the IMT */
                if (callbacks.get_imt_trampoline) {
                        /* lazy construction of the IMT entries enabled */
@@ -2297,13 +2290,9 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                if (iclass->max_interface_id > max_interface_id) max_interface_id = iclass->max_interface_id;
        }
 
-       if (ARCH_USE_IMT) {
-               imt_table_bytes = sizeof (gpointer) * MONO_IMT_SIZE;
-               mono_stats.imt_number_of_tables++;
-               mono_stats.imt_tables_size += imt_table_bytes;
-       } else {
-               imt_table_bytes = sizeof (gpointer) * (max_interface_id + 1);
-       }
+       imt_table_bytes = sizeof (gpointer) * MONO_IMT_SIZE;
+       mono_stats.imt_number_of_tables++;
+       mono_stats.imt_tables_size += imt_table_bytes;
 
        vtsize = imt_table_bytes + MONO_SIZEOF_VTABLE + class->vtable_size * sizeof (gpointer);
 
@@ -2349,14 +2338,6 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
        bitmap = mono_domain_alloc0 (domain, bsize);
 #endif
 
-       if (! ARCH_USE_IMT) {
-               /* initialize interface offsets */
-               for (i = 0; i < class->interface_offsets_count; ++i) {
-                       int interface_id = class->interfaces_packed [i]->interface_id;
-                       int slot = class->interface_offsets_packed [i];
-                       interface_offsets [class->max_interface_id - interface_id] = &(pvt->vtable [slot]);
-               }
-       }
        for (i = 0; i < class->interface_offsets_count; ++i) {
                int interface_id = class->interfaces_packed [i]->interface_id;
                bitmap [interface_id >> 3] |= (1 << (interface_id & 7));
@@ -2373,9 +2354,6 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                for (list_item = extra_interfaces; list_item != NULL; list_item=list_item->next) {
                        interf = list_item->data;
                        
-                       if (! ARCH_USE_IMT) {
-                               interface_offsets [max_interface_id - interf->interface_id] = &pvt->vtable [slot];
-                       }
                        bitmap [interf->interface_id >> 3] |= (1 << (interf->interface_id & 7));
 
                        iter = NULL;
@@ -2385,17 +2363,12 @@ mono_class_proxy_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, Mono
                        
                        slot += mono_class_num_methods (interf);
                }
-               if (! ARCH_USE_IMT) {
-                       g_slist_free (extra_interfaces);
-               }
        }
 
-       if (ARCH_USE_IMT) {
-               /* Now that the vtable is full, we can actually fill up the IMT */
-               build_imt (class, pvt, domain, interface_offsets, extra_interfaces);
-               if (extra_interfaces) {
-                       g_slist_free (extra_interfaces);
-               }
+       /* Now that the vtable is full, we can actually fill up the IMT */
+       build_imt (class, pvt, domain, interface_offsets, extra_interfaces);
+       if (extra_interfaces) {
+               g_slist_free (extra_interfaces);
        }
 
 #ifdef COMPRESSED_INTERFACE_BITMAP
index 0f5e45ad93fa98b40fea13a538e791e65f619430..6bce61df376328e46939bc6bc8bbfbb46f274848 100755 (executable)
@@ -2898,18 +2898,10 @@ mono_emit_method_call_full (MonoCompile *cfg, MonoMethod *method, MonoMethodSign
                        vtable_reg = alloc_preg (cfg);
                        MONO_EMIT_NEW_LOAD_MEMBASE_FAULT (cfg, vtable_reg, this_reg, MONO_STRUCT_OFFSET (MonoObject, vtable));
                        if (method->klass->flags & TYPE_ATTRIBUTE_INTERFACE) {
-                               slot_reg = -1;
-                               if (mono_use_imt) {
-                                       guint32 imt_slot = mono_method_get_imt_slot (method);
-                                       emit_imt_argument (cfg, call, call->method, imt_arg);
-                                       slot_reg = vtable_reg;
-                                       offset = ((gint32)imt_slot - MONO_IMT_SIZE) * SIZEOF_VOID_P;
-                               }
-                               if (slot_reg == -1) {
-                                       slot_reg = alloc_preg (cfg);
-                                       mini_emit_load_intf_reg_vtable (cfg, slot_reg, vtable_reg, method->klass);
-                                       offset = mono_method_get_vtable_index (method) * SIZEOF_VOID_P;
-                               }
+                               guint32 imt_slot = mono_method_get_imt_slot (method);
+                               emit_imt_argument (cfg, call, call->method, imt_arg);
+                               slot_reg = vtable_reg;
+                               offset = ((gint32)imt_slot - MONO_IMT_SIZE) * SIZEOF_VOID_P;
                        } else {
                                slot_reg = vtable_reg;
                                offset = MONO_STRUCT_OFFSET (MonoVTable, vtable) +
@@ -9260,7 +9252,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                        GSHAREDVT_FAILURE (*ip);
 
 #if MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK && defined(MONO_ARCH_GSHARED_SUPPORTED)
-                               if (cmethod->wrapper_type == MONO_WRAPPER_NONE && mono_use_imt)
+                               if (cmethod->wrapper_type == MONO_WRAPPER_NONE)
                                        use_imt = TRUE;
 #endif
 
@@ -9413,7 +9405,6 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                                GSHAREDVT_FAILURE (*ip);
                                        if (fsig->generic_param_count) {
                                                /* virtual generic call */
-                                               g_assert (mono_use_imt);
                                                g_assert (!imt_arg);
                                                /* Same as the virtual generic case above */
                                                imt_arg = emit_get_rgctx_method (cfg, context_used,
index 9b48dcde6bb6c50e23730cab721724624dcc5feb..c0943117994ef469b57b90cd38a9dc3ce5f561a9 100755 (executable)
@@ -86,8 +86,7 @@ MONO_FAST_TLS_DECLARE(mono_jit_tls);
 gboolean mono_compile_aot = FALSE;
 /* If this is set, no code is generated dynamically, everything is taken from AOT files */
 gboolean mono_aot_only = FALSE;
-/* Whenever to use IMT */
-gboolean mono_use_imt = TRUE;
+
 const char *mono_build_date;
 gboolean mono_do_signal_chaining;
 gboolean mono_do_crash_chaining;
@@ -2984,10 +2983,8 @@ mini_init (const char *filename, const char *runtime_version)
        callbacks.debug_log_is_enabled = mono_debugger_agent_debug_log_is_enabled;
        callbacks.tls_key_supported = mini_tls_key_supported;
 
-       if (mono_use_imt) {
-               callbacks.get_vtable_trampoline = mini_get_vtable_trampoline;
-               callbacks.get_imt_trampoline = mini_get_imt_trampoline;
-       }
+       callbacks.get_vtable_trampoline = mini_get_vtable_trampoline;
+       callbacks.get_imt_trampoline = mini_get_imt_trampoline;
 
        mono_install_callbacks (&callbacks);
 
@@ -3096,12 +3093,10 @@ mini_init (const char *filename, const char *runtime_version)
                mono_marshal_use_aot_wrappers (TRUE);
        }
 
-       if (mono_use_imt) {
-               if (mono_aot_only)
-                       mono_install_imt_thunk_builder (mono_aot_get_imt_thunk);
-               else
-                       mono_install_imt_thunk_builder (mono_arch_build_imt_thunk);
-       }
+       if (mono_aot_only)
+               mono_install_imt_thunk_builder (mono_aot_get_imt_thunk);
+       else
+               mono_install_imt_thunk_builder (mono_arch_build_imt_thunk);
 
        /*Init arch tls information only after the metadata side is inited to make sure we see dynamic appdomain tls keys*/
        mono_arch_finish_init ();
index feb08be3afd203fdb570c613060deb9de04c93c8..d195176c84c86680e4a84e931f90d07362b83d56 100644 (file)
@@ -482,7 +482,6 @@ extern gboolean mono_break_on_exc;
 extern int mono_exc_esp_offset;
 extern gboolean mono_compile_aot;
 extern gboolean mono_aot_only;
-extern gboolean mono_use_imt;
 extern MonoMethodDesc *mono_inject_async_exc_method;
 extern int mono_inject_async_exc_pos;
 extern MonoMethodDesc *mono_break_at_bb_method;