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

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 12 Dec 2003 05:02:44 -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 lupus@ximian.com.


--- shadow/52092	2003-12-12 05:02:43.000000000 -0500
+++ shadow/52092.tmp.26980	2003-12-12 05:02:43.000000000 -0500
@@ -0,0 +1,57 @@
+Bug#: 52092
+Product: Mono/Runtime
+Version: unspecified
+OS: other
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: lupus@ximian.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+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.