< 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     IsEliminatedFlag,
 350     IsSafepointFlag,
 351     IsStaticFlag,
 352     NeedsStoreCheckFlag,
 353     NeedsWriteBarrierFlag,
 354     PreservesStateFlag,
 355     TargetIsFinalFlag,
 356     TargetIsLoadedFlag,
 357     UnorderedIsTrueFlag,
 358     NeedsPatchingFlag,
 359     ThrowIncompatibleClassChangeErrorFlag,
 360     InvokeSpecialReceiverCheckFlag,
 361     ProfileMDOFlag,
 362     IsLinkedInBlockFlag,
 363     NeedsRangeCheckFlag,
 364     InWorkListFlag,
 365     DeoptimizeOnException,
 366     KillsMemoryFlag,

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


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

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

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




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

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

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

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

 822   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 823   {}


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

 835 
 836  public:
 837   // creation
 838   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 839              ValueStack* state_before, bool needs_patching)
 840   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 841   , _value(value)
 842   {
 843     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 844     ASSERT_VALUES
 845     pin();
 846   }
 847 
 848   // accessors
 849   Value value() const                            { return _value; }
 850   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }


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

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


 908 
 909  public:
 910   // creation
 911   AccessIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched)
 912   : AccessArray(as_ValueType(elt_type), array, state_before)
 913   , _index(index)
 914   , _length(length)
 915   , _elt_type(elt_type)
 916   , _mismatched(mismatched)

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









 932   // generic
 933   virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != nullptr) f->visit(&_length); }
 934 };
 935 

 936 
 937 LEAF(LoadIndexed, AccessIndexed)
 938  private:
 939   NullCheck*  _explicit_null_check;              // For explicit null check elimination


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






 957   // generic;
 958   HASHING3(LoadIndexed, true, elt_type(), array()->subst(), index()->subst())
 959 };
 960 























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

1085   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1086 };
1087 
1088 
1089 LEAF(CompareOp, Op2)
1090  public:
1091   // creation
1092   CompareOp(Bytecodes::Code op, Value x, Value y, ValueStack* state_before)
1093   : Op2(intType, op, x, y, state_before)
1094   {}
1095 
1096   // generic
1097   HASHING3(Op2, true, op(), x()->subst(), y()->subst())
1098 };
1099 
1100 
1101 LEAF(IfOp, Op2)
1102  private:
1103   Value _tval;
1104   Value _fval;

1105 
1106  public:
1107   // creation
1108   IfOp(Value x, Condition cond, Value y, Value tval, Value fval)
1109   : Op2(tval->type()->meet(fval->type()), (Bytecodes::Code)cond, x, y)
1110   , _tval(tval)
1111   , _fval(fval)

1112   {
1113     ASSERT_VALUES
1114     assert(tval->type()->tag() == fval->type()->tag(), "types must match");

1115   }
1116 
1117   // accessors
1118   virtual bool is_commutative() const;
1119   Bytecodes::Code op() const                     { ShouldNotCallThis(); return Bytecodes::_illegal; }
1120   Condition cond() const                         { return (Condition)Op2::op(); }
1121   Value tval() const                             { return _tval; }
1122   Value fval() const                             { return _fval; }
1123 
1124   // generic
1125   virtual void input_values_do(ValueVisitor* f)   { Op2::input_values_do(f); f->visit(&_tval); f->visit(&_fval); }
1126 };
1127 
1128 
1129 LEAF(Convert, Instruction)
1130  private:
1131   Bytecodes::Code _op;
1132   Value           _value;
1133 
1134  public:
1135   // creation
1136   Convert(Bytecodes::Code op, Value value, ValueType* to_type) : Instruction(to_type), _op(op), _value(value) {
1137     ASSERT_VALUES
1138   }
1139 
1140   // accessors
1141   Bytecodes::Code op() const                     { return _op; }
1142   Value value() const                            { return _value; }
1143 

1260   bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
1261   bool is_method_handle_intrinsic() const        { return target()->is_method_handle_intrinsic(); }
1262 
1263   virtual bool needs_exception_state() const     { return false; }
1264 
1265   // generic
1266   virtual bool can_trap() const                  { return true; }
1267   virtual void input_values_do(ValueVisitor* f) {
1268     StateSplit::input_values_do(f);
1269     if (has_receiver()) f->visit(&_recv);
1270     for (int i = 0; i < _args->length(); i++) f->visit(_args->adr_at(i));
1271   }
1272   virtual void state_values_do(ValueVisitor *f);
1273 };
1274 
1275 
1276 LEAF(NewInstance, StateSplit)
1277  private:
1278   ciInstanceKlass* _klass;
1279   bool _is_unresolved;

