[Mono-bugs] [Bug 325495] arrays don' t appear to be implementing all the generic interfaces in 2.0

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Sep 28 12:42:47 EDT 2007


Paolo Molaro <lupus at novell.com> changed:

           What    |Removed                                         |Added
            Summary|Mono crashes with                               |arrays don't appear to be implementing all the
                   |(mono_convert_imt_slot_to_vtable_slot):         |generic interfaces in 2.0
                   |assertion failed: (vtable_offset >= 0)          |

--- Comment #5 from Paolo Molaro <lupus at novell.com>  2007-09-28 10:42:46 MST ---
I made some changes in sn to support this, but it's not enabled yet (search for
ARRAY_IFACES_NUM in metadata/class.c).
The basic issue is this: let's say a class A implements 3 interfaces. A[] needs
to implement IList`1, ICollection`1 and IEnumerable`1 with A and all its
interfaces as a generic type argument, so in the end A[] implements 15
interfaces (this is assuming A derived directly from object, otherwise there
are even more).
Now consider A[][]: it needs to implement the generic interfaces for all the
interfaces supported by A[]. This causes a quick explosion on the number of
implemented interfaces and related data structures the runtime must maintain.
In svn I fixed a few easy offenders: for a simple program Ironpython now has a
15% smaller corlib mempool, but there are many that need fixing yet. I'll try
to list here the ones that come to mind.
Each interface gets assigned a different offset in the vtable for the type and
for each interface method we inflate the corresponding MonoMethod and
additionally we create a wrapper MonoMethod to invoke the real implementation.
First we should get rid of the wrappers as they don't have a real purpose but
to appear in the stacktraces with a somewhat helpful name.
Then we should consider assigning all the compatible interfaces the same offset
in the vtable: this way the array type vtable would be C + interface_methods
instead of C + interface_methods * num_interfaces. These two changes should be
doable without too much pain.
With those changes we'll still have to manage the number of MonoClass generated
to represent the interfaces: I don't have a proposal for a solution in this
A related improvement that is also generally useful would be to lazy-init the
IMT table (we also waste a lot of memory in it because we build the complete
thunks for all the types right away): in practice we set the imt slots to a
magic trampoline (which is unique process-wise, so the memory usage doesn't
depend on the number of methods implemented by a type) which when invoked will
build the complete thunk for just the one slot. As an example the same
ironpython proram uses currently 191 KB of IMT thunks, 260 KB with all the
array interfaces enabled. I'll likely work on this item next.

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list