[Mono-dev] AOT and generics

2012-07-06 Thread Virgile Bello
During full AOT, It seems that if generics is a ref type, AOT is skipped
(which makes sense because most of the time it is not necessary, one
codegen for any ref type is usually enough).
However, if the class internally uses a struct based on the generic types,
it will fail at runtime.
Here is a simple example showcasing the issue:

public class B
{
public void TestT()
{
System.Console.WriteLine(typeof(T));
}
}

public class AT
{
public void Test()
{
new B().TestSystem.Collections.Generic.KeyValuePairT, T();
}
}


class P
{
static void Main(string[] args)
{
new Aint().Test();
new Astring().Test();
}
}

If I run this program with full aot, it will fail.
new Aint will work (AOT forced because value type)
However, new Astring will generate a JIT exception (because even though
string is a ref type, A should be AOT for this specific type because
KeyValuePair inside AT needs to be JITed.)

But maybe I misunderstood the problem (or it is just a specific bug),
because this other case actually work (I was expecting it to have the same
issue):

public class B
{
public void TestT()
{

System.Console.WriteLine(typeof(System.Collections.Generic.KeyValuePairT,
T));
}
}

public class AT
{
public void Test()
{
new B().TestT();
}
}


class P
{
static void Main(string[] args)
{
new Aint().Test();
new Astring().Test();
}
}

Just wanted to check if I understood the issue right and if there would be
nothing preventing from fixing it?
I wouldn't mind taking a look at the sources by myself if necessary.

Virgile
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT and generics

2012-07-06 Thread Rodrigo Kumpera
You need to correctly drive the FullAOT compiler.
Why do you want to use FullAOT anyway?
Do you plan to run it on a target that disables JIT?
Do you hold a license that allows you to do so? Mono is LGPL and FullAOT
doesn't work with it.

