[runtime] Remove ves_icall_object_new_fast (), its only a bit faster than object_new_...
authorZoltan Varga <vargaz@gmail.com>
Tue, 8 Aug 2017 23:56:21 +0000 (19:56 -0400)
committerGitHub <noreply@github.com>
Tue, 8 Aug 2017 23:56:21 +0000 (19:56 -0400)
mono/metadata/boehm-gc.c
mono/metadata/mono-mlist.c
mono/metadata/object-internals.h
mono/metadata/object.c
mono/mini/method-to-ir.c
mono/mini/mini.h

index bd853b21eb9b45cce831504f95aeda945a74333f..e642be65561d391bdbf0bccef417f6394b531c56 100644 (file)
@@ -1171,11 +1171,8 @@ mono_gc_is_critical_method (MonoMethod *method)
  * @klass. The method will typically have an thread-local inline allocation sequence.
  * The signature of the called method is:
  *     object allocate (MonoVTable *vtable)
- * Some of the logic here is similar to mono_class_get_allocation_ftn () i object.c,
- * keep in sync.
  * The thread local alloc logic is taken from libgc/pthread_support.c.
  */
-
 MonoMethod*
 mono_gc_get_managed_allocator (MonoClass *klass, gboolean for_box, gboolean known_instance_size)
 {
index 27ed22e4307ce8a89ea793449f38ed45ecbd6e2d..cf67e7fd15b8685f6bd1f05634215eeb419168a2 100644 (file)
@@ -71,7 +71,7 @@ mono_mlist_alloc_checked (MonoObject *data, MonoError *error)
                monolist_item_vtable = mono_class_vtable (mono_get_root_domain (), klass);
                g_assert (monolist_item_vtable);
        }
-       res = (MonoMList*)mono_object_new_fast_checked (monolist_item_vtable, error);
+       res = (MonoMList*)mono_object_new_specific_checked (monolist_item_vtable, error);
        return_val_if_nok (error, NULL);
        MONO_OBJECT_SETREF (res, data, data);
        return res;
index 391e1cd994b314899300b48c87e4c525d8bf0cec..6167cb0ca127efd96d6f3cfb66ca2d3e058c4e8f 100644 (file)
@@ -683,9 +683,6 @@ mono_delegate_ctor_with_method (MonoObjectHandle this_obj, MonoObjectHandle targ
 gboolean
 mono_delegate_ctor         (MonoObjectHandle this_obj, MonoObjectHandle target, gpointer addr, MonoError *error);
 
-void*
-mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words);
-
 void
 mono_runtime_free_method    (MonoDomain *domain, MonoMethod *method);
 
@@ -1813,9 +1810,6 @@ mono_object_new_mature (MonoVTable *vtable, MonoError *error);
 MonoObject*
 mono_object_new_fast_checked (MonoVTable *vtable, MonoError *error);
 
-MonoObject *
-ves_icall_object_new_fast (MonoVTable *vtable);
-
 MonoObject *
 mono_object_clone_checked (MonoObject *obj, MonoError *error);
 
index 9a48d69e336752e91defb66bbe7023cb3f9d2437..3d3d68c8a1084a19699bea369f7b25ed57987945 100644 (file)
@@ -239,6 +239,7 @@ mono_type_initialization_init (void)
        type_initialization_hash = g_hash_table_new (NULL, NULL);
        blocked_thread_hash = g_hash_table_new (NULL, NULL);
        mono_os_mutex_init_recursive (&ldstr_section);
+       mono_register_jit_icall (ves_icall_string_alloc, "ves_icall_string_alloc", mono_create_icall_signature ("object int"), FALSE);
 }
 
 void
@@ -1008,19 +1009,8 @@ mono_class_compute_gc_descriptor (MonoClass *klass)
        int max_set = 0;
        gsize *bitmap;
        gsize default_bitmap [4] = {0};
-       static gboolean gcj_inited = FALSE;
        MonoGCDescriptor gc_descr;
 
-       if (!gcj_inited) {
-               mono_loader_lock ();
-
-               mono_register_jit_icall (ves_icall_object_new_fast, "ves_icall_object_new_fast", mono_create_icall_signature ("object ptr"), FALSE);
-               mono_register_jit_icall (ves_icall_string_alloc, "ves_icall_string_alloc", mono_create_icall_signature ("object int"), FALSE);
-
-               gcj_inited = TRUE;
-               mono_loader_unlock ();
-       }
-
        if (!klass->inited)
                mono_class_init (klass);
 
