[Mono-devel-list] [PATCH] Remove static and non-virtual methods from the VTable

Ben Maurer bmaurer at users.sourceforge.net
Sat Mar 13 11:47:41 EST 2004

As I understand it, the following code takes care of this:

> void 
> mini_emit_virtual_call (MonoCompile *cfg, void *st, MonoInst *tree, int novirtop, int virtop)
> {
> ...
> 	if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) || 
> 	    ((method->flags & METHOD_ATTRIBUTE_FINAL) && 
> 	     method->wrapper_type != MONO_WRAPPER_REMOTING_INVOKE_WITH_CHECK)) {
> 		/* 
> 		 * the method is not virtual, we just need to ensure this is not null
> 		 * and then we can call the method directly.
> 		 */
> 		if (method->klass->marshalbyref || method->klass == mono_defaults.object_class) {
> 			method = ((MonoCallInst*)tree)->method = mono_marshal_get_remoting_invoke_with_check (method);
> 		}

When I ran the mono test suite, the first remoting test passed. The
second two failed before my patch was in place, and still failed. The
first one seems to test what you are talking about.

Like you, I do not claim to be an expert in this area. I would love if
lupus or Lluis would chime in here :-).

As I said on IRC, this patch seemed too small to be true, so i would not
be supprised if i am doing something wrong.

-- Ben

On Sat, 2004-03-13 at 11:31, Jonathan Pryor wrote:
> On Sat, 2004-03-13 at 00:12, Ben Maurer wrote:
> <snip/>
> > * class.c : do not include static or non-virtual methods in the vtable.
> I could be completely wrong, but how do you handle remoting?
> AFAIK, .NET remoting is handled by giving a TransparentProxy object to
> the client code, instead of a reference to the actual object (as the
> actual object may be in a different process, etc.).  The
> TransparentProxy is special, in that it can be cast to any interface and
> any object, and it delegates function calls to a RealProxy, which
> handles communication with the actual object, wherever it may be.
> The key point to this, though, is that you can't directly invoke any
> methods on any class deriving from MarshalByRefObject, unless you KNOW
> it's in the same AppDomain you're in.  As such, all function calls on a
> MarshalByRefObject subclass are typically virtual, so that the
> TransparentProxy can intercept the method call and delegate it to the
> RealProxy appropriately.
> So if you remove all non-virtual functions from the vtable, how will
> this interact with Remoting?  With your patch, non-virtual methods won't
> have a vtable slot, so the TransparentProxy won't be able to intercept
> the invocation, breaking remoting behavior.
> Granted, I could be mis-understanding this (I'm no remoting expert), but
> this is my current understanding.
>  - Jon
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list

More information about the Mono-devel-list mailing list