Author: lupus
Date: 2006-05-23 06:36:55 -0400 (Tue, 23 May 2006)
New Revision: 60986

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/marshal.c
   trunk/mono/mono/metadata/marshal.h
Log:


Tue May 23 12:33:24 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>

        * marshal.h, marshal.c: added write barrier wrapper and precise type
        fixes.



Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2006-05-23 10:33:10 UTC (rev 60985)
+++ trunk/mono/mono/metadata/ChangeLog  2006-05-23 10:36:55 UTC (rev 60986)
@@ -1,4 +1,9 @@
 
+Tue May 23 12:33:24 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
+
+       * marshal.h, marshal.c: added write barrier wrapper and precise type
+       fixes.
+
 Tue May 23 12:31:22 CEST 2006 Paolo Molaro <[EMAIL PROTECTED]>
 
        * object.h, null-gc.c, boehm-gc.c: more write barrier functions and

Modified: trunk/mono/mono/metadata/marshal.c
===================================================================
--- trunk/mono/mono/metadata/marshal.c  2006-05-23 10:33:10 UTC (rev 60985)
+++ trunk/mono/mono/metadata/marshal.c  2006-05-23 10:36:55 UTC (rev 60986)
@@ -230,6 +230,7 @@
                register_icall (mono_context_set, "mono_context_set", "void 
object", FALSE);
                register_icall (mono_upgrade_remote_class_wrapper, 
"mono_upgrade_remote_class_wrapper", "void object object", FALSE);
                register_icall (type_from_handle, "type_from_handle", "object 
ptr", FALSE);
+               register_icall (mono_gc_wbarrier_generic_store, "wb_generic", 
"void ptr object", FALSE);
        }
 }
 
@@ -3673,7 +3674,7 @@
        mono_mb_emit_byte (mb, 3);      
        mono_mb_emit_byte (mb, CEE_LDARG_2);
        mono_mb_emit_byte (mb, CEE_LDNULL);
-       mono_mb_emit_byte (mb, CEE_STIND_I);
+       mono_mb_emit_byte (mb, CEE_STIND_REF);
 
        emit_thread_force_interrupt_checkpoint (mb);
 
@@ -3829,7 +3830,7 @@
        
        mono_mb_emit_byte (mb, CEE_LDARG_2);
        mono_mb_emit_ldloc (mb, 1);
-       mono_mb_emit_byte (mb, CEE_STIND_I);
+       mono_mb_emit_byte (mb, CEE_STIND_REF);
 
        mono_mb_emit_byte (mb, CEE_LDNULL);
        mono_mb_emit_stloc (mb, 0);
@@ -7708,6 +7709,46 @@
        return ret;
 }
 
+MonoMethod*
+mono_marshal_get_write_barrier (void)
+{
+       static MonoMethod* ret = NULL;
+       MonoMethodSignature *sig;
+       MonoMethodBuilder *mb;
+       int max_stack = 2;
+
+       if (ret)
+               return ret;
+       
+       mb = mono_mb_new (mono_defaults.object_class, "writebarrier", 
MONO_WRAPPER_WRITE_BARRIER);
+
+       sig = mono_metadata_signature_alloc (mono_defaults.corlib, 2);
+
+       /* void writebarrier (MonoObject** addr, MonoObject* obj) */
+       sig->ret = &mono_defaults.void_class->byval_arg;
+       sig->params [0] = &mono_defaults.object_class->this_arg;
+       sig->params [1] = &mono_defaults.object_class->byval_arg;
+
+       /* just the store right now: add an hook for the GC to use, maybe 
something
+        * that can be used for stelemref as well
+        * We need a write barrier variant to be used with struct copies as 
well, though
+        * there are also other approaches possible, like writing a wrapper 
specific to
+        * the struct or to the reference pattern in the struct...
+        * Depending on the GC, we may want variants that take the object we 
store to
+        * when it is available.
+        */
+       mono_mb_emit_ldarg (mb, 0);
+       mono_mb_emit_ldarg (mb, 1);
+       mono_mb_emit_icall (mb, mono_gc_wbarrier_generic_store);
+       /*mono_mb_emit_byte (mb, CEE_STIND_REF);*/
+
+       mono_mb_emit_byte (mb, CEE_RET);
+
+       ret = mono_mb_create_method (mb, sig, max_stack);
+       mono_mb_free (mb);
+       return ret;
+}
+
 void*
 mono_marshal_alloc (gulong size)
 {

Modified: trunk/mono/mono/metadata/marshal.h
===================================================================
--- trunk/mono/mono/metadata/marshal.h  2006-05-23 10:33:10 UTC (rev 60985)
+++ trunk/mono/mono/metadata/marshal.h  2006-05-23 10:36:55 UTC (rev 60986)
@@ -90,6 +90,9 @@
 void
 mono_marshal_free_asany (MonoObject *o, gpointer ptr, MonoMarshalNative 
string_encoding, int param_attrs);
 
+MonoMethod*
+mono_marshal_get_write_barrier (void);
+
 /* method builder functions */
 
 void

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

Reply via email to