< prev index next >

src/hotspot/share/opto/parse2.cpp

Print this page
rev 52049 : JDK11-only: Use WB-based acmp barrier


  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileLog.hpp"
  30 #include "interpreter/linkResolver.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "memory/universe.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "opto/addnode.hpp"
  35 #include "opto/castnode.hpp"
  36 #include "opto/convertnode.hpp"
  37 #include "opto/divnode.hpp"
  38 #include "opto/idealGraphPrinter.hpp"
  39 #include "opto/matcher.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/mulnode.hpp"
  42 #include "opto/opaquenode.hpp"
  43 #include "opto/parse.hpp"
  44 #include "opto/runtime.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/sharedRuntime.hpp"
  47 #include "utilities/macros.hpp"
  48 #if INCLUDE_SHENANDOAHGC
  49 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  50 #endif
  51 
  52 #ifndef PRODUCT
  53 extern int explicit_null_checks_inserted,
  54            explicit_null_checks_elided;
  55 #endif
  56 
  57 //---------------------------------array_load----------------------------------
  58 void Parse::array_load(BasicType bt) {
  59   const Type* elemtype = Type::TOP;
  60   bool big_val = bt == T_DOUBLE || bt == T_LONG;
  61   Node* adr = array_addressing(bt, 0, false, &elemtype);
  62   if (stopped())  return;     // guaranteed null or range check
  63 
  64   pop();                      // index (already used)
  65   Node* array = pop();        // the array itself
  66 
  67   if (elemtype == TypeInt::BOOL) {
  68     bt = T_BOOLEAN;
  69   } else if (bt == T_OBJECT) {
  70     elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();


1597       }
1598       c = tst->in(1);
1599     }
1600     BoolTest::mask neg_btest = BoolTest(btest).negate();
1601     taken_btest   = taken_if_true ?     btest : neg_btest;
1602     untaken_btest = taken_if_true ? neg_btest :     btest;
1603   }
1604 
1605   // Generate real control flow
1606   float true_prob = (taken_if_true ? prob : untaken_prob);
1607   IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt);
1608   assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
1609   Node* taken_branch   = new IfTrueNode(iff);
1610   Node* untaken_branch = new IfFalseNode(iff);
1611   if (!taken_if_true) {  // Finish conversion to canonical form
1612     Node* tmp      = taken_branch;
1613     taken_branch   = untaken_branch;
1614     untaken_branch = tmp;
1615   }
1616 
1617   taken_branch = _gvn.transform(taken_branch);
1618   untaken_branch = _gvn.transform(untaken_branch);
1619   Node* taken_memory = NULL;
1620   Node* untaken_memory = NULL;
1621 
1622 #if INCLUDE_SHENANDOAHGC
1623   ShenandoahBarrierNode::do_cmpp_if(*this, taken_branch, untaken_branch, taken_memory, untaken_memory);
1624 #endif
1625 
1626   // Branch is taken:
1627   { PreserveJVMState pjvms(this);

1628     set_control(taken_branch);
1629     if (taken_memory != NULL) {
1630       set_all_memory(taken_memory);
1631     }
1632 
1633     if (stopped()) {
1634       if (C->eliminate_boxing()) {
1635         // Mark the successor block as parsed
1636         branch_block->next_path_num();
1637       }
1638     } else {
1639       // Update method data
1640       profile_taken_branch(target_bci);
1641       adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
1642       if (!stopped()) {
1643         merge(target_bci);
1644       }
1645     }
1646   }
1647 

1648   set_control(untaken_branch);
1649   if (untaken_memory != NULL) {
1650     set_all_memory(untaken_memory);
1651   }
1652 
1653   // Branch not taken.
1654   if (stopped()) {
1655     if (C->eliminate_boxing()) {
1656       // Mark the successor block as parsed
1657       next_block->next_path_num();
1658     }
1659   } else {
1660     // Update method data
1661     profile_not_taken_branch();
1662     adjust_map_after_if(untaken_btest, c, untaken_prob,
1663                         next_block, branch_block);
1664   }
1665 }
1666 
1667 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
1668   // Don't want to speculate on uncommon traps when running with -Xcomp
1669   if (!UseInterpreter) {
1670     return false;
1671   }


