diff -r e6beb62de02d -r e1162778c1c8 src/share/vm/c1/c1_CodeStubs.hpp --- a/src/share/vm/c1/c1_CodeStubs.hpp Tue Apr 05 19:14:03 2011 -0700 +++ b/src/share/vm/c1/c1_CodeStubs.hpp Thu Apr 07 09:53:20 2011 -0700 @@ -519,42 +519,126 @@ // Code stubs for Garbage-First barriers. class G1PreBarrierStub: public CodeStub { private: + bool _do_load; LIR_Opr _addr; LIR_Opr _pre_val; LIR_PatchCode _patch_code; CodeEmitInfo* _info; public: + // Version that _does_ generate a load of the previous value from addr. + // addr (the address of the field to be read) must be a LIR_Address // pre_val (a temporary register) must be a register; - // addr (the address of the field to be read) must be a LIR_Address G1PreBarrierStub(LIR_Opr addr, LIR_Opr pre_val, LIR_PatchCode patch_code, CodeEmitInfo* info) : - _addr(addr), _pre_val(pre_val), _patch_code(patch_code), _info(info) + _addr(addr), _pre_val(pre_val), _do_load(true), + _patch_code(patch_code), _info(info) { assert(_pre_val->is_register(), "should be temporary register"); assert(_addr->is_address(), "should be the address of the field"); } + // Version that _does not_ generate load of the previous value; the + // previous value is assumed to have already been loaded into pre_val. + G1PreBarrierStub(LIR_Opr pre_val) : + _addr(LIR_OprFact::illegalOpr), _pre_val(pre_val), _do_load(false), + _patch_code(lir_patch_none), _info(NULL) + { + assert(_pre_val->is_register(), "should be a register"); + } + LIR_Opr addr() const { return _addr; } LIR_Opr pre_val() const { return _pre_val; } LIR_PatchCode patch_code() const { return _patch_code; } CodeEmitInfo* info() const { return _info; } + bool do_load() const { return _do_load; } virtual void emit_code(LIR_Assembler* e); virtual void visit(LIR_OpVisitState* visitor) { - // don't pass in the code emit info since it's processed in the fast - // path - if (_info != NULL) - visitor->do_slow_case(_info); - else + if (_do_load) { + // don't pass in the code emit info since it's processed in the fast + // path + if (_info != NULL) + visitor->do_slow_case(_info); + else + visitor->do_slow_case(); + + visitor->do_input(_addr); + visitor->do_temp(_pre_val); + } else { visitor->do_slow_case(); - visitor->do_input(_addr); - visitor->do_temp(_pre_val); + visitor->do_input(_pre_val); + } } #ifndef PRODUCT virtual void print_name(outputStream* out) const { out->print("G1PreBarrierStub"); } #endif // PRODUCT }; +// This G1 barrier code stub is used in Unsafe.getObject. +// It generates a sequence of guards around the SATB +// barrier code that are used to detect when we have +// the referent field of a Reference object. +// The first check is assumed to have been generated +// in the code generated for Unsafe.getObject(). + +class G1UnsafeGetObjSATBBarrierStub: public CodeStub { + private: + LIR_Opr _val; + LIR_Opr _src; + + LIR_Opr _tmp; + LIR_Opr _thread; + + bool _gen_src_check; + + public: + // A G1 barrier that is guarded by generated guards that determine whether + // val (which is the result of Unsafe.getObject() should be recorded in an + // SATB log buffer. We could be reading the referent field of a Reference object + // using Unsafe.getObject() and we need to record the referent. + // + // * val is the operand returned by the unsafe.getObject routine. + // * src is the base object + // * tmp is a temp used to load the klass of src, and then reference type + // * thread is the thread object. + + G1UnsafeGetObjSATBBarrierStub(LIR_Opr val, LIR_Opr src, + LIR_Opr tmp, LIR_Opr thread, + bool gen_src_check) : + _val(val), _src(src), + _tmp(tmp), _thread(thread), + _gen_src_check(gen_src_check) + { + assert(_val->is_register(), "should have already been loaded"); + assert(_src->is_register(), "should have already been loaded"); + + assert(_tmp->is_register(), "should be a temporary register"); + } + + LIR_Opr val() const { return _val; } + LIR_Opr src() const { return _src; } + + LIR_Opr tmp() const { return _tmp; } + LIR_Opr thread() const { return _thread; } + + bool gen_src_check() const { return _gen_src_check; } + + virtual void emit_code(LIR_Assembler* e); + + virtual void visit(LIR_OpVisitState* visitor) { + visitor->do_slow_case(); + visitor->do_input(_val); + visitor->do_input(_src); + visitor->do_input(_thread); + + visitor->do_temp(_tmp); + } + +#ifndef PRODUCT + virtual void print_name(outputStream* out) const { out->print("G1UnsafeGetObjSATBBarrierStub"); } +#endif // PRODUCT +}; + class G1PostBarrierStub: public CodeStub { private: LIR_Opr _addr;