Change mono_gc_get_managed_array_allocator to receive a MonoClass instead of a vtable...
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 25 Mar 2013 14:36:57 +0000 (10:36 -0400)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 25 Mar 2013 14:42:01 +0000 (10:42 -0400)
* method-to-ir.c: Given mono_gc_get_managed_array_allocator now takes a class and not an vtable,
we can now use it for shared code allocating arrays.

mono/metadata/boehm-gc.c
mono/metadata/gc-internal.h
mono/metadata/null-gc.c
mono/metadata/sgen-alloc.c
mono/mini/decompose.c
mono/mini/method-to-ir.c

index e8ff58a98ca020adbdf5c9782d7ce0f32da4504a..bcc86ba335a81f90f81805fc5fd985564f742190 100644 (file)
@@ -949,7 +949,7 @@ mono_gc_get_managed_allocator (MonoVTable *vtable, gboolean for_box)
 }
 
 MonoMethod*
-mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank)
+mono_gc_get_managed_array_allocator (MonoClass *klass)
 {
        return NULL;
 }
@@ -1002,7 +1002,7 @@ mono_gc_get_managed_allocator (MonoVTable *vtable, gboolean for_box)
 }
 
 MonoMethod*
-mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank)
+mono_gc_get_managed_array_allocator (MonoClass *klass)
 {
        return NULL;
 }
index 24880dd582069d86913aa22193264a92e5ec2eb8..4cd959a1933268700cde589640e1339c9880837a 100644 (file)
@@ -220,7 +220,7 @@ typedef struct {
 } AllocatorWrapperInfo;
 
 MonoMethod* mono_gc_get_managed_allocator (MonoVTable *vtable, gboolean for_box) MONO_INTERNAL;
-MonoMethod* mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank) MONO_INTERNAL;
+MonoMethod* mono_gc_get_managed_array_allocator (MonoClass *klass) MONO_INTERNAL;
 MonoMethod *mono_gc_get_managed_allocator_by_type (int atype) MONO_INTERNAL;
 
 guint32 mono_gc_get_managed_allocator_types (void) MONO_INTERNAL;
index 4d48eb50adc2f72ede553b7a8d1518908fd1e073..47d541594cf9aa7956acb144d36d9a171277cedb 100644 (file)
@@ -221,7 +221,7 @@ mono_gc_get_managed_allocator (MonoVTable *vtable, gboolean for_box)
 }
 
 MonoMethod*
-mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank)
+mono_gc_get_managed_array_allocator (MonoClass *klass)
 {
        return NULL;
 }
index 55cd85bc75b084f63ec8caa3c40f9e1aaf15d814..55a472ffa44e561703d9a3ac271fdaccce8355c7 100644 (file)
@@ -953,11 +953,9 @@ mono_gc_get_managed_allocator (MonoVTable *vtable, gboolean for_box)
 }
 
 MonoMethod*
-mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank)
+mono_gc_get_managed_array_allocator (MonoClass *klass)
 {
 #ifdef MANAGED_ALLOCATION
-       MonoClass *klass = vtable->klass;
-
 #ifdef HAVE_KW_THREAD
        int tlab_next_offset = -1;
        int tlab_temp_end_offset = -1;
@@ -968,7 +966,7 @@ mono_gc_get_managed_array_allocator (MonoVTable *vtable, int rank)
                return NULL;
 #endif
 
-       if (rank != 1)
+       if (klass->rank != 1)
                return NULL;
        if (!mono_runtime_has_tls_get ())
                return NULL;
index 29f2e348017cabd5ca9768b998ffcda681056d63..b86678d4e2305694c31a6a5706e162f09f10af0e 100644 (file)
@@ -1397,8 +1397,9 @@ mono_decompose_array_access_opts (MonoCompile *cfg)
                                                dest = mono_emit_jit_icall (cfg, mono_array_new, iargs);
                                                dest->dreg = ins->dreg;
                                        } else {
-                                               MonoVTable *vtable = mono_class_vtable (cfg->domain, mono_array_class_get (ins->inst_newa_class, 1));
-                                               MonoMethod *managed_alloc = mono_gc_get_managed_array_allocator (vtable, 1);
+                                               MonoClass *array_class = mono_array_class_get (ins->inst_newa_class, 1);
+                                               MonoVTable *vtable = mono_class_vtable (cfg->domain, array_class);
+                                               MonoMethod *managed_alloc = mono_gc_get_managed_array_allocator (array_class);
 
                                                g_assert (vtable); /*This shall not fail since we check for this condition on OP_NEWARR creation*/
                                                NEW_VTABLECONST (cfg, iargs [0], vtable);
index c57768c550edbfd648e52ad730bf0fbf8c128027..7e0121d5778226621ec86e243031fd48d4d8f5cc 100644 (file)
@@ -9910,21 +9910,9 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        if (context_used) {
                                MonoInst *args [3];
                                MonoClass *array_class = mono_array_class_get (klass, 1);
-                               /* FIXME: we cannot get a managed
-                                  allocator because we can't get the
-                                  open generic class's vtable.  We
-                                  have the same problem in
-                                  handle_alloc().  This
-                                  needs to be solved so that we can
-                                  have managed allocs of shared
-                                  generic classes. */
-                               /*
-                               MonoVTable *array_class_vtable = mono_class_vtable (cfg->domain, array_class);
-                               MonoMethod *managed_alloc = mono_gc_get_managed_array_allocator (array_class_vtable, 1);
-                               */
-                               MonoMethod *managed_alloc = NULL;
+                               MonoMethod *managed_alloc = mono_gc_get_managed_array_allocator (array_class);
 
-                               /* FIXME: Decompose later to help abcrem */
+                               /* FIXME: Use OP_NEWARR and decompose later to help abcrem */
 
                                /* vtable */
                                args [0] = emit_get_rgctx_klass (cfg, context_used,