[Mono-list] cpblk?

Gonzalo Paniagua Javier gonzalo@gnome-db.org
Sat, 25 May 2002 04:47:53 +0200


* [ Serge <serge@wildwestsoftware.com>
* Sat, 25 May 2002 03:40:53 +0200 ]
> That's right, but we still have a call, a ret, and a conditional or
> two ;-) By inlining we can get rid of these things (especially if size
> is known up-front).  Moreover, due to JIT's dynamic nature it's
> possible to generate faster code at run-time.  For example, the
> following (generic) memcpy is faster on pre-Pentium x86s (Intel
> syntax): 
>   mov esi, $src
>   mov ecx, $size
>   mov edi, $dest
>   shr ecx,1
>   rep movsw
>   adc cl,cl
>   rep movsb
> 
> For const size==1 we could just mov al, [src]; mov [dest],al
> etc.etc.
> BTW, MS JIT uses similar optimizations for cpblk/initblk.
> 
> This is a small optimization of course, something similar to inlining
> TLS access, but why not :-) In fact I'm more concerned about possible
> incompatibility, if people would rely on memmove-like behaviour for
> cpblk in Mono.
> 

Totally agreed, Serge.