[Mono-dev] Optimization 'precomp' violates ECMA-335
Rodrigo Kumpera
kumpera at gmail.com
Thu Jan 19 17:20:36 UTC 2012
Precomp is a non standard optimization for this precise reason.
Please file a bug report on the issue. I believe making it spec compliant
would be nice
but non-trivial. So, if you feel like you need it, feel free to submit a
patch.
On Thu, Jan 19, 2012 at 2:37 PM, Martin Däumler <mdae at cs.tu-chemnitz.de>wrote:
> Hello,
>
> I tried out several optimizations of Mono 2.6.1 and Mono 2.10.8.1.
> So I used "-O=precomp". The class 'Test' of the appended test case
> has an (explicit) class constructor. That is, in class Test's IL-code,
> the field "beforefieldinit" is not set. ECMA-335 §8.9.5 states that
> the class constructor is executed at first access to any static member
> of that class or at first creation of one instance of that class, as
> I understood it. When I execute the program with Mono 2.6.1 and the
> optimization "-O=precomp", class Test's class constructor is executed
> before first access. Even worse, Mono 2.10.8.1 crashes while
> precompiling.
>
> So, what have do be done in order to don't violate the specification?
> How is it handled in AOT-mode?
>
>
> With kind regards,
> Martin Däumler
>
>
>
> using System;
>
> class Test
> {
> public static string x;
>
> static Test ()
> {
> Console.WriteLine("In type initializer");
> x = "In type initializer";
> }
>
> public static string EchoAndReturn (string s)
> {
> Console.WriteLine (s);
> return s;
> }
> }
>
> class Driver
> {
> public static void Main()
> {
> Console.WriteLine("Starting Main");
> // Invoke a static method on Test
> Test.EchoAndReturn("Echo!");
> Console.WriteLine("After echo");
> // Reference a static field in Test
> string y = Test.x;
> // Use the value just to avoid compiler cleverness
> if (y != null)
> {
> Console.WriteLine("After field access");
> }
> }
> }
> ______________________________**_________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.**com <Mono-devel-list at lists.ximian.com>
> http://lists.ximian.com/**mailman/listinfo/mono-devel-**list<http://lists.ximian.com/mailman/listinfo/mono-devel-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20120119/7b901a55/attachment.html>
More information about the Mono-devel-list
mailing list