< prev index next >

src/share/vm/opto/lcm.cpp

Print this page
rev 12685 : 8176518: [9] C2: Invalid ImplicitNullChecks with non-protected heap base
Reviewed-by:

@@ -253,12 +253,13 @@
       intptr_t offset = 0;
       const TypePtr *adr_type = NULL;  // Do not need this return value here
       const Node* base = mach->get_base_and_disp(offset, adr_type);
       if (base == NULL || base == NodeSentinel) {
         // Narrow oop address doesn't have base, only index
-        if( val->bottom_type()->isa_narrowoop() &&
-            MacroAssembler::needs_explicit_null_check(offset) )
+        if (val->bottom_type()->isa_narrowoop() &&
+            (MacroAssembler::needs_explicit_null_check(offset) ||
+             !Universe::narrow_oop_use_implicit_null_checks()))
           continue;             // Give up if offset is beyond page size
         // cannot reason about it; is probably not implicit null exception
       } else {
         const TypePtr* tptr;
         if (UseCompressedOops && (Universe::narrow_oop_shift() == 0 ||

@@ -268,15 +269,19 @@
         } else {
           // only regular oops are expected here
           tptr = base->bottom_type()->is_ptr();
         }
         // Give up if offset is not a compile-time constant
-        if( offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot )
+        if (offset == Type::OffsetBot || tptr->_offset == Type::OffsetBot)
           continue;
         offset += tptr->_offset; // correct if base is offseted
-        if( MacroAssembler::needs_explicit_null_check(offset) )
+        if (MacroAssembler::needs_explicit_null_check(offset))
           continue;             // Give up is reference is beyond 4K page size
+        // Access to non-protected heap base
+        if (base->is_Mach() && base->as_Mach()->ideal_Opcode() == Op_DecodeN &&
+            !Universe::narrow_oop_use_implicit_null_checks())
+          continue;
       }
     }
 
     // Check ctrl input to see if the null-check dominates the memory op
     Block *cb = get_block_for_node(mach);
< prev index next >