Request for reviews (S): 6987555: JSR 292 unboxing to a boolean value fails on big-endian SPARC

Christian Thalinger christian.thalinger at oracle.com
Wed Sep 29 06:58:19 PDT 2010


On Wed, 2010-09-29 at 10:18 +0200, Christian Thalinger wrote:
> On Tue, 2010-09-28 at 20:33 -0700, John Rose wrote:
> > > I meant unboxing a Short and turning it into a byte.  Is something
> > like that allowed or is it done in two stages using unboxi then i2i?
> > 
> > Two stages.
> 
> Good to know.  Actually I thought it's possible to do unboxing and type
> conversion in one step.  That means that the proposed change works.
> 
> But changing the shift for boolean to 24 should also work, since
> booleans use 1 byte.  I'll try that.

What about this one:

diff -r 861f533d12b0 src/share/vm/prims/methodHandles.hpp
--- a/src/share/vm/prims/methodHandles.hpp
+++ b/src/share/vm/prims/methodHandles.hpp
@@ -226,11 +226,12 @@ class MethodHandles: AllStatic {
   }
 
   enum { CONV_VMINFO_SIGN_FLAG = 0x80 };
+  // Returns the number of insignificant bits (or padding bits).
   static int adapter_subword_vminfo(BasicType dest) {
-    if (dest == T_BOOLEAN) return (BitsPerInt -  1);
-    if (dest == T_CHAR)    return (BitsPerInt - 16);
-    if (dest == T_BYTE)    return (BitsPerInt -  8) | CONV_VMINFO_SIGN_FLAG;
-    if (dest == T_SHORT)   return (BitsPerInt - 16) | CONV_VMINFO_SIGN_FLAG;
+    if (dest == T_BOOLEAN) return (BitsPerInt - BitsPerByte );  // boolean is implemented as 1 byte
+    if (dest == T_CHAR)    return (BitsPerInt - BitsPerShort);
+    if (dest == T_BYTE)    return (BitsPerInt - BitsPerByte ) | CONV_VMINFO_SIGN_FLAG;
+    if (dest == T_SHORT)   return (BitsPerInt - BitsPerShort) | CONV_VMINFO_SIGN_FLAG;
     return 0;                   // case T_INT
   }
   // Here is the transformation the i2i adapter must perform:




More information about the hotspot-compiler-dev mailing list