February 10, 2004 2:01 pm

Doing the Generics Dance

This week, I started a larger rewrite of the generics support in the Mono runtime. It'll remove a lot of complexity and also reduce memory usage.

Here's a short summary:

  • I'm now trying to get rid of these managed MonoGenericInst, MonoInflatedMethod etc. classes.
  • There's now a new unmanaged MonoGenericMethod type which is used for generic methods and "inflated" methods. Moved some data from the managed MonoInflatedMethod to the unmanaged MonoGenericMethod.
  • We cannot inflate the methods in mono_reflection_bind_generic_parameters() ie. at the time its generic type is instantiated because at this time MCS hasn't defined the methods yet. However, I'm adding a new mono_reflection_generic_inst_initialize() interncall which'll be called the first time someone calls GetMethods(), GetFields() etc. on the type. Then we inflate all methods and fields and store them in special fields in the unmanged MonoGenericInst. This allows us to use something similar to ves_icall_Type_GetMethodsByName() to actually retrieve the methods. This has the big advantage that the methods are only inflated once.
  • I'm not totally sure about this, but most likely, the MonoClass of a generic instance will be very minimal and not contain and information about parent, methods, fields etc. - similar to the one from a type parameter.
Posted by martin at February 10, 2004 2:01 pm.