Browse files

2009-03-05 Mark Probst <mark.probst@gmail.com>

	* mini-trampolines.c (mono_create_jump_trampoline): If the method
	is shared generic code, return the trampoline, even if the method
	has already been compiled.  Fixes #479753.

	* mini.c, mini.h: New function
	mono_jit_find_compiled_method_with_jit_info() which is the same as
	mono_jit_find_compiled_method() but also returns the jit info.

2009-03-05  Mark Probst  <mark.probst@gmail.com>

	* generic-sharing.c (instantiate_other_info): Always return a jump
	trampoline for method code.

2009-03-05  Mark Probst  <mark.probst@gmail.com>

	* bug-479763.2.cs: New test.

	* Makefile.am: Test added.

svn path=/trunk/mono/; revision=128723
  • Loading branch information...
1 parent 41f4dc4 commit 8909dff35e830bd87e75297e05430fe15e2b196c @schani schani committed Mar 5, 2009
View
5 mono/metadata/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-05 Mark Probst <mark.probst@gmail.com>
+
+ * generic-sharing.c (instantiate_other_info): Always return a jump
+ trampoline for method code.
+
2009-03-05 Marek Habersack <mhabersack@novell.com>
* culture-info-tables.h: generated to include the en-tt culture.
View
3 mono/metadata/generic-sharing.c
@@ -813,7 +813,8 @@ instantiate_other_info (MonoDomain *domain, MonoRuntimeGenericContextOtherInfoTe
case MONO_RGCTX_INFO_METHOD:
return data;
case MONO_RGCTX_INFO_GENERIC_METHOD_CODE:
- return mono_compile_method (data);
+ return mono_create_ftnptr (mono_domain_get (),
+ mono_runtime_create_jump_trampoline (mono_domain_get (), data, TRUE));
case MONO_RGCTX_INFO_CLASS_FIELD:
return data;
case MONO_RGCTX_INFO_METHOD_RGCTX: {
View
10 mono/mini/ChangeLog
@@ -1,5 +1,15 @@
2009-03-05 Mark Probst <mark.probst@gmail.com>
+ * mini-trampolines.c (mono_create_jump_trampoline): If the method
+ is shared generic code, return the trampoline, even if the method
+ has already been compiled. Fixes #479753.
+
+ * mini.c, mini.h: New function
+ mono_jit_find_compiled_method_with_jit_info() which is the same as
+ mono_jit_find_compiled_method() but also returns the jit info.
+
+2009-03-05 Mark Probst <mark.probst@gmail.com>
+
* method-to-ir.c (mono_method_to_ir): Only force the vtable var
for methods which actually have one. For all other methods, make
sure the this argument var is live the whole method.
View
9 mono/mini/mini-trampolines.c
@@ -856,8 +856,13 @@ mono_create_jump_trampoline (MonoDomain *domain, MonoMethod *method, gboolean ad
gpointer code;
guint32 code_size = 0;
- code = mono_jit_find_compiled_method (domain, method);
- if (code)
+ code = mono_jit_find_compiled_method_with_jit_info (domain, method, &ji);
+ /*
+ * We cannot recover the correct type of a shared generic
+ * method from its native code address, so we use the
+ * trampoline instead.
+ */
+ if (code && !ji->has_generic_jit_info)
return code;
mono_domain_lock (domain);
View
12 mono/mini/mini.c
@@ -4109,7 +4109,7 @@ mono_jit_free_method (MonoDomain *domain, MonoMethod *method)
}
gpointer
-mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method)
+mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji)
{
MonoDomain *target_domain;
MonoJitInfo *info;
@@ -4124,13 +4124,23 @@ mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method)
/* We can't use a domain specific method in another domain */
if (! ((domain != target_domain) && !info->domain_neutral)) {
mono_jit_stats.methods_lookups++;
+ if (ji)
+ *ji = info;
return info->code_start;
}
}
+ if (ji)
+ *ji = NULL;
return NULL;
}
+gpointer
+mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method)
+{
+ return mono_jit_find_compiled_method_with_jit_info (domain, method, NULL);
+}
+
/**
* mono_jit_runtime_invoke:
* @method: the method to invoke
View
1 mono/mini/mini.h
@@ -1238,6 +1238,7 @@ guint mono_patch_info_hash (gconstpointer data) MONO_INTERNAL;
gint mono_patch_info_equal (gconstpointer ka, gconstpointer kb) MONO_INTERNAL;
MonoJumpInfo *mono_patch_info_list_prepend (MonoJumpInfo *list, int ip, MonoJumpInfoType type, gconstpointer target) MONO_INTERNAL;
gpointer mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors) MONO_INTERNAL;
+gpointer mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji) MONO_INTERNAL;
gpointer mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method) MONO_INTERNAL;
MonoLMF * mono_get_lmf (void) MONO_INTERNAL;
MonoLMF** mono_get_lmf_addr (void) MONO_INTERNAL;
View
6 mono/tests/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-05 Mark Probst <mark.probst@gmail.com>
+
+ * bug-479763.2.cs: New test.
+
+ * Makefile.am: Test added.
+
2009-03-04 Mark Probst <mark.probst@gmail.com>
* Makefile.am: Second part of the erroneous change reverted. I
View
4 mono/tests/Makefile.am
@@ -301,6 +301,7 @@ BASE_TEST_CS_SRC= \
recursive-generics.2.cs \
bug-473482.2.cs \
bug-473999.2.cs \
+ bug-479763.2.cs \
bug-80392.2.cs \
dynamic-method-access.2.cs \
bug-82194.2.cs \
@@ -749,7 +750,8 @@ test-generic-sharing : generics-sharing.2.exe shared-generic-methods.2.exe \
generic-marshalbyref.2.exe bug-459285.2.exe bug-461198.2.exe \
generic-sealed-virtual.2.exe generic-system-arrays.2.exe \
generic-stack-traces.2.exe generic-stack-traces2.2.exe \
- bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe
+ bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe \
+ bug-479763.2.exe
@for fn in $+ ; do \
echo "Testing $$fn ..."; \
MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared $$fn > $$fn.stdout || exit 1; \
View
32 mono/tests/bug-479763.2.cs
@@ -0,0 +1,32 @@
+using System;
+
+public class Foo
+{
+ public event EventHandler Event;
+
+ public void RaiseEvent()
+ {
+ Event(this, new EventArgs());
+ }
+
+ public void AddHandler<T>(string target)
+ {
+ Action<object, EventArgs> fn = (sender, e) => Console.WriteLine(target);
+ EventHandler handler = Delegate.CreateDelegate(typeof(EventHandler),
+ fn.Target, fn.Method) as EventHandler;
+
+ Event += handler;
+ }
+}
+
+public static class Program
+{
+ public static void Main()
+ {
+ var thing = new Foo();
+
+ thing.AddHandler<Type>("hello");
+ thing.RaiseEvent();
+ thing.AddHandler<Type>("there");
+ }
+}

0 comments on commit 8909dff

Please sign in to comment.