[jit] Add a new jit icall mono_interruption_checkpoint_from_trampoline () and use...
authorZoltan Varga <vargaz@gmail.com>
Tue, 26 Jan 2016 22:49:01 +0000 (17:49 -0500)
committerZoltan Varga <vargaz@gmail.com>
Tue, 26 Jan 2016 22:49:01 +0000 (17:49 -0500)
mono/mini/aot-runtime.c
mono/mini/jit-icalls.c
mono/mini/jit-icalls.h
mono/mini/mini-runtime.c
mono/mini/tramp-arm.c
mono/mini/tramp-ia64.c
mono/mini/tramp-sparc.c
mono/mini/tramp-x86.c

index 09e4b47943e1b6879a9e160fbeb61e61ba175cc5..50b07f61363609703b8d919cf2350c89ac23c9ae 100644 (file)
@@ -61,6 +61,7 @@
 #include "version.h"
 #include "debugger-agent.h"
 #include "aot-compiler.h"
+#include "jit-icalls.h"
 
 #ifndef DISABLE_AOT
 
@@ -4864,6 +4865,8 @@ load_function_full (MonoAotModule *amodule, const char *name, MonoTrampInfo **ou
                                        target = mono_thread_force_interruption_checkpoint;
                                } else if (!strcmp (ji->data.name, "mono_thread_force_interruption_checkpoint_noraise")) {
                                        target = mono_thread_force_interruption_checkpoint_noraise;
+                               } else if (!strcmp (ji->data.name, "mono_interruption_checkpoint_from_trampoline")) {
+                                       target = mono_interruption_checkpoint_from_trampoline;
                                } else if (!strcmp (ji->data.name, "mono_exception_from_token")) {
                                        target = mono_exception_from_token;
                                } else if (!strcmp (ji->data.name, "mono_throw_exception")) {
index 83603d75367601a16901b5f5b46e19451d7c6488..797a1f19d7f6a9be71fe937bb93c3cb87eac71fd 100644 (file)
@@ -18,6 +18,7 @@
 
 #include "jit-icalls.h"
 #include <mono/utils/mono-error-internals.h>
+#include <mono/metadata/threads-types.h>
 
 #ifdef ENABLE_LLVM
 #include "mini-llvm-cpp.h"
@@ -1717,3 +1718,22 @@ mono_llvmonly_get_calling_assembly (void)
                mono_raise_exception (mono_get_exception_not_supported ("Stack walks are not supported on this platform."));
        return (MonoObject*)mono_assembly_get_object (mono_domain_get (), jit_tls->calling_image->assembly);
 }
