# HG changeset patch # Parent 088a07bcf78aa6b020b7cc1c60231bb2dacc39b7 diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -930,6 +930,9 @@ } void ShenandoahBarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const { + if (node->is_shenandoah_wb_pre_call()) { + C->shenandoah_eliminate_wb_pre(n, &_igvn); + } } void ShenandoahBarrierSetC2::enqueue_useful_gc_barrier(Unique_Node_List &worklist, Node* node) const { @@ -965,3 +968,24 @@ } #endif } + +void ShenandoahBarrierSetC2::shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn) { + assert(UseShenandoahGC && call->is_shenandoah_wb_pre_call(), ""); + Node* c = call->as_Call()->proj_out(TypeFunc::Control); + c = c->unique_ctrl_out(); + assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); + c = c->unique_ctrl_out(); + assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); + Node* iff = c->in(1)->is_IfProj() ? c->in(1)->in(0) : c->in(2)->in(0); + assert(iff->is_If(), "expect test"); + if (!iff->is_shenandoah_marking_if(igvn)) { + c = c->unique_ctrl_out(); + assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); + iff = c->in(1)->is_IfProj() ? c->in(1)->in(0) : c->in(2)->in(0); + assert(iff->is_shenandoah_marking_if(igvn), "expect marking test"); + } + Node* cmpx = iff->in(1)->in(1); + igvn->replace_node(cmpx, igvn->makecon(TypeInt::CC_EQ)); + igvn->rehash_node_delayed(call); + call->del_req(call->req()-1); +} diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -73,6 +73,8 @@ void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar) const; + void shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn); + protected: virtual void resolve_address(C2Access& access) const; virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; diff --git a/src/hotspot/share/opto/callnode.cpp b/src/hotspot/share/opto/callnode.cpp --- a/src/hotspot/share/opto/callnode.cpp +++ b/src/hotspot/share/opto/callnode.cpp @@ -40,11 +40,6 @@ #include "opto/regmask.hpp" #include "opto/rootnode.hpp" #include "opto/runtime.hpp" -#include "utilities/macros.hpp" -#if INCLUDE_SHENANDOAHGC -#include "gc/shenandoah/c2/shenandoahSupport.hpp" -#include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp" -#endif // Portions of code courtesy of Clifford Click @@ -1087,38 +1082,6 @@ } #endif -Node *CallLeafNode::Ideal(PhaseGVN *phase, bool can_reshape) { -#if INCLUDE_SHENANDOAHGC - if (is_shenandoah_wb_pre_call()) { - uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); - if (req() > cnt) { - Node* addp = in(cnt); - if (has_only_shenandoah_wb_pre_uses(addp)) { - del_req(cnt); - if (can_reshape) { - phase->is_IterGVN()->_worklist.push(addp); - } - return this; - } - } - } -#endif - - return CallNode::Ideal(phase, can_reshape); -} - -#if INCLUDE_SHENANDOAHGC -bool CallLeafNode::has_only_shenandoah_wb_pre_uses(Node* n) { - for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { - Node* u = n->fast_out(i); - if (!u->is_shenandoah_wb_pre_call()) { - return false; - } - } - return n->outcnt() > 0; -} -#endif - //============================================================================= void SafePointNode::set_local(JVMState* jvms, uint idx, Node *c) { diff --git a/src/hotspot/share/opto/callnode.hpp b/src/hotspot/share/opto/callnode.hpp --- a/src/hotspot/share/opto/callnode.hpp +++ b/src/hotspot/share/opto/callnode.hpp @@ -32,13 +32,6 @@ #include "opto/phaseX.hpp" #include "opto/replacednodes.hpp" #include "opto/type.hpp" -#include "runtime/sharedRuntime.hpp" -#if INCLUDE_G1GC -#include "gc/g1/g1BarrierSetRuntime.hpp" -#endif -#if INCLUDE_SHENANDOAHGC -#include "gc/shenandoah/shenandoahRuntime.hpp" -#endif // Portions of code courtesy of Clifford Click @@ -802,13 +795,6 @@ } virtual int Opcode() const; virtual bool guaranteed_safepoint() { return false; } - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); - -#if INCLUDE_SHENANDOAHGC - virtual bool is_shenandoah_wb_pre_call() const { return entry_point() == CAST_FROM_FN_PTR(address, ShenandoahRuntime::write_ref_field_pre_entry); } - static bool has_only_shenandoah_wb_pre_uses(Node* n); -#endif - #ifndef PRODUCT virtual void dump_spec(outputStream *st) const; #endif diff --git a/src/hotspot/share/opto/cfgnode.hpp b/src/hotspot/share/opto/cfgnode.hpp --- a/src/hotspot/share/opto/cfgnode.hpp +++ b/src/hotspot/share/opto/cfgnode.hpp @@ -397,7 +397,6 @@ // Returns NULL is it couldn't improve the type. static const TypeInt* filtered_int_type(PhaseGVN* phase, Node* val, Node* if_proj); - bool is_g1_marking_if(PhaseTransform *phase) const; #if INCLUDE_SHENANDOAHGC bool is_shenandoah_marking_if(PhaseTransform *phase) const; #endif diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -396,13 +396,6 @@ if (n->outcnt() == 1 && n->has_special_unique_user()) { record_for_igvn(n->unique_out()); } -#if INCLUDE_SHENANDOAHGC - if (n->Opcode() == Op_AddP && CallLeafNode::has_only_shenandoah_wb_pre_uses(n)) { - for (DUIterator_Fast imax, i = n->fast_outs(imax); i < imax; i++) { - record_for_igvn(n->fast_out(i)); - } - } -#endif } // Remove useless macro and predicate opaq nodes for (int i = C->macro_count()-1; i >= 0; i--) { @@ -425,7 +418,6 @@ remove_expensive_node(n); } } - // Remove useless Opaque4 nodes for (int i = opaque4_count() - 1; i >= 0; i--) { Node* opaq = opaque4_node(i); @@ -2867,17 +2859,6 @@ case Op_CallLeafNoFP: { assert (n->is_Call(), ""); CallNode *call = n->as_Call(); -#if INCLUDE_SHENANDOAHGC - if (UseShenandoahGC && call->is_shenandoah_wb_pre_call()) { - uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); - if (call->req() > cnt) { - assert(call->req() == cnt+1, "only one extra input"); - Node* addp = call->in(cnt); - assert(!CallLeafNode::has_only_shenandoah_wb_pre_uses(addp), "useless address computation?"); - call->del_req(cnt); - } - } -#endif // Count call sites where the FP mode bit would have to be flipped. // Do not count uncommon runtime calls: // uncommon_trap, _complete_monitor_locking, _complete_monitor_unlocking, @@ -3902,8 +3883,9 @@ if (cmp->Opcode() == Op_CmpI && cmp->in(2)->is_Con() && cmp->in(2)->bottom_type()->is_int()->get_con() == 0 && cmp->in(1)->is_Load()) { LoadNode* load = cmp->in(1)->as_Load(); - if (load->is_g1_marking_load()) { - + if (load->Opcode() == Op_LoadB && load->in(2)->is_AddP() && load->in(2)->in(2)->Opcode() == Op_ThreadLocal + && load->in(2)->in(3)->is_Con() + && load->in(2)->in(3)->bottom_type()->is_intptr_t()->get_con() == marking_offset) { Node* if_ctrl = iff->in(0); Node* load_ctrl = load->in(0); @@ -4757,26 +4739,3 @@ ni.dump(); } } - -#if INCLUDE_SHENANDOAHGC -void Compile::shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn) { - assert(UseShenandoahGC && call->is_shenandoah_wb_pre_call(), ""); - Node* c = call->as_Call()->proj_out(TypeFunc::Control); - c = c->unique_ctrl_out(); - assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); - c = c->unique_ctrl_out(); - assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); - Node* iff = c->in(1)->is_IfProj() ? c->in(1)->in(0) : c->in(2)->in(0); - assert(iff->is_If(), "expect test"); - if (!iff->is_shenandoah_marking_if(igvn)) { - c = c->unique_ctrl_out(); - assert(c->is_Region() && c->req() == 3, "where's the pre barrier control flow?"); - iff = c->in(1)->is_IfProj() ? c->in(1)->in(0) : c->in(2)->in(0); - assert(iff->is_shenandoah_marking_if(igvn), "expect marking test"); - } - Node* cmpx = iff->in(1)->in(1); - igvn->replace_node(cmpx, igvn->makecon(TypeInt::CC_EQ)); - igvn->rehash_node_delayed(call); - call->del_req(call->req()-1); -} -#endif diff --git a/src/hotspot/share/opto/compile.hpp b/src/hotspot/share/opto/compile.hpp --- a/src/hotspot/share/opto/compile.hpp +++ b/src/hotspot/share/opto/compile.hpp @@ -1364,11 +1364,6 @@ // supporting clone_map CloneMap& clone_map(); void set_clone_map(Dict* d); - -#if INCLUDE_SHENANDOAHGC - void shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn); -#endif - }; #endif // SHARE_VM_OPTO_COMPILE_HPP diff --git a/src/hotspot/share/opto/ifnode.cpp b/src/hotspot/share/opto/ifnode.cpp --- a/src/hotspot/share/opto/ifnode.cpp +++ b/src/hotspot/share/opto/ifnode.cpp @@ -1707,22 +1707,6 @@ return iff; } -bool IfNode::is_g1_marking_if(PhaseTransform *phase) const { - if (Opcode() != Op_If) { - return false; - } - - Node* bol = in(1); - assert(bol->is_Bool(), ""); - Node* cmpx = bol->in(1); - if (bol->as_Bool()->_test._test == BoolTest::ne && - cmpx->is_Cmp() && cmpx->in(2) == phase->intcon(0) && - cmpx->in(1)->is_g1_marking_load()) { - return true; - } - return false; -} - #if INCLUDE_SHENANDOAHGC bool IfNode::is_shenandoah_marking_if(PhaseTransform *phase) const { if (!UseShenandoahGC) { diff --git a/src/hotspot/share/opto/macro.cpp b/src/hotspot/share/opto/macro.cpp --- a/src/hotspot/share/opto/macro.cpp +++ b/src/hotspot/share/opto/macro.cpp @@ -634,7 +634,6 @@ k < kmax && can_eliminate; k++) { Node* n = use->fast_out(k); if (!n->is_Store() && n->Opcode() != Op_CastP2X && - SHENANDOAHGC_ONLY((!UseShenandoahGC || !n->is_shenandoah_wb_pre_call()) &&) !(n->is_ArrayCopy() && n->as_ArrayCopy()->is_clonebasic() && n->in(ArrayCopyNode::Dest) == use)) { @@ -941,10 +940,6 @@ if (membar_after->is_MemBar()) { disconnect_projections(membar_after->as_MemBar(), _igvn); } -#if INCLUDE_SHENANDOAHGC - } else if (UseShenandoahGC && n->is_shenandoah_wb_pre_call()) { - C->shenandoah_eliminate_wb_pre(n, &_igvn); -#endif } else { eliminate_gc_barrier(n); } diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -1392,10 +1392,6 @@ // The restriction (outcnt() <= 2) is the same as in set_req_X() // and remove_globally_dead_node(). igvn->add_users_to_worklist( n ); -#if INCLUDE_SHENANDOAHGC - } else if (n->Opcode() == Op_AddP && CallLeafNode::has_only_shenandoah_wb_pre_uses(n)) { - igvn->add_users_to_worklist(n); -#endif } else { BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(igvn->_worklist, n); } diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -986,9 +986,6 @@ // Check if 'this' node dominates or equal to 'sub'. bool dominates(Node* sub, Node_List &nlist); - virtual bool is_g1_marking_load() const { return false; } - virtual bool is_g1_marking_if(PhaseTransform *phase) const { return false; } - virtual bool is_shenandoah_wb_pre_call() const { return false; } virtual bool is_shenandoah_state_load() const { return false; } virtual bool is_shenandoah_marking_if(PhaseTransform *phase) const { return false; }