< prev index next >

src/hotspot/share/c1/c1_LIRGenerator.cpp

Print this page

  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_Compilation.hpp"
  27 #include "c1/c1_Defs.hpp"
  28 #include "c1/c1_FrameMap.hpp"
  29 #include "c1/c1_Instruction.hpp"
  30 #include "c1/c1_LIRAssembler.hpp"
  31 #include "c1/c1_LIRGenerator.hpp"
  32 #include "c1/c1_ValueStack.hpp"
  33 #include "ci/ciArrayKlass.hpp"


  34 #include "ci/ciInstance.hpp"
  35 #include "ci/ciObjArray.hpp"
  36 #include "ci/ciUtilities.hpp"
  37 #include "gc/shared/barrierSet.hpp"
  38 #include "gc/shared/c1/barrierSetC1.hpp"
  39 #include "oops/klass.inline.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #include "runtime/vm_version.hpp"
  43 #include "utilities/bitMap.inline.hpp"
  44 #include "utilities/macros.hpp"
  45 #include "utilities/powerOfTwo.hpp"
  46 
  47 #ifdef ASSERT
  48 #define __ gen()->lir(__FILE__, __LINE__)->
  49 #else
  50 #define __ gen()->lir()->
  51 #endif
  52 
  53 #ifndef PATCHED_ADDR

 193   ResolveNode* source = source_node(src);
 194   source->append(destination_node(dest));
 195 }
 196 
 197 
 198 //--------------------------------------------------------------
 199 // LIRItem
 200 
 201 void LIRItem::set_result(LIR_Opr opr) {
 202   assert(value()->operand()->is_illegal() || value()->operand()->is_constant(), "operand should never change");
 203   value()->set_operand(opr);
 204 
 205   if (opr->is_virtual()) {
 206     _gen->_instruction_for_operand.at_put_grow(opr->vreg_number(), value(), NULL);
 207   }
 208 
 209   _result = opr;
 210 }
 211 
 212 void LIRItem::load_item() {


 213   if (result()->is_illegal()) {
 214     // update the items result
 215     _result = value()->operand();
 216   }
 217   if (!result()->is_register()) {
 218     LIR_Opr reg = _gen->new_register(value()->type());
 219     __ move(result(), reg);
 220     if (result()->is_constant()) {
 221       _result = reg;
 222     } else {
 223       set_result(reg);
 224     }
 225   }
 226 }
 227 
 228 
 229 void LIRItem::load_for_store(BasicType type) {
 230   if (_gen->can_store_as_constant(value(), type)) {
 231     _result = value()->operand();
 232     if (!_result->is_constant()) {

 588     assert(right_op != result_op, "malformed");
 589     __ move(left_op, result_op);
 590     left_op = result_op;
 591   }
 592 
 593   switch(code) {
 594     case Bytecodes::_iand:
 595     case Bytecodes::_land:  __ logical_and(left_op, right_op, result_op); break;
 596 
 597     case Bytecodes::_ior:
 598     case Bytecodes::_lor:   __ logical_or(left_op, right_op, result_op);  break;
 599 
 600     case Bytecodes::_ixor:
 601     case Bytecodes::_lxor:  __ logical_xor(left_op, right_op, result_op); break;
 602 
 603     default: ShouldNotReachHere();
 604   }
 605 }
 606 
 607 
 608 void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {

 609   if (!GenerateSynchronizationCode) return;
 610   // for slow path, use debug info for state after successful locking
 611   CodeStub* slow_path = new MonitorEnterStub(object, lock, info);
 612   __ load_stack_address_monitor(monitor_no, lock);
 613   // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
 614   __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception);
 615 }
 616 
 617 
 618 void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
 619   if (!GenerateSynchronizationCode) return;
 620   // setup registers
 621   LIR_Opr hdr = lock;
 622   lock = new_hdr;
 623   CodeStub* slow_path = new MonitorExitStub(lock, UseFastLocking, monitor_no);
 624   __ load_stack_address_monitor(monitor_no, lock);
 625   __ unlock_object(hdr, object, lock, scratch, slow_path);
 626 }
 627 
 628 #ifndef PRODUCT
 629 void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
 630   if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
 631     tty->print_cr("   ###class not loaded at new bci %d", new_instance->printable_bci());
 632   } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only_no_jvmci() && new_instance->is_unresolved())) {
 633     tty->print_cr("   ###class not resolved at new bci %d", new_instance->printable_bci());
 634   }
 635 }
 636 #endif
 637 
 638 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
 639   klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
 640   // If klass is not loaded we do not know if the klass has finalizers:
 641   if (UseFastNewInstance && klass->is_loaded()





 642       && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
 643 
 644     Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id;
 645 
 646     CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, stub_id);
 647 
 648     assert(klass->is_loaded(), "must be loaded");
 649     // allocate space for instance
 650     assert(klass->size_helper() > 0, "illegal instance size");
 651     const int instance_size = align_object_size(klass->size_helper());
 652     __ allocate_object(dst, scratch1, scratch2, scratch3, scratch4,
 653                        oopDesc::header_size(), instance_size, klass_reg, !klass->is_initialized(), slow_path);
 654   } else {
 655     CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, Runtime1::new_instance_id);
 656     __ branch(lir_cond_always, slow_path);
 657     __ branch_destination(slow_path->continuation());
 658   }
 659 }
 660 
 661 
 662 static bool is_constant_zero(Instruction* inst) {
 663   IntConstant* c = inst->type()->as_IntConstant();
 664   if (c) {
 665     return (c->value() == 0);
 666   }
 667   return false;
 668 }
 669 
 670 
 671 static bool positive_constant(Instruction* inst) {
 672   IntConstant* c = inst->type()->as_IntConstant();
 673   if (c) {
 674     return (c->value() >= 0);
 675   }
 676   return false;

 736       if (src_type != NULL) {
 737         if (src_type->element_type()->is_subtype_of(dst_type->element_type())) {
 738           is_exact = true;
 739           expected_type = dst_type;
 740         }
 741       }
 742     }
 743     // at least pass along a good guess
 744     if (expected_type == NULL) expected_type = dst_exact_type;
 745     if (expected_type == NULL) expected_type = src_declared_type;
 746     if (expected_type == NULL) expected_type = dst_declared_type;
 747 
 748     src_objarray = (src_exact_type && src_exact_type->is_obj_array_klass()) || (src_declared_type && src_declared_type->is_obj_array_klass());
 749     dst_objarray = (dst_exact_type && dst_exact_type->is_obj_array_klass()) || (dst_declared_type && dst_declared_type->is_obj_array_klass());
 750   }
 751 
 752   // if a probable array type has been identified, figure out if any
 753   // of the required checks for a fast case can be elided.
 754   int flags = LIR_OpArrayCopy::all_flags;
 755 










 756   if (!src_objarray)
 757     flags &= ~LIR_OpArrayCopy::src_objarray;
 758   if (!dst_objarray)
 759     flags &= ~LIR_OpArrayCopy::dst_objarray;
 760 
 761   if (!x->arg_needs_null_check(0))
 762     flags &= ~LIR_OpArrayCopy::src_null_check;
 763   if (!x->arg_needs_null_check(2))
 764     flags &= ~LIR_OpArrayCopy::dst_null_check;
 765 
 766 
 767   if (expected_type != NULL) {
 768     Value length_limit = NULL;
 769 
 770     IfOp* ifop = length->as_IfOp();
 771     if (ifop != NULL) {
 772       // look for expressions like min(v, a.length) which ends up as
 773       //   x > y ? y : x  or  x >= y ? y : x
 774       if ((ifop->cond() == If::gtr || ifop->cond() == If::geq) &&
 775           ifop->x() == ifop->fval() &&

1508       case T_FLOAT:
1509         if (c->as_jint_bits() != other->as_jint_bits()) continue;
1510         break;
1511       case T_LONG:
1512       case T_DOUBLE:
1513         if (c->as_jint_hi_bits() != other->as_jint_hi_bits()) continue;
1514         if (c->as_jint_lo_bits() != other->as_jint_lo_bits()) continue;
1515         break;
1516       case T_OBJECT:
1517         if (c->as_jobject() != other->as_jobject()) continue;
1518         break;
1519       default:
1520         break;
1521       }
1522       return _reg_for_constants.at(i);
1523     }
1524   }
1525 
1526   LIR_Opr result = new_register(t);
1527   __ move((LIR_Opr)c, result);
1528   _constants.append(c);
1529   _reg_for_constants.append(result);


1530   return result;
1531 }
1532 






1533 //------------------------field access--------------------------------------
1534 
1535 void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
1536   assert(x->number_of_arguments() == 4, "wrong type");
1537   LIRItem obj   (x->argument_at(0), this);  // object
1538   LIRItem offset(x->argument_at(1), this);  // offset of field
1539   LIRItem cmp   (x->argument_at(2), this);  // value to compare with field
1540   LIRItem val   (x->argument_at(3), this);  // replace field with val if matches cmp
1541   assert(obj.type()->tag() == objectTag, "invalid type");
1542   assert(cmp.type()->tag() == type->tag(), "invalid type");
1543   assert(val.type()->tag() == type->tag(), "invalid type");
1544 
1545   LIR_Opr result = access_atomic_cmpxchg_at(IN_HEAP, as_BasicType(type),
1546                                             obj, offset, cmp, val);
1547   set_result(x, result);
1548 }
1549 
1550 // Comment copied form templateTable_i486.cpp
1551 // ----------------------------------------------------------------------------
1552 // Volatile variables demand their effects be made known to all CPU's in

1604     // load item if field not constant
1605     // because of code patching we cannot inline constants
1606     if (field_type == T_BYTE || field_type == T_BOOLEAN) {
1607       value.load_byte_item();
1608     } else  {
1609       value.load_item();
1610     }
1611   } else {
1612     value.load_for_store(field_type);
1613   }
1614 
1615   set_no_result(x);
1616 
1617 #ifndef PRODUCT
1618   if (PrintNotLoaded && needs_patching) {
1619     tty->print_cr("   ###class not loaded at store_%s bci %d",
1620                   x->is_static() ?  "static" : "field", x->printable_bci());
1621   }
1622 #endif
1623 





1624   if (x->needs_null_check() &&
1625       (needs_patching ||
1626        MacroAssembler::needs_explicit_null_check(x->offset()))) {
1627     // Emit an explicit null check because the offset is too large.
1628     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
1629     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
1630     __ null_check(object.result(), new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1631   }
1632 
1633   DecoratorSet decorators = IN_HEAP;
1634   if (is_volatile) {
1635     decorators |= MO_SEQ_CST;
1636   }
1637   if (needs_patching) {
1638     decorators |= C1_NEEDS_PATCHING;
1639   }
1640 
1641   access_store_at(decorators, field_type, object, LIR_OprFact::intConst(x->offset()),
1642                   value.result(), info != NULL ? new CodeEmitInfo(info) : NULL, info);
1643 }
1644 











































































































































































1645 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
1646   assert(x->is_pinned(),"");