@@ -5452,16 +5442,6 @@ mono_object_new_fast_checked (MonoVTable *vtable, MonoError *error)
        return o;
 }
 
-MonoObject *
-ves_icall_object_new_fast (MonoVTable *vtable)
-{
-       MonoError error;
-       MonoObject *o = mono_object_new_fast_checked (vtable, &error);
-       mono_error_set_pending_exception (&error);
-
-       return o;
-}
-
 MonoObject*
 mono_object_new_mature (MonoVTable *vtable, MonoError *error)
 {
@@ -5481,44 +5461,6 @@ mono_object_new_mature (MonoVTable *vtable, MonoError *error)
        return o;
 }
 
-/**
- * mono_class_get_allocation_ftn:
- * \param vtable vtable
- * \param for_box the object will be used for boxing
- * \param pass_size_in_words Unused
- * \returns the allocation function appropriate for the given class.
- */
-void*
-mono_class_get_allocation_ftn (MonoVTable *vtable, gboolean for_box, gboolean *pass_size_in_words)
-{
-       MONO_REQ_GC_NEUTRAL_MODE;
-
-       *pass_size_in_words = FALSE;
-
-       if (mono_class_has_finalizer (vtable->klass) || mono_class_is_marshalbyref (vtable->klass))
-               return ves_icall_object_new_specific;
-
-       if (vtable->gc_descr != MONO_GC_DESCRIPTOR_NULL) {
-
-               return ves_icall_object_new_fast;
-
-               /* 
-                * FIXME: This is actually slower than ves_icall_object_new_fast, because
-                * of the overhead of parameter passing.
-                */
-               /*
-               *pass_size_in_words = TRUE;
-#ifdef GC_REDIRECT_TO_LOCAL
-               return GC_local_gcj_fast_malloc;
-#else
-               return GC_gcj_fast_malloc;
-#endif
-               */
-       }
-
-       return ves_icall_object_new_specific;
-}
-
 /**
  * mono_object_new_from_token:
  * \param image Context where the type_token is hosted
index a1f6e1fa9eee4b9f5cb060545bcf67a0c7b48e20..07585ad2f82dcdddc969c2cd41242f620400b387 100644 (file)
@@ -3701,11 +3701,10 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                /* This happens often in argument checking code, eg. throw new FooException... */
                /* Avoid relocations and save some space by calling a helper function specialized to mscorlib */
                EMIT_NEW_ICONST (cfg, iargs [0], mono_metadata_token_index (klass->type_token));
-               return mono_emit_jit_icall (cfg, mono_helper_newobj_mscorlib, iargs);
+               alloc_ftn = mono_helper_newobj_mscorlib;
        } else {
                MonoVTable *vtable = mono_class_vtable (cfg->domain, klass);
                MonoMethod *managed_alloc = NULL;
-               gboolean pass_lw;
 
                if (!vtable) {
                        mono_cfg_set_exception (cfg, MONO_EXCEPTION_TYPE_LOAD);
@@ -3724,16 +3723,8 @@ handle_alloc (MonoCompile *cfg, MonoClass *klass, gboolean for_box, int context_
                        EMIT_NEW_ICONST (cfg, iargs [1], size);
                        return mono_emit_method_call (cfg, managed_alloc, iargs, NULL);
                }
-               alloc_ftn = mono_class_get_allocation_ftn (vtable, for_box, &pass_lw);
-               if (pass_lw) {
-                       guint32 lw = vtable->klass->instance_size;
-                       lw = ((lw + (sizeof (gpointer) - 1)) & ~(sizeof (gpointer) - 1)) / sizeof (gpointer);
-                       EMIT_NEW_ICONST (cfg, iargs [0], lw);
-                       EMIT_NEW_VTABLECONST (cfg, iargs [1], vtable);
-               }
-               else {
-                       EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable);
-               }
+               alloc_ftn = ves_icall_object_new_specific;
+               EMIT_NEW_VTABLECONST (cfg, iargs [0], vtable);
        }
 
        return mono_emit_jit_icall (cfg, alloc_ftn, iargs);
index 9c6b71195f6d31104d14eb4b9734c7a3d01b423f..7629cef31299838bdd6836cdd7751bf2b01bd4f5 100644 (file)
 #endif
 
 /* Version number of the AOT file format */
-#define MONO_AOT_FILE_VERSION 140
+#define MONO_AOT_FILE_VERSION 141
 
 //TODO: This is x86/amd64 specific.
 #define mono_simd_shuffle_mask(a,b,c,d) ((a) | ((b) << 2) | ((c) << 4) | ((d) << 6))