+
+/*
+ * mono_interruption_checkpoint_from_trampoline:
+ *
+ *   Check whenever the thread has a pending exception, and throw it
+ * if needed.
+ * Architectures should move away from calling this function and
+ * instead call mono_thread_force_interruption_checkpoint_noraise (),
+ * rewrind to the parent frame, and throw the exception normally.
+ */
+void
+mono_interruption_checkpoint_from_trampoline (void)
+{
+       MonoException *ex;
+
+       ex = mono_thread_force_interruption_checkpoint_noraise ();
+       if (ex)
+               mono_raise_exception (ex);
+}
index e0f4172d03a887809408d1a5d85e74c49966d1b0..b5fad095722ffe1a06e5d8d84b1fbb4e7fdd2710 100644 (file)
@@ -186,6 +186,8 @@ mono_object_castclass_with_cache (MonoObject *obj, MonoClass *klass, gpointer *c
 void
 mono_generic_class_init (MonoVTable *vtable);
 
+void mono_interruption_checkpoint_from_trampoline (void);
+
 MonoObject*
 mono_gsharedvt_constrained_call (gpointer mp, MonoMethod *cmethod, MonoClass *klass, gboolean deref_arg, gpointer *args);
 
index c7270e2a8ec311f47d68d912de9746cb29895a65..a16063cb2d27920d24bac76e1492efbc4cfd5b4b 100644 (file)
@@ -3714,7 +3714,6 @@ register_icalls (void)
        register_icall (mono_thread_get_undeniable_exception, "mono_thread_get_undeniable_exception", "object", FALSE);
        register_icall (mono_thread_interruption_checkpoint, "mono_thread_interruption_checkpoint", "object", FALSE);
        register_icall (mono_thread_force_interruption_checkpoint_noraise, "mono_thread_force_interruption_checkpoint_noraise", "object", FALSE);
-       register_icall (mono_thread_force_interruption_checkpoint, "mono_thread_force_interruption_checkpoint", "void", FALSE);
 #ifndef DISABLE_REMOTING
        register_icall (mono_load_remote_field_new, "mono_load_remote_field_new", "object object ptr ptr", FALSE);
        register_icall (mono_store_remote_field_new, "mono_store_remote_field_new", "void object ptr ptr object", FALSE);
index 311a30c0f935b7f6e10efc6654dd32940bd78013..2edff4e901ad226d40dd9fbd04b74acc9b2a8249 100644 (file)
@@ -379,7 +379,7 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
         * Have to call the _force_ variant, since there could be a protected wrapper on the top of the stack.
         */
        if (aot) {
-               ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
+               ji = mono_patch_info_list_prepend (ji, code - buf, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_interruption_checkpoint_from_trampoline");
                ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
                ARM_B (code, 0);
                *(gpointer*)code = NULL;
@@ -389,11 +389,11 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
 #ifdef USE_JUMP_TABLES
                gpointer *jte = mono_jumptable_add_entry ();
                code = mono_arm_load_jumptable_entry (code, jte, ARMREG_IP);
-               jte [0] = mono_thread_force_interruption_checkpoint;
+               jte [0] = mono_interruption_checkpoint_from_trampoline;
 #else
                ARM_LDR_IMM (code, ARMREG_IP, ARMREG_PC, 0);
                ARM_B (code, 0);
-               *(gpointer*)code = mono_thread_force_interruption_checkpoint;
+               *(gpointer*)code = mono_interruption_checkpoint_from_trampoline;
                code += 4;
 #endif
        }
index 2b4af7f8fe2ac613acd6667519fa76134d17d8a0..cbcec80e1a6622214fa8712d0edf3d436568e52b 100644 (file)
@@ -256,7 +256,7 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
        /* This is not perf critical code so no need to check the interrupt flag */
        ia64_mov (code, l2, IA64_R8);
 
-       tramp = (guint8*)mono_thread_force_interruption_checkpoint;
+       tramp = (guint8*)mono_interruption_checkpoint_from_trampoline;
        ia64_movl (code, l0, tramp);
        ia64_ld8_inc_imm (code, l1, l0, 8);
        ia64_mov_to_br (code, IA64_B6, l1);
index 99143b723b30291f156655b305b3bc19b4135f81..095d1b180b7aa9bf351abef06242f0c939e2cb57 100644 (file)
@@ -170,7 +170,7 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
        sparc_sti_imm (code, sparc_o0, sparc_sp, MONO_SPARC_STACK_BIAS + 304);
 
        /* Check for thread interruption */
-       sparc_set (code, (guint8*)mono_thread_force_interruption_checkpoint, sparc_o7);
+       sparc_set (code, (guint8*)mono_interruption_checkpoint_from_trampoline, sparc_o7);
        sparc_jmpl (code, sparc_o7, sparc_g0, sparc_o7);
        sparc_nop (code);
 
index 2b4475f0a67e929629a8b46cee381cf8e911c365..acf826f617f97217676d916468278f0c6acc98b1 100644 (file)
@@ -378,10 +378,10 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf
 
        /* Check for interruptions */
        if (aot) {
-               code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_thread_force_interruption_checkpoint");
+               code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_interruption_checkpoint_from_trampoline");
                x86_call_reg (code, X86_EAX);
        } else {
-               x86_call_code (code, (guint8*)mono_thread_force_interruption_checkpoint);
+               x86_call_code (code, (guint8*)mono_interruption_checkpoint_from_trampoline);
        }
 
        /* Restore LMF */