_LP64, int32_t and intptr_t

Michael Franz mvfranz at gmail.com
Sat Dec 13 18:34:02 PST 2008


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
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);
  movslq(dst, src);

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.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20081213/9b7550d6/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hotspot.patches
Type: application/octet-stream
Size: 21340 bytes
Desc: not available
Url : http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20081213/9b7550d6/hotspot.patches 

More information about the bsd-port-dev mailing list