2756       assert(null_ctl->is_top(), "no null control here");
2757       dec_sp(1);
2758     } else if (_gvn.type(b)->speculative_always_null() &&
2759                !too_many_traps(Deoptimization::Reason_speculate_null_assert)) {
2760       inc_sp(1);
2761       b = null_assert(b);
2762       dec_sp(1);
2763     }
2764     c = _gvn.transform( new CmpPNode(b, a) );
2765     do_ifnull(btest, c);
2766     break;
2767 
2768   case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp;
2769   case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp;
2770   handle_if_acmp:
2771     // If this is a backwards branch in the bytecodes, add Safepoint
2772     maybe_add_safepoint(iter().get_dest());
2773     a = pop();
2774     b = pop();
2775 #if INCLUDE_SHENANDOAHGC
2776     if (UseShenandoahGC && ShenandoahAcmpBarrier && ShenandoahVerifyOptoBarriers) {
2777       a = access_resolve_for_write(a);
2778       b = access_resolve_for_write(b);
2779     }
2780 #endif
2781     c = _gvn.transform( new CmpPNode(b, a) );
2782     c = optimize_cmp_with_klass(c);
2783     do_if(btest, c);
2784     break;
2785 
2786   case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx;
2787   case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx;
2788   case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx;
2789   case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx;
2790   case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx;
2791   case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx;
2792   handle_ifxx:
2793     // If this is a backwards branch in the bytecodes, add Safepoint
2794     maybe_add_safepoint(iter().get_dest());
2795     a = _gvn.intcon(0);
2796     b = pop();




  27 #include "classfile/systemDictionary.hpp"
  28 #include "classfile/vmSymbols.hpp"
  29 #include "compiler/compileLog.hpp"
  30 #include "interpreter/linkResolver.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "memory/universe.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "opto/addnode.hpp"
  35 #include "opto/castnode.hpp"
  36 #include "opto/convertnode.hpp"
  37 #include "opto/divnode.hpp"
  38 #include "opto/idealGraphPrinter.hpp"
  39 #include "opto/matcher.hpp"
  40 #include "opto/memnode.hpp"
  41 #include "opto/mulnode.hpp"
  42 #include "opto/opaquenode.hpp"
  43 #include "opto/parse.hpp"
  44 #include "opto/runtime.hpp"
  45 #include "runtime/deoptimization.hpp"
  46 #include "runtime/sharedRuntime.hpp"




  47 
  48 #ifndef PRODUCT
  49 extern int explicit_null_checks_inserted,
  50            explicit_null_checks_elided;
  51 #endif
  52 
  53 //---------------------------------array_load----------------------------------
  54 void Parse::array_load(BasicType bt) {
  55   const Type* elemtype = Type::TOP;
  56   bool big_val = bt == T_DOUBLE || bt == T_LONG;
  57   Node* adr = array_addressing(bt, 0, false, &elemtype);
  58   if (stopped())  return;     // guaranteed null or range check
  59 
  60   pop();                      // index (already used)
  61   Node* array = pop();        // the array itself
  62 
  63   if (elemtype == TypeInt::BOOL) {
  64     bt = T_BOOLEAN;
  65   } else if (bt == T_OBJECT) {
  66     elemtype = _gvn.type(array)->is_aryptr()->elem()->make_oopptr();


1593       }
1594       c = tst->in(1);
1595     }
1596     BoolTest::mask neg_btest = BoolTest(btest).negate();
1597     taken_btest   = taken_if_true ?     btest : neg_btest;
1598     untaken_btest = taken_if_true ? neg_btest :     btest;
1599   }
1600 
1601   // Generate real control flow
1602   float true_prob = (taken_if_true ? prob : untaken_prob);
1603   IfNode* iff = create_and_map_if(control(), tst, true_prob, cnt);
1604   assert(iff->_prob > 0.0f,"Optimizer made bad probability in parser");
1605   Node* taken_branch   = new IfTrueNode(iff);
1606   Node* untaken_branch = new IfFalseNode(iff);
1607   if (!taken_if_true) {  // Finish conversion to canonical form
1608     Node* tmp      = taken_branch;
1609     taken_branch   = untaken_branch;
1610     untaken_branch = tmp;
1611   }
1612 









