# HG changeset patch # User rkennke # Date 1505554561 -7200 # Sat Sep 16 11:36:01 2017 +0200 # Node ID 4220516f5b023b725011d8c6d787554af59789c2 # Parent 21f981ddecf1c3a66d9535ddee5b45f4e4540433 Remove obsolete and unused reduce-storeval-barrier optimization code. diff --git a/src/share/vm/gc/shenandoah/shenandoah_globals.hpp b/src/share/vm/gc/shenandoah/shenandoah_globals.hpp --- a/src/share/vm/gc/shenandoah/shenandoah_globals.hpp +++ b/src/share/vm/gc/shenandoah/shenandoah_globals.hpp @@ -266,10 +266,6 @@ "Turns on heap region sampling via JVMStat") \ writeable(Always) \ \ - experimental(bool, ShenandoahReduceStoreValBarrier, false, \ - "If true, only execute storeval barrier when updating " \ - "references.") \ - \ experimental(bool, ShenandoahFastSyncRoots, true, \ "Enable fast synchronizer roots scanning") \ \ diff --git a/src/share/vm/opto/graphKit.cpp b/src/share/vm/opto/graphKit.cpp --- a/src/share/vm/opto/graphKit.cpp +++ b/src/share/vm/opto/graphKit.cpp @@ -1552,7 +1552,7 @@ } -Node* GraphKit::pre_barrier(bool do_load, +void GraphKit::pre_barrier(bool do_load, Node* ctl, Node* obj, Node* adr, @@ -1567,10 +1567,10 @@ switch (bs->kind()) { case BarrierSet::G1SATBCTLogging: g1_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt); - return val; + break; case BarrierSet::ShenandoahBarrierSet: - return shenandoah_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt); - + shenandoah_write_barrier_pre(do_load, obj, adr, adr_idx, val, val_type, pre_val, bt); + break; case BarrierSet::CardTableForRS: case BarrierSet::CardTableExtension: case BarrierSet::ModRef: @@ -1580,7 +1580,6 @@ ShouldNotReachHere(); } - return val; } bool GraphKit::can_move_pre_barrier() const { @@ -1692,7 +1691,7 @@ uint adr_idx = C->get_alias_index(adr_type); assert(adr_idx != Compile::AliasIdxTop, "use other store_to_memory factory" ); - val = pre_barrier(true /* do_load */, + pre_barrier(true /* do_load */, control(), obj, adr, adr_idx, val, val_type, NULL /* pre_val */, bt); @@ -4201,151 +4200,26 @@ g1_write_barrier_pre_helper(*this, adr); } -Node* GraphKit::shenandoah_write_barrier_pre(bool do_load, - Node* obj, - Node* adr, - uint alias_idx, - Node* val, - const TypeOopPtr* val_type, - Node* pre_val, - BasicType bt) { +void GraphKit::shenandoah_write_barrier_pre(bool do_load, + Node* obj, + Node* adr, + uint alias_idx, + Node* val, + const TypeOopPtr* val_type, + Node* pre_val, + BasicType bt) { // Some sanity checks // Note: val is unused in this routine. + if (val != NULL) { + shenandoah_update_matrix(adr, val); + } if (!ShenandoahSATBBarrier) { - if (val != NULL) { - shenandoah_update_matrix(adr, val); - } - return val; + return; } - if (val == NULL) { - g1_write_barrier_pre(do_load, obj, adr, alias_idx, val, val_type, pre_val, bt); - return NULL; - } - - if (! ShenandoahReduceStoreValBarrier) { - val = shenandoah_storeval_barrier(val); - shenandoah_update_matrix(adr, val); - g1_write_barrier_pre(do_load, obj, adr, alias_idx, val, val_type, pre_val, bt); - return val; - } - - if (do_load) { - // We need to generate the load of the previous value - assert(obj != NULL, "must have a base"); - assert(adr != NULL, "where are loading from?"); - assert(pre_val == NULL, "loaded already?"); - assert(val_type != NULL, "need a type"); - - if (use_ReduceInitialCardMarks() - && g1_can_remove_pre_barrier(&_gvn, adr, bt, alias_idx)) { - return shenandoah_storeval_barrier(val); - } - - } else { - // In this case both val_type and alias_idx are unused. - assert(pre_val != NULL, "must be loaded already"); - // Nothing to be done if pre_val is null. - if (pre_val->bottom_type() == TypePtr::NULL_PTR) return val; - assert(pre_val->bottom_type()->basic_type() == T_OBJECT, "or we shouldn't be here"); - } - assert(bt == T_OBJECT, "or we shouldn't be here"); - - IdealKit ideal(this, true, true); - IdealVariable ival(ideal); - __ declarations_done(); - __ set(ival, val); - Node* tls = __ thread(); // ThreadLocalStorage - - Node* no_ctrl = NULL; - Node* no_base = __ top(); - Node* zero = __ ConI(0); - Node* zeroX = __ ConX(0); - - float likely = PROB_LIKELY(0.999); - float unlikely = PROB_UNLIKELY(0.999); - - BasicType active_type = in_bytes(SATBMarkQueue::byte_width_of_active()) == 4 ? T_INT : T_BYTE; - assert(in_bytes(SATBMarkQueue::byte_width_of_active()) == 4 || in_bytes(SATBMarkQueue::byte_width_of_active()) == 1, "flag width"); - - // Offsets into the thread - const int marking_offset = in_bytes(JavaThread::satb_mark_queue_offset() + // 648 - SATBMarkQueue::byte_offset_of_active()); - const int index_offset = in_bytes(JavaThread::satb_mark_queue_offset() + // 656 - SATBMarkQueue::byte_offset_of_index()); - const int buffer_offset = in_bytes(JavaThread::satb_mark_queue_offset() + // 652 - SATBMarkQueue::byte_offset_of_buf()); - - // Now the actual pointers into the thread - Node* marking_adr = __ AddP(no_base, tls, __ ConX(marking_offset)); - Node* buffer_adr = __ AddP(no_base, tls, __ ConX(buffer_offset)); - Node* index_adr = __ AddP(no_base, tls, __ ConX(index_offset)); - - // Now some of the values - Node* marking = __ load(__ ctrl(), marking_adr, TypeInt::INT, active_type, Compile::AliasIdxRaw); - - // if (!marking) - __ if_then(marking, BoolTest::ne, zero, unlikely); { - - Node* storeval = ideal.value(ival); - sync_kit(ideal); - storeval = shenandoah_storeval_barrier(storeval); - __ sync_kit(this); - __ set(ival, storeval); - - BasicType index_bt = TypeX_X->basic_type(); - assert(sizeof(size_t) == type2aelembytes(index_bt), "Loading G1 SATBMarkQueue::_index with wrong size."); - Node* index = __ load(__ ctrl(), index_adr, TypeX_X, index_bt, Compile::AliasIdxRaw); - - if (do_load) { - // load original value - // alias_idx correct?? - pre_val = __ load(__ ctrl(), adr, val_type, bt, alias_idx); - } - - // if (pre_val != NULL) - __ if_then(pre_val, BoolTest::ne, null()); { - Node* buffer = __ load(__ ctrl(), buffer_adr, TypeRawPtr::NOTNULL, T_ADDRESS, Compile::AliasIdxRaw); - - // is the queue for this thread full? - __ if_then(index, BoolTest::ne, zeroX, likely); { - - // decrement the index - Node* next_index = _gvn.transform(new SubXNode(index, __ ConX(sizeof(intptr_t)))); - - // Now get the buffer location we will log the previous value into and store it - Node *log_addr = __ AddP(no_base, buffer, next_index); - __ store(__ ctrl(), log_addr, pre_val, T_OBJECT, Compile::AliasIdxRaw, MemNode::unordered); - // update the index - __ store(__ ctrl(), index_adr, next_index, index_bt, Compile::AliasIdxRaw, MemNode::unordered); - - } __ else_(); { - - // logging buffer is full, call the runtime - const TypeFunc *tf = OptoRuntime::g1_wb_pre_Type(); - __ make_leaf_call(tf, CAST_FROM_FN_PTR(address, SharedRuntime::g1_wb_pre), "g1_wb_pre", pre_val, tls); - } __ end_if(); // (!index) - } __ end_if(); // (pre_val != NULL) - } __ end_if(); // (!marking) - Node* new_val = __ value(ival); - // IdealKit generates a Phi with very conservative type, and even - // turns array types into TypeInstPtr (see type.cpp, _const_basic_type[T_ARRAY]). - // We're forcing the result to be the original type. - if (new_val != val) { - const Type* t = _gvn.type(val); - if (new_val->isa_Type()) { - new_val->as_Type()->set_type(t); - } - _gvn.set_type(new_val, t); - } - val = new_val; - __ dead(ival); - // Final sync IdealKit and GraphKit. - final_sync(ideal); - g1_write_barrier_pre_helper(*this, adr); - return val; + g1_write_barrier_pre(do_load, obj, adr, alias_idx, val, val_type, pre_val, bt); } void GraphKit::shenandoah_update_matrix(Node* adr, Node* val) { @@ -4716,6 +4590,7 @@ false, NULL, 0); const TypePtr* value_field_type = string_type->add_offset(value_offset); + value = shenandoah_storeval_barrier(value); str = shenandoah_write_barrier(str); store_oop_to_object(control(), str, basic_plus_adr(str, value_offset), value_field_type, diff --git a/src/share/vm/opto/graphKit.hpp b/src/share/vm/opto/graphKit.hpp --- a/src/share/vm/opto/graphKit.hpp +++ b/src/share/vm/opto/graphKit.hpp @@ -626,7 +626,7 @@ bool mismatched = false); // For the few case where the barriers need special help - Node* pre_barrier(bool do_load, Node* ctl, + void pre_barrier(bool do_load, Node* ctl, Node* obj, Node* adr, uint adr_idx, Node* val, const TypeOopPtr* val_type, Node* pre_val, BasicType bt); @@ -791,7 +791,7 @@ BasicType bt, bool use_precise); - Node* shenandoah_write_barrier_pre(bool do_load, + void shenandoah_write_barrier_pre(bool do_load, Node* obj, Node* adr, uint alias_idx, diff --git a/src/share/vm/opto/library_call.cpp b/src/share/vm/opto/library_call.cpp --- a/src/share/vm/opto/library_call.cpp +++ b/src/share/vm/opto/library_call.cpp @@ -2720,6 +2720,7 @@ } if (type == T_OBJECT) { + val = shenandoah_storeval_barrier(val); store_oop_to_unknown(control(), heap_base_oop, adr, adr_type, val, type, mo, mismatched); } else { store_to_memory(control(), adr, val, type, adr_type, mo, requires_atomic_access, unaligned, mismatched); @@ -3069,19 +3070,18 @@ if (_gvn.type(newval) == TypePtr::NULL_PTR) newval = _gvn.makecon(TypePtr::NULL_PTR); + newval = shenandoah_storeval_barrier(newval); + // Reference stores need a store barrier. switch(kind) { case LS_get_set: { // If pre-barrier must execute before the oop store, old value will require do_load here. if (!can_move_pre_barrier()) { - newval = pre_barrier(true /* do_load*/, + pre_barrier(true /* do_load*/, control(), base, adr, alias_idx, newval, value_type->make_oopptr(), NULL /* pre_val*/, T_OBJECT); } // Else move pre_barrier to use load_store value, see below. - else { - newval = shenandoah_storeval_barrier(newval); - } break; } case LS_cmp_swap_weak: @@ -3092,7 +3092,7 @@ oldval = _gvn.makecon(TypePtr::NULL_PTR); } // The only known value which might get overwritten is oldval. - newval = pre_barrier(false /* do_load */, + pre_barrier(false /* do_load */, control(), NULL, adr, max_juint, newval, NULL, oldval /* pre_val */, T_OBJECT); diff --git a/src/share/vm/opto/parse2.cpp b/src/share/vm/opto/parse2.cpp --- a/src/share/vm/opto/parse2.cpp +++ b/src/share/vm/opto/parse2.cpp @@ -1763,6 +1763,7 @@ // a is not used except for an assert. The address d already has the // write barrier. Adding a barrier on a only results in additional code // being generated. + c = shenandoah_storeval_barrier(c); Node* store = store_oop_to_array(control(), a, d, adr_type, c, elemtype, T_OBJECT, StoreNode::release_if_reference(T_OBJECT)); break; diff --git a/src/share/vm/opto/parse3.cpp b/src/share/vm/opto/parse3.cpp --- a/src/share/vm/opto/parse3.cpp +++ b/src/share/vm/opto/parse3.cpp @@ -302,6 +302,8 @@ field_type = TypeOopPtr::make_from_klass(field->type()->as_klass()); } + val = shenandoah_storeval_barrier(val); + store = store_oop_to_object(control(), obj, adr, adr_type, val, field_type, bt, mo); } else { bool needs_atomic_access = is_vol || AlwaysAtomicAccesses;