[Mono-dev] Simple method devirtualization patch

Robert Jordan robertj at gmx.net
Fri May 25 20:03:15 EDT 2007


Hey,

Rodrigo Kumpera wrote:
> The following patch perform simple devirtualization based on the sealed 
> flag
> of methods and types.
> 
> The patch makes pystone 4% faster with IronPython 2.0 and 1% faster with
> IronPython 1.0. It should improve other benchmarks as well, since it main
> contribution is statically dispatching delegate.Invoke. To provide more
> broad results a sse pass that perform type propagation is needed.
> 
> The only thing I'm not sure about this patch is if it should handle 
> remoting
> wrappers is some sort of way.

> --- inssel.brg	(revision 77933)
> +++ inssel.brg	(working copy)
> @@ -1690,6 +1690,17 @@
>  			method = ((MonoCallInst*)tree)->method = mono_marshal_get_remoting_invoke_with_check (method);
>  		}
>  
> +		MONO_EMIT_NEW_UNALU (cfg, OP_CHECK_THIS, -1, this_reg);
> +
> +		tree->dreg = state->reg1;
> +		tree->opcode = novirtop;
> +		mono_bblock_add_inst (cfg->cbb, tree);
> +		return;
> +	}
> +	
> +	if ((method->flags & METHOD_ATTRIBUTE_VIRTUAL) &&
> +		((method->klass->flags & TYPE_ATTRIBUTE_SEALED) ||
> +			(method->klass->flags & TYPE_ATTRIBUTE_SEALED))) {

One of the TYPE_ATTRIBUTE_SEALED checks is redundant.
You probably want method->flags & METHOD_ATTRIBUTE_FINAL.

>  		if (!method->string_ctor)

The string ctor is probably not virtual, so you should leave the check
where it was.

I'd rather remove the 2nd branch at all and put the
method->klass->flags & TYPE_ATTRIBUTE_SEALED check in the existing one.

I didn't test it, though.


Robert




More information about the Mono-devel-list mailing list