dotgnu-pnet
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Pnet-developers] ILTypeIdentical


From: Thong \(Tum\) Nguyen
Subject: RE: [Pnet-developers] ILTypeIdentical
Date: Fri, 22 Oct 2004 22:15:29 +1300

Hi Simon,

For performance reasons, the lower two bits of a type pointer are used to
identity whether it is a primitive, classref, valuetype or complex (i.e.
array) type.  These bits are masked out to get the actual pointer.  

In order to be able to use these lower two bits, your system has to allocate
memory on (at least) a 4-byte boundary.  It is possible that your system
doesn't do this.  You can add a check to support/allocate.c/ILMalloc and
make sure the return value from "malloc" divides into 4 evenly.  If it
doesn't you'll need to over-allocate and round down or replace your system's
malloc implementation (http://www.cs.colorado.edu/~zorn/Malloc.html).  If
you don't replace the malloc implementation and use over allocation, you
might have an interesting problem trying to find the right pointer to pass
to "free" unless you allocate an additional byte to store the negative
offset to the original pointer....

Regards,

^Tum

> -----Original Message-----
> From: Simon Posnjak [mailto:address@hidden
> Sent: Friday, 22 October 2004 9:31 p.m.
> To: Portable.Net
> Subject: [Pnet-developers] ILTypeIdentical
> 
> Hi,
> 
> I am still debugging the pnet on my embedded board and i have hard time
> comprehending what are you trying to do in meta_types.c:514 function
> ILTypeIdentical. Especially in line 539:
> 
> 
>         if(ILType_IsPrimitive(type1))
>         {
>                 return (type1 == type2);
>         }
> 
> According to il_types.h ILType_IsPrimitive is a macro that does:
> 
> #define ILType_IsPrimitive(type)        \
>                                 ((((ILNativeUInt)(type)) & 0x03) == 0x01)
> 
> so this function is expanded by cpp to:
> 
>       if((((ILNativeUInt)(type1)) & 0x03) == 0x01)
>       {
>               return (type1 == type2);
>       }
> 
> type1 is a pointer that you cast to uint and and with 0x03 to check if it
> is 1. Why?
> Can some body explain this to me, please. Thank you.
> 
> The problem I am seeing is that this condition is always true on my CRIS
> board.
> 
>               Regards Simon
> 
> 
> _______________________________________________
> Pnet-developers mailing list
> address@hidden
> http://dotgnu.org/mailman/listinfo/pnet-developers



reply via email to

[Prev in Thread] Current Thread [Next in Thread]