# HG changeset patch # User rkennke # Date 1542797259 -3600 # Wed Nov 21 11:47:39 2018 +0100 # Node ID d21d2ad9492725a2fafbfdc04f6f850e828bf89a # Parent f94ac11610b3fc25afc4a9fdfb7df8cf697a766a 8214055: GC/C2 abstraction for phaseX diff --git a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp --- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp +++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp @@ -262,7 +262,6 @@ virtual void clone_barrier_at_expansion(ArrayCopyNode* ac, Node* call, PhaseIterGVN& igvn) const; // Support for GC barriers emitted during parsing - virtual bool has_load_barriers() const { return false; } virtual bool is_gc_barrier_node(Node* node) const { return false; } virtual Node* step_over_gc_barrier(Node* c) const { return c; } @@ -303,6 +302,10 @@ virtual bool matcher_find_shared_visit(Matcher* matcher, Matcher::MStack& mstack, Node* n, uint opcode, bool& mem_op, int& mem_addr_idx) const { return false; }; virtual bool matcher_find_shared_post_visit(Matcher* matcher, Node* n, uint opcode) const { return false; }; virtual bool matcher_is_store_load_barrier(Node* x, uint xop) const { return false; } + + virtual void igvn_add_users_to_worklist(PhaseIterGVN* igvn, Node* use) const {} + virtual void ccp_analyze(PhaseCCP* ccp, Unique_Node_List& worklist, Node* use) const {} + }; #endif // SHARE_GC_SHARED_C2_BARRIERSETC2_HPP diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp @@ -1623,4 +1623,47 @@ break; } return false; -} \ No newline at end of file +} + +void ZBarrierSetC2::igvn_add_users_to_worklist(PhaseIterGVN* igvn, Node* use) const { + // Loading the java mirror from a Klass requires two loads and the type + // of the mirror load depends on the type of 'n'. See LoadNode::Value(). + // LoadBarrier?(LoadP(LoadP(AddP(foo:Klass, #java_mirror)))) + int use_op = use->Opcode(); + if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) { + for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { + Node* u = use->fast_out(i2); + const Type* ut = u->bottom_type(); + if (u->Opcode() == Op_LoadP && ut->isa_instptr()) { + // Search for load barriers behind the load + for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { + Node* b = u->fast_out(i3); + if (is_gc_barrier_node(b)) { + igvn->_worklist.push(b); + } + } + } + } + } +} + +void ZBarrierSetC2::ccp_analyze(PhaseCCP* ccp, Unique_Node_List& worklist, Node* use) const { + // Loading the java mirror from a Klass requires two loads and the type + // of the mirror load depends on the type of 'n'. See LoadNode::Value(). + int use_op = use->Opcode(); + if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) { + for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { + Node* u = use->fast_out(i2); + const Type* ut = u->bottom_type(); + if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != ccp->type(u)) { + // Search for load barriers behind the load + for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { + Node* b = u->fast_out(i3); + if (is_gc_barrier_node(b)) { + worklist.push(b); + } + } + } + } + } +} diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp --- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp +++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp @@ -190,7 +190,6 @@ bool oop_reload_allowed = true) const; virtual void* create_barrier_state(Arena* comp_arena) const; - virtual bool has_load_barriers() const { return true; } virtual bool is_gc_barrier_node(Node* node) const; virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const { } virtual void eliminate_useless_gc_barriers(Unique_Node_List &useful, Compile* C) const; @@ -218,6 +217,9 @@ virtual bool escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const; virtual bool escape_add_final_edges(ConnectionGraph* conn_graph, PhaseGVN* gvn, Node* n, uint opcode) const; + virtual void igvn_add_users_to_worklist(PhaseIterGVN* igvn, Node* use) const; + virtual void ccp_analyze(PhaseCCP* ccp, Unique_Node_List& worklist, Node* use) const; + }; #endif // SHARE_GC_Z_C2_ZBARRIERSETC2_HPP diff --git a/src/hotspot/share/opto/phaseX.cpp b/src/hotspot/share/opto/phaseX.cpp --- a/src/hotspot/share/opto/phaseX.cpp +++ b/src/hotspot/share/opto/phaseX.cpp @@ -1655,28 +1655,17 @@ } // Loading the java mirror from a Klass requires two loads and the type // of the mirror load depends on the type of 'n'. See LoadNode::Value(). - // LoadBarrier?(LoadP(LoadP(AddP(foo:Klass, #java_mirror)))) - BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); - bool has_load_barriers = bs->has_load_barriers(); - if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) { for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) { Node* u = use->fast_out(i2); const Type* ut = u->bottom_type(); if (u->Opcode() == Op_LoadP && ut->isa_instptr()) { - if (has_load_barriers) { - // Search for load barriers behind the load - for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { - Node* b = u->fast_out(i3); - if (bs->is_gc_barrier_node(b)) { - _worklist.push(b); - } - } - } _worklist.push(u); } } } + + BarrierSet::barrier_set()->barrier_set_c2()->igvn_add_users_to_worklist(this, use); } } @@ -1814,27 +1803,17 @@ } // Loading the java mirror from a Klass requires two loads and the type // of the mirror load depends on the type of 'n'. See LoadNode::Value(). - BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2(); - bool has_load_barriers = bs->has_load_barriers(); - if (m_op == Op_LoadP && m->bottom_type()->isa_rawptr()) { for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) { Node* u = m->fast_out(i2); const Type* ut = u->bottom_type(); if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != type(u)) { - if (has_load_barriers) { - // Search for load barriers behind the load - for (DUIterator_Fast i3max, i3 = u->fast_outs(i3max); i3 < i3max; i3++) { - Node* b = u->fast_out(i3); - if (bs->is_gc_barrier_node(b)) { - _worklist.push(b); - } - } - } worklist.push(u); } } } + + BarrierSet::barrier_set()->barrier_set_c2()->ccp_analyze(this, worklist, m); } } }