< 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; }

 667   }
 668 
 669   bool is_illegal() const {
 670     return type()->is_illegal();
 671   }
 672 
 673   // generic
 674   virtual void input_values_do(ValueVisitor* f) {
 675   }
 676 };
 677 
 678 
 679 // A local is a placeholder for an incoming argument to a function call.
 680 LEAF(Local, Instruction)
 681  private:
 682   int      _java_index;                          // the local index within the method to which the local belongs
 683   bool     _is_receiver;                         // if local variable holds the receiver: "this" for non-static methods
 684   ciType*  _declared_type;
 685  public:
 686   // creation
 687   Local(ciType* declared, ValueType* type, int index, bool receiver)
 688     : Instruction(type)
 689     , _java_index(index)
 690     , _is_receiver(receiver)
 691     , _declared_type(declared)
 692   {

 693     NOT_PRODUCT(set_printable_bci(-1));
 694   }
 695 
 696   // accessors
 697   int java_index() const                         { return _java_index; }
 698   bool is_receiver() const                       { return _is_receiver; }
 699 
 700   virtual ciType* declared_type() const          { return _declared_type; }
 701 
 702   // generic
 703   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
 704 };
 705 
 706 
 707 LEAF(Constant, Instruction)
 708  public:
 709   // creation
 710   Constant(ValueType* type):
 711       Instruction(type, nullptr, /*type_is_constant*/ true)
 712   {

 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,          // For "Q" signatures
 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; }

 695   }
 696 
 697   bool is_illegal() const {
 698     return type()->is_illegal();
 699   }
 700 
 701   // generic
 702   virtual void input_values_do(ValueVisitor* f) {
 703   }
 704 };
 705 
 706 
 707 // A local is a placeholder for an incoming argument to a function call.
 708 LEAF(Local, Instruction)
 709  private:
 710   int      _java_index;                          // the local index within the method to which the local belongs
 711   bool     _is_receiver;                         // if local variable holds the receiver: "this" for non-static methods
 712   ciType*  _declared_type;
 713  public:
 714   // creation
 715   Local(ciType* declared, ValueType* type, int index, bool receiver, bool null_free)
 716     : Instruction(type)
 717     , _java_index(index)
 718     , _is_receiver(receiver)
 719     , _declared_type(declared)
 720   {
 721     set_null_free(null_free);
 722     NOT_PRODUCT(set_printable_bci(-1));
 723   }
 724 
 725   // accessors
 726   int java_index() const                         { return _java_index; }
 727   bool is_receiver() const                       { return _is_receiver; }
 728 
 729   virtual ciType* declared_type() const          { return _declared_type; }
 730 
 731   // generic
 732   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
 733 };
 734 
 735 
 736 LEAF(Constant, Instruction)
 737  public:
 738   // creation
 739   Constant(ValueType* type):
 740       Instruction(type, nullptr, /*type_is_constant*/ true)
 741   {

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






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

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


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






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




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

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

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

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

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

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

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

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

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