1613   // Branch is taken:
1614   { PreserveJVMState pjvms(this);
1615     taken_branch = _gvn.transform(taken_branch);
1616     set_control(taken_branch);



1617 
1618     if (stopped()) {
1619       if (C->eliminate_boxing()) {
1620         // Mark the successor block as parsed
1621         branch_block->next_path_num();
1622       }
1623     } else {
1624       // Update method data
1625       profile_taken_branch(target_bci);
1626       adjust_map_after_if(taken_btest, c, prob, branch_block, next_block);
1627       if (!stopped()) {
1628         merge(target_bci);
1629       }
1630     }
1631   }
1632 
1633   untaken_branch = _gvn.transform(untaken_branch);
1634   set_control(untaken_branch);



1635 
1636   // Branch not taken.
1637   if (stopped()) {
1638     if (C->eliminate_boxing()) {
1639       // Mark the successor block as parsed
1640       next_block->next_path_num();
1641     }
1642   } else {
1643     // Update method data
1644     profile_not_taken_branch();
1645     adjust_map_after_if(untaken_btest, c, untaken_prob,
1646                         next_block, branch_block);
1647   }
1648 }
1649 
1650 bool Parse::path_is_suitable_for_uncommon_trap(float prob) const {
1651   // Don't want to speculate on uncommon traps when running with -Xcomp
1652   if (!UseInterpreter) {
1653     return false;
1654   }


2739       assert(null_ctl->is_top(), "no null control here");
2740       dec_sp(1);
2741     } else if (_gvn.type(b)->speculative_always_null() &&
2742                !too_many_traps(Deoptimization::Reason_speculate_null_assert)) {
2743       inc_sp(1);
2744       b = null_assert(b);
2745       dec_sp(1);
2746     }
2747     c = _gvn.transform( new CmpPNode(b, a) );
2748     do_ifnull(btest, c);
2749     break;
2750 
2751   case Bytecodes::_if_acmpeq: btest = BoolTest::eq; goto handle_if_acmp;
2752   case Bytecodes::_if_acmpne: btest = BoolTest::ne; goto handle_if_acmp;
2753   handle_if_acmp:
2754     // If this is a backwards branch in the bytecodes, add Safepoint
2755     maybe_add_safepoint(iter().get_dest());
2756     a = pop();
2757     b = pop();
2758 #if INCLUDE_SHENANDOAHGC
2759     if (UseShenandoahGC && ShenandoahAcmpBarrier) {
2760       a = access_resolve_for_write(a);
2761       b = access_resolve_for_write(b);
2762     }
2763 #endif
2764     c = _gvn.transform( new CmpPNode(b, a) );
2765     c = optimize_cmp_with_klass(c);
2766     do_if(btest, c);
2767     break;
2768 
2769   case Bytecodes::_ifeq: btest = BoolTest::eq; goto handle_ifxx;
2770   case Bytecodes::_ifne: btest = BoolTest::ne; goto handle_ifxx;
2771   case Bytecodes::_iflt: btest = BoolTest::lt; goto handle_ifxx;
2772   case Bytecodes::_ifle: btest = BoolTest::le; goto handle_ifxx;
2773   case Bytecodes::_ifgt: btest = BoolTest::gt; goto handle_ifxx;
2774   case Bytecodes::_ifge: btest = BoolTest::ge; goto handle_ifxx;
2775   handle_ifxx:
2776     // If this is a backwards branch in the bytecodes, add Safepoint
2777     maybe_add_safepoint(iter().get_dest());
2778     a = _gvn.intcon(0);
2779     b = pop();


< prev index next >