src/share/vm/c1/c1_GraphBuilder.cpp

changeset 4002
09aad8452938
parent 3970
977007096840
child 4003
7a302948f5a4
     1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Aug 20 09:07:21 2012 -0700
     1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp	Mon Aug 20 09:58:58 2012 -0700
     1.3 @@ -3058,7 +3058,7 @@
     1.4  
     1.5    case vmIntrinsics::_Reference_get:
     1.6      {
     1.7 -      if (UseG1GC) {
     1.8 +      {
     1.9          // With java.lang.ref.reference.get() we must go through the
    1.10          // intrinsic - when G1 is enabled - even when get() is the root
    1.11          // method of the compile so that, if necessary, the value in
    1.12 @@ -3070,6 +3070,9 @@
    1.13          // object removed from the list of discovered references during
    1.14          // reference processing.
    1.15  
    1.16 +        // Also we need intrinsic to prevent commoning reads from this field
    1.17 +        // across safepoint since GC can change its value.
    1.18 +
    1.19          // Set up a stream so that appending instructions works properly.
    1.20          ciBytecodeStream s(scope->method());
    1.21          s.reset_to_bci(0);
    1.22 @@ -3226,7 +3229,6 @@
    1.23  
    1.24  
    1.25  bool GraphBuilder::try_inline_intrinsics(ciMethod* callee) {
    1.26 -  if (!InlineNatives           ) INLINE_BAILOUT("intrinsic method inlining disabled");
    1.27    if (callee->is_synchronized()) {
    1.28      // We don't currently support any synchronized intrinsics
    1.29      return false;
    1.30 @@ -3234,9 +3236,13 @@
    1.31  
    1.32    // callee seems like a good candidate
    1.33    // determine id
    1.34 +  vmIntrinsics::ID id = callee->intrinsic_id();
    1.35 +  if (!InlineNatives && id != vmIntrinsics::_Reference_get) {
    1.36 +    // InlineNatives does not control Reference.get
    1.37 +    INLINE_BAILOUT("intrinsic method inlining disabled");
    1.38 +  }
    1.39    bool preserves_state = false;
    1.40    bool cantrap = true;
    1.41 -  vmIntrinsics::ID id = callee->intrinsic_id();
    1.42    switch (id) {
    1.43      case vmIntrinsics::_arraycopy:
    1.44        if (!InlineArrayCopy) return false;
    1.45 @@ -3376,11 +3382,10 @@
    1.46        return true;
    1.47  
    1.48      case vmIntrinsics::_Reference_get:
    1.49 -      // It is only when G1 is enabled that we absolutely
    1.50 -      // need to use the intrinsic version of Reference.get()
    1.51 -      // so that the value in the referent field, if necessary,
    1.52 -      // can be registered by the pre-barrier code.
    1.53 -      if (!UseG1GC) return false;
    1.54 +      // Use the intrinsic version of Reference.get() so that the value in
    1.55 +      // the referent field can be registered by the G1 pre-barrier code.
    1.56 +      // Also to prevent commoning reads from this field across safepoint
    1.57 +      // since GC can change its value.
    1.58        preserves_state = true;
    1.59        break;
    1.60  

mercurial