Author: lupus
Date: 2007-10-31 14:10:05 -0500 (Wed, 31 Oct 2007)
New Revision: 88602

Modified:
   trunk/mono/mono/mini/mini-x86.c
   trunk/mono/mono/mini/mini.c
Log:


Wed Oct 31 20:23:14 CET 2007 Paolo Molaro <[EMAIL PROTECTED]>

        * mini.c, mini-x86.c: when getting back from unmanaged code
        to managed via a marshaled delegate we also need to set the
        right domain.



Modified: trunk/mono/mono/mini/mini-x86.c
===================================================================
--- trunk/mono/mono/mini/mini-x86.c     2007-10-31 19:04:26 UTC (rev 88601)
+++ trunk/mono/mono/mini/mini-x86.c     2007-10-31 19:10:05 UTC (rev 88602)
@@ -3624,14 +3624,19 @@
        pos = 0;
 
        if (method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) {
-               /* Might need to attach the thread to the JIT */
-               if (lmf_tls_offset != -1) {
-                       guint8 *buf;
+               /* Might need to attach the thread to the JIT  or change the 
domain for the callback */
+               if (appdomain_tls_offset != -1 && lmf_tls_offset != -1) {
+                       guint8 *buf, *no_domain_branch;
 
+                       code = emit_tls_get (code, X86_EAX, 
appdomain_tls_offset);
+                       x86_alu_reg_imm (code, X86_CMP, X86_EAX, 
GPOINTER_TO_UINT (cfg->domain));
+                       no_domain_branch = code;
+                       x86_branch8 (code, X86_CC_NE, 0, 0);
                        code = emit_tls_get ( code, X86_EAX, lmf_tls_offset);
                        x86_test_reg_reg (code, X86_EAX, X86_EAX);
                        buf = code;
                        x86_branch8 (code, X86_CC_NE, 0, 0);
+                       x86_patch (no_domain_branch, code);
                        x86_push_imm (code, cfg->domain);
                        code = emit_call (cfg, code, 
MONO_PATCH_INFO_INTERNAL_METHOD, (gpointer)"mono_jit_thread_attach");
                        x86_alu_reg_imm (code, X86_ADD, X86_ESP, 4);

Modified: trunk/mono/mono/mini/mini.c
===================================================================
--- trunk/mono/mono/mini/mini.c 2007-10-31 19:04:26 UTC (rev 88601)
+++ trunk/mono/mono/mini/mini.c 2007-10-31 19:10:05 UTC (rev 88602)
@@ -9010,6 +9010,8 @@
        if (!TlsGetValue (mono_jit_tls_id))
                mono_thread_attach (domain);
 #endif
+       if (mono_domain_get () != domain)
+               mono_domain_set (domain, TRUE);
 }      
 
 /**

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to