< prev index next >

src/hotspot/share/c1/c1_Instruction.hpp

Print this page

  57 class       StoreIndexed;
  58 class   NegateOp;
  59 class   Op2;
  60 class     ArithmeticOp;
  61 class     ShiftOp;
  62 class     LogicOp;
  63 class     CompareOp;
  64 class     IfOp;
  65 class   Convert;
  66 class   NullCheck;
  67 class   TypeCast;
  68 class   OsrEntry;
  69 class   ExceptionObject;
  70 class   StateSplit;
  71 class     Invoke;
  72 class     NewInstance;
  73 class     NewArray;
  74 class       NewTypeArray;
  75 class       NewObjectArray;
  76 class       NewMultiArray;

  77 class     TypeCheck;
  78 class       CheckCast;
  79 class       InstanceOf;
  80 class     AccessMonitor;
  81 class       MonitorEnter;
  82 class       MonitorExit;
  83 class     Intrinsic;
  84 class     BlockBegin;
  85 class     BlockEnd;
  86 class       Goto;
  87 class       If;
  88 class       Switch;
  89 class         TableSwitch;
  90 class         LookupSwitch;
  91 class       Return;
  92 class       Throw;
  93 class       Base;
  94 class   UnsafeOp;
  95 class     UnsafeGet;
  96 class     UnsafePut;
  97 class     UnsafeGetAndSet;
  98 class   ProfileCall;
  99 class   ProfileReturnType;

 100 class   ProfileInvoke;
 101 class   RuntimeCall;
 102 class   MemBar;
 103 class   RangeCheckPredicate;
 104 #ifdef ASSERT
 105 class   Assert;
 106 #endif
 107 
 108 // A Value is a reference to the instruction creating the value
 109 typedef Instruction* Value;
 110 typedef GrowableArray<Value> Values;
 111 typedef GrowableArray<ValueStack*> ValueStackStack;
 112 
 113 // BlockClosure is the base class for block traversal/iteration.
 114 
 115 class BlockClosure: public CompilationResourceObj {
 116  public:
 117   virtual void block_do(BlockBegin* block)       = 0;
 118 };
 119 

 174   virtual void do_CheckCast      (CheckCast*       x) = 0;
 175   virtual void do_InstanceOf     (InstanceOf*      x) = 0;
 176   virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
 177   virtual void do_MonitorExit    (MonitorExit*     x) = 0;
 178   virtual void do_Intrinsic      (Intrinsic*       x) = 0;
 179   virtual void do_BlockBegin     (BlockBegin*      x) = 0;
 180   virtual void do_Goto           (Goto*            x) = 0;
 181   virtual void do_If             (If*              x) = 0;
 182   virtual void do_TableSwitch    (TableSwitch*     x) = 0;
 183   virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
 184   virtual void do_Return         (Return*          x) = 0;
 185   virtual void do_Throw          (Throw*           x) = 0;
 186   virtual void do_Base           (Base*            x) = 0;
 187   virtual void do_OsrEntry       (OsrEntry*        x) = 0;
 188   virtual void do_ExceptionObject(ExceptionObject* x) = 0;
 189   virtual void do_UnsafeGet      (UnsafeGet*       x) = 0;
 190   virtual void do_UnsafePut      (UnsafePut*       x) = 0;
 191   virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x) = 0;
 192   virtual void do_ProfileCall    (ProfileCall*     x) = 0;
 193   virtual void do_ProfileReturnType (ProfileReturnType*  x) = 0;

 194   virtual void do_ProfileInvoke  (ProfileInvoke*   x) = 0;
 195   virtual void do_RuntimeCall    (RuntimeCall*     x) = 0;
 196   virtual void do_MemBar         (MemBar*          x) = 0;
 197   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
 198 #ifdef ASSERT
 199   virtual void do_Assert         (Assert*          x) = 0;
 200 #endif
 201 };
 202 
 203 
 204 // Hashing support
 205 //
 206 // Note: This hash functions affect the performance
 207 //       of ValueMap - make changes carefully!
 208 
 209 #define HASH1(x1            )                    ((intx)(x1))
 210 #define HASH2(x1, x2        )                    ((HASH1(x1        ) << 7) ^ HASH1(x2))
 211 #define HASH3(x1, x2, x3    )                    ((HASH2(x1, x2    ) << 7) ^ HASH1(x3))
 212 #define HASH4(x1, x2, x3, x4)                    ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))

 213 
 214 
 215 // The following macros are used to implement instruction-specific hashing.
 216 // By default, each instruction implements hash() and is_equal(Value), used
 217 // for value numbering/common subexpression elimination. The default imple-
 218 // mentation disables value numbering. Each instruction which can be value-
 219 // numbered, should define corresponding hash() and is_equal(Value) functions
 220 // via the macros below. The f arguments specify all the values/op codes, etc.
 221 // that need to be identical for two instructions to be identical.
 222 //
 223 // Note: The default implementation of hash() returns 0 in order to indicate
 224 //       that the instruction should not be considered for value numbering.
 225 //       The currently used hash functions do not guarantee that never a 0
 226 //       is produced. While this is still correct, it may be a performance
 227 //       bug (no value numbering for that node). However, this situation is
 228 //       so unlikely, that we are not going to handle it specially.
 229 
 230 #define HASHING1(class_name, enabled, f1)             \
 231   virtual intx hash() const {                         \
 232     return (enabled) ? HASH2(name(), f1) : 0;         \

 251     if (f1 != _v->f1) return false;                   \
 252     if (f2 != _v->f2) return false;                   \
 253     return true;                                      \
 254   }                                                   \
 255 
 256 
 257 #define HASHING3(class_name, enabled, f1, f2, f3)     \
 258   virtual intx hash() const {                         \
 259     return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
 260   }                                                   \
 261   virtual bool is_equal(Value v) const {              \
 262     if (!(enabled)  ) return false;                   \
 263     class_name* _v = v->as_##class_name();            \
 264     if (_v == nullptr) return false;                  \
 265     if (f1 != _v->f1) return false;                   \
 266     if (f2 != _v->f2) return false;                   \
 267     if (f3 != _v->f3) return false;                   \
 268     return true;                                      \
 269   }                                                   \
 270 















 271 
 272 // The mother of all instructions...
 273 
 274 class Instruction: public CompilationResourceObj {
 275  private:
 276   int          _id;                              // the unique instruction id
 277 #ifndef PRODUCT
 278   int          _printable_bci;                   // the bci of the instruction for printing
 279 #endif
 280   int          _use_count;                       // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
 281   int          _pin_state;                       // set of PinReason describing the reason for pinning
 282   unsigned int _flags;                           // Flag bits
 283   ValueType*   _type;                            // the instruction value type
 284   Instruction* _next;                            // the next instruction if any (null for BlockEnd instructions)
 285   Instruction* _subst;                           // the substitution instruction if any
 286   LIR_Opr      _operand;                         // LIR specific information
 287 
 288   ValueStack*  _state_before;                    // Copy of state with input operands still on stack (or null)
 289   ValueStack*  _exception_state;                 // Copy of state for exception handling
 290   XHandlers*   _exception_handlers;              // Flat list of exception handlers covering this instruction
 291 
 292   friend class UseCountComputer;

 293 
 294   void update_exception_state(ValueStack* state);
 295 
 296  protected:
 297   BlockBegin*  _block;                           // Block that contains this instruction
 298 
 299   void set_type(ValueType* type) {
 300     assert(type != nullptr, "type must exist");
 301     _type = type;
 302   }
 303 
 304   // Helper class to keep track of which arguments need a null check
 305   class ArgsNonNullState {
 306   private:
 307     int _nonnull_state; // mask identifying which args are nonnull
 308   public:
 309     ArgsNonNullState()
 310       : _nonnull_state(AllBits) {}
 311 
 312     // Does argument number i needs a null check?

 325         if (check) {
 326           _nonnull_state |= (int)nth_bit(i);
 327         } else {
 328           _nonnull_state &= (int)~(nth_bit(i));
 329         }
 330       }
 331     }
 332   };
 333 
 334  public:
 335   void* operator new(size_t size) throw() {
 336     Compilation* c = Compilation::current();
 337     void* res = c->arena()->Amalloc(size);
 338     return res;
 339   }
 340 
 341   static const int no_bci = -99;
 342 
 343   enum InstructionFlag {
 344     NeedsNullCheckFlag = 0,

 345     CanTrapFlag,
 346     DirectCompareFlag,
 347     IsSafepointFlag,
 348     IsStaticFlag,
 349     PreservesStateFlag,
 350     TargetIsFinalFlag,
 351     TargetIsLoadedFlag,
 352     UnorderedIsTrueFlag,
 353     NeedsPatchingFlag,
 354     ThrowIncompatibleClassChangeErrorFlag,
 355     InvokeSpecialReceiverCheckFlag,
 356     ProfileMDOFlag,
 357     IsLinkedInBlockFlag,
 358     NeedsRangeCheckFlag,
 359     DeoptimizeOnException,
 360     KillsMemoryFlag,
 361     OmitChecksFlag,
 362     InstructionLastFlag
 363   };
 364 

 415   int id() const                                 { return _id; }
 416 #ifndef PRODUCT
 417   bool has_printable_bci() const                 { return _printable_bci != -99; }
 418   int printable_bci() const                      { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
 419   void set_printable_bci(int bci)                { _printable_bci = bci; }
 420 #endif
 421   int dominator_depth();
 422   int use_count() const                          { return _use_count; }
 423   int pin_state() const                          { return _pin_state; }
 424   bool is_pinned() const                         { return _pin_state != 0 || PinAllInstructions; }
 425   ValueType* type() const                        { return _type; }
 426   BlockBegin *block() const                      { return _block; }
 427   Instruction* prev();                           // use carefully, expensive operation
 428   Instruction* next() const                      { return _next; }
 429   bool has_subst() const                         { return _subst != nullptr; }
 430   Instruction* subst()                           { return _subst == nullptr ? this : _subst->subst(); }
 431   LIR_Opr operand() const                        { return _operand; }
 432 
 433   void set_needs_null_check(bool f)              { set_flag(NeedsNullCheckFlag, f); }
 434   bool needs_null_check() const                  { return check_flag(NeedsNullCheckFlag); }


 435   bool is_linked() const                         { return check_flag(IsLinkedInBlockFlag); }
 436   bool can_be_linked()                           { return as_Local() == nullptr && as_Phi() == nullptr; }
 437 
 438   bool is_null_obj()                             { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
 439 
 440   bool has_uses() const                          { return use_count() > 0; }
 441   ValueStack* state_before() const               { return _state_before; }
 442   ValueStack* exception_state() const            { return _exception_state; }
 443   virtual bool needs_exception_state() const     { return true; }
 444   XHandlers* exception_handlers() const          { return _exception_handlers; }

 445 
 446   // manipulation
 447   void pin(PinReason reason)                     { _pin_state |= reason; }
 448   void pin()                                     { _pin_state |= PinUnknown; }
 449   // DANGEROUS: only used by EliminateStores
 450   void unpin(PinReason reason)                   { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
 451 
 452   Instruction* set_next(Instruction* next) {
 453     assert(next->has_printable_bci(), "_printable_bci should have been set");
 454     assert(next != nullptr, "must not be null");
 455     assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
 456     assert(next->can_be_linked(), "shouldn't link these instructions into list");
 457 
 458     BlockBegin *block = this->block();
 459     next->_block = block;
 460 
 461     next->set_flag(Instruction::IsLinkedInBlockFlag, true);
 462     _next = next;
 463     return next;
 464   }

 469 #endif
 470     return set_next(next);
 471   }
 472 
 473   // when blocks are merged
 474   void fixup_block_pointers() {
 475     Instruction *cur = next()->next(); // next()'s block is set in set_next
 476     while (cur && cur->_block != block()) {
 477       cur->_block = block();
 478       cur = cur->next();
 479     }
 480   }
 481 
 482   Instruction *insert_after(Instruction *i) {
 483     Instruction* n = _next;
 484     set_next(i);
 485     i->set_next(n);
 486     return _next;
 487   }
 488 




 489   Instruction *insert_after_same_bci(Instruction *i) {
 490 #ifndef PRODUCT
 491     i->set_printable_bci(printable_bci());
 492 #endif
 493     return insert_after(i);
 494   }
 495 
 496   void set_subst(Instruction* subst)             {
 497     assert(subst == nullptr ||
 498            type()->base() == subst->type()->base() ||
 499            subst->type()->base() == illegalType, "type can't change");
 500     _subst = subst;
 501   }
 502   void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
 503   void set_exception_state(ValueStack* s)        { check_state(s); _exception_state = s; }
 504   void set_state_before(ValueStack* s)           { check_state(s); _state_before = s; }
 505 
 506   // machine-specifics
 507   void set_operand(LIR_Opr operand)              { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
 508   void clear_operand()                           { _operand = LIR_OprFact::illegalOpr; }

 796 
 797   // Under certain circumstances, if a previous NullCheck instruction
 798   // proved the target object non-null, we can eliminate the explicit
 799   // null check and do an implicit one, simply specifying the debug
 800   // information from the NullCheck. This field should only be consulted
 801   // if needs_null_check() is true.
 802   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 803 
 804   // generic
 805   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 806   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 807 };
 808 
 809 
 810 LEAF(LoadField, AccessField)
 811  public:
 812   // creation
 813   LoadField(Value obj, int offset, ciField* field, bool is_static,
 814             ValueStack* state_before, bool needs_patching)
 815   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 816   {}


 817 
 818   ciType* declared_type() const;
 819 
 820   // generic; cannot be eliminated if needs patching or if volatile.
 821   HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
 822 };
 823 
 824 
 825 LEAF(StoreField, AccessField)
 826  private:
 827   Value _value;

 828 
 829  public:
 830   // creation
 831   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 832              ValueStack* state_before, bool needs_patching)
 833   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 834   , _value(value)
 835   {
 836     ASSERT_VALUES
 837     pin();
 838   }
 839 
 840   // accessors
 841   Value value() const                            { return _value; }


 842 
 843   // generic
 844   virtual void input_values_do(ValueVisitor* f)   { AccessField::input_values_do(f); f->visit(&_value); }
 845 };
 846 
 847 
 848 BASE(AccessArray, Instruction)
 849  private:
 850   Value       _array;
 851 
 852  public:
 853   // creation
 854   AccessArray(ValueType* type, Value array, ValueStack* state_before)
 855   : Instruction(type, state_before)
 856   , _array(array)
 857   {
 858     set_needs_null_check(true);
 859     ASSERT_VALUES
 860     pin(); // instruction with side effect (null exception or range check throwing)
 861   }

 879   , _explicit_null_check(nullptr) {}
 880 
 881   // accessors
 882   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 883 
 884   // setters
 885   // See LoadField::set_explicit_null_check for documentation
 886   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 887 
 888   // generic
 889   HASHING1(ArrayLength, true, array()->subst())
 890 };
 891 
 892 
 893 BASE(AccessIndexed, AccessArray)
 894  private:
 895   Value     _index;
 896   Value     _length;
 897   BasicType _elt_type;
 898   bool      _mismatched;


 899 
 900  public:
 901   // creation
 902   AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
 903   : AccessArray(as_ValueType(elt_type), array, state_before)
 904   , _index(index)
 905   , _length(length)
 906   , _elt_type(elt_type)
 907   , _mismatched(mismatched)

 908   {
 909     set_flag(Instruction::NeedsRangeCheckFlag, true);
 910     ASSERT_VALUES
 911   }
 912 
 913   // accessors
 914   Value index() const                            { return _index; }
 915   Value length() const                           { return _length; }
 916   BasicType elt_type() const                     { return _elt_type; }
 917   bool mismatched() const                        { return _mismatched; }
 918 
 919   void clear_length()                            { _length = nullptr; }
 920   // perform elimination of range checks involving constants
 921   bool compute_needs_range_check();
 922 









 923   // generic
 924   virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
 925 };
 926 

 927 
 928 LEAF(LoadIndexed, AccessIndexed)
 929  private:
 930   NullCheck*  _explicit_null_check;              // For explicit null check elimination


 931 
 932  public:
 933   // creation
 934   LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
 935   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 936   , _explicit_null_check(nullptr) {}
 937 
 938   // accessors
 939   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 940 
 941   // setters
 942   // See LoadField::set_explicit_null_check for documentation
 943   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 944 
 945   ciType* exact_type() const;
 946   ciType* declared_type() const;
 947 






 948   // generic;
 949   HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst())
 950 };
 951 























 952 
 953 LEAF(StoreIndexed, AccessIndexed)
 954  private:
 955   Value       _value;
 956 
 957   ciMethod* _profiled_method;
 958   int       _profiled_bci;
 959   bool      _check_boolean;
 960 
 961  public:
 962   // creation
 963   StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
 964                bool check_boolean, bool mismatched = false)
 965   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 966   , _value(value), _profiled_method(nullptr), _profiled_bci(0), _check_boolean(check_boolean)
 967   {
 968     ASSERT_VALUES
 969     pin();
 970   }
 971 
 972   // accessors
 973   Value value() const                            { return _value; }
 974   bool check_boolean() const                     { return _check_boolean; }
 975   // Helpers for MethodData* profiling
 976   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
 977   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
 978   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
 979   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
 980   ciMethod* profiled_method() const                  { return _profiled_method;     }
 981   int       profiled_bci() const                     { return _profiled_bci;        }
 982   // generic
 983   virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
 984 };
 985 
 986 
 987 LEAF(NegateOp, Instruction)
 988  private:
 989   Value _x;
 990 
 991  public:
 992   // creation
 993   NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
 994     ASSERT_VALUES
 995   }
 996 
 997   // accessors
 998   Value x() const                                { return _x; }
 999 
