_LP64, int32_t and intptr_t

Xiaobin Lu Xiaobin.Lu at Sun.COM
Tue Dec 16 23:20:42 PST 2008


Hi Michael,

Your patch looks fine to me. For this particular build failure, there is 
a better solution which someone from our compiler team might want to 
explore when he has time.

A more general problem is the usage of _LP64 which is defined on Solaris 
x86_64 platform at least. For Mac, I believe we need some similar flag 
to identify that platform. Anyone know that flag on top of their head?

Regards,
-Xiaobin


Michael Franz wrote:
> Hi,
>
> Looking at assembler_x86.hpp and the usage of _LP64.  It seems that 
> _LP64 is used to decide whether or not to define 32 bit version of
>   void movptr(Address dst, int32_t imm32);
>   void movptr(Register dst, int32_t imm32);
> to work around casting calls when imm32 would be zero or NULL on 64 
> bit platforms.  Wouldn't it be better to use the NOT_LP64 and 
> LP64_ONLY macros with
> void MacroAssembler::movptr(Address dst, intptr_t src)
> void MacroAssembler::movptr(Register dst, intptr_t src)
> instead?  This would change the casting to use the intptr_t instead of 
> int32_t.  This would allow the compiler to pick the correct method and 
> reduce the need for 32 bit only versions.
>
> The the implementation would be:
> void MacroAssembler::movptr(Address dst, intptr_t src) {
> #ifdef _LP64
>   mov64(rscratch1, src);
>   movq(dst, rscratch1);   
> #else
>   movslq(dst, src);
> #endif
> }
>
> void MacroAssembler::movptr(Register dst, intptr_t src) {
>   LP64_ONLY(mov64(dst, src)) NOT_LP64(movl(dst, src));
> }
> would not need to be changed as it already uses the LP64 macros.
>
> What is interesting that
> void MacroAssembler::movptr(Register dst, int32_t src) {
>   mov64(dst, (intptr_t)src);
> }
> uses mov64 instead of movl.
>
>
> I have attached the changes I did to get the OS X build to work again.
>
> Michael




More information about the bsd-port-dev mailing list