8213489: GC/C2 abstraction for Compile::final_graph_reshaping()
Reviewed-by: kvn, roland
--- a/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp Fri Nov 09 10:38:07 2018 +0100
+++ b/src/hotspot/share/gc/shared/c2/barrierSetC2.hpp Fri Nov 09 10:38:07 2018 +0100
@@ -288,6 +288,9 @@
#ifdef ASSERT
virtual bool verify_gc_alias_type(const TypePtr* adr_type, int offset) const { return false; }
#endif
+
+ virtual bool final_graph_reshaping(Compile* compile, Node* n, uint opcode) const { return false; }
+
};
#endif // SHARE_GC_SHARED_C2_BARRIERSETC2_HPP
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp Fri Nov 09 10:38:07 2018 +0100
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp Fri Nov 09 10:38:07 2018 +0100
@@ -1435,6 +1435,29 @@
return type == T_OBJECT || type == T_ARRAY;
}
+bool ZBarrierSetC2::final_graph_reshaping(Compile* compile, Node* n, uint opcode) const {
+ bool handled;
+ switch (opcode) {
+ case Op_LoadBarrierSlowReg:
+ case Op_LoadBarrierWeakSlowReg:
+#ifdef ASSERT
+ if (VerifyOptoOopOffsets) {
+ MemNode* mem = n->as_Mem();
+ // Check to see if address types have grounded out somehow.
+ const TypeInstPtr* tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
+ ciInstanceKlass* k = tp->klass()->as_instance_klass();
+ bool oop_offset_is_sane = k->contains_field_offset(tp->offset());
+ assert(!tp || oop_offset_is_sane, "");
+ }
+#endif
+ handled = true;
+ break;
+ default:
+ handled = false;
+ }
+ return handled;
+}
+
// == Verification ==
#ifdef ASSERT
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp Fri Nov 09 10:38:07 2018 +0100
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.hpp Fri Nov 09 10:38:07 2018 +0100
@@ -207,6 +207,8 @@
static void find_dominating_barriers(PhaseIterGVN& igvn);
static void loop_optimize_gc_barrier(PhaseIdealLoop* phase, Node* node, bool last_round);
+ virtual bool final_graph_reshaping(Compile* compile, Node* n, uint opcode) const;
+
#ifdef ASSERT
virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const;
#endif
--- a/src/hotspot/share/opto/compile.cpp Fri Nov 09 10:38:07 2018 +0100
+++ b/src/hotspot/share/opto/compile.cpp Fri Nov 09 10:38:07 2018 +0100
@@ -2792,6 +2792,18 @@
}
#endif
// Count FPU ops and common calls, implements item (3)
+ bool gc_handled = BarrierSet::barrier_set()->barrier_set_c2()->final_graph_reshaping(this, n, nop);
+ if (!gc_handled) {
+ final_graph_reshaping_main_switch(n, frc, nop);
+ }
+
+ // Collect CFG split points
+ if (n->is_MultiBranch() && !n->is_RangeCheck()) {
+ frc._tests.push(n);
+ }
+}
+
+void Compile::final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop) {
switch( nop ) {
// Count all float operations that may use FPU
case Op_AddF:
@@ -2938,18 +2950,13 @@
case Op_LoadL_unaligned:
case Op_LoadPLocked:
case Op_LoadP:
-#if INCLUDE_ZGC
- case Op_LoadBarrierSlowReg:
- case Op_LoadBarrierWeakSlowReg:
-#endif
case Op_LoadN:
case Op_LoadRange:
case Op_LoadS: {
handle_mem:
#ifdef ASSERT
if( VerifyOptoOopOffsets ) {
- assert( n->is_Mem(), "" );
- MemNode *mem = (MemNode*)n;
+ MemNode* mem = n->as_Mem();
// Check to see if address types have grounded out somehow.
const TypeInstPtr *tp = mem->in(MemNode::Address)->bottom_type()->isa_instptr();
assert( !tp || oop_offset_is_sane(tp), "" );
@@ -3467,16 +3474,11 @@
break;
}
default:
- assert( !n->is_Call(), "" );
- assert( !n->is_Mem(), "" );
- assert( nop != Op_ProfileBoolean, "should be eliminated during IGVN");
+ assert(!n->is_Call(), "");
+ assert(!n->is_Mem(), "");
+ assert(nop != Op_ProfileBoolean, "should be eliminated during IGVN");
break;
}
-
- // Collect CFG split points
- if (n->is_MultiBranch() && !n->is_RangeCheck()) {
- frc._tests.push(n);
- }
}
//------------------------------final_graph_reshaping_walk---------------------
--- a/src/hotspot/share/opto/compile.hpp Fri Nov 09 10:38:07 2018 +0100
+++ b/src/hotspot/share/opto/compile.hpp Fri Nov 09 10:38:07 2018 +0100
@@ -1304,6 +1304,7 @@
// Function calls made by the public function final_graph_reshaping.
// No need to be made public as they are not called elsewhere.
void final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc);
+ void final_graph_reshaping_main_switch(Node* n, Final_Reshape_Counts& frc, uint nop);
void final_graph_reshaping_walk( Node_Stack &nstack, Node *root, Final_Reshape_Counts &frc );
void eliminate_redundant_card_marks(Node* n);