1000   // generic
1001   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }

1072   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1073 };
1074 
1075 
1076 LEAF(CompareOp, Op2)
1077  public:
1078   // creation
1079   CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1080   : Op2(intType, op, x, y, state_before)
1081   {}
1082 
1083   // generic
1084   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1085 };
1086 
1087 
1088 LEAF(IfOp, Op2)
1089  private:
1090   Value _tval;
1091   Value _fval;

1092 
1093  public:
1094   // creation
1095   IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
1096   : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1097   , _tval(tval)
1098   , _fval(fval)

1099   {
1100     ASSERT_VALUES
1101     assert(tval->type()->tag() == fval->type()->tag(), "types must match");

1102   }
1103 
1104   // accessors
1105   virtual bool is_commutative() const;
1106   Bytecodes::Code op() const                     { ShouldNotCallThis(); return Bytecodes::_illegal; }
1107   Condition cond() const                         { return (Condition)Op2::op(); }
1108   Value tval() const                             { return _tval; }
1109   Value fval() const                             { return _fval; }
1110 
1111   // generic
1112   virtual void input_values_do(ValueVisitor* f)   { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1113 };
1114 
1115 
1116 LEAF(Convert, Instruction)
1117  private:
1118   Bytecodes::Code _op;
1119   Value           _value;
1120 
1121  public:
1122   // creation
1123   Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1124     ASSERT_VALUES
1125   }
1126 
1127   // accessors
1128   Bytecodes::Code op() const                     { return _op; }
1129   Value value() const                            { return _value; }
1130 