On Fri, Jul 6, 2012 at 9:29 AM, Virgile Bello virgile.be...@gmail.comwrote:

 During full AOT, It seems that if generics is a ref type, AOT is skipped
 (which makes sense because most of the time it is not necessary, one
 codegen for any ref type is usually enough).
 However, if the class internally uses a struct based on the generic types,
 it will fail at runtime.
 Here is a simple example showcasing the issue:

 public class B
 {
 public void TestT()
 {
 System.Console.WriteLine(typeof(T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestSystem.Collections.Generic.KeyValuePairT, T();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 If I run this program with full aot, it will fail.
 new Aint will work (AOT forced because value type)
 However, new Astring will generate a JIT exception (because even though
 string is a ref type, A should be AOT for this specific type because
 KeyValuePair inside AT needs to be JITed.)

 But maybe I misunderstood the problem (or it is just a specific bug),
 because this other case actually work (I was expecting it to have the same
 issue):

 public class B
 {
 public void TestT()
 {

 System.Console.WriteLine(typeof(System.Collections.Generic.KeyValuePairT,
 T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestT();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 Just wanted to check if I understood the issue right and if there would be
 nothing preventing from fixing it?
 I wouldn't mind taking a look at the sources by myself if necessary.

 Virgile


 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list


___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT and generics

2012-07-06 Thread Virgile Bello
It would be for platforms supporting only AOT.
Of course we would license Mono. We already had a quick discussion about
licensing maybe a year ago (it's still RD/proof of concept for now, and it
was only Windows until now so we just delayed actual deal until necessary),
but thanks for pointing out, maybe now is a good time to start the
discussion again with Xamarin, I will send an email right away.

On Fri, Jul 6, 2012 at 10:31 PM, Rodrigo Kumpera kump...@gmail.com wrote:

 You need to correctly drive the FullAOT compiler.
 Why do you want to use FullAOT anyway?
 Do you plan to run it on a target that disables JIT?
 Do you hold a license that allows you to do so? Mono is LGPL and FullAOT
 doesn't work with it.

 On Fri, Jul 6, 2012 at 9:29 AM, Virgile Bello virgile.be...@gmail.comwrote:

 During full AOT, It seems that if generics is a ref type, AOT is skipped
 (which makes sense because most of the time it is not necessary, one
 codegen for any ref type is usually enough).
 However, if the class internally uses a struct based on the generic
 types, it will fail at runtime.
 Here is a simple example showcasing the issue:

 public class B
 {
 public void TestT()
 {
 System.Console.WriteLine(typeof(T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestSystem.Collections.Generic.KeyValuePairT, T();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 If I run this program with full aot, it will fail.
 new Aint will work (AOT forced because value type)
 However, new Astring will generate a JIT exception (because even though
 string is a ref type, A should be AOT for this specific type because
 KeyValuePair inside AT needs to be JITed.)

 But maybe I misunderstood the problem (or it is just a specific bug),
 because this other case actually work (I was expecting it to have the same
 issue):

 public class B
 {
 public void TestT()
 {

 System.Console.WriteLine(typeof(System.Collections.Generic.KeyValuePairT,
 T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestT();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 Just wanted to check if I understood the issue right and if there would
 be nothing preventing from fixing it?
 I wouldn't mind taking a look at the sources by myself if necessary.

 Virgile


 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list



___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT and generics

2012-07-06 Thread Rodrigo Kumpera
The FullAOT compiler handles generics by compiling a single shared instance
for all ref-only type arguments.
so Listobject shares code with Liststring but Listint gets its own
version. This is the default behavior.

If this is not the case, then you have something broken in your setup.


On Fri, Jul 6, 2012 at 11:24 AM, Virgile Bello virgile.be...@gmail.comwrote:

 It would be for platforms supporting only AOT.
 Of course we would license Mono. We already had a quick discussion about
 licensing maybe a year ago (it's still RD/proof of concept for now, and it
 was only Windows until now so we just delayed actual deal until necessary),
 but thanks for pointing out, maybe now is a good time to start the
 discussion again with Xamarin, I will send an email right away.


 On Fri, Jul 6, 2012 at 10:31 PM, Rodrigo Kumpera kump...@gmail.comwrote:

 You need to correctly drive the FullAOT compiler.
 Why do you want to use FullAOT anyway?
 Do you plan to run it on a target that disables JIT?
 Do you hold a license that allows you to do so? Mono is LGPL and FullAOT
 doesn't work with it.

 On Fri, Jul 6, 2012 at 9:29 AM, Virgile Bello virgile.be...@gmail.comwrote:

 During full AOT, It seems that if generics is a ref type, AOT is skipped
 (which makes sense because most of the time it is not necessary, one
 codegen for any ref type is usually enough).
 However, if the class internally uses a struct based on the generic
 types, it will fail at runtime.
 Here is a simple example showcasing the issue:

 public class B
 {
 public void TestT()
 {
 System.Console.WriteLine(typeof(T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestSystem.Collections.Generic.KeyValuePairT, T();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 If I run this program with full aot, it will fail.
 new Aint will work (AOT forced because value type)
 However, new Astring will generate a JIT exception (because even
 though string is a ref type, A should be AOT for this specific type because
 KeyValuePair inside AT needs to be JITed.)

 But maybe I misunderstood the problem (or it is just a specific bug),
 because this other case actually work (I was expecting it to have the same
 issue):

 public class B
 {
 public void TestT()
 {

 System.Console.WriteLine(typeof(System.Collections.Generic.KeyValuePairT,
 T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestT();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 Just wanted to check if I understood the issue right and if there would
 be nothing preventing from fixing it?
 I wouldn't mind taking a look at the sources by myself if necessary.

 Virgile


 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list




___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] AOT and generics

2012-07-06 Thread Virgile Bello
Thanks for the confirmation, that's what I could guess as well (one shared
code for every ref instance).
However, in that case, I can't think of any way this code can run because
for every ref type in A, the method B::TestXT() will need to be
generated (X being a struct -- it's just like bringing a non-shareable
struct type into the shared generic instance). Basically, if the class is
requested with T, if it has any method call depending on T, they should be
generated. It seems to actually be done if B::TestT is called but not
B::TestXT. There might be some other related cases as well (when
bringing a struct into a generic type). That's why I was suggesting sharing
might be problematic in this case, I will take a look at the code to have a
better idea of it.

Also, I will double check my setup, but it pretty seems standard (other AOT
stuff works fine, experimenting under linux x64).
Anyway, I will fill a bug to not pollute the mailing list too much.

Virgile

On Fri, Jul 6, 2012 at 11:39 PM, Rodrigo Kumpera kump...@gmail.com wrote:

 The FullAOT compiler handles generics by compiling a single shared
 instance for all ref-only type arguments.
 so Listobject shares code with Liststring but Listint gets its own
 version. This is the default behavior.

 If this is not the case, then you have something broken in your setup.


 On Fri, Jul 6, 2012 at 11:24 AM, Virgile Bello virgile.be...@gmail.comwrote:

 It would be for platforms supporting only AOT.
 Of course we would license Mono. We already had a quick discussion about
 licensing maybe a year ago (it's still RD/proof of concept for now, and it
 was only Windows until now so we just delayed actual deal until necessary),
 but thanks for pointing out, maybe now is a good time to start the
 discussion again with Xamarin, I will send an email right away.


 On Fri, Jul 6, 2012 at 10:31 PM, Rodrigo Kumpera kump...@gmail.comwrote:

 You need to correctly drive the FullAOT compiler.
 Why do you want to use FullAOT anyway?
 Do you plan to run it on a target that disables JIT?
 Do you hold a license that allows you to do so? Mono is LGPL and FullAOT
 doesn't work with it.

 On Fri, Jul 6, 2012 at 9:29 AM, Virgile Bello 
 virgile.be...@gmail.comwrote:

 During full AOT, It seems that if generics is a ref type, AOT is
 skipped (which makes sense because most of the time it is not necessary,
 one codegen for any ref type is usually enough).
 However, if the class internally uses a struct based on the generic
 types, it will fail at runtime.
 Here is a simple example showcasing the issue:

 public class B
 {
 public void TestT()
 {
 System.Console.WriteLine(typeof(T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestSystem.Collections.Generic.KeyValuePairT, T();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 If I run this program with full aot, it will fail.
 new Aint will work (AOT forced because value type)
 However, new Astring will generate a JIT exception (because even
 though string is a ref type, A should be AOT for this specific type because
 KeyValuePair inside AT needs to be JITed.)

 But maybe I misunderstood the problem (or it is just a specific bug),
 because this other case actually work (I was expecting it to have the same
 issue):

 public class B
 {
 public void TestT()
 {

 System.Console.WriteLine(typeof(System.Collections.Generic.KeyValuePairT,
 T));
 }
 }

 public class AT
 {
 public void Test()
 {
 new B().TestT();
 }
 }


 class P
 {
 static void Main(string[] args)
 {
 new Aint().Test();
 new Astring().Test();
 }
 }

 Just wanted to check if I understood the issue right and if there would
 be nothing preventing from fixing it?
 I wouldn't mind taking a look at the sources by myself if necessary.

 Virgile


 ___
 Mono-devel-list mailing list
 Mono-devel-list@lists.ximian.com
 http://lists.ximian.com/mailman/listinfo/mono-devel-list





___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list