[Mono-bugs] [Bug 52092][Nor] New - ldftn must not compile the method

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Sat, 14 Feb 2004 08:35:54 -0500 (EST)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by vargaz@freemail.hu.

http://bugzilla.ximian.com/show_bug.cgi?id=52092

--- shadow/52092	2004-02-14 08:35:54.000000000 -0500
+++ shadow/52092.tmp.23466	2004-02-14 08:35:54.000000000 -0500
@@ -0,0 +1,60 @@
+Bug#: 52092
+Product: Mono/Runtime
+Version: unspecified
+OS: other
+OS Details: 
+Status: RESOLVED   
+Resolution: FIXED
+Severity: Unknown
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: ldftn must not compile the method
+
+This test case:
+using System;
+
+class A {
+	static A () {
+		Console.WriteLine ("In A cctor");
+	}
+	public static void method () {
+		Console.WriteLine ("In A method");
+	}
+}
+
+delegate void DoIt ();
+
+class B {
+	static void Main () {
+		DoIt d = new DoIt (A.method);
+		Console.WriteLine ("Created delegate");
+		d ();
+		Console.WriteLine ("Invoked delegate");
+	}
+}
+
+prints (in mono):
+In A cctor
+Created delegate
+In A method
+Invoked delegate
+while it should print:Created delegate
+In A cctor
+In A method
+Invoked delegate
+
+The error is because we assume that a method is compiled just in time when
+it's first invoked and it that context we need to run the class cctor.
+But ldftn currently cause the method to be compiled even if it's not run
+until later.
+We need to use for ldftn the same mechanism used for tail calls: a jump
+trampoline is created that simply invokes the method.
+
+------- Additional Comments From vargaz@freemail.hu  2004-02-14 08:35 -------
+Fixed in CVS.