1247   bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
1248   bool is_method_handle_intrinsic() const        { return target()->is_method_handle_intrinsic(); }
1249 
1250   virtual bool needs_exception_state() const     { return false; }
1251 
1252   // generic
1253   virtual bool can_trap() const                  { return true; }
1254   virtual void input_values_do(ValueVisitor* f) {
1255     StateSplit::input_values_do(f);
1256     if (has_receiver()) f->visit(&_recv);
1257     for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1258   }
1259   virtual void state_values_do(ValueVisitor *f);
1260 };
1261 
1262 
1263 LEAF(NewInstance, StateSplit)
1264  private:
1265   ciInstanceKlass* _klass;
1266   bool _is_unresolved;

1267 
1268  public:
1269   // creation
1270   NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1271   : StateSplit(instanceType, state_before)
1272   , _klass(klass), _is_unresolved(is_unresolved)
1273   {}
1274 
1275   // accessors
1276   ciInstanceKlass* klass() const                 { return _klass; }
1277   bool is_unresolved() const                     { return _is_unresolved; }

1278 
1279   virtual bool needs_exception_state() const     { return false; }
1280 
1281   // generic
1282   virtual bool can_trap() const                  { return true; }
1283   ciType* exact_type() const;
1284   ciType* declared_type() const;
1285 };
1286 
1287 
1288 BASE(NewArray, StateSplit)
1289  private:
1290   Value       _length;
1291 
1292  public:
1293   // creation
1294   NewArray(Value length, ValueStack* state_before)
1295   : StateSplit(objectType, state_before)
1296   , _length(length)
1297   {
1298     // Do not ASSERT_VALUES since length is null for NewMultiArray
1299   }
1300 
1301   // accessors
1302   Value length() const                           { return _length; }
1303 
1304   virtual bool needs_exception_state() const     { return false; }
1305 
1306   ciType* exact_type() const                     { return nullptr; }
1307   ciType* declared_type() const;

1321   // creation
1322   NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before, bool zero_array)
1323   : NewArray(length, state_before)
1324   , _elt_type(elt_type)
1325   , _zero_array(zero_array)
1326   {}
1327 
1328   // accessors
1329   BasicType elt_type() const                     { return _elt_type; }
1330   bool zero_array()    const                     { return _zero_array; }
1331   ciType* exact_type() const;
1332 };
1333 
1334 
1335 LEAF(NewObjectArray, NewArray)
1336  private:
1337   ciKlass* _klass;
1338 
1339  public:
1340   // creation
1341   NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}

1342 
1343   // accessors
1344   ciKlass* klass() const                         { return _klass; }
1345   ciType* exact_type() const;
1346 };
1347 
1348 
1349 LEAF(NewMultiArray, NewArray)
1350  private:
1351   ciKlass* _klass;
1352   Values*  _dims;
1353 
1354  public:
1355   // creation
1356   NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1357     ASSERT_VALUES
1358   }
1359 
1360   // accessors
1361   ciKlass* klass() const                         { return _klass; }
1362   Values* dims() const                           { return _dims; }
1363   int rank() const                               { return dims()->length(); }
1364 
1365   // generic
1366   virtual void input_values_do(ValueVisitor* f) {
1367     // NOTE: we do not call NewArray::input_values_do since "length"
1368     // is meaningless for a multi-dimensional array; passing the
1369     // zeroth element down to NewArray as its length is a bad idea
1370     // since there will be a copy in the "dims" array which doesn't
1371     // get updated, and the value must not be traversed twice. Was bug
1372     // - kbr 4/10/2001
1373     StateSplit::input_values_do(f);
1374     for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1375   }


1376 };
1377 
1378 
1379 BASE(TypeCheck, StateSplit)
1380  private:
1381   ciKlass*    _klass;
1382   Value       _obj;
1383 
1384   ciMethod* _profiled_method;
1385   int       _profiled_bci;
1386 
1387  public:
1388   // creation
1389   TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1390   : StateSplit(type, state_before), _klass(klass), _obj(obj),
1391     _profiled_method(nullptr), _profiled_bci(0) {
1392     ASSERT_VALUES
1393     set_direct_compare(false);
1394   }
1395 

1403   void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
1404 
1405   // generic
1406   virtual bool can_trap() const                  { return true; }
1407   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1408 
1409   // Helpers for MethodData* profiling
1410   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1411   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1412   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1413   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1414   ciMethod* profiled_method() const                  { return _profiled_method;     }
1415   int       profiled_bci() const                     { return _profiled_bci;        }
1416 };
1417 
1418 
1419 LEAF(CheckCast, TypeCheck)
1420  public:
1421   // creation
1422   CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
1423   : TypeCheck(klass, obj, objectType, state_before) {}
1424 
1425   void set_incompatible_class_change_check() {
1426     set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1427   }
1428   bool is_incompatible_class_change_check() const {
1429     return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1430   }
1431   void set_invokespecial_receiver_check() {
1432     set_flag(InvokeSpecialReceiverCheckFlag, true);
1433   }
1434   bool is_invokespecial_receiver_check() const {
1435     return check_flag(InvokeSpecialReceiverCheckFlag);
1436   }
1437 
1438   virtual bool needs_exception_state() const {
1439     return !is_invokespecial_receiver_check();
1440   }
1441 
1442   ciType* declared_type() const;
1443 };

1461   // creation
1462   AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1463   : StateSplit(illegalType, state_before)
1464   , _obj(obj)
1465   , _monitor_no(monitor_no)
1466   {
1467     set_needs_null_check(true);
1468     ASSERT_VALUES
1469   }
1470 
1471   // accessors
1472   Value obj() const                              { return _obj; }
1473   int monitor_no() const                         { return _monitor_no; }
1474 
1475   // generic
1476   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1477 };
1478 
1479 
1480 LEAF(MonitorEnter, AccessMonitor)

