[Mono-bugs] [Bug 44229][Nor] Changed - mcs does not set beforefieldinit

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 12 Sep 2003 09:35:35 -0400 (EDT)

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.


--- shadow/44229	2003-09-12 09:27:51.000000000 -0400
+++ shadow/44229.tmp.790	2003-09-12 09:35:35.000000000 -0400
@@ -78,6 +78,33 @@
 Setting this to NEEDINFO.
 ------- Additional Comments From vargaz@freemail.hu  2003-09-12 09:27 -------
 *** Bug 48428 has been marked as a duplicate of this bug. ***
+------- Additional Comments From vargaz@freemail.hu  2003-09-12 09:35 -------
+I think beforefieldinit means 'it's ok to initialize the type sometime 
+before its static fields are used', i.e. initialization does not need
+to be triggered by the first access to the type. Setting this flag
+helps the JIT to compile better code, since it can run the static
+constructor at JIT time, and does not need to generate code to call it
+(possibly lots of times) at runtime. Unfortunately, mcs does not set
+this flag for lots of classes like String. 
+csc sets this flag if the type does not have an explicit static 
+constructor. The reasoning seems to be that if there are only static
+initalizers for a type, and no static constructor, then the programmer
+does not care when this initialization happens, so beforefieldinit
+can be used.
+This bug prevents the AOT compiler from being usable, since it 
+generates so many calls to mono_runtime_class_init that the AOT code
+is much slower than the JITted code. The JITted code is faster, 
+because it does not generate these calls if the vtable is type is
+already initialized, which is true in the majority of cases. But the
+AOT compiler can't do this.