< 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   RoundFP;
  95 class   UnsafeOp;
  96 class     UnsafeGet;
  97 class     UnsafePut;
  98 class     UnsafeGetAndSet;
  99 class   ProfileCall;
 100 class   ProfileReturnType;

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

 176   virtual void do_InstanceOf     (InstanceOf*      x) = 0;
 177   virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
 178   virtual void do_MonitorExit    (MonitorExit*     x) = 0;
 179   virtual void do_Intrinsic      (Intrinsic*       x) = 0;
 180   virtual void do_BlockBegin     (BlockBegin*      x) = 0;
 181   virtual void do_Goto           (Goto*            x) = 0;
 182   virtual void do_If             (If*              x) = 0;
 183   virtual void do_TableSwitch    (TableSwitch*     x) = 0;
 184   virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
 185   virtual void do_Return         (Return*          x) = 0;
 186   virtual void do_Throw          (Throw*           x) = 0;
 187   virtual void do_Base           (Base*            x) = 0;
 188   virtual void do_OsrEntry       (OsrEntry*        x) = 0;
 189   virtual void do_ExceptionObject(ExceptionObject* x) = 0;
 190   virtual void do_RoundFP        (RoundFP*         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_ProfileInvoke  (ProfileInvoke*   x) = 0;
 197   virtual void do_RuntimeCall    (RuntimeCall*     x) = 0;
 198   virtual void do_MemBar         (MemBar*          x) = 0;
 199   virtual void do_RangeCheckPredicate(RangeCheckPredicate* x) = 0;
 200 #ifdef ASSERT
 201   virtual void do_Assert         (Assert*          x) = 0;
 202 #endif
 203 };
 204 
 205 
 206 // Hashing support
 207 //
 208 // Note: This hash functions affect the performance
 209 //       of ValueMap - make changes carefully!
 210 
 211 #define HASH1(x1            )                    ((intx)(x1))
 212 #define HASH2(x1, x2        )                    ((HASH1(x1        ) << 7) ^ HASH1(x2))
 213 #define HASH3(x1, x2, x3    )                    ((HASH2(x1, x2    ) << 7) ^ HASH1(x3))
 214 #define HASH4(x1, x2, x3, x4)                    ((HASH3(x1, x2, x3) << 7) ^ HASH1(x4))

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

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















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

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

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

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

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


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

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

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




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

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

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

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


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

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


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

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


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

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









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

 930 
 931 LEAF(LoadIndexed, AccessIndexed)
 932  private:
 933   NullCheck*  _explicit_null_check;              // For explicit null check elimination


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






 951   // generic;
 952   HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst())
 953 };
 954 























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

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

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

1102   {
1103     ASSERT_VALUES
1104     assert(tval->type()->tag() == fval->type()->tag(), "types must match");

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

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

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

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

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

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


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

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

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

1484  public:
1485   // creation
1486   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1487   : AccessMonitor(obj, monitor_no, state_before)

1488   {
1489     ASSERT_VALUES
1490   }
1491 



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

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

1951  public:
1952   // creation
1953   // unordered_is_true is valid for float/double compares only
1954   If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
1955     : BlockEnd(illegalType, state_before, is_safepoint)
1956   , _x(x)
1957   , _cond(cond)
1958   , _y(y)
1959   , _profiled_method(nullptr)
1960   , _profiled_bci(0)
1961   , _swapped(false)

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

1996   // generic
1997   virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1998 };
1999 
2000 
2001 BASE(Switch, BlockEnd)
2002  private:
2003   Value       _tag;
2004 
2005  public:
2006   // creation
2007   Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2008   : BlockEnd(illegalType, state_before, is_safepoint)
2009   , _tag(tag) {
2010     ASSERT_VALUES
2011     set_sux(sux);
2012   }
2013 
2014   // accessors
2015   Value tag() const                              { return _tag; }

2310     }
2311   }
2312 };
2313 
2314 LEAF(ProfileReturnType, Instruction)
2315  private:
2316   ciMethod*        _method;
2317   ciMethod*        _callee;
2318   int              _bci_of_invoke;
2319   Value            _ret;
2320 
2321  public:
2322   ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2323     : Instruction(voidType)
2324     , _method(method)
2325     , _callee(callee)
2326     , _bci_of_invoke(bci)
2327     , _ret(ret)
2328   {
2329     set_needs_null_check(true);
2330     // The ProfileType has side-effects and must occur precisely where located
2331     pin();
2332   }
2333 
2334   ciMethod* method()             const { return _method; }
2335   ciMethod* callee()             const { return _callee; }
2336   int bci_of_invoke()            const { return _bci_of_invoke; }
2337   Value ret()                    const { return _ret; }
2338 
2339   virtual void input_values_do(ValueVisitor* f)   {
2340     if (_ret != nullptr) {
2341       f->visit(&_ret);
2342     }
2343   }
2344 };
2345 










