1481  public:
1482   // creation
1483   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1484   : AccessMonitor(obj, monitor_no, state_before)

1485   {
1486     ASSERT_VALUES
1487   }
1488 



1489   // generic
1490   virtual bool can_trap() const                  { return true; }
1491 };
1492 
1493 
1494 LEAF(MonitorExit, AccessMonitor)
1495  public:
1496   // creation
1497   MonitorExit(Value obj, int monitor_no)
1498   : AccessMonitor(obj, monitor_no, nullptr)
1499   {
1500     ASSERT_VALUES
1501   }
1502 };
1503 
1504 
1505 LEAF(Intrinsic, StateSplit)
1506  private:
1507   vmIntrinsics::ID _id;
1508   ArgsNonNullState _nonnull_state;

1924   Condition cond() const                         { return _cond; }
1925   bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
1926   Value y() const                                { return _y; }
1927 
1928   void always_fail()                             { _x = _y = nullptr; }
1929 
1930   // generic
1931   virtual void input_values_do(ValueVisitor* f)  { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1932   HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
1933 };
1934 
1935 LEAF(If, BlockEnd)
1936  private:
1937   Value       _x;
1938   Condition   _cond;
1939   Value       _y;
1940   ciMethod*   _profiled_method;
1941   int         _profiled_bci; // Canonicalizer may alter bci of If node
1942   bool        _swapped;      // Is the order reversed with respect to the original If in the
1943                              // bytecode stream?

1944  public:
1945   // creation
1946   // unordered_is_true is valid for float/double compares only
1947   If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
1948     : BlockEnd(illegalType, state_before, is_safepoint)
1949   , _x(x)
1950   , _cond(cond)
1951   , _y(y)
1952   , _profiled_method(nullptr)
1953   , _profiled_bci(0)
1954   , _swapped(false)

1955   {
1956     ASSERT_VALUES
1957     set_flag(UnorderedIsTrueFlag, unordered_is_true);
1958     assert(x->type()->tag() == y->type()->tag(), "types must match");
1959     BlockList* s = new BlockList(2);
1960     s->append(tsux);
1961     s->append(fsux);
1962     set_sux(s);
1963   }
1964 
1965   // accessors
1966   Value x() const                                { return _x; }
1967   Condition cond() const                         { return _cond; }
1968   bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
1969   Value y() const                                { return _y; }
1970   BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
1971   BlockBegin* tsux() const                       { return sux_for(true); }
1972   BlockBegin* fsux() const                       { return sux_for(false); }
1973   BlockBegin* usux() const                       { return sux_for(unordered_is_true()); }
1974   bool should_profile() const                    { return check_flag(ProfileMDOFlag); }
1975   ciMethod* profiled_method() const              { return _profiled_method; } // set only for profiled branches
1976   int profiled_bci() const                       { return _profiled_bci; }    // set for profiled branches and tiered
1977   bool is_swapped() const                        { return _swapped; }
1978 
1979   // manipulation
1980   void swap_operands() {
1981     Value t = _x; _x = _y; _y = t;
1982     _cond = mirror(_cond);
1983   }
1984 
1985   void set_should_profile(bool value)             { set_flag(ProfileMDOFlag, value); }
1986   void set_profiled_method(ciMethod* method)      { _profiled_method = method; }
1987   void set_profiled_bci(int bci)                  { _profiled_bci = bci;       }
1988   void set_swapped(bool value)                    { _swapped = value;         }

1989   // generic
1990   virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1991 };
1992 
1993 
1994 BASE(Switch, BlockEnd)
1995  private:
1996   Value       _tag;
1997 
1998  public:
1999   // creation
2000   Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2001   : BlockEnd(illegalType, state_before, is_safepoint)
2002   , _tag(tag) {
2003     ASSERT_VALUES
2004     set_sux(sux);
2005   }
2006 
2007   // accessors
2008   Value tag() const                              { return _tag; }

2279     }
2280   }
2281 };
2282 
2283 LEAF(ProfileReturnType, Instruction)
2284  private:
2285   ciMethod*        _method;
2286   ciMethod*        _callee;
2287   int              _bci_of_invoke;
2288   Value            _ret;
2289 
2290  public:
2291   ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2292     : Instruction(voidType)
2293     , _method(method)
2294     , _callee(callee)
2295     , _bci_of_invoke(bci)
2296     , _ret(ret)
2297   {
2298     set_needs_null_check(true);
2299     // The ProfileType has side-effects and must occur precisely where located
2300     pin();
2301   }
2302 
2303   ciMethod* method()             const { return _method; }
2304   ciMethod* callee()             const { return _callee; }
2305   int bci_of_invoke()            const { return _bci_of_invoke; }
2306   Value ret()                    const { return _ret; }
2307 
2308   virtual void input_values_do(ValueVisitor* f)   {
2309     if (_ret != nullptr) {
2310       f->visit(&_ret);
2311     }
2312   }
2313 };
2314 










































