--- a/hotspot/src/share/vm/opto/library_call.cpp Tue Feb 07 11:33:15 2012 -0800
+++ b/hotspot/src/share/vm/opto/library_call.cpp Tue Feb 07 16:33:43 2012 -0800
@@ -2678,7 +2678,13 @@
cas = _gvn.transform(new (C, 5) CompareAndSwapLNode(control(), mem, adr, newval, oldval));
break;
case T_OBJECT:
- // reference stores need a store barrier.
+ // Transformation of a value which could be NULL pointer (CastPP #NULL)
+ // could be delayed during Parse (for example, in adjust_map_after_if()).
+ // Execute transformation here to avoid barrier generation in such case.
+ if (_gvn.type(newval) == TypePtr::NULL_PTR)
+ newval = _gvn.makecon(TypePtr::NULL_PTR);
+
+ // Reference stores need a store barrier.
// (They don't if CAS fails, but it isn't worth checking.)
pre_barrier(true /* do_load*/,
control(), base, adr, alias_idx, newval, value_type->make_oopptr(),