1280 
1281  public:
1282   // creation
1283   NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1284   : StateSplit(instanceType, state_before)
1285   , _klass(klass), _is_unresolved(is_unresolved)
1286   {}
1287 
1288   // accessors
1289   ciInstanceKlass* klass() const                 { return _klass; }
1290   bool is_unresolved() const                     { return _is_unresolved; }

1291 
1292   virtual bool needs_exception_state() const     { return false; }
1293 
1294   // generic
1295   virtual bool can_trap() const                  { return true; }
1296   ciType* exact_type() const;
1297   ciType* declared_type() const;
1298 };
1299 
1300 
1301 BASE(NewArray, StateSplit)
1302  private:
1303   Value       _length;
1304 
1305  public:
1306   // creation
1307   NewArray(Value length, ValueStack* state_before)
1308   : StateSplit(objectType, state_before)
1309   , _length(length)
1310   {
1311     // Do not ASSERT_VALUES since length is null for NewMultiArray
1312   }
1313 
1314   // accessors
1315   Value length() const                           { return _length; }
1316 
1317   virtual bool needs_exception_state() const     { return false; }
1318 
1319   ciType* exact_type() const                     { return nullptr; }
1320   ciType* declared_type() const;

1334   // creation
1335   NewTypeArray(Value length, BasicType elt_type, ValueStack* state_before, bool zero_array)
1336   : NewArray(length, state_before)
1337   , _elt_type(elt_type)
1338   , _zero_array(zero_array)
1339   {}
1340 
1341   // accessors
1342   BasicType elt_type() const                     { return _elt_type; }
1343   bool zero_array()    const                     { return _zero_array; }
1344   ciType* exact_type() const;
1345 };
1346 
1347 
1348 LEAF(NewObjectArray, NewArray)
1349  private:
1350   ciKlass* _klass;
1351 
1352  public:
1353   // creation
1354   NewObjectArray(ciKlass* klass, Value length, ValueStack* state_before) : NewArray(length, state_before), _klass(klass) {}

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


1389 };
1390 
1391 
1392 BASE(TypeCheck, StateSplit)
1393  private:
1394   ciKlass*    _klass;
1395   Value       _obj;
1396 
1397   ciMethod* _profiled_method;
1398   int       _profiled_bci;
1399 
1400  public:
1401   // creation
1402   TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1403   : StateSplit(type, state_before), _klass(klass), _obj(obj),
1404     _profiled_method(nullptr), _profiled_bci(0) {
1405     ASSERT_VALUES
1406     set_direct_compare(false);
1407   }
1408 

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

1474   // creation
1475   AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = nullptr)
1476   : StateSplit(illegalType, state_before)
1477   , _obj(obj)
1478   , _monitor_no(monitor_no)
1479   {
1480     set_needs_null_check(true);
1481     ASSERT_VALUES
1482   }
1483 
1484   // accessors
1485   Value obj() const                              { return _obj; }
1486   int monitor_no() const                         { return _monitor_no; }
1487 
1488   // generic
1489   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1490 };
1491 
1492 
1493 LEAF(MonitorEnter, AccessMonitor)

1494  public:
1495   // creation
1496   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1497   : AccessMonitor(obj, monitor_no, state_before)

1498   {
1499     ASSERT_VALUES
1500   }
1501 



1502   // generic
1503   virtual bool can_trap() const                  { return true; }
1504 };
1505 
1506 
1507 LEAF(MonitorExit, AccessMonitor)
1508  public:
1509   // creation
1510   MonitorExit(Value obj, int monitor_no)
1511   : AccessMonitor(obj, monitor_no, nullptr)
1512   {
1513     ASSERT_VALUES
1514   }
1515 };
1516 
1517 
1518 LEAF(Intrinsic, StateSplit)
1519  private:
1520   vmIntrinsics::ID _id;
1521   ArgsNonNullState _nonnull_state;

1941   Condition cond() const                         { return _cond; }
1942   bool unordered_is_true() const                 { return check_flag(UnorderedIsTrueFlag); }
1943   Value y() const                                { return _y; }
1944 
1945   void always_fail()                             { _x = _y = nullptr; }
1946 
1947   // generic
1948   virtual void input_values_do(ValueVisitor* f)  { StateSplit::input_values_do(f); f->visit(&_x); f->visit(&_y); }
1949   HASHING3(RangeCheckPredicate, true, x()->subst(), y()->subst(), cond())
1950 };
1951 
1952 LEAF(If, BlockEnd)
1953  private:
1954   Value       _x;
1955   Condition   _cond;
1956   Value       _y;
1957   ciMethod*   _profiled_method;
1958   int         _profiled_bci; // Canonicalizer may alter bci of If node
1959   bool        _swapped;      // Is the order reversed with respect to the original If in the
1960                              // bytecode stream?