2315 // Call some C runtime function that doesn't safepoint,
2316 // optionally passing the current thread as the first argument.
2317 LEAF(RuntimeCall, Instruction)
2318  private:
2319   const char* _entry_name;
2320   address     _entry;
2321   Values*     _args;
2322   bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
2323 
2324  public:
2325   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2326     : Instruction(type)
2327     , _entry_name(entry_name)
2328     , _entry(entry)
2329     , _args(args)
2330     , _pass_thread(pass_thread) {
2331     ASSERT_VALUES
2332     pin();
2333   }
2334 

  57 class       StoreIndexed;
  58 class   NegateOp;
  59 class   Op2;
  60 class     ArithmeticOp;
  61 class     ShiftOp;
  62 class     LogicOp;
  63 class     CompareOp;
  64 class     IfOp;
  65 class   Convert;
  66 class   NullCheck;
  67 class   TypeCast;
  68 class   OsrEntry;
  69 class   ExceptionObject;
  70 class   StateSplit;
  71 class     Invoke;
  72 class     NewInstance;
  73 class     NewArray;
  74 class       NewTypeArray;
  75 class       NewObjectArray;
  76 class       NewMultiArray;
  77 class     Deoptimize;
  78 class     TypeCheck;
  79 class       CheckCast;
  80 class       InstanceOf;
  81 class     AccessMonitor;
  82 class       MonitorEnter;
  83 class       MonitorExit;
  84 class     Intrinsic;
  85 class     BlockBegin;
  86 class     BlockEnd;
  87 class       Goto;
  88 class       If;
  89 class       Switch;
  90 class         TableSwitch;
  91 class         LookupSwitch;
  92 class       Return;
  93 class       Throw;
  94 class       Base;
  95 class   UnsafeOp;
  96 class     UnsafeGet;
  97 class     UnsafePut;
  98 class     UnsafeGetAndSet;
  99 class   ProfileCall;
 100 class   ProfileReturnType;
 101 class   ProfileACmpTypes;
 102 class   ProfileInvoke;
 103 class   RuntimeCall;
 104 class   MemBar;
 105 class   RangeCheckPredicate;
 106 #ifdef ASSERT
 107 class   Assert;
 108 #endif
 109 
 110 // A Value is a reference to the instruction creating the value
 111 typedef Instruction* Value;
 112 typedef GrowableArray<Value> Values;
 113 typedef GrowableArray<ValueStack*> ValueStackStack;
 114 
 115 // BlockClosure is the base class for block traversal/iteration.
 116 
 117 class BlockClosure: public CompilationResourceObj {
 118  public:
 119   virtual void block_do(BlockBegin* block)       = 0;
 120 };
 121 

 176   virtual void do_CheckCast      (CheckCast*       x) = 0;
 177   virtual void do_InstanceOf     (InstanceOf*      x) = 0;
 178   virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
 179   virtual void do_MonitorExit    (MonitorExit*     x) = 0;
 180   virtual void do_Intrinsic      (Intrinsic*       x) = 0;
 181   virtual void do_BlockBegin     (BlockBegin*      x) = 0;
 182   virtual void do_Goto           (Goto*            x) = 0;
 183   virtual void do_If             (If*              x) = 0;
 184   virtual void do_TableSwitch    (TableSwitch*     x) = 0;
 185   virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
 186   virtual void do_Return         (Return*          x) = 0;
 187   virtual void do_Throw          (Throw*           x) = 0;
 188   virtual void do_Base           (Base*            x) = 0;
 189   virtual void do_OsrEntry       (OsrEntry*        x) = 0;
 190   virtual void do_ExceptionObject(ExceptionObject* x) = 0;
 191   virtual void do_UnsafeGet      (UnsafeGet*       x) = 0;
 192   virtual void do_UnsafePut      (UnsafePut*       x) = 0;
 193   virtual void do_UnsafeGetAndSet(UnsafeGetAndSet* x) = 0;
 194   virtual void do_ProfileCall    (ProfileCall*     x) = 0;
 195   virtual void do_ProfileReturnType (ProfileReturnType*  x) = 0;
 196   virtual void do_ProfileACmpTypes(ProfileACmpTypes*  x) = 0;
 197   virtual void do_ProfileInvoke  (ProfileInvoke*   x) = 0;
 198   virtual void do_RuntimeCall    (RuntimeCall*     x) = 0;
 199   virtual void do_MemBar         (MemBar*          x) = 0;
 200   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
 201 #ifdef ASSERT
 202   virtual void do_Assert         (Assert*          x) = 0;
 203 #endif
 204 };
 205 
 206 
 207 // Hashing support
 208 //
 209 // Note: This hash functions affect the performance
 210 //       of ValueMap - make changes carefully!
 211 
 212 #define HASH1(x1            )                    ((intx)(x1))
 213 #define HASH2(x1, x2        )                    ((HASH1(x1            ) << 7) ^ HASH1(x2))
 214 #define HASH3(x1, x2, x3    )                    ((HASH2(x1, x2        ) << 7) ^ HASH1(x3))
 215 #define HASH4(x1, x2, x3, x4)                    ((HASH3(x1, x2, x3    ) << 7) ^ HASH1(x4))
 216 #define HASH5(x1, x2, x3, x4, x5)                ((HASH4(x1, x2, x3, x4) << 7) ^ HASH1(x5))
 217 
 218 
 219 // The following macros are used to implement instruction-specific hashing.
 220 // By default, each instruction implements hash() and is_equal(Value), used
 221 // for value numbering/common subexpression elimination. The default imple-
 222 // mentation disables value numbering. Each instruction which can be value-
 223 // numbered, should define corresponding hash() and is_equal(Value) functions
 224 // via the macros below. The f arguments specify all the values/op codes, etc.
 225 // that need to be identical for two instructions to be identical.
 226 //
 227 // Note: The default implementation of hash() returns 0 in order to indicate
 228 //       that the instruction should not be considered for value numbering.
 229 //       The currently used hash functions do not guarantee that never a 0
 230 //       is produced. While this is still correct, it may be a performance
 231 //       bug (no value numbering for that node). However, this situation is
 232 //       so unlikely, that we are not going to handle it specially.
 233 
 234 #define HASHING1(class_name, enabled, f1)             \
 235   virtual intx hash() const {                         \
 236     return (enabled) ? HASH2(name(), f1) : 0;         \

 255     if (f1 != _v->f1) return false;                   \
 256     if (f2 != _v->f2) return false;                   \
 257     return true;                                      \
 258   }                                                   \
 259 
 260 
 261 #define HASHING3(class_name, enabled, f1, f2, f3)     \
 262   virtual intx hash() const {                         \
 263     return (enabled) ? HASH4(name(), f1, f2, f3) : 0; \
 264   }                                                   \
 265   virtual bool is_equal(Value v) const {              \
 266     if (!(enabled)  ) return false;                   \
 267     class_name* _v = v->as_##class_name();            \
 268     if (_v == nullptr) return false;                  \
 269     if (f1 != _v->f1) return false;                   \
 270     if (f2 != _v->f2) return false;                   \
 271     if (f3 != _v->f3) return false;                   \
 272     return true;                                      \
 273   }                                                   \
 274 
 275 #define HASHING4(class_name, enabled, f1, f2, f3, f4) \
 276   virtual intx hash() const {                         \
 277     return (enabled) ? HASH5(name(), f1, f2, f3, f4) : 0; \
 278   }                                                   \
 279   virtual bool is_equal(Value v) const {              \
 280     if (!(enabled)  ) return false;                   \
 281     class_name* _v = v->as_##class_name();            \
 282     if (_v == nullptr  ) return false;                   \
 283     if (f1 != _v->f1) return false;                   \
 284     if (f2 != _v->f2) return false;                   \
 285     if (f3 != _v->f3) return false;                   \
 286     if (f4 != _v->f4) return false;                   \
 287     return true;                                      \
 288   }                                                   \
 289 
 290 
 291 // The mother of all instructions...
 292 
 293 class Instruction: public CompilationResourceObj {
 294  private:
 295   int          _id;                              // the unique instruction id
 296 #ifndef PRODUCT
 297   int          _printable_bci;                   // the bci of the instruction for printing
 298 #endif
 299   int          _use_count;                       // the number of instructions referring to this value (w/o prev/next); only roots can have use count = 0 or > 1
 300   int          _pin_state;                       // set of PinReason describing the reason for pinning
 301   unsigned int _flags;                           // Flag bits
 302   ValueType*   _type;                            // the instruction value type
 303   Instruction* _next;                            // the next instruction if any (null for BlockEnd instructions)
 304   Instruction* _subst;                           // the substitution instruction if any
 305   LIR_Opr      _operand;                         // LIR specific information
 306 
 307   ValueStack*  _state_before;                    // Copy of state with input operands still on stack (or null)
 308   ValueStack*  _exception_state;                 // Copy of state for exception handling
 309   XHandlers*   _exception_handlers;              // Flat list of exception handlers covering this instruction
 310 
 311   friend class UseCountComputer;
 312   friend class GraphBuilder;
 313 
 314   void update_exception_state(ValueStack* state);
 315 
 316  protected:
 317   BlockBegin*  _block;                           // Block that contains this instruction
 318 
 319   void set_type(ValueType* type) {
 320     assert(type != nullptr, "type must exist");
 321     _type = type;
 322   }
 323 
 324   // Helper class to keep track of which arguments need a null check
 325   class ArgsNonNullState {
 326   private:
 327     int _nonnull_state; // mask identifying which args are nonnull
 328   public:
 329     ArgsNonNullState()
 330       : _nonnull_state(AllBits) {}
 331 
 332     // Does argument number i needs a null check?

 345         if (check) {
 346           _nonnull_state |= (int)nth_bit(i);
 347         } else {
 348           _nonnull_state &= (int)~(nth_bit(i));
 349         }
 350       }
 351     }
 352   };
 353 
 354  public:
 355   void* operator new(size_t size) throw() {
 356     Compilation* c = Compilation::current();
 357     void* res = c->arena()->Amalloc(size);
 358     return res;
 359   }
 360 
 361   static const int no_bci = -99;
 362 
 363   enum InstructionFlag {
 364     NeedsNullCheckFlag = 0,
 365     NeverNullFlag,
 366     CanTrapFlag,
 367     DirectCompareFlag,
 368     IsSafepointFlag,
 369     IsStaticFlag,
 370     PreservesStateFlag,
 371     TargetIsFinalFlag,
 372     TargetIsLoadedFlag,
 373     UnorderedIsTrueFlag,
 374     NeedsPatchingFlag,
 375     ThrowIncompatibleClassChangeErrorFlag,
 376     InvokeSpecialReceiverCheckFlag,
 377     ProfileMDOFlag,
 378     IsLinkedInBlockFlag,
 379     NeedsRangeCheckFlag,
 380     DeoptimizeOnException,
 381     KillsMemoryFlag,
 382     OmitChecksFlag,
 383     InstructionLastFlag
 384   };
 385 

 436   int id() const                                 { return _id; }
 437 #ifndef PRODUCT
 438   bool has_printable_bci() const                 { return _printable_bci != -99; }
 439   int printable_bci() const                      { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
 440   void set_printable_bci(int bci)                { _printable_bci = bci; }
 441 #endif
 442   int dominator_depth();
 443   int use_count() const                          { return _use_count; }
 444   int pin_state() const                          { return _pin_state; }
 445   bool is_pinned() const                         { return _pin_state != 0 || PinAllInstructions; }
 446   ValueType* type() const                        { return _type; }
 447   BlockBegin *block() const                      { return _block; }
 448   Instruction* prev();                           // use carefully, expensive operation
 449   Instruction* next() const                      { return _next; }
 450   bool has_subst() const                         { return _subst != nullptr; }
 451   Instruction* subst()                           { return _subst == nullptr ? this : _subst->subst(); }
 452   LIR_Opr operand() const                        { return _operand; }
 453 
 454   void set_needs_null_check(bool f)              { set_flag(NeedsNullCheckFlag, f); }
 455   bool needs_null_check() const                  { return check_flag(NeedsNullCheckFlag); }
 456   void set_null_free(bool f)                     { set_flag(NeverNullFlag, f); }
 457   bool is_null_free() const                      { return check_flag(NeverNullFlag); }
 458   bool is_linked() const                         { return check_flag(IsLinkedInBlockFlag); }
 459   bool can_be_linked()                           { return as_Local() == nullptr && as_Phi() == nullptr; }
 460 
 461   bool is_null_obj()                             { return as_Constant() != nullptr && type()->as_ObjectType()->constant_value()->is_null_object(); }
 462 
 463   bool has_uses() const                          { return use_count() > 0; }
 464   ValueStack* state_before() const               { return _state_before; }
 465   ValueStack* exception_state() const            { return _exception_state; }
 466   virtual bool needs_exception_state() const     { return true; }
 467   XHandlers* exception_handlers() const          { return _exception_handlers; }
 468   ciKlass* as_loaded_klass_or_null() const;
 469 
 470   // manipulation
 471   void pin(PinReason reason)                     { _pin_state |= reason; }
 472   void pin()                                     { _pin_state |= PinUnknown; }
 473   // DANGEROUS: only used by EliminateStores
 474   void unpin(PinReason reason)                   { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
 475 
 476   Instruction* set_next(Instruction* next) {
 477     assert(next->has_printable_bci(), "_printable_bci should have been set");
 478     assert(next != nullptr, "must not be null");
 479     assert(as_BlockEnd() == nullptr, "BlockEnd instructions must have no next");
 480     assert(next->can_be_linked(), "shouldn't link these instructions into list");
 481 
 482     BlockBegin *block = this->block();
 483     next->_block = block;
 484 
 485     next->set_flag(Instruction::IsLinkedInBlockFlag, true);
 486     _next = next;
 487     return next;
 488   }

 493 #endif
 494     return set_next(next);
 495   }
 496 
 497   // when blocks are merged
 498   void fixup_block_pointers() {
 499     Instruction *cur = next()->next(); // next()'s block is set in set_next
 500     while (cur && cur->_block != block()) {
 501       cur->_block = block();
 502       cur = cur->next();
 503     }
 504   }
 505 
 506   Instruction *insert_after(Instruction *i) {
 507     Instruction* n = _next;
 508     set_next(i);
 509     i->set_next(n);
 510     return _next;
 511   }
 512 
 513   bool is_loaded_flat_array() const;
 514   bool maybe_flat_array();
 515   bool maybe_null_free_array();
 516 
 517   Instruction *insert_after_same_bci(Instruction *i) {
 518 #ifndef PRODUCT
 519     i->set_printable_bci(printable_bci());
 520 #endif
 521     return insert_after(i);
 522   }
 523 
 524   void set_subst(Instruction* subst)             {
 525     assert(subst == nullptr ||
 526            type()->base() == subst->type()->base() ||
 527            subst->type()->base() == illegalType, "type can't change");
 528     _subst = subst;
 529   }
 530   void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
 531   void set_exception_state(ValueStack* s)        { check_state(s); _exception_state = s; }
 532   void set_state_before(ValueStack* s)           { check_state(s); _state_before = s; }
 533 
 534   // machine-specifics
 535   void set_operand(LIR_Opr operand)              { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
 536   void clear_operand()                           { _operand = LIR_OprFact::illegalOpr; }

 824 
 825   // Under certain circumstances, if a previous NullCheck instruction
 826   // proved the target object non-null, we can eliminate the explicit
 827   // null check and do an implicit one, simply specifying the debug
 828   // information from the NullCheck. This field should only be consulted
 829   // if needs_null_check() is true.
 830   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 831 
 832   // generic
 833   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 834   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 835 };
 836 
 837 
 838 LEAF(LoadField, AccessField)
 839  public:
 840   // creation
 841   LoadField(Value obj, int offset, ciField* field, bool is_static,
 842             ValueStack* state_before, bool needs_patching)
 843   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 844   {
 845     set_null_free(field->is_null_free());
 846   }
 847 
 848   ciType* declared_type() const;
 849 
 850   // generic; cannot be eliminated if needs patching or if volatile.
 851   HASHING3(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset(), declared_type())
 852 };
 853 
 854 
 855 LEAF(StoreField, AccessField)
 856  private:
 857   Value _value;
 858   ciField* _enclosing_field;   // enclosing field (the flat one) for nested fields
 859 
 860  public:
 861   // creation
 862   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 863              ValueStack* state_before, bool needs_patching);






 864 
 865   // accessors
 866   Value value() const                            { return _value; }
 867   ciField* enclosing_field() const               { return _enclosing_field; }
 868   void set_enclosing_field(ciField* field)       { _enclosing_field = field; }
 869 
 870   // generic
 871   virtual void input_values_do(ValueVisitor* f)   { AccessField::input_values_do(f); f->visit(&_value); }
 872 };
 873 
 874 
 875 BASE(AccessArray, Instruction)
 876  private:
 877   Value       _array;
 878 
 879  public:
 880   // creation
 881   AccessArray(ValueType* type, Value array, ValueStack* state_before)
 882   : Instruction(type, state_before)
 883   , _array(array)
 884   {
 885     set_needs_null_check(true);
 886     ASSERT_VALUES
 887     pin(); // instruction with side effect (null exception or range check throwing)
 888   }

 906   , _explicit_null_check(nullptr) {}
 907 
 908   // accessors
 909   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 910 
 911   // setters
 912   // See LoadField::set_explicit_null_check for documentation
 913   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 914 
 915   // generic
 916   HASHING1(ArrayLength, true, array()->subst())
 917 };
 918 
 919 
 920 BASE(AccessIndexed, AccessArray)
 921  private:
 922   Value     _index;
 923   Value     _length;
 924   BasicType _elt_type;
 925   bool      _mismatched;
 926   ciMethod* _profiled_method;
 927   int       _profiled_bci;
 928 
 929  public:
 930   // creation
 931   AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
 932   : AccessArray(as_ValueType(elt_type), array, state_before)
 933   , _index(index)
 934   , _length(length)
 935   , _elt_type(elt_type)
 936   , _mismatched(mismatched)
 937   , _profiled_method(nullptr), _profiled_bci(0)
 938   {
 939     set_flag(Instruction::NeedsRangeCheckFlag, true);
 940     ASSERT_VALUES
 941   }
 942 
 943   // accessors
 944   Value index() const                            { return _index; }
 945   Value length() const                           { return _length; }
 946   BasicType elt_type() const                     { return _elt_type; }
 947   bool mismatched() const                        { return _mismatched; }
 948 
 949   void clear_length()                            { _length = nullptr; }
 950   // perform elimination of range checks involving constants
 951   bool compute_needs_range_check();
 952 
 953   // Helpers for MethodData* profiling
 954   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
 955   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
 956   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
 957   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
 958   ciMethod* profiled_method() const                  { return _profiled_method;     }
 959   int       profiled_bci() const                     { return _profiled_bci;        }
 960 
 961 
 962   // generic
 963   virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
 964 };
 965 
 966 class DelayedLoadIndexed;
 967 
 968 LEAF(LoadIndexed, AccessIndexed)
 969  private:
 970   NullCheck*  _explicit_null_check;              // For explicit null check elimination
 971   NewInstance* _vt;
 972   DelayedLoadIndexed* _delayed;
 973 
 974  public:
 975   // creation
 976   LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
 977   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 978   , _explicit_null_check(nullptr), _vt(nullptr), _delayed(nullptr) {}
 979 
 980   // accessors
 981   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 982 
 983   // setters
 984   // See LoadField::set_explicit_null_check for documentation
 985   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 986 
 987   ciType* exact_type() const;
 988   ciType* declared_type() const;
 989 
 990   NewInstance* vt() const { return _vt; }
 991   void set_vt(NewInstance* vt) { _vt = vt; }
 992 
 993   DelayedLoadIndexed* delayed() const { return _delayed; }
 994   void set_delayed(DelayedLoadIndexed* delayed) { _delayed = delayed; }
 995 
 996   // generic;
 997   HASHING4(LoadIndexed, delayed() == nullptr && !should_profile(), elt_type(), array()->subst(), index()->subst(), vt())
 998 };
 999 