1647   bool needs_range_check = x->compute_needs_range_check();
1648   bool use_length = x->length() != NULL;
1649   bool obj_store = is_reference_type(x->elt_type());
1650   bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
1651                                          !get_jobject_constant(x->value())->is_null_object() ||
1652                                          x->should_profile());
1653 
1654   LIRItem array(x->array(), this);
1655   LIRItem index(x->index(), this);
1656   LIRItem value(x->value(), this);
1657   LIRItem length(this);
1658 
1659   array.load_item();
1660   index.load_nonconstant();
1661 
1662   if (use_length && needs_range_check) {
1663     length.set_instruction(x->length());
1664     length.load_item();
1665 
1666   }
1667   if (needs_store_check || x->check_boolean()) {


1668     value.load_item();
1669   } else {
1670     value.load_for_store(x->elt_type());
1671   }
1672 
1673   set_no_result(x);
1674 
1675   // the CodeEmitInfo must be duplicated for each different
1676   // LIR-instruction because spilling can occur anywhere between two
1677   // instructions and so the debug information must be different
1678   CodeEmitInfo* range_check_info = state_for(x);
1679   CodeEmitInfo* null_check_info = NULL;
1680   if (x->needs_null_check()) {
1681     null_check_info = new CodeEmitInfo(range_check_info);
1682   }
1683 
1684   if (GenerateRangeChecks && needs_range_check) {
1685     if (use_length) {
1686       __ cmp(lir_cond_belowEqual, length.result(), index.result());
1687       __ branch(lir_cond_belowEqual, new RangeCheckStub(range_check_info, index.result(), array.result()));
1688     } else {
1689       array_range_check(array.result(), index.result(), null_check_info, range_check_info);
1690       // range_check also does the null check
1691       null_check_info = NULL;
1692     }
1693   }
1694 
















1695   if (GenerateArrayStoreCheck && needs_store_check) {
1696     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
1697     array_store_check(value.result(), array.result(), store_check_info, x->profiled_method(), x->profiled_bci());
1698   }
1699 
1700   DecoratorSet decorators = IN_HEAP | IS_ARRAY;
1701   if (x->check_boolean()) {
1702     decorators |= C1_MASK_BOOLEAN;
1703   }






1704 
1705   access_store_at(decorators, x->elt_type(), array, index.result(), value.result(),
1706                   NULL, null_check_info);





















1707 }
1708 
1709 void LIRGenerator::access_load_at(DecoratorSet decorators, BasicType type,
1710                                   LIRItem& base, LIR_Opr offset, LIR_Opr result,
1711                                   CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info) {
1712   decorators |= ACCESS_READ;
1713   LIRAccess access(this, decorators, base, offset, type, patch_info, load_emit_info);
1714   if (access.is_raw()) {
1715     _barrier_set->BarrierSetC1::load_at(access, result);
1716   } else {
1717     _barrier_set->load_at(access, result);
1718   }
1719 }
1720 
1721 void LIRGenerator::access_load(DecoratorSet decorators, BasicType type,
1722                                LIR_Opr addr, LIR_Opr result) {
1723   decorators |= ACCESS_READ;
1724   LIRAccess access(this, decorators, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, type);
1725   access.set_resolved_addr(addr);
1726   if (access.is_raw()) {

1767     return _barrier_set->BarrierSetC1::atomic_xchg_at(access, value);
1768   } else {
1769     return _barrier_set->atomic_xchg_at(access, value);
1770   }
1771 }
1772 
1773 LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType type,
1774                                            LIRItem& base, LIRItem& offset, LIRItem& value) {
1775   decorators |= ACCESS_READ;
1776   decorators |= ACCESS_WRITE;
1777   // Atomic operations are SEQ_CST by default
1778   decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0;
1779   LIRAccess access(this, decorators, base, offset, type);
1780   if (access.is_raw()) {
1781     return _barrier_set->BarrierSetC1::atomic_add_at(access, value);
1782   } else {
1783     return _barrier_set->atomic_add_at(access, value);
1784   }
1785 }
1786 

























1787 void LIRGenerator::do_LoadField(LoadField* x) {
1788   bool needs_patching = x->needs_patching();
1789   bool is_volatile = x->field()->is_volatile();
1790   BasicType field_type = x->field_type();
1791 
1792   CodeEmitInfo* info = NULL;
1793   if (needs_patching) {
1794     assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
1795     info = state_for(x, x->state_before());
1796   } else if (x->needs_null_check()) {
1797     NullCheck* nc = x->explicit_null_check();
1798     if (nc == NULL) {
1799       info = state_for(x);
1800     } else {
1801       info = state_for(nc);
1802     }
1803   }
1804 
1805   LIRItem object(x->obj(), this);
1806 
1807   object.load_item();
1808 
1809 #ifndef PRODUCT
1810   if (PrintNotLoaded && needs_patching) {
1811     tty->print_cr("   ###class not loaded at load_%s bci %d",
1812                   x->is_static() ?  "static" : "field", x->printable_bci());
1813   }
1814 #endif
1815 







1816   bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception();
1817   if (x->needs_null_check() &&
1818       (needs_patching ||
1819        MacroAssembler::needs_explicit_null_check(x->offset()) ||
1820        stress_deopt)) {
1821     LIR_Opr obj = object.result();
1822     if (stress_deopt) {
1823       obj = new_register(T_OBJECT);
1824       __ move(LIR_OprFact::oopConst(NULL), obj);
1825     }
1826     // Emit an explicit null check because the offset is too large.
1827     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
1828     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
1829     __ null_check(obj, new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1830   }
1831 
1832   DecoratorSet decorators = IN_HEAP;
1833   if (is_volatile) {
1834     decorators |= MO_SEQ_CST;
1835   }
1836   if (needs_patching) {
1837     decorators |= C1_NEEDS_PATCHING;
1838   }
1839 
1840   LIR_Opr result = rlock_result(x, field_type);
1841   access_load_at(decorators, field_type,
1842                  object, LIR_OprFact::intConst(x->offset()), result,
1843                  info ? new CodeEmitInfo(info) : NULL, info);



























1844 }
1845 
1846 // int/long jdk.internal.util.Preconditions.checkIndex
1847 void LIRGenerator::do_PreconditionsCheckIndex(Intrinsic* x, BasicType type) {
1848   assert(x->number_of_arguments() == 3, "wrong type");
1849   LIRItem index(x->argument_at(0), this);
1850   LIRItem length(x->argument_at(1), this);
1851   LIRItem oobef(x->argument_at(2), this);
1852 
1853   index.load_item();
1854   length.load_item();
1855   oobef.load_item();
1856 
1857   LIR_Opr result = rlock_result(x);
1858   // x->state() is created from copy_state_for_exception, it does not contains arguments
1859   // we should prepare them before entering into interpreter mode due to deoptimization.
1860   ValueStack* state = x->state();
1861   for (int i = 0; i < x->number_of_arguments(); i++) {
1862     Value arg = x->argument_at(i);
1863     state->push(arg->type(), arg);

1968       __ move(LIR_OprFact::oopConst(NULL), obj);
1969       __ null_check(obj, new CodeEmitInfo(null_check_info));
1970     }
1971   }
1972 
1973   if (GenerateRangeChecks && needs_range_check) {
1974     if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) {
1975       __ branch(lir_cond_always, new RangeCheckStub(range_check_info, index.result(), array.result()));
1976     } else if (use_length) {
1977       // TODO: use a (modified) version of array_range_check that does not require a
1978       //       constant length to be loaded to a register
1979       __ cmp(lir_cond_belowEqual, length.result(), index.result());
1980       __ branch(lir_cond_belowEqual, new RangeCheckStub(range_check_info, index.result(), array.result()));
1981     } else {
1982       array_range_check(array.result(), index.result(), null_check_info, range_check_info);
1983       // The range check performs the null check, so clear it out for the load
1984       null_check_info = NULL;
1985     }
1986   }
1987 
1988   DecoratorSet decorators = IN_HEAP | IS_ARRAY;







































1989 
1990   LIR_Opr result = rlock_result(x, x->elt_type());
1991   access_load_at(decorators, x->elt_type(),
1992                  array, index.result(), result,
1993                  NULL, null_check_info);

























1994 }
1995 












1996 
1997 void LIRGenerator::do_NullCheck(NullCheck* x) {
1998   if (x->can_trap()) {
1999     LIRItem value(x->obj(), this);
2000     value.load_item();
2001     CodeEmitInfo* info = state_for(x);
2002     __ null_check(value.result(), info);
2003   }
2004 }
2005 
2006 
2007 void LIRGenerator::do_TypeCast(TypeCast* x) {
2008   LIRItem value(x->obj(), this);
2009   value.load_item();
2010   // the result is the same as from the node we are casting
2011   set_result(x, value.result());
2012 }
2013 
2014 
2015 void LIRGenerator::do_Throw(Throw* x) {

2474   Compilation* comp = Compilation::current();
2475   if (do_update) {
2476     // try to find exact type, using CHA if possible, so that loading
2477     // the klass from the object can be avoided
2478     ciType* type = obj->exact_type();
2479     if (type == NULL) {
2480       type = obj->declared_type();
2481       type = comp->cha_exact_type(type);
2482     }
2483     assert(type == NULL || type->is_klass(), "type should be class");
2484     exact_klass = (type != NULL && type->is_loaded()) ? (ciKlass*)type : NULL;
2485 
2486     do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
2487   }
2488 
2489   if (!do_null && !do_update) {
2490     return result;
2491   }
2492 
2493   ciKlass* exact_signature_k = NULL;
2494   if (do_update) {
2495     // Is the type from the signature exact (the only one possible)?
2496     exact_signature_k = signature_at_call_k->exact_klass();
2497     if (exact_signature_k == NULL) {
2498       exact_signature_k = comp->cha_exact_type(signature_at_call_k);
2499     } else {
2500       result = exact_signature_k;
2501       // Known statically. No need to emit any code: prevent
2502       // LIR_Assembler::emit_profile_type() from emitting useless code
2503       profiled_k = ciTypeEntries::with_status(result, profiled_k);
2504     }
2505     // exact_klass and exact_signature_k can be both non NULL but
2506     // different if exact_klass is loaded after the ciObject for
2507     // exact_signature_k is created.
2508     if (exact_klass == NULL && exact_signature_k != NULL && exact_klass != exact_signature_k) {
2509       // sometimes the type of the signature is better than the best type
2510       // the compiler has
2511       exact_klass = exact_signature_k;
2512     }
2513     if (callee_signature_k != NULL &&
2514         callee_signature_k != signature_at_call_k) {

2559         assert(!src->is_illegal(), "check");
2560         BasicType t = src->type();
2561         if (is_reference_type(t)) {
2562           intptr_t profiled_k = parameters->type(j);
2563           Local* local = x->state()->local_at(java_index)->as_Local();
2564           ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
2565                                         in_bytes(ParametersTypeData::type_offset(j)) - in_bytes(ParametersTypeData::type_offset(0)),
2566                                         profiled_k, local, mdp, false, local->declared_type()->as_klass(), NULL);
2567           // If the profile is known statically set it once for all and do not emit any code
2568           if (exact != NULL) {
2569             md->set_parameter_type(j, exact);
2570           }
2571           j++;
2572         }
2573         java_index += type2size[t];
2574       }
2575     }
2576   }
2577 }
2578 














































