[Mono-devel-list] Cross application domain call optimization, Take 2.

Lluis Sanchez lluis at ximian.com
Thu Oct 28 12:44:57 EDT 2004


El dj 28 de 10 del 2004 a les 17:59 +0200, en/na Paolo Molaro va
escriure:

> > +/* mono_get_xdomain_marshal_type()
> > + * Returns the kind of marshalling that a type needs for cross domain calls.
> > + */
> > +static MonoXDomainMarshalType
> > +mono_get_xdomain_marshal_type (MonoType *t)
> > +{
> > +	switch (t->type) {
> 
> Can you ever get a byref type here?

Yes, 't' can be a byref parameter type. Is that a problem (I guess it
is)?

> 
> > +/* mono_marshal_emit_load_domain_method ()
> > + * Loads into the stack a pointer to the code of the provided method for
> > + * the current domain.
> > + */
> > +static void
> > +mono_marshal_emit_load_domain_method (MonoMethodBuilder *mb, MonoMethod *method)
> > +{
> > +	static MonoMethodSignature *csig = NULL;
> > +	if (!csig) {
> > +		csig = mono_metadata_signature_alloc (mono_defaults.corlib, 1);
> > +		csig->params [0] = &mono_defaults.int_class->byval_arg;
> > +		csig->ret = &mono_defaults.int_class->byval_arg;
> > +		csig->pinvoke = 1;
> > +	}
> > +
> > +	mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
> > +	mono_mb_emit_byte (mb, CEE_MONO_LDPTR);
> > +	mono_mb_emit_i4 (mb, mono_mb_add_data (mb, method));
> > +	mono_mb_emit_native_call (mb, csig, mono_compile_method);
> 
> Why do you need to compile the method? It seems unusual. Maybe you can just use LDFTN?

I don't think so. LDFNT would load the method from the domain that is
compiling the wrapper, right? I need here to get the method for the
target domain, which is only known when running the wrapper.

> 
> > +	for (i = 0; i < sig->param_count; i++)
> > +		if (marshal_types [i] != MONO_MARSHAL_SERIALIZE)
> > +			csig->params [j++] = sig->params [i];
> This copies also the attributes of the params: is that the intended behaviour?

I think it is correct. Would those attribute have any side effect in the
JIT?

> > +	/* Main exception catch */
> > +	main_clause->flags = MONO_EXCEPTION_CLAUSE_FILTER;
> > +	main_clause->try_len = mb->pos - main_clause->try_offset;
> > +	main_clause->token_or_filter = mb->pos;
> > +	/* filter code */
> > +	mono_mb_emit_byte (mb, CEE_POP);
> > +	mono_mb_emit_byte (mb, CEE_LDC_I4_1);
> > +	mono_mb_emit_byte (mb, CEE_PREFIX1);
> > +	mono_mb_emit_byte (mb, CEE_ENDFILTER);
> 
> Why do you need a filter that always catches the exception?

I really don't, I just need to catch all exceptions. Which clause type
should I use?

Thanks!
Lluis.






More information about the Mono-devel-list mailing list