changeset 51280:d6e90a7411bb lworld

[lworld] Cleanup of 8207844 Reviewed-by: jrose
author thartmann
date Fri, 20 Jul 2018 11:14:30 +0200
parents 20e4a243dbda
children 34a480be2a04
files src/hotspot/share/opto/parseHelper.cpp
diffstat 1 files changed, 44 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/opto/parseHelper.cpp	Fri Jul 20 10:56:00 2018 +0200
+++ b/src/hotspot/share/opto/parseHelper.cpp	Fri Jul 20 11:14:30 2018 +0200
@@ -264,41 +264,50 @@
 
 
 void Parse::emit_guard_for_new(ciInstanceKlass* klass) {
-  // Emit guarded new
-  //   if (klass->_init_thread != current_thread ||
-  //       klass->_init_state != being_initialized)
-  //      uncommon_trap
-  Node* cur_thread = _gvn.transform( new ThreadLocalNode() );
-  Node* merge = new RegionNode(3);
-  _gvn.set_type(merge, Type::CONTROL);
-  Node* kls = makecon(TypeKlassPtr::make(klass));
+  if ((!klass->is_initialized() && !klass->is_being_initialized()) ||
+      klass->is_abstract() || klass->is_interface() ||
+      klass->name() == ciSymbol::java_lang_Class() ||
+      iter().is_unresolved_klass()) {
+    uncommon_trap(Deoptimization::Reason_uninitialized,
+                  Deoptimization::Action_reinterpret,
+                  klass);
+  } if (klass->is_being_initialized()) {
+    // Emit guarded new
+    //   if (klass->_init_thread != current_thread ||
+    //       klass->_init_state != being_initialized)
+    //      uncommon_trap
+    Node* cur_thread = _gvn.transform( new ThreadLocalNode() );
+    Node* merge = new RegionNode(3);
+    _gvn.set_type(merge, Type::CONTROL);
+    Node* kls = makecon(TypeKlassPtr::make(klass));
 
-  Node* init_thread_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_thread_offset()));
-  Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset);
-  Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
-  Node *tst   = Bool( CmpP( init_thread, cur_thread), BoolTest::eq);
-  IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
-  set_control(IfTrue(iff));
-  merge->set_req(1, IfFalse(iff));
+    Node* init_thread_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_thread_offset()));
+    Node* adr_node = basic_plus_adr(kls, kls, init_thread_offset);
+    Node* init_thread = make_load(NULL, adr_node, TypeRawPtr::BOTTOM, T_ADDRESS, MemNode::unordered);
+    Node *tst   = Bool( CmpP( init_thread, cur_thread), BoolTest::eq);
+    IfNode* iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
+    set_control(IfTrue(iff));
+    merge->set_req(1, IfFalse(iff));
 
-  Node* init_state_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_state_offset()));
-  adr_node = basic_plus_adr(kls, kls, init_state_offset);
-  // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler
-  // can generate code to load it as unsigned byte.
-  Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered);
-  Node* being_init = _gvn.intcon(InstanceKlass::being_initialized);
-  tst   = Bool( CmpI( init_state, being_init), BoolTest::eq);
-  iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
-  set_control(IfTrue(iff));
-  merge->set_req(2, IfFalse(iff));
+    Node* init_state_offset = _gvn.MakeConX(in_bytes(InstanceKlass::init_state_offset()));
+    adr_node = basic_plus_adr(kls, kls, init_state_offset);
+    // Use T_BOOLEAN for InstanceKlass::_init_state so the compiler
+    // can generate code to load it as unsigned byte.
+    Node* init_state = make_load(NULL, adr_node, TypeInt::UBYTE, T_BOOLEAN, MemNode::unordered);
+    Node* being_init = _gvn.intcon(InstanceKlass::being_initialized);
+    tst   = Bool( CmpI( init_state, being_init), BoolTest::eq);
+    iff = create_and_map_if(control(), tst, PROB_ALWAYS, COUNT_UNKNOWN);
+    set_control(IfTrue(iff));
+    merge->set_req(2, IfFalse(iff));
 
-  PreserveJVMState pjvms(this);
-  record_for_igvn(merge);
-  set_control(merge);
+    PreserveJVMState pjvms(this);
+    record_for_igvn(merge);
+    set_control(merge);
 
-  uncommon_trap(Deoptimization::Reason_uninitialized,
-                Deoptimization::Action_reinterpret,
-                klass);
+    uncommon_trap(Deoptimization::Reason_uninitialized,
+                  Deoptimization::Action_reinterpret,
+                  klass);
+  }
 }
 
 
@@ -311,18 +320,8 @@
   assert(will_link, "_new: typeflow responsibility");
 
   // Should initialize, or throw an InstantiationError?
-  if ((!klass->is_initialized() && !klass->is_being_initialized()) ||
-      klass->is_abstract() || klass->is_interface() ||
-      klass->name() == ciSymbol::java_lang_Class() ||
-      iter().is_unresolved_klass()) {
-    uncommon_trap(Deoptimization::Reason_uninitialized,
-                  Deoptimization::Action_reinterpret,
-                  klass);
-    return;
-  }
-  if (klass->is_being_initialized()) {
-    emit_guard_for_new(klass);
-  }
+  emit_guard_for_new(klass);
+  if (stopped()) return;
 
   Node* kls = makecon(TypeKlassPtr::make(klass));
   Node* obj = new_instance(kls);
@@ -351,14 +350,8 @@
   assert(will_link, "defaultvalue: typeflow responsibility");
 
   // Should initialize, or throw an InstantiationError?
-  if (!vk->is_initialized() && !vk->is_being_initialized()) {
-    uncommon_trap(Deoptimization::Reason_uninitialized,
-                  Deoptimization::Action_reinterpret,
-                  vk);
-    return;
-  } else if (vk->is_being_initialized()) {
-    emit_guard_for_new(vk);
-  }
+  emit_guard_for_new(vk);
+  if (stopped()) return;
 
   // Create and push a new default ValueTypeNode
   push(ValueTypeNode::make_default(_gvn, vk));