c1_LIRAssembler_x86 bug in 64-bit Windows code

Salter, Thomas A Thomas.Salter at unisys.com
Fri May 20 10:49:52 PDT 2011

When running a 64-bit JVM on Windows 7, the JVM.dll failed to load due to an exception in the following code.   Since long is a 32-bit integer, the casts in the operand calculation have the effect of truncating a 64-bit address to 32 bits and then sign-extending it.  The casts should be to intptr_t, not long.

I encountered this in JDK 7 build 130, but the source code is the same in build 142

In hotspot\src\cpu\x86\vm\c1_LIRAssembler_x86.cpp:

// Note: 'double' and 'long long' have 32-bits alignment on x86.
static jlong* double_quadword(jlong *adr, jlong lo, jlong hi) {
  // Use the expression (adr)&(~0xF) to provide 128-bits aligned address
  // of 128-bits operands for SSE instructions.
  jlong *operand = (jlong*)(((long)adr)&((long)(~0xF)));
  // Store the value to a 128-bits operand.
  operand[0] = lo;
  operand[1] = hi;
  return operand;

The corrected statement would be:
  jlong *operand = (jlong*)(((intptr_t)adr)&((intptr_t)(~0xF)));

Tom Salter  |  Software Engineer  |  Java & Middleware Development

Unisys  |  476 Swedesford Road  |  Malvern, PA  19355   |  610-648-2568 |  N385-2568

[cid:image001.gif at 01CC16F2.6DB09ED0]

THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20110520/fe8b9691/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.gif
Type: image/gif
Size: 2511 bytes
Desc: image001.gif
Url : http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20110520/fe8b9691/attachment.gif 

More information about the hotspot-compiler-dev mailing list