2579 void LIRGenerator::do_Base(Base* x) {
2580   __ std_entry(LIR_OprFact::illegalOpr);
2581   // Emit moves from physical registers / stack slots to virtual registers
2582   CallingConvention* args = compilation()->frame_map()->incoming_arguments();
2583   IRScope* irScope = compilation()->hir()->top_scope();
2584   int java_index = 0;
2585   for (int i = 0; i < args->length(); i++) {
2586     LIR_Opr src = args->at(i);
2587     assert(!src->is_illegal(), "check");
2588     BasicType t = src->type();
2589 
2590     // Types which are smaller than int are passed as int, so
2591     // correct the type which passed.
2592     switch (t) {
2593     case T_BYTE:
2594     case T_BOOLEAN:
2595     case T_SHORT:
2596     case T_CHAR:
2597       t = T_INT;
2598       break;

2643       LIR_Opr lock = syncLockOpr();
2644       __ load_stack_address_monitor(0, lock);
2645 
2646       CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException));
2647       CodeStub* slow_path = new MonitorEnterStub(obj, lock, info);
2648 
2649       // receiver is guaranteed non-NULL so don't need CodeEmitInfo
2650       __ lock_object(syncTempOpr(), obj, lock, new_register(T_OBJECT), slow_path, NULL);
2651     }
2652   }
2653   if (compilation()->age_code()) {
2654     CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, 0), NULL, false);
2655     decrement_age(info);
2656   }
2657   // increment invocation counters if needed
2658   if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting.
2659     profile_parameters(x);
2660     CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false);
2661     increment_invocation_counter(info);
2662   }








2663 
2664   // all blocks with a successor must end with an unconditional jump
2665   // to the successor even if they are consecutive
2666   __ jump(x->default_sux());
2667 }
2668 
2669 
2670 void LIRGenerator::do_OsrEntry(OsrEntry* x) {
2671   // construct our frame and model the production of incoming pointer
2672   // to the OSR buffer.
2673   __ osr_entry(LIR_Assembler::osrBufferPointer());
2674   LIR_Opr result = rlock_result(x);
2675   __ move(LIR_Assembler::osrBufferPointer(), result);
2676 }
2677 














2678 
2679 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) {
2680   assert(args->length() == arg_list->length(),
2681          "args=%d, arg_list=%d", args->length(), arg_list->length());
2682   for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) {
2683     LIRItem* param = args->at(i);
2684     LIR_Opr loc = arg_list->at(i);
2685     if (loc->is_register()) {
2686       param->load_item_force(loc);
2687     } else {
2688       LIR_Address* addr = loc->as_address_ptr();
2689       param->load_for_store(addr->type());
2690       if (addr->type() == T_OBJECT) {
2691         __ move_wide(param->result(), addr);
2692       } else
2693         __ move(param->result(), addr);
2694     }
2695   }
2696 
2697   if (x->has_receiver()) {
2698     LIRItem* receiver = args->at(0);
2699     LIR_Opr loc = arg_list->at(0);
2700     if (loc->is_register()) {
2701       receiver->load_item_force(loc);
2702     } else {
2703       assert(loc->is_address(), "just checking");
2704       receiver->load_for_store(T_OBJECT);
2705       __ move_wide(receiver->result(), loc->as_address_ptr());
2706     }
2707   }
2708 }
2709 
2710 
2711 // Visits all arguments, returns appropriate items without loading them
2712 LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) {
2713   LIRItemList* argument_items = new LIRItemList();
2714   if (x->has_receiver()) {

2840   __ move(tmp, reg);
2841 }
2842 
2843 
2844 
2845 // Code for  :  x->x() {x->cond()} x->y() ? x->tval() : x->fval()
2846 void LIRGenerator::do_IfOp(IfOp* x) {
2847 #ifdef ASSERT
2848   {
2849     ValueTag xtag = x->x()->type()->tag();
2850     ValueTag ttag = x->tval()->type()->tag();
2851     assert(xtag == intTag || xtag == objectTag, "cannot handle others");
2852     assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others");
2853     assert(ttag == x->fval()->type()->tag(), "cannot handle others");
2854   }
2855 #endif
2856 
2857   LIRItem left(x->x(), this);
2858   LIRItem right(x->y(), this);
2859   left.load_item();
2860   if (can_inline_as_constant(right.value())) {
2861     right.dont_load_item();
2862   } else {

2863     right.load_item();
2864   }
2865 
2866   LIRItem t_val(x->tval(), this);
2867   LIRItem f_val(x->fval(), this);
2868   t_val.dont_load_item();
2869   f_val.dont_load_item();
2870   LIR_Opr reg = rlock_result(x);
2871 
2872   __ cmp(lir_cond(x->cond()), left.result(), right.result());
2873   __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));


























































2874 }
2875 
2876 #ifdef JFR_HAVE_INTRINSICS
2877 
2878 void LIRGenerator::do_getEventWriter(Intrinsic* x) {
2879   LabelObj* L_end = new LabelObj();
2880 
2881   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
2882   // meaning of these two is mixed up (see JDK-8026837).
2883   LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
2884                                            in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR),
2885                                            T_ADDRESS);
2886   LIR_Opr result = rlock_result(x);
2887   __ move(LIR_OprFact::oopConst(NULL), result);
2888   LIR_Opr jobj = new_register(T_METADATA);
2889   __ move_wide(jobj_addr, jobj);
2890   __ cmp(lir_cond_equal, jobj, LIR_OprFact::metadataConst(0));
2891   __ branch(lir_cond_equal, L_end->label());
2892 
2893   access_load(IN_NATIVE, T_OBJECT, LIR_OprFact::address(new LIR_Address(jobj, T_OBJECT)), result);

3145   if (x->recv() != NULL || x->nb_profiled_args() > 0) {
3146     profile_parameters_at_call(x);
3147   }
3148 
3149   if (x->recv() != NULL) {
3150     LIRItem value(x->recv(), this);
3151     value.load_item();
3152     recv = new_register(T_OBJECT);
3153     __ move(value.result(), recv);
3154   }
3155   __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
3156 }
3157 
3158 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
3159   int bci = x->bci_of_invoke();
3160   ciMethodData* md = x->method()->method_data_or_null();
3161   assert(md != NULL, "Sanity");
3162   ciProfileData* data = md->bci_to_data(bci);
3163   if (data != NULL) {
3164     assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
3165     ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
3166     LIR_Opr mdp = LIR_OprFact::illegalOpr;
3167 
3168     bool ignored_will_link;
3169     ciSignature* signature_at_call = NULL;
3170     x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3171 
3172     // The offset within the MDO of the entry to update may be too large
3173     // to be used in load/store instructions on some platforms. So have
3174     // profile_type() compute the address of the profile in a register.
3175     ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
3176         ret->type(), x->ret(), mdp,
3177         !x->needs_null_check(),
3178         signature_at_call->return_type()->as_klass(),
3179         x->callee()->signature()->return_type()->as_klass());
3180     if (exact != NULL) {
3181       md->set_return_type(bci, exact);
3182     }
3183   }
3184 }
3185 















































