[llvm] Fix LLVM support after e7166e4f9cee4eb896f1a2ff0290e0b9d8fedacb.
authorZoltan Varga <vargaz@gmail.com>
Wed, 23 Dec 2015 06:09:02 +0000 (01:09 -0500)
committerZoltan Varga <vargaz@gmail.com>
Wed, 23 Dec 2015 06:09:19 +0000 (01:09 -0500)
mono/mini/mini-amd64.c
mono/mini/mini-amd64.h
mono/mini/mini-llvm.c

index 20ecb114327a415e7e71d848ba1ccc4165d22308..d90f82b4d8ec4b19c08839fc98f06e03397d718b 100644 (file)
@@ -2775,6 +2775,7 @@ mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, g
        DynCallArgs *p = (DynCallArgs*)buf;
        int arg_index, greg, i, pindex;
        MonoMethodSignature *sig = dinfo->sig;
        DynCallArgs *p = (DynCallArgs*)buf;
        int arg_index, greg, i, pindex;
        MonoMethodSignature *sig = dinfo->sig;
+       int buffer_offset = 0;
 
        g_assert (buf_len >= sizeof (DynCallArgs));
 
 
        g_assert (buf_len >= sizeof (DynCallArgs));
 
@@ -2848,6 +2849,22 @@ mono_arch_start_dyn_call (MonoDynCallInfo *info, gpointer **args, guint8 *ret, g
                    if (MONO_TYPE_IS_REFERENCE (t)) {
                                p->regs [greg ++] = PTR_TO_GREG(*(arg));
                                break;
                    if (MONO_TYPE_IS_REFERENCE (t)) {
                                p->regs [greg ++] = PTR_TO_GREG(*(arg));
                                break;
+                       } else if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) {
+                                       MonoClass *klass = mono_class_from_mono_type (t);
+                                       guint8 *nullable_buf;
+                                       int size;
+
+                                       size = mono_class_value_size (klass, NULL);
+                                       nullable_buf = p->buffer + buffer_offset;
+                                       buffer_offset += size;
+                                       g_assert (buffer_offset <= 256);
+
+                                       /* The argument pointed to by arg is either a boxed vtype or null */
+                                       mono_nullable_init (nullable_buf, (MonoObject*)arg, klass);
+
+                                       arg = (gpointer*)nullable_buf;
+                                       /* Fall though */
+
                        } else {
                                /* Fall through */
                        }
                        } else {
                                /* Fall through */
                        }
index 7292aae2ffeb5c7599af3facb205c87429bfb3d3..526e5b00c195d3652e55a35ef1766472b3ed90b5 100644 (file)
@@ -233,6 +233,7 @@ typedef struct {
        mgreg_t regs [PARAM_REGS];
        mgreg_t res;
        guint8 *ret;
        mgreg_t regs [PARAM_REGS];
        mgreg_t res;
        guint8 *ret;
+       guint8 buffer [256];
 } DynCallArgs;
 
 #define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->gregs [AMD64_RAX] = (gsize)exc; } while (0)
 } DynCallArgs;
 
 #define MONO_CONTEXT_SET_LLVM_EXC_REG(ctx, exc) do { (ctx)->gregs [AMD64_RAX] = (gsize)exc; } while (0)
index 8cbd01305f708e80256af5847d985c13b5fd5ed6..ff3eeb6f8ce817e94e0b7a61bb5cb00c7f53f57c 100644 (file)
@@ -7558,7 +7558,7 @@ emit_aot_file_info (MonoLLVMModule *module)
        info = &module->aot_info;
 
        /* Create an LLVM type to represent MonoAotFileInfo */
        info = &module->aot_info;
 
        /* Create an LLVM type to represent MonoAotFileInfo */
-       nfields = 2 + MONO_AOT_FILE_INFO_NUM_SYMBOLS + 14 + 4;
+       nfields = 2 + MONO_AOT_FILE_INFO_NUM_SYMBOLS + 15 + 5;
        eltypes = g_new (LLVMTypeRef, nfields);
        tindex = 0;
        eltypes [tindex ++] = LLVMInt32Type ();
        eltypes = g_new (LLVMTypeRef, nfields);
        tindex = 0;
        eltypes [tindex ++] = LLVMInt32Type ();
@@ -7567,9 +7567,10 @@ emit_aot_file_info (MonoLLVMModule *module)
        for (i = 0; i < MONO_AOT_FILE_INFO_NUM_SYMBOLS; ++i)
                eltypes [tindex ++] = LLVMPointerType (LLVMInt8Type (), 0);
        /* Scalars */
        for (i = 0; i < MONO_AOT_FILE_INFO_NUM_SYMBOLS; ++i)
                eltypes [tindex ++] = LLVMPointerType (LLVMInt8Type (), 0);
        /* Scalars */
-       for (i = 0; i < 14; ++i)
+       for (i = 0; i < 15; ++i)
                eltypes [tindex ++] = LLVMInt32Type ();
        /* Arrays */
                eltypes [tindex ++] = LLVMInt32Type ();
        /* Arrays */
+       eltypes [tindex ++] = LLVMArrayType (LLVMInt32Type (), MONO_AOT_TABLE_NUM);
        for (i = 0; i < 4; ++i)
                eltypes [tindex ++] = LLVMArrayType (LLVMInt32Type (), MONO_AOT_TRAMP_NUM);
        g_assert (tindex == nfields);
        for (i = 0; i < 4; ++i)
                eltypes [tindex ++] = LLVMArrayType (LLVMInt32Type (), MONO_AOT_TRAMP_NUM);
        g_assert (tindex == nfields);
@@ -7627,9 +7628,9 @@ emit_aot_file_info (MonoLLVMModule *module)
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_table");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "got_info_offsets");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "llvm_got_info_offsets");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "extra_method_table");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "got_info_offsets");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "llvm_got_info_offsets");
+       fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "image_table");
        /* Not needed (mem_end) */
        fields [tindex ++] = LLVMConstNull (eltype);
        /* Not needed (mem_end) */
        fields [tindex ++] = LLVMConstNull (eltype);
-       fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "image_table");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "assembly_guid");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "runtime_version");
        if (info->trampoline_size [0]) {
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "assembly_guid");
        fields [tindex ++] = LLVMGetNamedGlobal (lmodule, "runtime_version");
        if (info->trampoline_size [0]) {
@@ -7682,7 +7683,9 @@ emit_aot_file_info (MonoLLVMModule *module)
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->generic_tramp_num, FALSE);
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->tramp_page_size, FALSE);
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->nshared_got_entries, FALSE);
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->generic_tramp_num, FALSE);
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->tramp_page_size, FALSE);
        fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->nshared_got_entries, FALSE);
+       fields [tindex ++] = LLVMConstInt (LLVMInt32Type (), info->datafile_size, FALSE);
        /* Arrays */
        /* Arrays */
+       fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->table_offsets, MONO_AOT_TABLE_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->num_trampolines, MONO_AOT_TRAMP_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->trampoline_got_offset_base, MONO_AOT_TRAMP_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->trampoline_size, MONO_AOT_TRAMP_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->num_trampolines, MONO_AOT_TRAMP_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->trampoline_got_offset_base, MONO_AOT_TRAMP_NUM);
        fields [tindex ++] = llvm_array_from_uints (LLVMInt32Type (), info->trampoline_size, MONO_AOT_TRAMP_NUM);