[Mono-list] Static constructor issue
massi at ximian.com
Fri Sep 8 01:03:16 EDT 2006
On Thu, 2006-09-07 at 22:00 -0400, Jonathan Pryor wrote:
> beforefieldinit is a performance advantage: it allows the JIT inliner to
> invoke the static constructor during JIT time, instead of needing to
> delay static constructor invocation until just before a member is
> accessed. It's also useful for --aot code, as the initialization
> performed by the static constructor could be cached (in some principal)
> within the AOT code.
The (sad) truth is that apparently the MS runtime does not take
of this fact.
Our runtime did, but when inline was enabled by default in the Mono JIT,
many programs which depended on the order in which .cctors were executed
started showing a different behavior in the two runtimes.
Of course, this different behavior was perceived as a Mono bug
by the inline optimization, even if it was perfectly standard compliant
and it was the program that was at fault, using the wrong
To make a long story short, we now behave like the MS runtime so that
developers have their life easier...
> If the `Pixbuf' constructor requires that Gtk# be initialized, this use
> _may_ fail if the Foo static constructor is invoked before Gtk# is
> initialized. This will be hell to debug. :-/
These are the sort of things that happened (and were debugged) when we
enabled inline by default.
More information about the Mono-list