From 4b294019c65290519d45c8ae858f7a04133ca9c6 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Mon, 25 Mar 2013 10:36:57 -0400 Subject: [PATCH] Change mono_gc_get_managed_array_allocator to receive a MonoClass instead of a vtable, rank pair. * 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 | 4 ++-- mono/metadata/gc-internal.h | 2 +- mono/metadata/null-gc.c | 2 +- mono/metadata/sgen-alloc.c | 6 ++---- mono/mini/decompose.c | 5 +++-- mono/mini/method-to-ir.c | 16 ++-------------- 6 files changed, 11 insertions(+), 24 deletions(-) diff --git a/mono/metadata/boehm-gc.c b/mono/metadata/boehm-gc.c index e8ff58a98ca..bcc86ba335a 100644 --- a/mono/metadata/boehm-gc.c +++ b/mono/metadata/boehm-gc.c @@ -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; } diff --git a/mono/metadata/gc-internal.h b/mono/metadata/gc-internal.h index 24880dd5820..4cd959a1933 100644 --- a/mono/metadata/gc-internal.h +++ b/mono/metadata/gc-internal.h @@ -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; diff --git a/mono/metadata/null-gc.c b/mono/metadata/null-gc.c index 4d48eb50adc..47d541594cf 100644 --- a/mono/metadata/null-gc.c +++ b/mono/metadata/null-gc.c @@ -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; } diff --git a/mono/metadata/sgen-alloc.c b/mono/metadata/sgen-alloc.c index 55cd85bc75b..55a472ffa44 100644 --- a/mono/metadata/sgen-alloc.c +++ b/mono/metadata/sgen-alloc.c @@ -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; diff --git a/mono/mini/decompose.c b/mono/mini/decompose.c index 29f2e348017..b86678d4e23 100644 --- a/mono/mini/decompose.c +++ b/mono/mini/decompose.c @@ -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); diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index c57768c550e..7e0121d5778 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -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, -- 2.11.4.GIT