[Mono-devel-list] Patch for String.Equals

Bernie Solomon bernard at ugsolutions.com
Mon Apr 5 12:25:29 EDT 2004


Given the current object layout chars in a string is only going
to be 4 byte aligned on a 64 bit machines. This means you can't
use long to do the comparisons without code to understand
alignment in the C#. Using int should be safe assuming nothing else
changes in object layout.

Bernie Solomon
----- Original Message ----- 
From: "Ben Maurer" <05mauben at hawken.edu>
To: <mono-devel-list at lists.ximian.com>; <malekith at pld-linux.org>
Sent: Monday, April 05, 2004 7:31 AM
Subject: Re: [Mono-devel-list] Patch for String.Equals


> oops, sorry it is sizeof (char)/sizeof (void*)
> 
> The problem with long ops is that we cant optimize as much for them. The
> burg rules are simply not there. the benefit seen from this may actually
> be from unrolling the loop. It is possible that better performance (on
> the 32 bit) would be obtained by just doing two integer compares.
> 
> I can take a look at the code we are generating later...
> 
> >>> Michal Moskal <malekith at pld-linux.org> 04/05/04 10:27 AM >>>
> On Mon, Apr 05, 2004 at 07:43:07AM -0400, Ben Maurer wrote:
> > To optimize for both platforms, the native integer size should be
> used.
> > You can do this by casting the char* to a void**, and using
> > string.Length * sizeof (char*) / sizeof (void**).
> 
> As far as I can tell sizeof(char*)==sizeof(void**), at least in C on all
> sane platforms. So the code above isn't very helpful.
> 
> Anyway if the long compares doesn't hurt performance on x86, why avoid
> it?
> 
> -- 
> : Michal Moskal :: http://www.kernel.pl/~malekith :: GCS !tv h e>+++ b++
> : When in doubt, use brute force. -- Ken Thompson :: UL++++$ C++ E--- a?
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 



More information about the Mono-devel-list mailing list