3186 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
3187   // We can safely ignore accessors here, since c2 will inline them anyway,
3188   // accessors are also always mature.
3189   if (!x->inlinee()->is_accessor()) {
3190     CodeEmitInfo* info = state_for(x, x->state(), true);
3191     // Notify the runtime very infrequently only to take care of counter overflows
3192     int freq_log = Tier23InlineeNotifyFreqLog;
3193     double scale;
3194     if (_method->has_option_value(CompileCommand::CompileThresholdScaling, scale)) {
3195       freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3196     }
3197     increment_event_counter_impl(info, x->inlinee(), LIR_OprFact::intConst(InvocationCounter::count_increment), right_n_bits(freq_log), InvocationEntryBci, false, true);
3198   }
3199 }
3200 
3201 void LIRGenerator::increment_backedge_counter_conditionally(LIR_Condition cond, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info, int left_bci, int right_bci, int bci) {
3202   if (compilation()->is_profiling()) {
3203 #if defined(X86) && !defined(_LP64)
3204     // BEWARE! On 32-bit x86 cmp clobbers its left argument so we need a temp copy.
3205     LIR_Opr left_copy = new_register(left->type());

  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "c1/c1_Compilation.hpp"
  27 #include "c1/c1_Defs.hpp"
  28 #include "c1/c1_FrameMap.hpp"
  29 #include "c1/c1_Instruction.hpp"
  30 #include "c1/c1_LIRAssembler.hpp"
  31 #include "c1/c1_LIRGenerator.hpp"
  32 #include "c1/c1_ValueStack.hpp"
  33 #include "ci/ciArrayKlass.hpp"
  34 #include "ci/ciFlatArrayKlass.hpp"
  35 #include "ci/ciInlineKlass.hpp"
  36 #include "ci/ciInstance.hpp"
  37 #include "ci/ciObjArray.hpp"
  38 #include "ci/ciUtilities.hpp"
  39 #include "gc/shared/barrierSet.hpp"
  40 #include "gc/shared/c1/barrierSetC1.hpp"
  41 #include "oops/klass.inline.hpp"
  42 #include "runtime/sharedRuntime.hpp"
  43 #include "runtime/stubRoutines.hpp"
  44 #include "runtime/vm_version.hpp"
  45 #include "utilities/bitMap.inline.hpp"
  46 #include "utilities/macros.hpp"
  47 #include "utilities/powerOfTwo.hpp"
  48 
  49 #ifdef ASSERT
  50 #define __ gen()->lir(__FILE__, __LINE__)->
  51 #else
  52 #define __ gen()->lir()->
  53 #endif
  54 
  55 #ifndef PATCHED_ADDR

 195   ResolveNode* source = source_node(src);
 196   source->append(destination_node(dest));
 197 }
 198 
 199 
 200 //--------------------------------------------------------------
 201 // LIRItem
 202 
 203 void LIRItem::set_result(LIR_Opr opr) {
 204   assert(value()->operand()->is_illegal() || value()->operand()->is_constant(), "operand should never change");
 205   value()->set_operand(opr);
 206 
 207   if (opr->is_virtual()) {
 208     _gen->_instruction_for_operand.at_put_grow(opr->vreg_number(), value(), NULL);
 209   }
 210 
 211   _result = opr;
 212 }
 213 
 214 void LIRItem::load_item() {
 215   assert(!_gen->in_conditional_code(), "LIRItem cannot be loaded in conditional code");
 216 
 217   if (result()->is_illegal()) {
 218     // update the items result
 219     _result = value()->operand();
 220   }
 221   if (!result()->is_register()) {
 222     LIR_Opr reg = _gen->new_register(value()->type());
 223     __ move(result(), reg);
 224     if (result()->is_constant()) {
 225       _result = reg;
 226     } else {
 227       set_result(reg);
 228     }
 229   }
 230 }
 231 
 232 
 233 void LIRItem::load_for_store(BasicType type) {
 234   if (_gen->can_store_as_constant(value(), type)) {
 235     _result = value()->operand();
 236     if (!_result->is_constant()) {

 592     assert(right_op != result_op, "malformed");
 593     __ move(left_op, result_op);
 594     left_op = result_op;
 595   }
 596 
 597   switch(code) {
 598     case Bytecodes::_iand:
 599     case Bytecodes::_land:  __ logical_and(left_op, right_op, result_op); break;
 600 
 601     case Bytecodes::_ior:
 602     case Bytecodes::_lor:   __ logical_or(left_op, right_op, result_op);  break;
 603 
 604     case Bytecodes::_ixor:
 605     case Bytecodes::_lxor:  __ logical_xor(left_op, right_op, result_op); break;
 606 
 607     default: ShouldNotReachHere();
 608   }
 609 }
 610 
 611 
 612 void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no,
 613                                  CodeEmitInfo* info_for_exception, CodeEmitInfo* info, CodeStub* throw_imse_stub) {
 614   if (!GenerateSynchronizationCode) return;
 615   // for slow path, use debug info for state after successful locking
 616   CodeStub* slow_path = new MonitorEnterStub(object, lock, info, throw_imse_stub, scratch);
 617   __ load_stack_address_monitor(monitor_no, lock);
 618   // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
 619   __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception, throw_imse_stub);
 620 }
 621 
 622 
 623 void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
 624   if (!GenerateSynchronizationCode) return;
 625   // setup registers
 626   LIR_Opr hdr = lock;
 627   lock = new_hdr;
 628   CodeStub* slow_path = new MonitorExitStub(lock, UseFastLocking, monitor_no);
 629   __ load_stack_address_monitor(monitor_no, lock);
 630   __ unlock_object(hdr, object, lock, scratch, slow_path);
 631 }
 632 
 633 #ifndef PRODUCT
 634 void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
 635   if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
 636     tty->print_cr("   ###class not loaded at new bci %d", new_instance->printable_bci());
 637   } else if (PrintNotLoaded && (!CompilerConfig::is_c1_only_no_jvmci() && new_instance->is_unresolved())) {
 638     tty->print_cr("   ###class not resolved at new bci %d", new_instance->printable_bci());
 639   }
 640 }
 641 #endif
 642 
 643 void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, bool allow_inline, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
 644   if (allow_inline) {
 645     assert(!is_unresolved && klass->is_loaded(), "inline type klass should be resolved");
 646     __ metadata2reg(klass->constant_encoding(), klass_reg);
 647   } else {
 648     klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
 649   }
 650   // If klass is not loaded we do not know if the klass has finalizers or is an unexpected inline klass
 651   if (UseFastNewInstance && klass->is_loaded() && (allow_inline || !klass->is_inlinetype())
 652       && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
 653 
 654     Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id;
 655 
 656     CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, stub_id);
 657 
 658     assert(klass->is_loaded(), "must be loaded");
 659     // allocate space for instance
 660     assert(klass->size_helper() > 0, "illegal instance size");
 661     const int instance_size = align_object_size(klass->size_helper());
 662     __ allocate_object(dst, scratch1, scratch2, scratch3, scratch4,
 663                        oopDesc::header_size(), instance_size, klass_reg, !klass->is_initialized(), slow_path);
 664   } else {
 665     CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, allow_inline ? Runtime1::new_instance_id : Runtime1::new_instance_no_inline_id);
 666     __ jump(slow_path);
 667     __ branch_destination(slow_path->continuation());
 668   }
 669 }
 670 
 671 
 672 static bool is_constant_zero(Instruction* inst) {
 673   IntConstant* c = inst->type()->as_IntConstant();
 674   if (c) {
 675     return (c->value() == 0);
 676   }
 677   return false;
 678 }
 679 
 680 
 681 static bool positive_constant(Instruction* inst) {
 682   IntConstant* c = inst->type()->as_IntConstant();
 683   if (c) {
 684     return (c->value() >= 0);
 685   }
 686   return false;

 746       if (src_type != NULL) {
 747         if (src_type->element_type()->is_subtype_of(dst_type->element_type())) {
 748           is_exact = true;
 749           expected_type = dst_type;
 750         }
 751       }
 752     }
 753     // at least pass along a good guess
 754     if (expected_type == NULL) expected_type = dst_exact_type;
 755     if (expected_type == NULL) expected_type = src_declared_type;
 756     if (expected_type == NULL) expected_type = dst_declared_type;
 757 
 758     src_objarray = (src_exact_type && src_exact_type->is_obj_array_klass()) || (src_declared_type && src_declared_type->is_obj_array_klass());
 759     dst_objarray = (dst_exact_type && dst_exact_type->is_obj_array_klass()) || (dst_declared_type && dst_declared_type->is_obj_array_klass());
 760   }
 761 
 762   // if a probable array type has been identified, figure out if any
 763   // of the required checks for a fast case can be elided.
 764   int flags = LIR_OpArrayCopy::all_flags;
 765 
 766   if (!src->is_loaded_flattened_array() && !dst->is_loaded_flattened_array()) {
 767     flags &= ~LIR_OpArrayCopy::always_slow_path;
 768   }
 769   if (!src->maybe_flattened_array()) {
 770     flags &= ~LIR_OpArrayCopy::src_inlinetype_check;
 771   }
 772   if (!dst->maybe_flattened_array() && !dst->maybe_null_free_array()) {
 773     flags &= ~LIR_OpArrayCopy::dst_inlinetype_check;
 774   }
 775 
 776   if (!src_objarray)
 777     flags &= ~LIR_OpArrayCopy::src_objarray;
 778   if (!dst_objarray)
 779     flags &= ~LIR_OpArrayCopy::dst_objarray;
 780 
 781   if (!x->arg_needs_null_check(0))
 782     flags &= ~LIR_OpArrayCopy::src_null_check;
 783   if (!x->arg_needs_null_check(2))
 784     flags &= ~LIR_OpArrayCopy::dst_null_check;
 785 
 786 
 787   if (expected_type != NULL) {
 788     Value length_limit = NULL;
 789 
 790     IfOp* ifop = length->as_IfOp();
 791     if (ifop != NULL) {
 792       // look for expressions like min(v, a.length) which ends up as
 793       //   x > y ? y : x  or  x >= y ? y : x
 794       if ((ifop->cond() == If::gtr || ifop->cond() == If::geq) &&
 795           ifop->x() == ifop->fval() &&

1528       case T_FLOAT:
1529         if (c->as_jint_bits() != other->as_jint_bits()) continue;
1530         break;
1531       case T_LONG:
1532       case T_DOUBLE:
1533         if (c->as_jint_hi_bits() != other->as_jint_hi_bits()) continue;
1534         if (c->as_jint_lo_bits() != other->as_jint_lo_bits()) continue;
1535         break;
1536       case T_OBJECT:
1537         if (c->as_jobject() != other->as_jobject()) continue;
1538         break;
1539       default:
1540         break;
1541       }
1542       return _reg_for_constants.at(i);
1543     }
1544   }
1545 
1546   LIR_Opr result = new_register(t);
1547   __ move((LIR_Opr)c, result);
1548   if (!in_conditional_code()) {
1549     _constants.append(c);
1550     _reg_for_constants.append(result);
1551   }
1552   return result;
1553 }
1554 
1555 void LIRGenerator::set_in_conditional_code(bool v) {
1556   assert(v != _in_conditional_code, "must change state");
1557   _in_conditional_code = v;
1558 }
1559 
1560 
1561 //------------------------field access--------------------------------------
1562 
1563 void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
1564   assert(x->number_of_arguments() == 4, "wrong type");
1565   LIRItem obj   (x->argument_at(0), this);  // object
1566   LIRItem offset(x->argument_at(1), this);  // offset of field
1567   LIRItem cmp   (x->argument_at(2), this);  // value to compare with field
1568   LIRItem val   (x->argument_at(3), this);  // replace field with val if matches cmp
1569   assert(obj.type()->tag() == objectTag, "invalid type");
1570   assert(cmp.type()->tag() == type->tag(), "invalid type");
1571   assert(val.type()->tag() == type->tag(), "invalid type");
1572 
1573   LIR_Opr result = access_atomic_cmpxchg_at(IN_HEAP, as_BasicType(type),
1574                                             obj, offset, cmp, val);
1575   set_result(x, result);
1576 }
1577 
1578 // Comment copied form templateTable_i486.cpp
1579 // ----------------------------------------------------------------------------
1580 // Volatile variables demand their effects be made known to all CPU's in

