Permalink
Browse files

Change mono_gc_get_managed_array_allocator to receive a MonoClass ins…

…tead 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.
  • Loading branch information...
1 parent 4189fe3 commit 4b294019c65290519d45c8ae858f7a04133ca9c6 @kumpera kumpera committed Mar 25, 2013
@@ -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;
}
@@ -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;
@@ -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;
}
@@ -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;
@@ -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);
@@ -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,

0 comments on commit 4b29401

Please sign in to comment.