[llvmonly] Various small fixes. Make mono_llvm_throw_exception etc. directly callable...
authorZoltan Varga <vargaz@gmail.com>
Fri, 5 Feb 2016 07:07:40 +0000 (02:07 -0500)
committerZoltan Varga <vargaz@gmail.com>
Fri, 5 Feb 2016 07:07:46 +0000 (02:07 -0500)
mono/mini/aot-compiler.c
mono/mini/jit-icalls.c
mono/mini/mini-exceptions.c
mono/mini/mini-llvm.c
mono/mini/mini-runtime.c

index b053cb2cfccfaa8e694cc2675ce5ff1d28b5e57f..a9ae9794f87098ff328d359b5f7a216ae3408708 100644 (file)
@@ -7758,6 +7758,8 @@ mono_aot_get_direct_call_symbol (MonoJumpInfoType type, gconstpointer data)
                        MonoMethod *method = (MonoMethod *)data;
                        if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                                sym = mono_lookup_icall_symbol (method);
+                       else if (llvm_acfg->aot_opts.direct_pinvoke)
+                               sym = get_pinvoke_import (llvm_acfg, method);
                }
                if (sym)
                        return g_strdup (sym);
index 3c71c3dd71d31f95d34e3a1a95cf489569ffefa9..c880ff893121a0fff7171859b4c3128d969bc9b9 100644 (file)
@@ -1829,7 +1829,7 @@ mono_llvmonly_get_calling_assembly (void)
        } else {
                assembly = dest->klass->image->assembly;
        }
-       return (MonoObject*)mono_assembly_get_object (mono_domain_get (), jit_tls->calling_image->assembly);
+       return (MonoObject*)mono_assembly_get_object (mono_domain_get (), assembly);
 }
 
 /*
index 8bf8ade17e407ca9190e7ac5404de4509757c12c..2d00d36525eaa19f3372170686720fe06a138296 100644 (file)
@@ -733,7 +733,11 @@ ves_icall_get_trace (MonoException *exc, gint32 skip, MonoBoolean need_file_info
 
                g_assert (ji != NULL);
 
-               method = get_method_from_stack_frame (ji, generic_info);
+               if (mono_llvm_only)
+                       /* Can't resolve actual method */
+                       method = jinfo_get_method (ji);
+               else
+                       method = get_method_from_stack_frame (ji, generic_info);
                if (jinfo_get_method (ji)->wrapper_type) {
                        char *s;
 
index 3e34f8001da3df110e63dfbd1c753e6084837b1b..e15a5d09102eefc8420a0e140b2e9fc92d463718 100644 (file)
@@ -1603,7 +1603,8 @@ get_aotconst_typed (EmitContext *ctx, MonoJumpInfoType type, gconstpointer data,
 
        name = get_aotconst_name (type, data, got_offset);
        if (llvm_type) {
-               load = convert (ctx, LLVMBuildLoad (builder, got_entry_addr, ""), llvm_type);
+               load = LLVMBuildLoad (builder, got_entry_addr, "");
+               load = convert (ctx, load, llvm_type);
                LLVMSetValueName (load, name ? name : "");
        } else {
                load = LLVMBuildLoad (builder, got_entry_addr, name ? name : "");
@@ -1638,6 +1639,10 @@ get_callee (EmitContext *ctx, LLVMTypeRef llvm_sig, MonoJumpInfoType type, gcons
 
                                g_hash_table_insert (ctx->module->direct_callables, (char*)callee_name, callee);
                        } else {
+                               /* LLVMTypeRef's are uniqued */
+                               if (LLVMGetElementType (LLVMTypeOf (callee)) != llvm_sig)
+                                       return LLVMConstBitCast (callee, LLVMPointerType (llvm_sig, 0));
+
                                g_free (callee_name);
                        }
                        return callee;
@@ -2030,7 +2035,7 @@ emit_cond_system_exception (EmitContext *ctx, MonoBasicBlock *bb, const char *ex
 
                if (!sig)
                        sig = LLVMFunctionType1 (LLVMVoidType (), LLVMInt32Type (), FALSE);
-               callee = get_callee (ctx, sig, MONO_PATCH_INFO_INTERNAL_METHOD, "mono_llvm_throw_corlib_exception");
+               callee = get_callee (ctx, sig, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_llvm_throw_corlib_exception");
 
                LLVMBuildBr (builder, ex2_bb);
 
@@ -3449,7 +3454,7 @@ emit_llvmonly_throw (EmitContext *ctx, MonoBasicBlock *bb, gboolean rethrow, LLV
                LLVMTypeRef fun_sig = LLVMFunctionType1 (LLVMVoidType (), exc_type, FALSE);
 
                if (ctx->cfg->compile_aot) {
-                       callee = get_callee (ctx, fun_sig, MONO_PATCH_INFO_INTERNAL_METHOD, icall_name);
+                       callee = get_callee (ctx, fun_sig, MONO_PATCH_INFO_JIT_ICALL_ADDR, icall_name);
                } else {
                        callee = LLVMAddFunction (ctx->lmodule, icall_name, fun_sig);
                        LLVMAddGlobalMapping (ctx->module->ee, callee, resolve_patch (ctx->cfg, MONO_PATCH_INFO_INTERNAL_METHOD, icall_name));
@@ -5113,7 +5118,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
                        values [ins->dreg] = LLVMBuildLoad (builder, got_entry_addr, name);
                        g_free (name);
                        /* Can't use this in llvmonly mode since the got slots are initialized by the methods themselves */
-                       if (!mono_llvm_only)
+                       if (!cfg->llvm_only)
                                set_invariant_load_flag (values [ins->dreg]);
                        break;
                }
index e0ccf6fac248fc03b4272b40a2338e3864d79204..cee7b4d158da469943cf1fae1f410a8ddd80d39e 100644 (file)
@@ -3710,7 +3710,7 @@ register_icalls (void)
        register_icall (mono_llvm_match_exception, "mono_llvm_match_exception", "int ptr int int", TRUE);
        register_icall (mono_llvm_clear_exception, "mono_llvm_clear_exception", NULL, TRUE);
        register_icall (mono_llvm_load_exception, "mono_llvm_load_exception", "object", TRUE);
-       register_icall (mono_llvm_throw_corlib_exception, "mono_llvm_throw_corlib_exception", "void int", FALSE);
+       register_icall (mono_llvm_throw_corlib_exception, "mono_llvm_throw_corlib_exception", "void int", TRUE);
 #if defined(ENABLE_LLVM) && !defined(MONO_LLVM_LOADED)
        register_icall (mono_llvm_set_unhandled_exception_handler, "mono_llvm_set_unhandled_exception_handler", NULL, TRUE);