1000 class DelayedLoadIndexed : public CompilationResourceObj {
1001 private:
1002   LoadIndexed* _load_instr;
1003   ValueStack* _state_before;
1004   ciField* _field;
1005   int _offset;
1006  public:
1007   DelayedLoadIndexed(LoadIndexed* load, ValueStack* state_before)
1008   : _load_instr(load)
1009   , _state_before(state_before)
1010   , _field(nullptr)
1011   , _offset(0) { }
1012 
1013   void update(ciField* field, int offset) {
1014     _field = field;
1015     _offset += offset;
1016   }
1017 
1018   LoadIndexed* load_instr() const { return _load_instr; }
1019   ValueStack* state_before() const { return _state_before; }
1020   ciField* field() const { return _field; }
1021   int offset() const { return _offset; }
1022 };
1023 
1024 LEAF(StoreIndexed, AccessIndexed)
1025  private:
1026   Value       _value;
1027 


1028   bool      _check_boolean;
1029 
1030  public:
1031   // creation
1032   StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
1033                bool check_boolean, bool mismatched = false);






1034 
1035   // accessors
1036   Value value() const                            { return _value; }
1037   bool check_boolean() const                     { return _check_boolean; }
1038 
1039   // Flattened array support
1040   bool is_exact_flat_array_store() const;