1961  public:
1962   // creation
1963   // unordered_is_true is valid for float/double compares only
1964   If(Value x, Condition cond, bool unordered_is_true, Value y, BlockBegin* tsux, BlockBegin* fsux, ValueStack* state_before, bool is_safepoint)
1965     : BlockEnd(illegalType, state_before, is_safepoint)
1966   , _x(x)
1967   , _cond(cond)
1968   , _y(y)
1969   , _profiled_method(nullptr)
1970   , _profiled_bci(0)
1971   , _swapped(false)

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

2006   // generic
2007   virtual void input_values_do(ValueVisitor* f)   { BlockEnd::input_values_do(f); f->visit(&_x); f->visit(&_y); }
2008 };
2009 
2010 
2011 BASE(Switch, BlockEnd)
2012  private:
2013   Value       _tag;
2014 
2015  public:
2016   // creation
2017   Switch(Value tag, BlockList* sux, ValueStack* state_before, bool is_safepoint)
2018   : BlockEnd(illegalType, state_before, is_safepoint)
2019   , _tag(tag) {
2020     ASSERT_VALUES
2021     set_sux(sux);
2022   }
2023 
2024   // accessors
2025   Value tag() const                              { return _tag; }

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










































2356 // Call some C runtime function that doesn't safepoint,
2357 // optionally passing the current thread as the first argument.
2358 LEAF(RuntimeCall, Instruction)
2359  private:
2360   const char* _entry_name;
2361   address     _entry;
2362   Values*     _args;
2363   bool        _pass_thread;  // Pass the JavaThread* as an implicit first argument
2364 
2365  public:
2366   RuntimeCall(ValueType* type, const char* entry_name, address entry, Values* args, bool pass_thread = true)
2367     : Instruction(type)
2368     , _entry_name(entry_name)
2369     , _entry(entry)
2370     , _args(args)
2371     , _pass_thread(pass_thread) {
2372     ASSERT_VALUES
2373     pin();
2374   }
2375 

  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     IsEliminatedFlag,
 371     IsSafepointFlag,
 372     IsStaticFlag,
 373     NeedsStoreCheckFlag,
 374     NeedsWriteBarrierFlag,
 375     PreservesStateFlag,
 376     TargetIsFinalFlag,
 377     TargetIsLoadedFlag,
 378     UnorderedIsTrueFlag,
 379     NeedsPatchingFlag,
 380     ThrowIncompatibleClassChangeErrorFlag,
 381     InvokeSpecialReceiverCheckFlag,
 382     ProfileMDOFlag,
 383     IsLinkedInBlockFlag,
 384     NeedsRangeCheckFlag,
 385     InWorkListFlag,
 386     DeoptimizeOnException,
 387     KillsMemoryFlag,

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

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

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

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







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

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


1038   bool      _check_boolean;
1039 
1040  public:
1041   // creation
1042   StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
1043                bool check_boolean, bool mismatched = false);








1044 
1045   // accessors
1046   Value value() const                            { return _value; }
1047   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
1048   bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
1049   bool check_boolean() const                     { return _check_boolean; }
1050 
1051   // Flattened array support
1052   bool is_exact_flat_array_store() const;




1053   // generic
1054   virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
1055 };
1056 
1057 
1058 LEAF(NegateOp, Instruction)
1059  private:
1060   Value _x;
1061 
1062  public:
1063   // creation
1064   NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1065     ASSERT_VALUES
1066   }
1067 
1068   // accessors
1069   Value x() const                                { return _x; }
1070 
1071   // generic
1072   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }

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

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

1363 BASE(NewArray, StateSplit)
1364  private:
1365   Value       _length;
1366 
1367  public:
1368   // creation
1369   NewArray(Value length, ValueStack* state_before)
1370   : StateSplit(objectType, state_before)
1371   , _length(length)
1372   {
1373     // Do not ASSERT_VALUES since length is null for NewMultiArray
1374   }
1375 
1376   // accessors
1377   Value length() const                           { return _length; }
1378 
1379   virtual bool needs_exception_state() const     { return false; }
1380 
1381   ciType* exact_type() const                     { return nullptr; }
1382   ciType* declared_type() const;

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

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

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

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

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