2346 // Call some C runtime function that doesn't safepoint,
2347 // optionally passing the current thread as the first argument.
2348 LEAF(RuntimeCall, Instruction)
2349  private:
2350   const char* _entry_name;
2351   address     _entry;
2352   Values*     _args;
2353   bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
2354 
2355  public:
2356   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2357     : Instruction(type)
2358     , _entry_name(entry_name)
2359     , _entry(entry)
2360     , _args(args)
2361     , _pass_thread(pass_thread) {
2362     ASSERT_VALUES
2363     pin();
2364   }
2365 

  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   RoundFP;
  96 class   UnsafeOp;
  97 class     UnsafeGet;
  98 class     UnsafePut;
  99 class     UnsafeGetAndSet;
 100 class   ProfileCall;
 101 class   ProfileReturnType;
 102 class   ProfileACmpTypes;
 103 class   ProfileInvoke;
 104 class   RuntimeCall;
 105 class   MemBar;
 106 class   RangeCheckPredicate;
 107 #ifdef ASSERT
 108 class   Assert;
 109 #endif
 110 
 111 // A Value is a reference to the instruction creating the value
 112 typedef Instruction* Value;
 113 typedef GrowableArray<Value> Values;
 114 typedef GrowableArray<ValueStack*> ValueStackStack;
 115 
 116 // BlockClosure is the base class for block traversal/iteration.
 117 
 118 class BlockClosure: public CompilationResourceObj {
 119  public:
 120   virtual void block_do(BlockBegin* block)       = 0;
 121 };
 122 

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

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

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

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

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

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

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






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

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


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






1038 
1039   // accessors
1040   Value value() const                            { return _value; }
1041   bool check_boolean() const                     { return _check_boolean; }
1042 
1043   // Flattened array support
1044   bool is_exact_flat_array_store() const;




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

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

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

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

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

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

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

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

2385     }
2386   }
2387 };
2388 
2389 LEAF(ProfileReturnType, Instruction)
2390  private:
2391   ciMethod*        _method;
2392   ciMethod*        _callee;
2393   int              _bci_of_invoke;
2394   Value            _ret;
2395 
2396  public:
2397   ProfileReturnType(ciMethod* method, int bci, ciMethod* callee, Value ret)
2398     : Instruction(voidType)
2399     , _method(method)
2400     , _callee(callee)
2401     , _bci_of_invoke(bci)
2402     , _ret(ret)
2403   {
2404     set_needs_null_check(true);
2405     // The ProfileReturnType has side-effects and must occur precisely where located
2406     pin();
2407   }
2408 
2409   ciMethod* method()             const { return _method; }
2410   ciMethod* callee()             const { return _callee; }
2411   int bci_of_invoke()            const { return _bci_of_invoke; }
2412   Value ret()                    const { return _ret; }
2413 
2414   virtual void input_values_do(ValueVisitor* f)   {
2415     if (_ret != nullptr) {
2416       f->visit(&_ret);
2417     }
2418   }
2419 };
2420 
2421 LEAF(ProfileACmpTypes, Instruction)
2422  private:
2423   ciMethod*        _method;
2424   int              _bci;
2425   Value            _left;
2426   Value            _right;
2427   bool             _left_maybe_null;
2428   bool             _right_maybe_null;
2429 
2430  public:
2431   ProfileACmpTypes(ciMethod* method, int bci, Value left, Value right)
2432     : Instruction(voidType)
2433     , _method(method)
2434     , _bci(bci)
2435     , _left(left)
2436     , _right(right)
2437   {
2438     // The ProfileACmp has side-effects and must occur precisely where located
2439     pin();
2440     _left_maybe_null = true;
2441     _right_maybe_null = true;
2442   }
2443 
2444   ciMethod* method()             const { return _method; }
2445   int bci()                      const { return _bci; }
2446   Value left()                   const { return _left; }
2447   Value right()                  const { return _right; }
2448   bool left_maybe_null()         const { return _left_maybe_null; }
2449   bool right_maybe_null()        const { return _right_maybe_null; }
2450   void set_left_maybe_null(bool v)     { _left_maybe_null = v; }
2451   void set_right_maybe_null(bool v)    { _right_maybe_null = v; }
2452 
2453   virtual void input_values_do(ValueVisitor* f)   {
2454     if (_left != nullptr) {
2455       f->visit(&_left);
2456     }
2457     if (_right != nullptr) {
2458       f->visit(&_right);
2459     }
2460   }
2461 };
2462 
2463 // Call some C runtime function that doesn't safepoint,
2464 // optionally passing the current thread as the first argument.
2465 LEAF(RuntimeCall, Instruction)
2466  private:
2467   const char* _entry_name;
2468   address     _entry;
2469   Values*     _args;
2470   bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
2471 
2472  public:
2473   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2474     : Instruction(type)
2475     , _entry_name(entry_name)
2476     , _entry(entry)
2477     , _args(args)
2478     , _pass_thread(pass_thread) {
2479     ASSERT_VALUES
2480     pin();
2481   }
2482 
< prev index next >