1.1 --- a/src/share/vm/c1/c1_GraphBuilder.cpp Sat Apr 09 21:16:12 2011 -0700 1.2 +++ b/src/share/vm/c1/c1_GraphBuilder.cpp Thu Apr 14 13:45:41 2011 -0700 1.3 @@ -2913,6 +2913,46 @@ 1.4 block()->set_end(end); 1.5 break; 1.6 } 1.7 + 1.8 + case vmIntrinsics::_Reference_get: 1.9 + { 1.10 + if (UseG1GC) { 1.11 + // With java.lang.ref.reference.get() we must go through the 1.12 + // intrinsic - when G1 is enabled - even when get() is the root 1.13 + // method of the compile so that, if necessary, the value in 1.14 + // the referent field of the reference object gets recorded by 1.15 + // the pre-barrier code. 1.16 + // Specifically, if G1 is enabled, the value in the referent 1.17 + // field is recorded by the G1 SATB pre barrier. This will 1.18 + // result in the referent being marked live and the reference 1.19 + // object removed from the list of discovered references during 1.20 + // reference processing. 1.21 + 1.22 + // Set up a stream so that appending instructions works properly. 1.23 + ciBytecodeStream s(scope->method()); 1.24 + s.reset_to_bci(0); 1.25 + scope_data()->set_stream(&s); 1.26 + s.next(); 1.27 + 1.28 + // setup the initial block state 1.29 + _block = start_block; 1.30 + _state = start_block->state()->copy_for_parsing(); 1.31 + _last = start_block; 1.32 + load_local(objectType, 0); 1.33 + 1.34 + // Emit the intrinsic node. 1.35 + bool result = try_inline_intrinsics(scope->method()); 1.36 + if (!result) BAILOUT("failed to inline intrinsic"); 1.37 + method_return(apop()); 1.38 + 1.39 + // connect the begin and end blocks and we're all done. 1.40 + BlockEnd* end = last()->as_BlockEnd(); 1.41 + block()->set_end(end); 1.42 + break; 1.43 + } 1.44 + // Otherwise, fall thru 1.45 + } 1.46 + 1.47 default: 1.48 scope_data()->add_to_work_list(start_block); 1.49 iterate_all_blocks(); 1.50 @@ -3150,6 +3190,15 @@ 1.51 append_unsafe_CAS(callee); 1.52 return true; 1.53 1.54 + case vmIntrinsics::_Reference_get: 1.55 + // It is only when G1 is enabled that we absolutely 1.56 + // need to use the intrinsic version of Reference.get() 1.57 + // so that the value in the referent field, if necessary, 1.58 + // can be registered by the pre-barrier code. 1.59 + if (!UseG1GC) return false; 1.60 + preserves_state = true; 1.61 + break; 1.62 + 1.63 default : return false; // do not inline 1.64 } 1.65 // create intrinsic node