diff src/share/vm/opto/lcm.cpp @ 1151:1271af4ec18c

6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE. Summary: Add missing check that value is used in memory expression in instructions with embedded load. Reviewed-by: never, jrose
author kvn
date Thu, 07 Jan 2010 16:26:31 -0800
parents 97125851f396
children c18cbe5936b8 3657cb01ffc5
line wrap: on
line diff
--- a/src/share/vm/opto/lcm.cpp	Thu Jan 07 16:24:17 2010 -0800
+++ b/src/share/vm/opto/lcm.cpp	Thu Jan 07 16:26:31 2010 -0800
@@ -120,6 +120,7 @@
     case Op_LoadRange:
     case Op_LoadD_unaligned:
     case Op_LoadL_unaligned:
+      assert(mach->in(2) == val, "should be address");
       break;
     case Op_StoreB:
     case Op_StoreC:
@@ -146,6 +147,21 @@
     default:                    // Also check for embedded loads
       if( !mach->needs_anti_dependence_check() )
         continue;               // Not an memory op; skip it
+      {
+        // Check that value is used in memory address.
+        Node* base;
+        Node* index;
+        const MachOper* oper = mach->memory_inputs(base, index);
+        if (oper == NULL || oper == (MachOper*)-1) {
+          continue;             // Not an memory op; skip it
+        }
+        if (val == base ||
+            val == index && val->bottom_type()->isa_narrowoop()) {
+          break;                // Found it
+        } else {
+          continue;             // Skip it
+        }
+      }
       break;
     }
     // check if the offset is not too high for implicit exception