1041   // generic
1042   virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
1043 };
1044 
1045 
1046 LEAF(NegateOp, Instruction)
1047  private:
1048   Value _x;
1049 
1050  public:
1051   // creation
1052   NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1053     ASSERT_VALUES
1054   }
1055 
1056   // accessors
1057   Value x() const                                { return _x; }
1058 
1059   // generic
1060   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }

1131   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1132 };
1133 
1134 
1135 LEAF(CompareOp, Op2)
1136  public:
1137   // creation
1138   CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1139   : Op2(intType, op, x, y, state_before)
1140   {}
1141 
1142   // generic
1143   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1144 };
1145 
1146 
1147 LEAF(IfOp, Op2)
1148  private:
1149   Value _tval;
1150   Value _fval;
1151   bool _substitutability_check;
1152 
1153  public:
1154   // creation
1155   IfOp(Value x, Condition cond, Value y, Value tval, Value fval, ValueStack* state_before, bool substitutability_check)
1156   : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1157   , _tval(tval)
1158   , _fval(fval)
1159   , _substitutability_check(substitutability_check)
1160   {
1161     ASSERT_VALUES
1162     assert(tval->type()->tag() == fval->type()->tag(), "types must match");
1163     set_state_before(state_before);
1164   }
1165 
1166   // accessors
1167   virtual bool is_commutative() const;
1168   Bytecodes::Code op() const                     { ShouldNotCallThis(); return Bytecodes::_illegal; }
1169   Condition cond() const                         { return (Condition)Op2::op(); }
1170   Value tval() const                             { return _tval; }
1171   Value fval() const                             { return _fval; }
1172   bool substitutability_check() const             { return _substitutability_check; }
1173   // generic
1174   virtual void input_values_do(ValueVisitor* f)   { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1175 };
1176 
1177 
1178 LEAF(Convert, Instruction)
1179  private:
1180   Bytecodes::Code _op;
1181   Value           _value;
1182 
1183  public:
1184   // creation
1185   Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1186     ASSERT_VALUES
1187   }
1188 
1189   // accessors
1190   Bytecodes::Code op() const                     { return _op; }
1191   Value value() const                            { return _value; }
1192 

1309   bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
1310   bool is_method_handle_intrinsic() const        { return target()->is_method_handle_intrinsic(); }
1311 
1312   virtual bool needs_exception_state() const     { return false; }
1313 
1314   // generic
1315   virtual bool can_trap() const                  { return true; }
1316   virtual void input_values_do(ValueVisitor* f) {
1317     StateSplit::input_values_do(f);
1318     if (has_receiver()) f->visit(&_recv);
1319     for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1320   }
1321   virtual void state_values_do(ValueVisitor *f);
1322 };
1323 
1324 
1325 LEAF(NewInstance, StateSplit)
1326  private:
1327   ciInstanceKlass* _klass;
1328   bool _is_unresolved;
1329   bool _needs_state_before;
1330 
1331  public:
1332   // creation
1333   NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved, bool needs_state_before)
1334   : StateSplit(instanceType, state_before)
1335   , _klass(klass), _is_unresolved(is_unresolved), _needs_state_before(needs_state_before)
1336   {}
1337 
1338   // accessors
1339   ciInstanceKlass* klass() const                 { return _klass; }
1340   bool is_unresolved() const                     { return _is_unresolved; }
1341   bool needs_state_before() const                { return _needs_state_before; }
1342 
1343   virtual bool needs_exception_state() const     { return false; }
1344 
1345   // generic
1346   virtual bool can_trap() const                  { return true; }
1347   ciType* exact_type() const;
1348   ciType* declared_type() const;
1349 };
1350 

1351 BASE(NewArray, StateSplit)
1352  private:
1353   Value       _length;
1354 
1355  public:
1356   // creation
1357   NewArray(Value length, ValueStack* state_before)
1358   : StateSplit(objectType, state_before)
1359   , _length(length)
1360   {
1361     // Do not ASSERT_VALUES since length is null for NewMultiArray
1362   }
1363 
1364   // accessors
1365   Value length() const                           { return _length; }
1366 
1367   virtual bool needs_exception_state() const     { return false; }
1368 
1369   ciType* exact_type() const                     { return nullptr; }
1370   ciType* declared_type() const;

1384   // creation
1385   NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before, bool zero_array)
1386   : NewArray(length, state_before)
1387   , _elt_type(elt_type)
1388   , _zero_array(zero_array)
1389   {}
1390 
1391   // accessors
1392   BasicType elt_type() const                     { return _elt_type; }
1393   bool zero_array()    const                     { return _zero_array; }
1394   ciType* exact_type() const;
1395 };
1396 
1397 
1398 LEAF(NewObjectArray, NewArray)
1399  private:
1400   ciKlass* _klass;
1401 
1402  public:
1403   // creation
1404   NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before)
1405   : NewArray(length, state_before), _klass(klass) { }
1406 
1407   // accessors
1408   ciKlass* klass() const                         { return _klass; }
1409   ciType* exact_type() const;
1410 };
1411 
1412 
1413 LEAF(NewMultiArray, NewArray)
1414  private:
1415   ciKlass* _klass;
1416   Values*  _dims;
1417 
1418  public:
1419   // creation
1420   NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(nullptr, state_before), _klass(klass), _dims(dims) {
1421     ASSERT_VALUES
1422   }
1423 
1424   // accessors
1425   ciKlass* klass() const                         { return _klass; }
1426   Values* dims() const                           { return _dims; }
1427   int rank() const                               { return dims()->length(); }
1428 
1429   // generic
1430   virtual void input_values_do(ValueVisitor* f) {
1431     // NOTE: we do not call NewArray::input_values_do since "length"
1432     // is meaningless for a multi-dimensional array; passing the
1433     // zeroth element down to NewArray as its length is a bad idea
1434     // since there will be a copy in the "dims" array which doesn't
1435     // get updated, and the value must not be traversed twice. Was bug
1436     // - kbr 4/10/2001
1437     StateSplit::input_values_do(f);
1438     for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1439   }
1440 
1441   ciType* exact_type() const;
1442 };
1443 
1444 
1445 BASE(TypeCheck, StateSplit)
1446  private:
1447   ciKlass*    _klass;
1448   Value       _obj;
1449 
1450   ciMethod* _profiled_method;
1451   int       _profiled_bci;
1452 
1453  public:
1454   // creation
1455   TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1456   : StateSplit(type, state_before), _klass(klass), _obj(obj),
1457     _profiled_method(nullptr), _profiled_bci(0) {
1458     ASSERT_VALUES
1459     set_direct_compare(false);
1460   }
1461 

1469   void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
1470 
1471   // generic
1472   virtual bool can_trap() const                  { return true; }
1473   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1474 
1475   // Helpers for MethodData* profiling
1476   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1477   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1478   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1479   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1480   ciMethod* profiled_method() const                  { return _profiled_method;     }
1481   int       profiled_bci() const                     { return _profiled_bci;        }
1482 };
1483 
1484 
1485 LEAF(CheckCast, TypeCheck)
1486  public:
1487   // creation
1488   CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
1489   : TypeCheck(klass, obj, objectType, state_before) { }
1490 
1491   void set_incompatible_class_change_check() {
1492     set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1493   }
1494   bool is_incompatible_class_change_check() const {
1495     return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1496   }
1497   void set_invokespecial_receiver_check() {
1498     set_flag(InvokeSpecialReceiverCheckFlag, true);
1499   }
1500   bool is_invokespecial_receiver_check() const {
1501     return check_flag(InvokeSpecialReceiverCheckFlag);
1502   }
1503 
1504   virtual bool needs_exception_state() const {
1505     return !is_invokespecial_receiver_check();
1506   }
1507 
1508   ciType* declared_type() const;
1509 };

