[jit] Transition some memory allocations to memory managers. (#42351)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 18 Sep 2020 11:45:27 +0000 (07:45 -0400)
committerGitHub <noreply@github.com>
Fri, 18 Sep 2020 11:45:27 +0000 (07:45 -0400)
Co-authored-by: vargaz <vargaz@users.noreply.github.com>
15 files changed:
src/mono/mono/metadata/class-internals.h
src/mono/mono/metadata/class-setup-vtable.c
src/mono/mono/metadata/loader-internals.h
src/mono/mono/metadata/memory-manager.c
src/mono/mono/mini/cfold.c
src/mono/mono/mini/interp/interp.c
src/mono/mono/mini/interp/transform.c
src/mono/mono/mini/interp/transform.h
src/mono/mono/mini/intrinsics.c
src/mono/mono/mini/method-to-ir.c
src/mono/mono/mini/mini-gc.c
src/mono/mono/mini/mini-runtime.c
src/mono/mono/mini/mini-trampolines.c
src/mono/mono/mini/mini.c
src/mono/mono/mini/mini.h

index 49f5460..0ba3ea1 100644 (file)
@@ -1592,6 +1592,59 @@ m_field_get_offset (MonoClassField *field)
        return field->offset;
 }
 
+/*
+ * Memory allocation for classes/methods
+ *
+ *   These should be used to allocate memory whose lifetime is equal to
+ * the lifetime of the domain+class/method pair.
+ */
+
+static inline MonoMemoryManager*
+m_class_get_mem_manager (MonoDomain *domain, MonoClass *klass)
+{
+#ifdef ENABLE_NETCORE
+       // FIXME:
+       return mono_domain_memory_manager (domain);
+#else
+       return mono_domain_memory_manager (domain);
+#endif
+}
+
+static inline void *
+m_class_alloc (MonoDomain *domain, MonoClass *klass, guint size)
+{
+       return mono_mem_manager_alloc (m_class_get_mem_manager (domain, klass), size);
+}
+
+static inline void *
+m_class_alloc0 (MonoDomain *domain, MonoClass *klass, guint size)
+{
+       return mono_mem_manager_alloc0 (m_class_get_mem_manager (domain, klass), size);
+}
+
+static inline MonoMemoryManager*
+m_method_get_mem_manager (MonoDomain *domain, MonoMethod *method)
+{
+#ifdef ENABLE_NETCORE
+       // FIXME:
+       return mono_domain_memory_manager (domain);
+#else
+       return mono_domain_memory_manager (domain);
+#endif
+}
+
+static inline void *
+m_method_alloc (MonoDomain *domain, MonoMethod *method, guint size)
+{
+       return mono_mem_manager_alloc (m_method_get_mem_manager (domain, method), size);
+}
+
+static inline void *
+m_method_alloc0 (MonoDomain *domain, MonoMethod *method, guint size)
+{
+       return mono_mem_manager_alloc0 (m_method_get_mem_manager (domain, method), size);
+}
+
 // Enum and static storage for JIT icalls.
 #include "jit-icall-reg.h"
 
