[Mono-dev] How To Convince Mono To Allocate Big Arrays

Luis F. Ortiz LuisOrtiz at verizon.net
Thu May 8 12:54:07 EDT 2008


On May 7, 2008, at 10:50 PM, Rodrigo Kumpera wrote:

> Hi Luis,
>
> To have your patch integrated, some changes are needed. First, we  
> want to default to 32bits sized arrays on 64bits machines, so your  
> changes must be conditionally compiled. To help with that some  
> changed to your patch are due. Next are some comments about it:
> ...
>  /* helper macros to check for overflow when calculating the size of  
> arrays */
> -#define MYGUINT32_MAX 4294967295U
> +#if (GLIB_SIZEOF_SIZE_T < 4 )
> +#define MYGUINT32_MAX 0xFFFFFFFFUL
> +#define MYGUINT_MAX MYGUINT32_MAX
>
> This #if seens bogus, don't you mean "if ((GLIB_SIZEOF_SIZE_T ==  
> 4 )" as mono never supported 16bits machines.
> The macros can be unified by using MYGUINT_MAX and the  
> 'array_size_t' type I talked before. The definition of MYGUINT_MAX
> should be put together in the same place we define 'array_size_t'.  
> And we could go with a meaningful name, don't you think?

The whole MYGUINT32 thing was there before made my changes and appears  
in other places in interpreter/interp.c as well.
I don't understand why the GLIB define of G_MAXUINT32 was not used  
instead these private definitions.

I get nervous when I see magic constants, either in hexadecimal or  
decimal.

I would rather see a definition of MONO_ARRAY_MAX_INDEX set to either  
G_MAXINT32 or G_MAXINT64 and a definition
of MONO_ARRAY_MAX_SIZE set to either G_MAXUNIT32 or G_MAXUNIT64, in  
object.h .

Then this code could lose the #if here and the magic numbers would be  
kept in one place.

/Ortiz/Luis


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080508/a0204658/attachment.html 


More information about the Mono-devel-list mailing list