1527   // creation
1528   AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1529   : StateSplit(illegalType, state_before)
1530   , _obj(obj)
1531   , _monitor_no(monitor_no)
1532   {
1533     set_needs_null_check(true);
1534     ASSERT_VALUES
1535   }
1536 
1537   // accessors
1538   Value obj() const                              { return _obj; }
1539   int monitor_no() const                         { return _monitor_no; }
1540 
1541   // generic
1542   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1543 };
1544 
1545 
1546 LEAF(MonitorEnter, AccessMonitor)
1547   bool _maybe_inlinetype;
1548  public:
1549   // creation
1550   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before, bool maybe_inlinetype)
1551   : AccessMonitor(obj, monitor_no, state_before)
1552   , _maybe_inlinetype(maybe_inlinetype)
1553   {
1554     ASSERT_VALUES
1555   }
1556 
1557   // accessors
1558   bool maybe_inlinetype() const                   { return _maybe_inlinetype; }
1559 
1560   // generic
1561   virtual bool can_trap() const                  { return true; }
1562 };
1563 
1564 
1565 LEAF(MonitorExit, AccessMonitor)
1566  public:
1567   // creation
1568   MonitorExit(Value obj, int monitor_no)
1569   : AccessMonitor(obj, monitor_no, nullptr)
1570   {
1571     ASSERT_VALUES
1572   }
1573 };
1574 
1575 
1576 LEAF(Intrinsic, StateSplit)
1577  private:
1578   vmIntrinsics::ID _id;
1579   ArgsNonNullState _nonnull_state;

1995   Condition cond() const                         { return _cond; }
1996   bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
1997   Value y() const                                { return _y; }
1998 
1999   void always_fail()                             { _x = _y = nullptr; }
2000 
2001   // generic
2002   virtual void input_values_do(ValueVisitor* f)  { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2003   HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
2004 };
2005 
2006 LEAF(If, BlockEnd)
2007  private:
2008   Value       _x;
2009   Condition   _cond;
2010   Value       _y;
2011   ciMethod*   _profiled_method;
2012   int         _profiled_bci; // Canonicalizer may alter bci of If node
2013   bool        _swapped;      // Is the order reversed with respect to the original If in the
2014                              // bytecode stream?
2015   bool        _substitutability_check;
2016  public:
2017   // creation
2018   // unordered_is_true is valid for float/double compares only
2019   If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint, bool substitutability_check=false)
2020     : BlockEnd(illegalType, state_before, is_safepoint)
2021   , _x(x)
2022   , _cond(cond)
2023   , _y(y)
2024   , _profiled_method(nullptr)
2025   , _profiled_bci(0)
2026   , _swapped(false)
2027   , _substitutability_check(substitutability_check)
2028   {
2029     ASSERT_VALUES
2030     set_flag(UnorderedIsTrueFlag, unordered_is_true);
2031     assert(x->type()->tag() == y->type()->tag(), "types must match");
2032     BlockList* s = new BlockList(2);
2033     s->append(tsux);
2034     s->append(fsux);
2035     set_sux(s);
2036   }
2037 
2038   // accessors
2039   Value x() const                                { return _x; }
2040   Condition cond() const                         { return _cond; }
2041   bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
2042   Value y() const                                { return _y; }
2043   BlockBegin* sux_for(bool is_true) const        { return sux_at(is_true ? 0 : 1); }
2044   BlockBegin* tsux() const                       { return sux_for(true); }
2045   BlockBegin* fsux() const                       { return sux_for(false); }
2046   BlockBegin* usux() const                       { return sux_for(unordered_is_true()); }
2047   bool should_profile() const                    { return check_flag(ProfileMDOFlag); }
2048   ciMethod* profiled_method() const              { return _profiled_method; } // set only for profiled branches
2049   int profiled_bci() const                       { return _profiled_bci; }    // set for profiled branches and tiered
2050   bool is_swapped() const                        { return _swapped; }
2051 
2052   // manipulation
2053   void swap_operands() {
2054     Value t = _x; _x = _y; _y = t;
2055     _cond = mirror(_cond);
2056   }
2057 
2058   void set_should_profile(bool value)             { set_flag(ProfileMDOFlag, value); }
2059   void set_profiled_method(ciMethod* method)      { _profiled_method = method; }
2060   void set_profiled_bci(int bci)                  { _profiled_bci = bci;       }
2061   void set_swapped(bool value)                    { _swapped = value;         }
2062   bool substitutability_check() const              { return _substitutability_check; }
2063   // generic
2064   virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2065 };
2066 
2067 
2068 BASE(Switch, BlockEnd)
2069  private:
2070   Value       _tag;
2071 
2072  public:
2073   // creation
2074   Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2075   : BlockEnd(illegalType, state_before, is_safepoint)
2076   , _tag(tag) {
2077     ASSERT_VALUES
2078     set_sux(sux);
2079   }
2080 
2081   // accessors
2082   Value tag() const                              { return _tag; }

2353     }
2354   }
2355 };
2356 
2357 LEAF(ProfileReturnType, Instruction)
2358  private:
2359   ciMethod*        _method;
2360   ciMethod*        _callee;
2361   int              _bci_of_invoke;
2362   Value            _ret;
2363 
2364  public:
2365   ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2366     : Instruction(voidType)
2367     , _method(method)
2368     , _callee(callee)
2369     , _bci_of_invoke(bci)
2370     , _ret(ret)
2371   {
2372     set_needs_null_check(true);
2373     // The ProfileReturnType has side-effects and must occur precisely where located
2374     pin();
2375   }
2376 
2377   ciMethod* method()             const { return _method; }
2378   ciMethod* callee()             const { return _callee; }
2379   int bci_of_invoke()            const { return _bci_of_invoke; }
2380   Value ret()                    const { return _ret; }
2381 
2382   virtual void input_values_do(ValueVisitor* f)   {
2383     if (_ret != nullptr) {
2384       f->visit(&_ret);
2385     }
2386   }
2387 };
2388 
2389 LEAF(ProfileACmpTypes, Instruction)
2390  private:
2391   ciMethod*        _method;
2392   int              _bci;
2393   Value            _left;
2394   Value            _right;
2395   bool             _left_maybe_null;
2396   bool             _right_maybe_null;
2397 
2398  public:
2399   ProfileACmpTypes(ciMethod* method, int bci, Value left, Value right)
2400     : Instruction(voidType)
2401     , _method(method)
2402     , _bci(bci)
2403     , _left(left)
2404     , _right(right)
2405   {
2406     // The ProfileACmp has side-effects and must occur precisely where located
2407     pin();
2408     _left_maybe_null = true;
2409     _right_maybe_null = true;
2410   }
2411 
2412   ciMethod* method()             const { return _method; }
2413   int bci()                      const { return _bci; }
2414   Value left()                   const { return _left; }
2415   Value right()                  const { return _right; }
2416   bool left_maybe_null()         const { return _left_maybe_null; }
2417   bool right_maybe_null()        const { return _right_maybe_null; }
2418   void set_left_maybe_null(bool v)     { _left_maybe_null = v; }
2419   void set_right_maybe_null(bool v)    { _right_maybe_null = v; }
2420 
2421   virtual void input_values_do(ValueVisitor* f)   {
2422     if (_left != nullptr) {
2423       f->visit(&_left);
2424     }
2425     if (_right != nullptr) {
2426       f->visit(&_right);
2427     }
2428   }
2429 };
2430 
2431 // Call some C runtime function that doesn't safepoint,
2432 // optionally passing the current thread as the first argument.
2433 LEAF(RuntimeCall, Instruction)
2434  private:
2435   const char* _entry_name;
2436   address     _entry;
2437   Values*     _args;
2438   bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
2439 
2440  public:
2441   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2442     : Instruction(type)
2443     , _entry_name(entry_name)
2444     , _entry(entry)
2445     , _args(args)
2446     , _pass_thread(pass_thread) {
2447     ASSERT_VALUES
2448     pin();
2449   }
2450 
< prev index next >