RFD: C2: Poor code quality for Unsafe

Andrew Haley aph at redhat.com
Wed Jul 27 16:19:29 UTC 2016


On 27/07/16 13:49, Andrew Haley wrote:
> Summary: The code we generate for heap-based X-Buffers is good, but
> for off-heap X-Buffers it can be bad.  Quite startlingly so.

I've been trying this, and it seems to work well:

diff --git a/src/share/vm/opto/castnode.cpp b/src/share/vm/opto/castnode.cpp
--- a/src/share/vm/opto/castnode.cpp
+++ b/src/share/vm/opto/castnode.cpp
@@ -456,6 +456,14 @@
     if (fits_in_int(phase->type(x))) {
       return addP_of_X2P(phase, y, x);
     }
+    // convert CastX2P(AddX(x, y)) to AddP(CastX2P(x), y) if y is a
+    // pointer-size shift.
+    if (y->Opcode() == Op_LShiftX) {
+      return addP_of_X2P(phase, x, y);
+    }
+    if (x->Opcode() == Op_LShiftX) {
+      return addP_of_X2P(phase, y, x);
+    }
     break;
   }
   return NULL;

Andrew.



More information about the hotspot-dev mailing list