--- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Aug 20 09:07:21 2012 -0700
+++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp Mon Aug 20 09:58:58 2012 -0700
@@ -3058,7 +3058,7 @@
case vmIntrinsics::_Reference_get:
{
- if (UseG1GC) {
+ {
// With java.lang.ref.reference.get() we must go through the
// intrinsic - when G1 is enabled - even when get() is the root
// method of the compile so that, if necessary, the value in
@@ -3070,6 +3070,9 @@
// object removed from the list of discovered references during
// reference processing.
+ // Also we need intrinsic to prevent commoning reads from this field
+ // across safepoint since GC can change its value.
+
// Set up a stream so that appending instructions works properly.
ciBytecodeStream s(scope->method());
s.reset_to_bci(0);
@@ -3226,7 +3229,6 @@
bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
- if (!InlineNatives ) INLINE_BAILOUT("intrinsic method inlining disabled");
if (callee->is_synchronized()) {
// We don't currently support any synchronized intrinsics
return false;
@@ -3234,9 +3236,13 @@
// callee seems like a good candidate
// determine id
+ vmIntrinsics::ID id = callee->intrinsic_id();
+ if (!InlineNatives && id != vmIntrinsics::_Reference_get) {
+ // InlineNatives does not control Reference.get
+ INLINE_BAILOUT("intrinsic method inlining disabled");
+ }
bool preserves_state = false;
bool cantrap = true;
- vmIntrinsics::ID id = callee->intrinsic_id();
switch (id) {
case vmIntrinsics::_arraycopy:
if (!InlineArrayCopy) return false;
@@ -3376,11 +3382,10 @@
return true;
case vmIntrinsics::_Reference_get:
- // It is only when G1 is enabled that we absolutely
- // need to use the intrinsic version of Reference.get()
- // so that the value in the referent field, if necessary,
- // can be registered by the pre-barrier code.
- if (!UseG1GC) return false;
+ // Use the intrinsic version of Reference.get() so that the value in
+ // the referent field can be registered by the G1 pre-barrier code.
+ // Also to prevent commoning reads from this field across safepoint
+ // since GC can change its value.
preserves_state = true;
break;