index 58ac82f..486fed9 100644 (file)
@@ -1967,7 +1967,9 @@ mono_class_setup_vtable_general (MonoClass *klass, MonoMethod **overrides, int o
                MonoMethod *impl = overrides [i*2 + 1];
                if (!MONO_CLASS_IS_INTERFACE_INTERNAL (decl->klass)) {
                        g_assert (decl->slot != -1);
+#ifdef FEATURE_COVARIANT_RETURNS
                        MonoMethod *prev_impl = vtable [decl->slot];
+#endif
                        vtable [decl->slot] = impl;
 #ifdef FEATURE_COVARIANT_RETURNS
                        gboolean impl_newslot = (impl->flags & METHOD_ATTRIBUTE_NEW_SLOT) != 0;
index 9a5e504..f7742cd 100644 (file)
@@ -241,4 +241,7 @@ mono_mem_manager_code_commit (MonoMemoryManager *memory_manager, void *data, int
 void
 mono_mem_manager_code_foreach (MonoMemoryManager *memory_manager, MonoCodeManagerFunc func, void *user_data);
 
+char*
+mono_mem_manager_strdup (MonoMemoryManager *memory_manager, const char *s);
+
 #endif
index 4d2b55d..01cb24e 100644 (file)
@@ -169,6 +169,17 @@ mono_mem_manager_alloc0_nolock (MonoMemoryManager *memory_manager, guint size)
        return mono_mempool_alloc0 (memory_manager->mp, size);
 }
 
+char*
+mono_mem_manager_strdup (MonoMemoryManager *memory_manager, const char *s)
+{
+       char *res;
+
+       mono_mem_manager_lock (memory_manager);
+       res = mono_mempool_strdup (memory_manager->mp, s);
+       mono_mem_manager_unlock (memory_manager);
+
+       return res;
+}
 
 void *
 mono_mem_manager_code_reserve (MonoMemoryManager *memory_manager, int size)
index 7c08247..89c4f7b 100644 (file)
@@ -45,13 +45,13 @@ mono_is_power_of_two (guint32 val)
 
 #define FOLD_FBINOP(name, op) \
        case name: \
-       dest->inst_p0 = (double *)mono_domain_alloc (cfg->domain, sizeof (double)); \
+       dest->inst_p0 = (double *)mono_mem_manager_alloc (cfg->mem_manager, sizeof (double)); \
        *(double *)dest->inst_p0 = (*((double *) arg1->inst_p0)) op (*((double *) arg2->inst_p0)); \
        break;
 
 #define FOLD_RBINOP(name, op) \
        case name: \
-       dest->inst_p0 = (float *)mono_domain_alloc (cfg->domain, sizeof (float)); \
+       dest->inst_p0 = (float *)mono_mem_manager_alloc (cfg->mem_manager, sizeof (float)); \
        *(float *)dest->inst_p0 = (*((float *) arg1->inst_p0)) op (*((float *) arg2->inst_p0)); \
        break;
 
index 555ea5a..6bd1767 100644 (file)
@@ -505,7 +505,7 @@ mono_interp_get_imethod (MonoDomain *domain, MonoMethod *method, MonoError *erro
 
        sig = mono_method_signature_internal (method);
 
-       imethod = (InterpMethod*)mono_domain_alloc0 (domain, sizeof (InterpMethod));
+       imethod = (InterpMethod*)m_method_alloc0 (domain, method, sizeof (InterpMethod));
        imethod->method = method;
        imethod->domain = domain;
        imethod->param_count = sig->param_count;
@@ -516,7 +516,7 @@ mono_interp_get_imethod (MonoDomain *domain, MonoMethod *method, MonoError *erro
                imethod->rtype = m_class_get_byval_arg (mono_defaults.string_class);
        else
                imethod->rtype = mini_get_underlying_type (sig->ret);
-       imethod->param_types = (MonoType**)mono_domain_alloc0 (domain, sizeof (MonoType*) * sig->param_count);
+       imethod->param_types = (MonoType**)m_method_alloc0 (domain, method, sizeof (MonoType*) * sig->param_count);
        for (i = 0; i < sig->param_count; ++i)
                imethod->param_types [i] = mini_get_underlying_type (sig->params [i]);
 
@@ -713,7 +713,7 @@ alloc_method_table (MonoVTable *vtable, int offset)
        gpointer *table;
 
        if (offset >= 0) {
-               table = mono_domain_alloc0 (vtable->domain, m_class_get_vtable_size (vtable->klass) * sizeof (gpointer));
+               table = (gpointer*)m_class_alloc0 (vtable->domain, vtable->klass, m_class_get_vtable_size (vtable->klass) * sizeof (gpointer));
                vtable->interp_vtable = table;
        } else {
                table = (gpointer*)vtable;
@@ -726,7 +726,7 @@ static InterpMethod* // Inlining causes additional stack use in caller.
 get_virtual_method_fast (InterpMethod *imethod, MonoVTable *vtable, int offset)
 {
        gpointer *table;
-       MonoMemoryManager *memory_manager = mono_domain_ambient_memory_manager (vtable->domain);
+       MonoMemoryManager *memory_manager = m_class_get_mem_manager (vtable->domain, vtable->klass);
 
 #ifndef DISABLE_REMOTING
        /* FIXME Remoting */
index f699f3d..504c6e6 100644 (file)
@@ -1046,9 +1046,8 @@ static void
 interp_generate_ipe_throw_with_msg (TransformData *td, MonoError *error_msg)
 {
        MonoJitICallInfo *info = &mono_get_jit_icall_info ()->mono_throw_invalid_program;
-       MonoMemoryManager *memory_manager = mono_domain_ambient_memory_manager (td->rtm->domain);
 
-       char *msg = mono_mempool_strdup (memory_manager->mp, mono_error_get_message (error_msg));
+       char *msg = mono_mem_manager_strdup (td->mem_manager, mono_error_get_message (error_msg));
 
        interp_add_ins (td, MINT_MONO_LDPTR);
        td->last_ins->data [0] = get_data_item_index (td, msg);
@@ -6246,7 +6245,7 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
                                interp_add_ins (td, MINT_MONO_LDPTR);
                                g_assert (method->wrapper_type != MONO_WRAPPER_NONE);
                                /* This is a memory slot used by the wrapper */
-                               gpointer addr = mono_domain_alloc0 (td->rtm->domain, sizeof (gpointer));
+                               gpointer addr = mono_mem_manager_alloc0 (td->mem_manager, sizeof (gpointer));
                                td->last_ins->data [0] = get_data_item_index (td, addr);
                                PUSH_SIMPLE_TYPE (td, STACK_TYPE_I);
                                break;
@@ -7022,7 +7021,7 @@ generate_compacted_code (TransformData *td)
        }
 
        // Generate the compacted stream of instructions
-       td->new_code = ip = (guint16*)mono_domain_alloc0 (td->rtm->domain, size * sizeof (guint16));
+       td->new_code = ip = (guint16*)mono_mem_manager_alloc0 (td->mem_manager, size * sizeof (guint16));
 
        for (bb = td->entry_bb; bb != NULL; bb = bb->next_bb) {
                InterpInst *ins = bb->first_ins;
@@ -8047,7 +8046,6 @@ get_native_offset (TransformData *td, int il_offset)
 static void
 generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoGenericContext *generic_context, MonoError *error)
 {
-       MonoDomain *domain = rtm->domain;
        int i;
        TransformData transform_data;
        TransformData *td;
@@ -8070,6 +8068,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        td->in_offsets = (int*)g_malloc0((header->code_size + 1) * sizeof(int));
        td->clause_indexes = (int*)g_malloc (header->code_size * sizeof (int));
        td->mempool = mono_mempool_new ();
+       td->mem_manager = m_method_get_mem_manager (rtm->domain, method);
        td->n_data_items = 0;
        td->max_data_items = 0;
        td->data_items = NULL;
@@ -8140,7 +8139,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        code_len_u8 = (guint8 *) td->new_code_end - (guint8 *) td->new_code;
        code_len_u16 = td->new_code_end - td->new_code;
 
-       rtm->clauses = (MonoExceptionClause*)mono_domain_alloc0 (domain, header->num_clauses * sizeof (MonoExceptionClause));
+       rtm->clauses = (MonoExceptionClause*)mono_mem_manager_alloc0 (td->mem_manager, header->num_clauses * sizeof (MonoExceptionClause));
        memcpy (rtm->clauses, header->clauses, header->num_clauses * sizeof(MonoExceptionClause));
        rtm->code = (gushort*)td->new_code;
        rtm->init_locals = header->init_locals;
@@ -8163,7 +8162,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        rtm->vt_stack_size = td->max_vt_sp;
        rtm->total_locals_size = ALIGN_TO (td->total_locals_size, MINT_VT_ALIGNMENT);
        rtm->alloca_size = ALIGN_TO (rtm->total_locals_size + rtm->vt_stack_size + rtm->stack_size, 8);
-       rtm->data_items = (gpointer*)mono_domain_alloc0 (domain, td->n_data_items * sizeof (td->data_items [0]));
+       rtm->data_items = (gpointer*)mono_mem_manager_alloc0 (td->mem_manager, td->n_data_items * sizeof (td->data_items [0]));
        memcpy (rtm->data_items, td->data_items, td->n_data_items * sizeof (td->data_items [0]));
 
        /* Save debug info */
@@ -8173,7 +8172,7 @@ generate (MonoMethod *method, MonoMethodHeader *header, InterpMethod *rtm, MonoG
        int jinfo_len;
        jinfo_len = mono_jit_info_size ((MonoJitInfoFlags)0, header->num_clauses, 0);
        MonoJitInfo *jinfo;
-       jinfo = (MonoJitInfo *)mono_domain_alloc0 (domain, jinfo_len);
+       jinfo = (MonoJitInfo *)mono_mem_manager_alloc0 (td->mem_manager, jinfo_len);
        jinfo->is_interp = 1;
        rtm->jinfo = jinfo;
        mono_jit_info_init (jinfo, method, (guint8*)rtm->code, code_len_u8, (MonoJitInfoFlags)0, header->num_clauses, 0);
index fca337a..6a4781f 100644 (file)
@@ -167,6 +167,7 @@ typedef struct
        InterpBasicBlock *entry_bb, *cbb;
        int bb_count;
        MonoMemPool     *mempool;
+       MonoMemoryManager *mem_manager;
        GList *basic_blocks;
        GPtrArray *relocs;
        gboolean verbose_level;
index 912e12e..2655d10 100644 (file)
@@ -1724,7 +1724,7 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign
                        }
 
                        if (opcode) {
-                               double *dest = (double *) mono_domain_alloc (cfg->domain, sizeof (double));
+                               double *dest = (double *)mono_mem_manager_alloc (cfg->mem_manager, sizeof (double));
                                double result = 0;
                                MONO_INST_NEW (cfg, ins, OP_R8CONST);
                                ins->type = STACK_R8;
index f3c0a84..3818622 100644 (file)
@@ -2317,10 +2317,8 @@ static void
 emit_invalid_program_with_msg (MonoCompile *cfg, MonoError *error_msg, MonoMethod *caller, MonoMethod *callee)
 {
        g_assert (!is_ok (error_msg));
-       MonoMemoryManager *memory_manager = mono_domain_ambient_memory_manager (cfg->domain);
-       mono_mem_manager_lock (memory_manager);
-       char *str = mono_mempool_strdup (memory_manager->mp, mono_error_get_message (error_msg));
-       mono_mem_manager_unlock (memory_manager);
+
+       char *str = mono_mem_manager_strdup (cfg->mem_manager, mono_error_get_message (error_msg));
        MonoInst *iargs[1];
        if (cfg->compile_aot)
                EMIT_NEW_LDSTRLITCONST (cfg, iargs [0], str);
@@ -3626,14 +3624,14 @@ handle_delegate_ctor (MonoCompile *cfg, MonoClass *klass, MonoInst *target, Mono
                                domain_jit_info (domain)->method_code_hash = g_hash_table_new (NULL, NULL);
                        code_slot = (guint8 **)g_hash_table_lookup (domain_jit_info (domain)->method_code_hash, method);
                        if (!code_slot) {
-                               code_slot = (guint8 **)mono_domain_alloc0 (domain, sizeof (gpointer));
+                               code_slot = (guint8 **)m_method_alloc0 (domain, method, sizeof (gpointer));
                                g_hash_table_insert (domain_jit_info (domain)->method_code_hash, method, code_slot);
                        }
                        mono_domain_unlock (domain);
 
                        code_slot_ins = mini_emit_runtime_constant (cfg, MONO_PATCH_INFO_METHOD_CODE_SLOT, method);
                }
-               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, MONO_STRUCT_OFFSET (MonoDelegate, method_code), code_slot_ins->dreg);                
+               MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, obj->dreg, MONO_STRUCT_OFFSET (MonoDelegate, method_code), code_slot_ins->dreg);
        }
 
        if (cfg->llvm_only) {
@@ -6859,7 +6857,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                                use_aotconst = TRUE;
 #endif
                        /* FIXME: we should really allocate this only late in the compilation process */
-                       f = (float *)mono_domain_alloc (cfg->domain, sizeof (float));
+                       f = (float *)mono_mem_manager_alloc (cfg->mem_manager, sizeof (float));
 
                        if (use_aotconst) {
                                MonoInst *cons;
@@ -6892,7 +6890,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
 #endif
 
                        /* FIXME: we should really allocate this only late in the compilation process */
-                       d = (double *)mono_domain_alloc (cfg->domain, sizeof (double));
+                       d = (double *)mono_mem_manager_alloc (cfg->mem_manager, sizeof (double));
 
                        if (use_aotconst) {
                                MonoInst *cons;
@@ -10790,7 +10788,7 @@ mono_ldptr:
                        if (cfg->compile_aot) {
                                EMIT_NEW_AOTCONST (cfg, ins, MONO_PATCH_INFO_METHOD_PINVOKE_ADDR_CACHE, pinvoke_method);
                        } else {
-                               gpointer addr = mono_domain_alloc0 (cfg->domain, sizeof (gpointer));
+                               gpointer addr = mono_mem_manager_alloc0 (cfg->mem_manager, sizeof (gpointer));
                                EMIT_NEW_PCONST (cfg, ins, addr);
                        }
                        *sp++ = ins;
index d5ede5a..6dc4488 100644 (file)
@@ -2425,7 +2425,7 @@ create_map (MonoCompile *cfg)
                encoded_size = endbuf - buf;
                alloc_size = sizeof (GCEncodedMap) + ALIGN_TO (encoded_size, map->callsite_entry_size) + (map->callsite_entry_size * map->ncallsites) + bitmaps_size;
 
-               emap = mono_domain_alloc0 (cfg->domain, alloc_size);
+               emap = mono_mem_manager_alloc0 (cfg->mem_manager, alloc_size);
                //emap->ref_slots = map->ref_slots;
 
                /* Encoded fixed fields */
index 57f0da6..6711c9a 100644 (file)
@@ -1459,10 +1459,11 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                if (method && method->dynamic) {
                        jump_table = (void **)mono_code_manager_reserve (mono_dynamic_code_hash_lookup (domain, method)->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
                } else {
+                       MonoMemoryManager *mem_manager = m_method_get_mem_manager (domain, method);
                        if (mono_aot_only) {
-                               jump_table = (void **)mono_domain_alloc (domain, sizeof (gpointer) * patch_info->data.table->table_size);
+                               jump_table = (void **)mono_mem_manager_alloc (mem_manager, sizeof (gpointer) * patch_info->data.table->table_size);
                        } else {
-                               jump_table = (void **)mono_domain_code_reserve (domain, sizeof (gpointer) * patch_info->data.table->table_size);
+                               jump_table = (void **)mono_mem_manager_code_reserve (mem_manager, sizeof (gpointer) * patch_info->data.table->table_size);
                        }
                }
 
index 5bb42d1..ab362b6 100644 (file)
@@ -131,7 +131,7 @@ mono_create_static_rgctx_trampoline (MonoMethod *m, gpointer addr)
 
        mono_domain_lock (domain);
        /* Duplicates inserted while we didn't hold the lock are OK */
-       info = (RgctxTrampInfo *)mono_domain_alloc (domain, sizeof (RgctxTrampInfo));
+       info = (RgctxTrampInfo *)m_method_alloc (domain, m, sizeof (RgctxTrampInfo));
        info->m = m;
        info->addr = addr;
        g_hash_table_insert (domain_jit_info (domain)->static_rgctx_trampoline_hash, info, res);
@@ -1376,7 +1376,7 @@ mono_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean ad
        code = mono_create_specific_trampoline (method, MONO_TRAMPOLINE_JUMP, mono_domain_get (), &code_size);
        g_assert (code_size);
 
-       ji = (MonoJitInfo *)mono_domain_alloc0 (domain, MONO_SIZEOF_JIT_INFO);
+       ji = (MonoJitInfo *)m_method_alloc0 (domain, method, MONO_SIZEOF_JIT_INFO);
        ji->code_start = code;
        ji->code_size = code_size;
        ji->d.method = method;
index 2a6ca7f..5df5d87 100644 (file)
@@ -2106,7 +2106,7 @@ mono_postprocess_patches (MonoCompile *cfg)
                        if (cfg->method->dynamic) {
                                table = (void **)mono_code_manager_reserve (cfg->dynamic_info->code_mp, sizeof (gpointer) * patch_info->data.table->table_size);
                        } else {
-                               table = (void **)mono_domain_code_reserve (cfg->domain, sizeof (gpointer) * patch_info->data.table->table_size);
+                               table = (void **)mono_mem_manager_code_reserve (cfg->mem_manager, sizeof (gpointer) * patch_info->data.table->table_size);
                        }
 
                        for (i = 0; i < patch_info->data.table->table_size; i++) {
@@ -2155,7 +2155,7 @@ mono_codegen (MonoCompile *cfg)
        MonoBasicBlock *bb;
        int max_epilog_size;
        guint8 *code;
-       MonoDomain *code_domain;
+       MonoMemoryManager *code_mem_manager;
        guint unwindlen = 0;
 
        if (mono_using_xdebug)
@@ -2164,9 +2164,9 @@ mono_codegen (MonoCompile *cfg)
                 * overlapping address ranges, so allocate all code from the code manager
                 * of the root domain. (#666152).
                 */
-               code_domain = mono_get_root_domain ();
+               code_mem_manager = mono_domain_memory_manager (mono_get_root_domain ());
        else
-               code_domain = cfg->domain;
+               code_mem_manager = cfg->mem_manager;
 
        for (bb = cfg->bb_entry; bb; bb = bb->next_bb) {
                cfg->spill_count = 0;
@@ -2241,11 +2241,11 @@ mono_codegen (MonoCompile *cfg)
 
                if (mono_using_xdebug)
                        /* See the comment for cfg->code_domain */
-                       code = (guint8 *)mono_domain_code_reserve (code_domain, cfg->code_size + cfg->thunk_area + unwindlen);
+                       code = (guint8 *)mono_mem_manager_code_reserve (code_mem_manager, cfg->code_size + cfg->thunk_area + unwindlen);
                else
                        code = (guint8 *)mono_code_manager_reserve (cfg->dynamic_info->code_mp, cfg->code_size + cfg->thunk_area + unwindlen);
        } else {
-               code = (guint8 *)mono_domain_code_reserve (code_domain, cfg->code_size + cfg->thunk_area + unwindlen);
+               code = (guint8 *)mono_mem_manager_code_reserve (code_mem_manager, cfg->code_size + cfg->thunk_area + unwindlen);
        }
 
        mono_codeman_enable_write ();
@@ -2335,11 +2335,11 @@ mono_codegen (MonoCompile *cfg)
 
        if (cfg->method->dynamic) {
                if (mono_using_xdebug)
-                       mono_domain_code_commit (code_domain, cfg->native_code, cfg->code_size, cfg->code_len);
+                       mono_mem_manager_code_commit (code_mem_manager, cfg->native_code, cfg->code_size, cfg->code_len);
                else
                        mono_code_manager_commit (cfg->dynamic_info->code_mp, cfg->native_code, cfg->code_size, cfg->code_len);
        } else {
-               mono_domain_code_commit (code_domain, cfg->native_code, cfg->code_size, cfg->code_len);
+               mono_mem_manager_code_commit (code_mem_manager, cfg->native_code, cfg->code_size, cfg->code_len);
        }
 
        mono_codeman_disable_write ();
@@ -2489,7 +2489,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
        if (cfg->method->dynamic)
                jinfo = (MonoJitInfo *)g_malloc0 (mono_jit_info_size (flags, num_clauses, num_holes));
        else
-               jinfo = (MonoJitInfo *)mono_domain_alloc0 (cfg->domain, mono_jit_info_size (flags, num_clauses, num_holes));
+               jinfo = (MonoJitInfo *)mono_mem_manager_alloc0 (cfg->mem_manager, mono_jit_info_size (flags, num_clauses, num_holes));
        jinfo_try_holes_size += num_holes * sizeof (MonoTryBlockHoleJitInfo);
 
        mono_jit_info_init (jinfo, cfg->method_to_register, cfg->native_code, cfg->code_len, flags, num_clauses, num_holes);
@@ -2509,7 +2509,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                if (cfg->method->dynamic)
                        gi->generic_sharing_context = g_new0 (MonoGenericSharingContext, 1);
                else
-                       gi->generic_sharing_context = (MonoGenericSharingContext *)mono_domain_alloc0 (cfg->domain, sizeof (MonoGenericSharingContext));
+                       gi->generic_sharing_context = (MonoGenericSharingContext *)mono_mem_manager_alloc0 (cfg->mem_manager, sizeof (MonoGenericSharingContext));
                mini_init_gsctx (cfg->method->dynamic ? NULL : cfg->domain, NULL, cfg->gsctx_context, gi->generic_sharing_context);
 
                if ((method_to_compile->flags & METHOD_ATTRIBUTE_STATIC) ||
@@ -2541,7 +2541,7 @@ create_jit_info (MonoCompile *cfg, MonoMethod *method_to_compile)
                        if (cfg->method->dynamic)
                                gi->locations = (MonoDwarfLocListEntry *)g_malloc0 (gi->nlocs * sizeof (MonoDwarfLocListEntry));
                        else
-                               gi->locations = (MonoDwarfLocListEntry *)mono_domain_alloc0 (cfg->domain, gi->nlocs * sizeof (MonoDwarfLocListEntry));
+                               gi->locations = (MonoDwarfLocListEntry *)mono_mem_manager_alloc0 (cfg->mem_manager, gi->nlocs * sizeof (MonoDwarfLocListEntry));
                        i = 0;
                        for (l = loclist; l; l = l->next) {
                                memcpy (&(gi->locations [i]), l->data, sizeof (MonoDwarfLocListEntry));
@@ -3191,6 +3191,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
        cfg->self_init = (flags & JIT_FLAG_SELF_INIT) != 0;
        cfg->code_exec_only = (flags & JIT_FLAG_CODE_EXEC_ONLY) != 0;
        cfg->backend = current_backend;
+       cfg->mem_manager = m_method_get_mem_manager (domain, cfg->method);
 
        if (cfg->method->wrapper_type == MONO_WRAPPER_ALLOC) {
                /* We can't have seq points inside gc critical regions */
index 6038153..b5570f9 100644 (file)
@@ -1349,6 +1349,8 @@ typedef struct {
 
        MonoGSharedVtMethodInfo *gsharedvt_info;
 
+       MonoMemoryManager *mem_manager;
+
        /* Points to the gsharedvt locals area at runtime */
        MonoInst *gsharedvt_locals_var;