[Mono-devel-list] Cross application domain call optimization

Ben Maurer bmaurer at ximian.com
Sun Oct 17 11:49:56 EDT 2004


Some more comments.

> +typedef enum {
> +	MONO_MARSHAL_NONE,			/* No marshalling needed */
> +	MONO_MARSHAL_COPY,			/* Can be copied by value to the new domain */
> +	MONO_MARSHAL_COPY_OUT,		/* out parameter that needs to be copied back to the original instance */
> +	MONO_MARSHAL_SERIALIZE		/* Value needs to be serialized into the new domain */
> +} MonoXDomainMarshalType;

Trivial style thing: you need to use spaces not tabs between the comma
and the beginning of the comment. Things get unaligned with different
tab sizes.

> +	case MONO_TYPE_VOID:
> +		g_assert_not_reached ();
> +		break;
No break needed here.

> +	case MONO_TYPE_R8:
> +		val = mono_object_clone (val);
> +		val->vtable = mono_class_vtable (domain, val->vtable->klass);

This isn't correct. If the object is not in the default app domain, we
will not use the gcj gc alloc for correctness reasons. However, by
creating the object and switching the vtable, you violate this
assumption.




> +	for (i = 0; i <= sig->param_count; i++)
> +		mono_mb_emit_ldarg (mb, i);
> ...
> +	if (mono_marshal_supports_fast_xdomain (method)) {
> +	...
> +		mono_mb_emit_managed_call (mb, native, native->signature);
> +		mono_mb_emit_byte (mb, CEE_RET);
> +		...
> +	}
> +	/* wrapper for normal remote calls */
> +	...
> +	mono_mb_emit_managed_call (mb, native, native->signature);
> +	mono_mb_emit_byte (mb, CEE_RET);
> +...
> +	mono_mb_emit_managed_call (mb, method, method->signature);
> +	mono_mb_emit_byte (mb, CEE_RET);

Rather than loading the args and doing managed calls, you should really
do CEE_JMP. It is smaller (because you dont push the args on the stack
either in IL or native code), and faster (jmp is faster than call).

[nb: you cant do this without removing the wrapper indirection stuff.
However, the indirection stuff should be done with a trampoline, if we
do it at all, so that should be ok for now].

-- Ben




More information about the Mono-devel-list mailing list