dotgnu-pnet
[Top][All Lists]
Advanced

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

Re: [Pnet-developers] ILTypeIdentical


From: Miroslaw Dobrzanski-Neumann
Subject: Re: [Pnet-developers] ILTypeIdentical
Date: Fri, 22 Oct 2004 11:00:47 +0200
User-agent: Mutt/1.5.6i

On Fri, Oct 22, 2004 at 10:30:51AM +0200, Simon Posnjak wrote:
> 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.

The assumption here is that structs are always at least 4 byte aligned (on
each platform). Based on this assumption the two lower bits of an address are
reused for storing metadate about the pointer. There is no way to fix it with
reasonable effort. So you must participate and move the two bits somewhere
else in the *safe* part of the pointer modifying the definitions in
include/il_types.h

i.e.
if the bits 22 and 23 are not use by the system both processor and mmu and ...
enum {
        META_BITS = 22,
        META_MASK = 0x3 << META_BITS
};

static inline int ILType_IsPrimitive (void *type)
{
        return (((intptr_t)type & META_MASK) >> META_BITS) == 0x01;
}

Regards
-- 
Mirosław Dobrzański-Neumann
E-mail: address@hidden

This message is utf-8 encoded


reply via email to

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