1632     // load item if field not constant
1633     // because of code patching we cannot inline constants
1634     if (field_type == T_BYTE || field_type == T_BOOLEAN) {
1635       value.load_byte_item();
1636     } else  {
1637       value.load_item();
1638     }
1639   } else {
1640     value.load_for_store(field_type);
1641   }
1642 
1643   set_no_result(x);
1644 
1645 #ifndef PRODUCT
1646   if (PrintNotLoaded && needs_patching) {
1647     tty->print_cr("   ###class not loaded at store_%s bci %d",
1648                   x->is_static() ?  "static" : "field", x->printable_bci());
1649   }
1650 #endif
1651 
1652   if (!inline_type_field_access_prolog(x)) {
1653     // Field store will always deopt due to unloaded field or holder klass
1654     return;
1655   }
1656 
1657   if (x->needs_null_check() &&
1658       (needs_patching ||
1659        MacroAssembler::needs_explicit_null_check(x->offset()))) {
1660     // Emit an explicit null check because the offset is too large.
1661     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
1662     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
1663     __ null_check(object.result(), new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1664   }
1665 
1666   DecoratorSet decorators = IN_HEAP;
1667   if (is_volatile) {
1668     decorators |= MO_SEQ_CST;
1669   }
1670   if (needs_patching) {
1671     decorators |= C1_NEEDS_PATCHING;
1672   }
1673 
1674   access_store_at(decorators, field_type, object, LIR_OprFact::intConst(x->offset()),
1675                   value.result(), info != NULL ? new CodeEmitInfo(info) : NULL, info);
1676 }
1677 
1678 // FIXME -- I can't find any other way to pass an address to access_load_at().
1679 class TempResolvedAddress: public Instruction {
1680  public:
1681   TempResolvedAddress(ValueType* type, LIR_Opr addr) : Instruction(type) {
1682     set_operand(addr);
1683   }
1684   virtual void input_values_do(ValueVisitor*) {}
1685   virtual void visit(InstructionVisitor* v)   {}
1686   virtual const char* name() const  { return "TempResolvedAddress"; }
1687 };
1688 
1689 LIR_Opr LIRGenerator::get_and_load_element_address(LIRItem& array, LIRItem& index) {
1690   ciType* array_type = array.value()->declared_type();
1691   ciFlatArrayKlass* flat_array_klass = array_type->as_flat_array_klass();
1692   assert(flat_array_klass->is_loaded(), "must be");
1693 
1694   int array_header_size = flat_array_klass->array_header_in_bytes();
1695   int shift = flat_array_klass->log2_element_size();
1696 
1697 #ifndef _LP64
1698   LIR_Opr index_op = new_register(T_INT);
1699   // FIXME -- on 32-bit, the shift below can overflow, so we need to check that
1700   // the top (shift+1) bits of index_op must be zero, or
1701   // else throw ArrayIndexOutOfBoundsException
1702   if (index.result()->is_constant()) {
1703     jint const_index = index.result()->as_jint();
1704     __ move(LIR_OprFact::intConst(const_index << shift), index_op);
1705   } else {
1706     __ shift_left(index_op, shift, index.result());
1707   }
1708 #else
1709   LIR_Opr index_op = new_register(T_LONG);
1710   if (index.result()->is_constant()) {
1711     jint const_index = index.result()->as_jint();
1712     __ move(LIR_OprFact::longConst(const_index << shift), index_op);
1713   } else {
1714     __ convert(Bytecodes::_i2l, index.result(), index_op);
1715     // Need to shift manually, as LIR_Address can scale only up to 3.
1716     __ shift_left(index_op, shift, index_op);
1717   }
1718 #endif
1719 
1720   LIR_Opr elm_op = new_pointer_register();
1721   LIR_Address* elm_address = generate_address(array.result(), index_op, 0, array_header_size, T_ADDRESS);
1722   __ leal(LIR_OprFact::address(elm_address), elm_op);
1723   return elm_op;
1724 }
1725 
1726 void LIRGenerator::access_sub_element(LIRItem& array, LIRItem& index, LIR_Opr& result, ciField* field, int sub_offset) {
1727   assert(field != NULL, "Need a subelement type specified");
1728 
1729   // Find the starting address of the source (inside the array)
1730   LIR_Opr elm_op = get_and_load_element_address(array, index);
1731 
1732   BasicType subelt_type = field->type()->basic_type();
1733   TempResolvedAddress* elm_resolved_addr = new TempResolvedAddress(as_ValueType(subelt_type), elm_op);
1734   LIRItem elm_item(elm_resolved_addr, this);
1735 
1736   DecoratorSet decorators = IN_HEAP;
1737   access_load_at(decorators, subelt_type,
1738                      elm_item, LIR_OprFact::intConst(sub_offset), result,
1739                      NULL, NULL);
1740 
1741   if (field->is_null_free()) {
1742     assert(field->type()->as_inline_klass()->is_loaded(), "Must be");
1743     LabelObj* L_end = new LabelObj();
1744     __ cmp(lir_cond_notEqual, result, LIR_OprFact::oopConst(NULL));
1745     __ branch(lir_cond_notEqual, L_end->label());
1746     set_in_conditional_code(true);
1747     Constant* default_value = new Constant(new InstanceConstant(field->type()->as_inline_klass()->default_instance()));
1748     if (default_value->is_pinned()) {
1749       __ move(LIR_OprFact::value_type(default_value->type()), result);
1750     } else {
1751       __ move(load_constant(default_value), result);
1752     }
1753     __ branch_destination(L_end->label());
1754     set_in_conditional_code(false);
1755   }
1756 }
1757 
1758 void LIRGenerator::access_flattened_array(bool is_load, LIRItem& array, LIRItem& index, LIRItem& obj_item,
1759                                           ciField* field, int sub_offset) {
1760   assert(sub_offset == 0 || field != NULL, "Sanity check");
1761 
1762   // Find the starting address of the source (inside the array)
1763   LIR_Opr elm_op = get_and_load_element_address(array, index);
1764 
1765   ciInlineKlass* elem_klass = NULL;
1766   if (field != NULL) {
1767     elem_klass = field->type()->as_inline_klass();
1768   } else {
1769     elem_klass = array.value()->declared_type()->as_flat_array_klass()->element_klass()->as_inline_klass();
1770   }
1771   for (int i = 0; i < elem_klass->nof_nonstatic_fields(); i++) {
1772     ciField* inner_field = elem_klass->nonstatic_field_at(i);
1773     assert(!inner_field->is_flattened(), "flattened fields must have been expanded");
1774     int obj_offset = inner_field->offset();
1775     int elm_offset = obj_offset - elem_klass->first_field_offset() + sub_offset; // object header is not stored in array.
1776     BasicType field_type = inner_field->type()->basic_type();
1777 
1778     // Types which are smaller than int are still passed in an int register.
1779     BasicType reg_type = field_type;
1780     switch (reg_type) {
1781     case T_BYTE:
1782     case T_BOOLEAN:
1783     case T_SHORT:
1784     case T_CHAR:
1785       reg_type = T_INT;
1786       break;
1787     default:
1788       break;
1789     }
1790 
1791     LIR_Opr temp = new_register(reg_type);
1792     TempResolvedAddress* elm_resolved_addr = new TempResolvedAddress(as_ValueType(field_type), elm_op);
1793     LIRItem elm_item(elm_resolved_addr, this);
1794 
1795     DecoratorSet decorators = IN_HEAP;
1796     if (is_load) {
1797       access_load_at(decorators, field_type,
1798                      elm_item, LIR_OprFact::intConst(elm_offset), temp,
1799                      NULL, NULL);
1800       access_store_at(decorators, field_type,
1801                       obj_item, LIR_OprFact::intConst(obj_offset), temp,
1802                       NULL, NULL);
1803     } else {
1804       access_load_at(decorators, field_type,
1805                      obj_item, LIR_OprFact::intConst(obj_offset), temp,
1806                      NULL, NULL);
1807       access_store_at(decorators, field_type,
1808                       elm_item, LIR_OprFact::intConst(elm_offset), temp,
1809                       NULL, NULL);
1810     }
1811   }
1812 }
1813 
1814 void LIRGenerator::check_flattened_array(LIR_Opr array, LIR_Opr value, CodeStub* slow_path) {
1815   LIR_Opr tmp = new_register(T_METADATA);
1816   __ check_flattened_array(array, value, tmp, slow_path);
1817 }
1818 
1819 void LIRGenerator::check_null_free_array(LIRItem& array, LIRItem& value, CodeEmitInfo* info) {
1820   LabelObj* L_end = new LabelObj();
1821   LIR_Opr tmp = new_register(T_METADATA);
1822   __ check_null_free_array(array.result(), tmp);
1823   __ branch(lir_cond_equal, L_end->label());
1824   __ null_check(value.result(), info);
1825   __ branch_destination(L_end->label());
1826 }
1827 
1828 bool LIRGenerator::needs_flattened_array_store_check(StoreIndexed* x) {
1829   if (x->elt_type() == T_OBJECT && x->array()->maybe_flattened_array()) {
1830     ciType* type = x->value()->declared_type();
1831     if (type != NULL && type->is_klass()) {
1832       ciKlass* klass = type->as_klass();
1833       if (!klass->can_be_inline_klass() || (klass->is_inlinetype() && !klass->as_inline_klass()->flatten_array())) {
1834         // This is known to be a non-flattened object. If the array is flattened,
1835         // it will be caught by the code generated by array_store_check().
1836         return false;
1837       }
1838     }
1839     // We're not 100% sure, so let's do the flattened_array_store_check.
1840     return true;
1841   }
1842   return false;
1843 }
1844 
1845 bool LIRGenerator::needs_null_free_array_store_check(StoreIndexed* x) {
1846   return x->elt_type() == T_OBJECT && x->array()->maybe_null_free_array();
1847 }
1848 
1849 void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
1850   assert(x->is_pinned(),"");
1851   assert(x->elt_type() != T_ARRAY, "never used");
1852   bool is_loaded_flattened_array = x->array()->is_loaded_flattened_array();
1853   bool needs_range_check = x->compute_needs_range_check();
1854   bool use_length = x->length() != NULL;
1855   bool obj_store = is_reference_type(x->elt_type());
1856   bool needs_store_check = obj_store && !(is_loaded_flattened_array && x->is_exact_flattened_array_store()) &&
1857                                         (x->value()->as_Constant() == NULL ||
1858                                          !get_jobject_constant(x->value())->is_null_object());
1859 
1860   LIRItem array(x->array(), this);
1861   LIRItem index(x->index(), this);
1862   LIRItem value(x->value(), this);
1863   LIRItem length(this);
1864 
1865   array.load_item();
1866   index.load_nonconstant();
1867 
1868   if (use_length && needs_range_check) {
1869     length.set_instruction(x->length());
1870     length.load_item();

1871   }
1872 
1873   if (needs_store_check || x->check_boolean()
1874       || is_loaded_flattened_array || needs_flattened_array_store_check(x) || needs_null_free_array_store_check(x)) {
1875     value.load_item();
1876   } else {
1877     value.load_for_store(x->elt_type());
1878   }
1879 
1880   set_no_result(x);
1881 
1882   // the CodeEmitInfo must be duplicated for each different
1883   // LIR-instruction because spilling can occur anywhere between two
1884   // instructions and so the debug information must be different
1885   CodeEmitInfo* range_check_info = state_for(x);
1886   CodeEmitInfo* null_check_info = NULL;
1887   if (x->needs_null_check()) {
1888     null_check_info = new CodeEmitInfo(range_check_info);
1889   }
1890 
1891   if (GenerateRangeChecks && needs_range_check) {
1892     if (use_length) {
1893       __ cmp(lir_cond_belowEqual, length.result(), index.result());
1894       __ branch(lir_cond_belowEqual, new RangeCheckStub(range_check_info, index.result(), array.result()));
1895     } else {
1896       array_range_check(array.result(), index.result(), null_check_info, range_check_info);
1897       // range_check also does the null check
1898       null_check_info = NULL;
1899     }
1900   }
1901 
1902   if (x->should_profile()) {
1903     if (x->array()->is_loaded_flattened_array()) {
1904       // No need to profile a store to a flattened array of known type. This can happen if
1905       // the type only became known after optimizations (for example, after the PhiSimplifier).
1906       x->set_should_profile(false);
1907     } else {
1908       ciMethodData* md = NULL;
1909       ciArrayLoadStoreData* load_store = NULL;
1910       profile_array_type(x, md, load_store);
1911       if (x->array()->maybe_null_free_array()) {
1912         profile_null_free_array(array, md, load_store);
1913       }
1914       profile_element_type(x->value(), md, load_store);
1915     }
1916   }
1917 
1918   if (GenerateArrayStoreCheck && needs_store_check) {
1919     CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
1920     array_store_check(value.result(), array.result(), store_check_info, NULL, -1);
1921   }
1922 
1923   if (is_loaded_flattened_array) {
1924     if (!x->value()->is_null_free()) {
1925       __ null_check(value.result(), new CodeEmitInfo(range_check_info));
1926     }
1927     // If array element is an empty inline type, no need to copy anything
1928     if (!x->array()->declared_type()->as_flat_array_klass()->element_klass()->as_inline_klass()->is_empty()) {
1929       access_flattened_array(false, array, index, value);
1930     }
1931   } else {
1932     StoreFlattenedArrayStub* slow_path = NULL;
1933 
1934     if (needs_flattened_array_store_check(x)) {
1935       // Check if we indeed have a flattened array
1936       index.load_item();
1937       slow_path = new StoreFlattenedArrayStub(array.result(), index.result(), value.result(), state_for(x, x->state_before()));
1938       check_flattened_array(array.result(), value.result(), slow_path);
1939       set_in_conditional_code(true);
1940     } else if (needs_null_free_array_store_check(x)) {
1941       CodeEmitInfo* info = new CodeEmitInfo(range_check_info);
1942       check_null_free_array(array, value, info);
1943     }
1944 
1945     DecoratorSet decorators = IN_HEAP | IS_ARRAY;
1946     if (x->check_boolean()) {
1947       decorators |= C1_MASK_BOOLEAN;
1948     }
1949 
1950     access_store_at(decorators, x->elt_type(), array, index.result(), value.result(),
1951                     NULL, null_check_info);
1952     if (slow_path != NULL) {
1953       __ branch_destination(slow_path->continuation());
1954       set_in_conditional_code(false);
1955     }
1956   }
1957 }
1958 
1959 void LIRGenerator::access_load_at(DecoratorSet decorators, BasicType type,
1960                                   LIRItem& base, LIR_Opr offset, LIR_Opr result,
1961                                   CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info) {
1962   decorators |= ACCESS_READ;
1963   LIRAccess access(this, decorators, base, offset, type, patch_info, load_emit_info);
1964   if (access.is_raw()) {
1965     _barrier_set->BarrierSetC1::load_at(access, result);
1966   } else {
1967     _barrier_set->load_at(access, result);
1968   }
1969 }
1970 
1971 void LIRGenerator::access_load(DecoratorSet decorators, BasicType type,
1972                                LIR_Opr addr, LIR_Opr result) {
1973   decorators |= ACCESS_READ;
1974   LIRAccess access(this, decorators, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, type);
1975   access.set_resolved_addr(addr);
1976   if (access.is_raw()) {

2017     return _barrier_set->BarrierSetC1::atomic_xchg_at(access, value);
2018   } else {
2019     return _barrier_set->atomic_xchg_at(access, value);
2020   }
2021 }
2022 
2023 LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType type,
2024                                            LIRItem& base, LIRItem& offset, LIRItem& value) {
2025   decorators |= ACCESS_READ;
2026   decorators |= ACCESS_WRITE;
2027   // Atomic operations are SEQ_CST by default
2028   decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0;
2029   LIRAccess access(this, decorators, base, offset, type);
2030   if (access.is_raw()) {
2031     return _barrier_set->BarrierSetC1::atomic_add_at(access, value);
2032   } else {
2033     return _barrier_set->atomic_add_at(access, value);
2034   }
2035 }
2036 
2037 bool LIRGenerator::inline_type_field_access_prolog(AccessField* x) {
2038   ciField* field = x->field();
2039   assert(!field->is_flattened(), "Flattened field access should have been expanded");
2040   if (!field->is_null_free()) {
2041     return true; // Not an inline type field
2042   }
2043   // Deoptimize if the access is non-static and requires patching (holder not loaded
2044   // or not accessible) because then we only have partial field information and the
2045   // field could be flattened (see ciField constructor).
2046   bool could_be_flat = !x->is_static() && x->needs_patching();
2047   // Deoptimize if we load from a static field with an uninitialized type because we
2048   // need to throw an exception if initialization of the type failed.
2049   bool not_initialized = x->is_static() && x->as_LoadField() != NULL &&
2050       !field->type()->as_instance_klass()->is_initialized();
2051   if (could_be_flat || not_initialized) {
2052     CodeEmitInfo* info = state_for(x, x->state_before());
2053     CodeStub* stub = new DeoptimizeStub(new CodeEmitInfo(info),
2054                                         Deoptimization::Reason_unloaded,
2055                                         Deoptimization::Action_make_not_entrant);
2056     __ jump(stub);
2057     return false;
2058   }
2059   return true;
2060 }
2061 
2062 void LIRGenerator::do_LoadField(LoadField* x) {
2063   bool needs_patching = x->needs_patching();
2064   bool is_volatile = x->field()->is_volatile();
2065   BasicType field_type = x->field_type();
2066 
2067   CodeEmitInfo* info = NULL;
2068   if (needs_patching) {
2069     assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
2070     info = state_for(x, x->state_before());
2071   } else if (x->needs_null_check()) {
2072     NullCheck* nc = x->explicit_null_check();
2073     if (nc == NULL) {
2074       info = state_for(x);
2075     } else {
2076       info = state_for(nc);
2077     }
2078   }
2079 
2080   LIRItem object(x->obj(), this);
2081 
2082   object.load_item();
2083 
2084 #ifndef PRODUCT
2085   if (PrintNotLoaded && needs_patching) {
2086     tty->print_cr("   ###class not loaded at load_%s bci %d",
2087                   x->is_static() ?  "static" : "field", x->printable_bci());
2088   }
2089 #endif
2090 
2091   if (!inline_type_field_access_prolog(x)) {
2092     // Field load will always deopt due to unloaded field or holder klass
2093     LIR_Opr result = rlock_result(x, field_type);
2094     __ move(LIR_OprFact::oopConst(NULL), result);
2095     return;
2096   }
2097 
2098   bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception();
2099   if (x->needs_null_check() &&
2100       (needs_patching ||
2101        MacroAssembler::needs_explicit_null_check(x->offset()) ||
2102        stress_deopt)) {
2103     LIR_Opr obj = object.result();
2104     if (stress_deopt) {
2105       obj = new_register(T_OBJECT);
2106       __ move(LIR_OprFact::oopConst(NULL), obj);
2107     }
2108     // Emit an explicit null check because the offset is too large.
2109     // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
2110     // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
2111     __ null_check(obj, new CodeEmitInfo(info), /* deoptimize */ needs_patching);
2112   }
2113 
2114   DecoratorSet decorators = IN_HEAP;
2115   if (is_volatile) {
2116     decorators |= MO_SEQ_CST;
2117   }
2118   if (needs_patching) {
2119     decorators |= C1_NEEDS_PATCHING;
2120   }
2121 
2122   LIR_Opr result = rlock_result(x, field_type);
2123   access_load_at(decorators, field_type,
2124                  object, LIR_OprFact::intConst(x->offset()), result,
2125                  info ? new CodeEmitInfo(info) : NULL, info);
2126 
2127   ciField* field = x->field();
2128   if (field->is_null_free()) {
2129     // Load from non-flattened inline type field requires
2130     // a null check to replace null with the default value.
2131     ciInstanceKlass* holder = field->holder();
2132     if (field->is_static() && holder->is_loaded()) {
2133       ciObject* val = holder->java_mirror()->field_value(field).as_object();
2134       if (!val->is_null_object()) {
2135         // Static field is initialized, we don need to perform a null check.
2136         return;
2137       }
2138     }
2139     LabelObj* L_end = new LabelObj();
2140     __ cmp(lir_cond_notEqual, result, LIR_OprFact::oopConst(NULL));
2141     __ branch(lir_cond_notEqual, L_end->label());
2142     set_in_conditional_code(true);
2143     ciInlineKlass* inline_klass = field->type()->as_inline_klass();
2144     Constant* default_value = new Constant(new InstanceConstant(inline_klass->default_instance()));
2145     if (default_value->is_pinned()) {
2146       __ move(LIR_OprFact::value_type(default_value->type()), result);
2147     } else {
2148       __ move(load_constant(default_value), result);
2149     }
2150     __ branch_destination(L_end->label());
2151     set_in_conditional_code(false);
2152   }
2153 }
2154 
2155 // int/long jdk.internal.util.Preconditions.checkIndex
2156 void LIRGenerator::do_PreconditionsCheckIndex(Intrinsic* x, BasicType type) {
2157   assert(x->number_of_arguments() == 3, "wrong type");
2158   LIRItem index(x->argument_at(0), this);
2159   LIRItem length(x->argument_at(1), this);
2160   LIRItem oobef(x->argument_at(2), this);
2161 
2162   index.load_item();
2163   length.load_item();
2164   oobef.load_item();
2165 
2166   LIR_Opr result = rlock_result(x);
2167   // x->state() is created from copy_state_for_exception, it does not contains arguments
2168   // we should prepare them before entering into interpreter mode due to deoptimization.
2169   ValueStack* state = x->state();
2170   for (int i = 0; i < x->number_of_arguments(); i++) {
2171     Value arg = x->argument_at(i);
2172     state->push(arg->type(), arg);

2277       __ move(LIR_OprFact::oopConst(NULL), obj);
2278       __ null_check(obj, new CodeEmitInfo(null_check_info));
2279     }
2280   }
2281 
2282   if (GenerateRangeChecks && needs_range_check) {
2283     if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) {
2284       __ branch(lir_cond_always, new RangeCheckStub(range_check_info, index.result(), array.result()));
2285     } else if (use_length) {
2286       // TODO: use a (modified) version of array_range_check that does not require a
2287       //       constant length to be loaded to a register
2288       __ cmp(lir_cond_belowEqual, length.result(), index.result());
2289       __ branch(lir_cond_belowEqual, new RangeCheckStub(range_check_info, index.result(), array.result()));
2290     } else {
2291       array_range_check(array.result(), index.result(), null_check_info, range_check_info);
2292       // The range check performs the null check, so clear it out for the load
2293       null_check_info = NULL;
2294     }
2295   }
2296 
2297   ciMethodData* md = NULL;
2298   ciArrayLoadStoreData* load_store = NULL;
2299   if (x->should_profile()) {
2300     if (x->array()->is_loaded_flattened_array()) {
2301       // No need to profile a load from a flattened array of known type. This can happen if
2302       // the type only became known after optimizations (for example, after the PhiSimplifier).
2303       x->set_should_profile(false);
2304     } else {
2305       profile_array_type(x, md, load_store);
2306     }
2307   }
2308 
2309   Value element;
2310   if (x->vt() != NULL) {
2311     assert(x->array()->is_loaded_flattened_array(), "must be");
2312     // Find the destination address (of the NewInlineTypeInstance).
2313     LIRItem obj_item(x->vt(), this);
2314 
2315     access_flattened_array(true, array, index, obj_item,
2316                            x->delayed() == NULL ? 0 : x->delayed()->field(),
2317                            x->delayed() == NULL ? 0 : x->delayed()->offset());
2318     set_no_result(x);
2319   } else if (x->delayed() != NULL) {
2320     assert(x->array()->is_loaded_flattened_array(), "must be");
2321     LIR_Opr result = rlock_result(x, x->delayed()->field()->type()->basic_type());
2322     access_sub_element(array, index, result, x->delayed()->field(), x->delayed()->offset());
2323   } else if (x->array() != NULL && x->array()->is_loaded_flattened_array() &&
2324              x->array()->declared_type()->as_flat_array_klass()->element_klass()->as_inline_klass()->is_empty()) {
2325     // Load the default instance instead of reading the element
2326     ciInlineKlass* elem_klass = x->array()->declared_type()->as_flat_array_klass()->element_klass()->as_inline_klass();
2327     LIR_Opr result = rlock_result(x, x->elt_type());
2328     Constant* default_value = new Constant(new InstanceConstant(elem_klass->default_instance()));
2329     if (default_value->is_pinned()) {
2330       __ move(LIR_OprFact::value_type(default_value->type()), result);
2331     } else {
2332       __ move(load_constant(default_value), result);
2333     }
2334   } else {
2335     LIR_Opr result = rlock_result(x, x->elt_type());
2336     LoadFlattenedArrayStub* slow_path = NULL;
2337 
2338     if (x->should_profile() && x->array()->maybe_null_free_array()) {
2339       profile_null_free_array(array, md, load_store);
2340     }
2341 
2342     if (x->elt_type() == T_OBJECT && x->array()->maybe_flattened_array()) {
2343       assert(x->delayed() == NULL, "Delayed LoadIndexed only apply to loaded_flattened_arrays");
2344       index.load_item();
2345       // if we are loading from flattened array, load it using a runtime call
2346       slow_path = new LoadFlattenedArrayStub(array.result(), index.result(), result, state_for(x, x->state_before()));
2347       check_flattened_array(array.result(), LIR_OprFact::illegalOpr, slow_path);
2348       set_in_conditional_code(true);
2349     }
2350 
2351     DecoratorSet decorators = IN_HEAP | IS_ARRAY;
2352     access_load_at(decorators, x->elt_type(),
2353                    array, index.result(), result,
2354                    NULL, null_check_info);
2355 
2356     if (slow_path != NULL) {
2357       __ branch_destination(slow_path->continuation());
2358       set_in_conditional_code(false);
2359     }
2360 
2361     element = x;
2362   }
2363 
2364   if (x->should_profile()) {
2365     profile_element_type(element, md, load_store);
2366   }
2367 }
2368 
2369 void LIRGenerator::do_Deoptimize(Deoptimize* x) {
2370   // This happens only when a class X uses the withfield/defaultvalue bytecode
2371   // to refer to an inline class V, where V has not yet been loaded/resolved.
2372   // This is not a common case. Let's just deoptimize.
2373   CodeEmitInfo* info = state_for(x, x->state_before());
2374   CodeStub* stub = new DeoptimizeStub(new CodeEmitInfo(info),
2375                                       Deoptimization::Reason_unloaded,
2376                                       Deoptimization::Action_make_not_entrant);
2377   __ jump(stub);
2378   LIR_Opr reg = rlock_result(x, T_OBJECT);
2379   __ move(LIR_OprFact::oopConst(NULL), reg);
2380 }
2381 
2382 void LIRGenerator::do_NullCheck(NullCheck* x) {
2383   if (x->can_trap()) {
2384     LIRItem value(x->obj(), this);
2385     value.load_item();
2386     CodeEmitInfo* info = state_for(x);
2387     __ null_check(value.result(), info);
2388   }
2389 }
2390 
2391 
2392 void LIRGenerator::do_TypeCast(TypeCast* x) {
2393   LIRItem value(x->obj(), this);
2394   value.load_item();
2395   // the result is the same as from the node we are casting
2396   set_result(x, value.result());
2397 }
2398 
2399 
2400 void LIRGenerator::do_Throw(Throw* x) {

2859   Compilation* comp = Compilation::current();
2860   if (do_update) {
2861     // try to find exact type, using CHA if possible, so that loading
2862     // the klass from the object can be avoided
2863     ciType* type = obj->exact_type();
2864     if (type == NULL) {
2865       type = obj->declared_type();
2866       type = comp->cha_exact_type(type);
2867     }
2868     assert(type == NULL || type->is_klass(), "type should be class");
2869     exact_klass = (type != NULL && type->is_loaded()) ? (ciKlass*)type : NULL;
2870 
2871     do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
2872   }
2873 
2874   if (!do_null && !do_update) {
2875     return result;
2876   }
2877 
2878   ciKlass* exact_signature_k = NULL;
2879   if (do_update && signature_at_call_k != NULL) {
2880     // Is the type from the signature exact (the only one possible)?
2881     exact_signature_k = signature_at_call_k->exact_klass();
2882     if (exact_signature_k == NULL) {
2883       exact_signature_k = comp->cha_exact_type(signature_at_call_k);
2884     } else {
2885       result = exact_signature_k;
2886       // Known statically. No need to emit any code: prevent
2887       // LIR_Assembler::emit_profile_type() from emitting useless code
2888       profiled_k = ciTypeEntries::with_status(result, profiled_k);
2889     }
2890     // exact_klass and exact_signature_k can be both non NULL but
2891     // different if exact_klass is loaded after the ciObject for
2892     // exact_signature_k is created.
2893     if (exact_klass == NULL && exact_signature_k != NULL && exact_klass != exact_signature_k) {
2894       // sometimes the type of the signature is better than the best type
2895       // the compiler has
2896       exact_klass = exact_signature_k;
2897     }
2898     if (callee_signature_k != NULL &&
2899         callee_signature_k != signature_at_call_k) {

2944         assert(!src->is_illegal(), "check");
2945         BasicType t = src->type();
2946         if (is_reference_type(t)) {
2947           intptr_t profiled_k = parameters->type(j);
2948           Local* local = x->state()->local_at(java_index)->as_Local();
2949           ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
2950                                         in_bytes(ParametersTypeData::type_offset(j)) - in_bytes(ParametersTypeData::type_offset(0)),
2951                                         profiled_k, local, mdp, false, local->declared_type()->as_klass(), NULL);
2952           // If the profile is known statically set it once for all and do not emit any code
2953           if (exact != NULL) {
2954             md->set_parameter_type(j, exact);
2955           }
2956           j++;
2957         }
2958         java_index += type2size[t];
2959       }
2960     }
2961   }
2962 }
2963 
2964 void LIRGenerator::profile_flags(ciMethodData* md, ciProfileData* data, int flag, LIR_Condition condition) {
2965   assert(md != NULL && data != NULL, "should have been initialized");
2966   LIR_Opr mdp = new_register(T_METADATA);
2967   __ metadata2reg(md->constant_encoding(), mdp);
2968   LIR_Address* addr = new LIR_Address(mdp, md->byte_offset_of_slot(data, DataLayout::flags_offset()), T_BYTE);
2969   LIR_Opr flags = new_register(T_INT);
2970   __ move(addr, flags);
2971   if (condition != lir_cond_always) {
2972     LIR_Opr update = new_register(T_INT);
2973     __ cmove(condition, LIR_OprFact::intConst(0), LIR_OprFact::intConst(flag), update, T_INT);
2974   } else {
2975     __ logical_or(flags, LIR_OprFact::intConst(flag), flags);
2976   }
2977   __ store(flags, addr);
2978 }
2979 
2980 void LIRGenerator::profile_null_free_array(LIRItem array, ciMethodData* md, ciArrayLoadStoreData* load_store) {
2981   assert(compilation()->profile_array_accesses(), "array access profiling is disabled");
2982   LabelObj* L_end = new LabelObj();
2983   LIR_Opr tmp = new_register(T_METADATA);
2984   __ check_null_free_array(array.result(), tmp);
2985 
2986   profile_flags(md, load_store, ArrayLoadStoreData::null_free_array_byte_constant(), lir_cond_equal);
2987 }
2988 
2989 void LIRGenerator::profile_array_type(AccessIndexed* x, ciMethodData*& md, ciArrayLoadStoreData*& load_store) {
2990   assert(compilation()->profile_array_accesses(), "array access profiling is disabled");
2991   int bci = x->profiled_bci();
2992   md = x->profiled_method()->method_data();
2993   assert(md != NULL, "Sanity");
2994   ciProfileData* data = md->bci_to_data(bci);
2995   assert(data != NULL && data->is_ArrayLoadStoreData(), "incorrect profiling entry");
2996   load_store = (ciArrayLoadStoreData*)data;
2997   LIR_Opr mdp = LIR_OprFact::illegalOpr;
2998   profile_type(md, md->byte_offset_of_slot(load_store, ArrayLoadStoreData::array_offset()), 0,
2999                load_store->array()->type(), x->array(), mdp, true, NULL, NULL);
3000 }
3001 
3002 void LIRGenerator::profile_element_type(Value element, ciMethodData* md, ciArrayLoadStoreData* load_store) {
3003   assert(compilation()->profile_array_accesses(), "array access profiling is disabled");
3004   assert(md != NULL && load_store != NULL, "should have been initialized");
3005   LIR_Opr mdp = LIR_OprFact::illegalOpr;
3006   profile_type(md, md->byte_offset_of_slot(load_store, ArrayLoadStoreData::element_offset()), 0,
3007                load_store->element()->type(), element, mdp, false, NULL, NULL);
3008 }
3009 
3010 void LIRGenerator::do_Base(Base* x) {
3011   __ std_entry(LIR_OprFact::illegalOpr);
3012   // Emit moves from physical registers / stack slots to virtual registers
3013   CallingConvention* args = compilation()->frame_map()->incoming_arguments();
3014   IRScope* irScope = compilation()->hir()->top_scope();
3015   int java_index = 0;
3016   for (int i = 0; i < args->length(); i++) {
3017     LIR_Opr src = args->at(i);
3018     assert(!src->is_illegal(), "check");
3019     BasicType t = src->type();
3020 
3021     // Types which are smaller than int are passed as int, so
3022     // correct the type which passed.
3023     switch (t) {
3024     case T_BYTE:
3025     case T_BOOLEAN:
3026     case T_SHORT:
3027     case T_CHAR:
3028       t = T_INT;
3029       break;

3074       LIR_Opr lock = syncLockOpr();
3075       __ load_stack_address_monitor(0, lock);
3076 
3077       CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException));
3078       CodeStub* slow_path = new MonitorEnterStub(obj, lock, info);
3079 
3080       // receiver is guaranteed non-NULL so don't need CodeEmitInfo
3081       __ lock_object(syncTempOpr(), obj, lock, new_register(T_OBJECT), slow_path, NULL);
3082     }
3083   }
3084   if (compilation()->age_code()) {
3085     CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, 0), NULL, false);
3086     decrement_age(info);
3087   }
3088   // increment invocation counters if needed
3089   if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting.
3090     profile_parameters(x);
3091     CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false);
3092     increment_invocation_counter(info);
3093   }
3094   if (method()->has_scalarized_args()) {
3095     // Check if deoptimization was triggered (i.e. orig_pc was set) while buffering scalarized inline type arguments
3096     // in the entry point (see comments in frame::deoptimize). If so, deoptimize only now that we have the right state.
3097     CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, 0), NULL, false);
3098     CodeStub* deopt_stub = new DeoptimizeStub(info, Deoptimization::Reason_none, Deoptimization::Action_none);
3099     __ append(new LIR_Op0(lir_check_orig_pc));
3100     __ branch(lir_cond_notEqual, deopt_stub);
3101   }
3102 
3103   // all blocks with a successor must end with an unconditional jump
3104   // to the successor even if they are consecutive
3105   __ jump(x->default_sux());
3106 }
3107 
3108 
3109 void LIRGenerator::do_OsrEntry(OsrEntry* x) {
3110   // construct our frame and model the production of incoming pointer
3111   // to the OSR buffer.
3112   __ osr_entry(LIR_Assembler::osrBufferPointer());
3113   LIR_Opr result = rlock_result(x);
3114   __ move(LIR_Assembler::osrBufferPointer(), result);
3115 }
3116 
3117 void LIRGenerator::invoke_load_one_argument(LIRItem* param, LIR_Opr loc) {
3118   if (loc->is_register()) {
3119     param->load_item_force(loc);
3120   } else {
3121     LIR_Address* addr = loc->as_address_ptr();
3122     param->load_for_store(addr->type());
3123     assert(addr->type() != T_INLINE_TYPE, "not supported yet");
3124     if (addr->type() == T_OBJECT) {
3125       __ move_wide(param->result(), addr);
3126     } else {
3127       __ move(param->result(), addr);
3128     }
3129   }
3130 }
3131 
3132 void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) {
3133   assert(args->length() == arg_list->length(),
3134          "args=%d, arg_list=%d", args->length(), arg_list->length());
3135   for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) {
3136     LIRItem* param = args->at(i);
3137     LIR_Opr loc = arg_list->at(i);
3138     invoke_load_one_argument(param, loc);









3139   }
3140 
3141   if (x->has_receiver()) {
3142     LIRItem* receiver = args->at(0);
3143     LIR_Opr loc = arg_list->at(0);
3144     if (loc->is_register()) {
3145       receiver->load_item_force(loc);
3146     } else {
3147       assert(loc->is_address(), "just checking");
3148       receiver->load_for_store(T_OBJECT);
3149       __ move_wide(receiver->result(), loc->as_address_ptr());
3150     }
3151   }
3152 }
3153 
3154 
3155 // Visits all arguments, returns appropriate items without loading them
3156 LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) {
3157   LIRItemList* argument_items = new LIRItemList();
3158   if (x->has_receiver()) {

3284   __ move(tmp, reg);
3285 }
3286 
3287 
3288 
3289 // Code for  :  x->x() {x->cond()} x->y() ? x->tval() : x->fval()
3290 void LIRGenerator::do_IfOp(IfOp* x) {
3291 #ifdef ASSERT
3292   {
3293     ValueTag xtag = x->x()->type()->tag();
3294     ValueTag ttag = x->tval()->type()->tag();
3295     assert(xtag == intTag || xtag == objectTag, "cannot handle others");
3296     assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others");
3297     assert(ttag == x->fval()->type()->tag(), "cannot handle others");
3298   }
3299 #endif
3300 
3301   LIRItem left(x->x(), this);
3302   LIRItem right(x->y(), this);
3303   left.load_item();
3304   if (can_inline_as_constant(right.value()) && !x->substitutability_check()) {
3305     right.dont_load_item();
3306   } else {
3307     // substitutability_check() needs to use right as a base register.
3308     right.load_item();
3309   }
3310 
3311   LIRItem t_val(x->tval(), this);
3312   LIRItem f_val(x->fval(), this);
3313   t_val.dont_load_item();
3314   f_val.dont_load_item();

3315 
3316   if (x->substitutability_check()) {
3317     substitutability_check(x, left, right, t_val, f_val);
3318   } else {
3319     LIR_Opr reg = rlock_result(x);
3320     __ cmp(lir_cond(x->cond()), left.result(), right.result());
3321     __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
3322   }
3323 }
3324 
3325 void LIRGenerator::substitutability_check(IfOp* x, LIRItem& left, LIRItem& right, LIRItem& t_val, LIRItem& f_val) {
3326   assert(x->cond() == If::eql || x->cond() == If::neq, "must be");
3327   bool is_acmpeq = (x->cond() == If::eql);
3328   LIR_Opr equal_result     = is_acmpeq ? t_val.result() : f_val.result();
3329   LIR_Opr not_equal_result = is_acmpeq ? f_val.result() : t_val.result();
3330   LIR_Opr result = rlock_result(x);
3331   CodeEmitInfo* info = state_for(x, x->state_before());
3332 
3333   substitutability_check_common(x->x(), x->y(), left, right, equal_result, not_equal_result, result, info);
3334 }
3335 
3336 void LIRGenerator::substitutability_check(If* x, LIRItem& left, LIRItem& right) {
3337   LIR_Opr equal_result     = LIR_OprFact::intConst(1);
3338   LIR_Opr not_equal_result = LIR_OprFact::intConst(0);
3339   LIR_Opr result = new_register(T_INT);
3340   CodeEmitInfo* info = state_for(x, x->state_before());
3341 
3342   substitutability_check_common(x->x(), x->y(), left, right, equal_result, not_equal_result, result, info);
3343 
3344   assert(x->cond() == If::eql || x->cond() == If::neq, "must be");
3345   __ cmp(lir_cond(x->cond()), result, equal_result);
3346 }
3347 
3348 void LIRGenerator::substitutability_check_common(Value left_val, Value right_val, LIRItem& left, LIRItem& right,
3349                                                  LIR_Opr equal_result, LIR_Opr not_equal_result, LIR_Opr result,
3350                                                  CodeEmitInfo* info) {
3351   LIR_Opr tmp1 = LIR_OprFact::illegalOpr;
3352   LIR_Opr tmp2 = LIR_OprFact::illegalOpr;
3353   LIR_Opr left_klass_op = LIR_OprFact::illegalOpr;
3354   LIR_Opr right_klass_op = LIR_OprFact::illegalOpr;
3355 
3356   ciKlass* left_klass  = left_val ->as_loaded_klass_or_null();
3357   ciKlass* right_klass = right_val->as_loaded_klass_or_null();
3358 
3359   if ((left_klass == NULL || right_klass == NULL) ||// The klass is still unloaded, or came from a Phi node.
3360       !left_klass->is_inlinetype() || !right_klass->is_inlinetype()) {
3361     init_temps_for_substitutability_check(tmp1, tmp2);
3362   }
3363 
3364   if (left_klass != NULL && left_klass->is_inlinetype() && left_klass == right_klass) {
3365     // No need to load klass -- the operands are statically known to be the same inline klass.
3366   } else {
3367     BasicType t_klass = UseCompressedOops ? T_INT : T_METADATA;
3368     left_klass_op = new_register(t_klass);
3369     right_klass_op = new_register(t_klass);
3370   }
3371 
3372   CodeStub* slow_path = new SubstitutabilityCheckStub(left.result(), right.result(), info);
3373   __ substitutability_check(result, left.result(), right.result(), equal_result, not_equal_result,
3374                             tmp1, tmp2,
3375                             left_klass, right_klass, left_klass_op, right_klass_op, info, slow_path);
3376 }
3377 
3378 #ifdef JFR_HAVE_INTRINSICS
3379 
3380 void LIRGenerator::do_getEventWriter(Intrinsic* x) {
3381   LabelObj* L_end = new LabelObj();
3382 
3383   // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
3384   // meaning of these two is mixed up (see JDK-8026837).
3385   LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
3386                                            in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR),
3387                                            T_ADDRESS);
3388   LIR_Opr result = rlock_result(x);
3389   __ move(LIR_OprFact::oopConst(NULL), result);
3390   LIR_Opr jobj = new_register(T_METADATA);
3391   __ move_wide(jobj_addr, jobj);
3392   __ cmp(lir_cond_equal, jobj, LIR_OprFact::metadataConst(0));
3393   __ branch(lir_cond_equal, L_end->label());
3394 
3395   access_load(IN_NATIVE, T_OBJECT, LIR_OprFact::address(new LIR_Address(jobj, T_OBJECT)), result);

