dotgnu-pnet
[Top][All Lists]
Advanced

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

Re: [Pnet-developers] Use of ILNativeUInt vs. unsigned long in pointer c


From: Peter Colson
Subject: Re: [Pnet-developers] Use of ILNativeUInt vs. unsigned long in pointer casting and manipulation
Date: Fri, 24 Sep 2004 13:56:15 +1000

On 24/09/2004, at 11:36 AM, Rhys Weatherley wrote:

On Friday 24 September 2004 11:40 am, Peter Colson wrote:

OK. I just want to understand how the resultant pointer can be used as a
real 'type' pointer in an environment that uses 8 byte pointers, if
it's sourced from a 32 bit integral?

"ILType *" is not a pointer. It is a pointer-sized union between 32-bit
integers, class pointers, value type pointers, and complex types.  The
low-order bits indicate which arm of the union is being used. Essentially,
it is the following structure, packed into one word:

struct
{
    int what_is_this : 2;
    union
    {
        ILInt32 element_type;
        ILClass *class_ptr;
        ILClass *value_type_ptr;
        ILComplexType *complex_ptr;
    };
};

It's a space-saving hack. One which is too late to change. If your platform cannot bit-pack into low-order bits, then it is time to get a new platform.
It is that simple.

I think I mentioned in a previous post that the later release environment we're now in allows for 8 byte pointers that can be bit manipulated. That is
no longer a problem. I understand how the low-order bits are being used
to hold type information.

But your ILType* union above does resolve some elements to pointers
(ILClass*, ILComplexType*) once the 'what_is_this' element is stripped.

Do these 'pointers' then get used as real pointers that point to structures
defining the class or complex type? I would guess they do?

But if the ILType* is sourced from a function like ILMetaUncompressData
that returns a 4 byte unsigned long (which is one example I've seen) do
we then have a problem on a platform using 8 byte pointers when (if) we
need to use the ILClass* or ILComplexType* as a 'real' pointer?

(Or are these union elements not really used as pointers either?)

Regards,
Peter Colson.



reply via email to

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