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

Paolo Molaro lupus at ximian.com
Fri Oct 29 06:15:23 EDT 2004


On 10/28/04 Lluis Sanchez wrote:
> El dj 28 de 10 del 2004 a les 17:59 +0200, en/na Paolo Molaro va
> > > +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)?

Yes, you usually deal with it separately before the switch:
	if (t->byref) {
		do something;
		return xx;
	}

> > > +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.

Ok. If it's semantically correct to have the method compiled right away it's fine
(like, if there is no side effect, for types that need to obey the beforefieldinit
flag value). But please add a comment that says you need the pointer to the method in
the current domain.

> > > +	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?

It's likely ok then, there should not be any weird side effect.

> > > +	/* 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?

A catch (object) clause will catch all the exceptions (this requires a small
change, though: where token_or_filter is used, it needs to be replaced with
a union holding a MonoClass* and the filter offset).

lupus

-- 
-----------------------------------------------------------------
lupus at debian.org                                     debian/rules
lupus at ximian.com                             Monkeys do it better



More information about the Mono-devel-list mailing list