3647   if (x->recv() != NULL || x->nb_profiled_args() > 0) {
3648     profile_parameters_at_call(x);
3649   }
3650 
3651   if (x->recv() != NULL) {
3652     LIRItem value(x->recv(), this);
3653     value.load_item();
3654     recv = new_register(T_OBJECT);
3655     __ move(value.result(), recv);
3656   }
3657   __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
3658 }
3659 
3660 void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
3661   int bci = x->bci_of_invoke();
3662   ciMethodData* md = x->method()->method_data_or_null();
3663   assert(md != NULL, "Sanity");
3664   ciProfileData* data = md->bci_to_data(bci);
3665   if (data != NULL) {
3666     assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
3667     ciSingleTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
3668     LIR_Opr mdp = LIR_OprFact::illegalOpr;
3669 
3670     bool ignored_will_link;
3671     ciSignature* signature_at_call = NULL;
3672     x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
3673 
3674     // The offset within the MDO of the entry to update may be too large
3675     // to be used in load/store instructions on some platforms. So have
3676     // profile_type() compute the address of the profile in a register.
3677     ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
3678         ret->type(), x->ret(), mdp,
3679         !x->needs_null_check(),
3680         signature_at_call->return_type()->as_klass(),
3681         x->callee()->signature()->return_type()->as_klass());
3682     if (exact != NULL) {
3683       md->set_return_type(bci, exact);
3684     }
3685   }
3686 }
3687 
3688 bool LIRGenerator::profile_inline_klass(ciMethodData* md, ciProfileData* data, Value value, int flag) {
3689   ciKlass* klass = value->as_loaded_klass_or_null();
3690   if (klass != NULL) {
3691     if (klass->is_inlinetype()) {
3692       profile_flags(md, data, flag, lir_cond_always);
3693     } else if (klass->can_be_inline_klass()) {
3694       return false;
3695     }
3696   } else {
3697     return false;
3698   }
3699   return true;
3700 }
3701 
3702 
3703 void LIRGenerator::do_ProfileACmpTypes(ProfileACmpTypes* x) {
3704   ciMethod* method = x->method();
3705   assert(method != NULL, "method should be set if branch is profiled");
3706   ciMethodData* md = method->method_data_or_null();
3707   assert(md != NULL, "Sanity");
3708   ciProfileData* data = md->bci_to_data(x->bci());
3709   assert(data != NULL, "must have profiling data");
3710   assert(data->is_ACmpData(), "need BranchData for two-way branches");
3711   ciACmpData* acmp = (ciACmpData*)data;
3712   LIR_Opr mdp = LIR_OprFact::illegalOpr;
3713   profile_type(md, md->byte_offset_of_slot(acmp, ACmpData::left_offset()), 0,
3714                acmp->left()->type(), x->left(), mdp, !x->left_maybe_null(), NULL, NULL);
3715   int flags_offset = md->byte_offset_of_slot(data, DataLayout::flags_offset());
3716   if (!profile_inline_klass(md, acmp, x->left(), ACmpData::left_inline_type_byte_constant())) {
3717     LIR_Opr mdp = new_register(T_METADATA);
3718     __ metadata2reg(md->constant_encoding(), mdp);
3719     LIRItem value(x->left(), this);
3720     value.load_item();
3721     __ profile_inline_type(new LIR_Address(mdp, flags_offset, T_INT), value.result(), ACmpData::left_inline_type_byte_constant(), new_register(T_INT), !x->left_maybe_null());
3722   }
3723   profile_type(md, md->byte_offset_of_slot(acmp, ACmpData::left_offset()),
3724                in_bytes(ACmpData::right_offset()) - in_bytes(ACmpData::left_offset()),
3725                acmp->right()->type(), x->right(), mdp, !x->right_maybe_null(), NULL, NULL);
3726   if (!profile_inline_klass(md, acmp, x->right(), ACmpData::right_inline_type_byte_constant())) {
3727     LIR_Opr mdp = new_register(T_METADATA);
3728     __ metadata2reg(md->constant_encoding(), mdp);
3729     LIRItem value(x->right(), this);
3730     value.load_item();
3731     __ profile_inline_type(new LIR_Address(mdp, flags_offset, T_INT), value.result(), ACmpData::right_inline_type_byte_constant(), new_register(T_INT), !x->left_maybe_null());
3732   }
3733 }
3734 
3735 void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
3736   // We can safely ignore accessors here, since c2 will inline them anyway,
3737   // accessors are also always mature.
3738   if (!x->inlinee()->is_accessor()) {
3739     CodeEmitInfo* info = state_for(x, x->state(), true);
3740     // Notify the runtime very infrequently only to take care of counter overflows
3741     int freq_log = Tier23InlineeNotifyFreqLog;
3742     double scale;
3743     if (_method->has_option_value(CompileCommand::CompileThresholdScaling, scale)) {
3744       freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
3745     }
3746     increment_event_counter_impl(info, x->inlinee(), LIR_OprFact::intConst(InvocationCounter::count_increment), right_n_bits(freq_log), InvocationEntryBci, false, true);
3747   }
3748 }
3749 
3750 void LIRGenerator::increment_backedge_counter_conditionally(LIR_Condition cond, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info, int left_bci, int right_bci, int bci) {
3751   if (compilation()->is_profiling()) {
3752 #if defined(X86) && !defined(_LP64)
3753     // BEWARE! On 32-bit x86 cmp clobbers its left argument so we need a temp copy.
3754     LIR_Opr left_copy = new_register(left->type());
< prev index next >