< prev index next >

src/hotspot/share/c1/c1_Instruction.hpp

Print this page




  55 class   AccessArray;
  56 class     ArrayLength;
  57 class     AccessIndexed;
  58 class       LoadIndexed;
  59 class       StoreIndexed;
  60 class   NegateOp;
  61 class   Op2;
  62 class     ArithmeticOp;
  63 class     ShiftOp;
  64 class     LogicOp;
  65 class     CompareOp;
  66 class     IfOp;
  67 class   Convert;
  68 class   NullCheck;
  69 class   TypeCast;
  70 class   OsrEntry;
  71 class   ExceptionObject;
  72 class   StateSplit;
  73 class     Invoke;
  74 class     NewInstance;

  75 class     NewArray;
  76 class       NewTypeArray;
  77 class       NewObjectArray;
  78 class       NewMultiArray;
  79 class     TypeCheck;
  80 class       CheckCast;
  81 class       InstanceOf;
  82 class     AccessMonitor;
  83 class       MonitorEnter;
  84 class       MonitorExit;
  85 class     Intrinsic;
  86 class     BlockBegin;
  87 class     BlockEnd;
  88 class       Goto;
  89 class       If;
  90 class       IfInstanceOf;
  91 class       Switch;
  92 class         TableSwitch;
  93 class         LookupSwitch;
  94 class       Return;


 160  public:
 161   virtual void do_Phi            (Phi*             x) = 0;
 162   virtual void do_Local          (Local*           x) = 0;
 163   virtual void do_Constant       (Constant*        x) = 0;
 164   virtual void do_LoadField      (LoadField*       x) = 0;
 165   virtual void do_StoreField     (StoreField*      x) = 0;
 166   virtual void do_ArrayLength    (ArrayLength*     x) = 0;
 167   virtual void do_LoadIndexed    (LoadIndexed*     x) = 0;
 168   virtual void do_StoreIndexed   (StoreIndexed*    x) = 0;
 169   virtual void do_NegateOp       (NegateOp*        x) = 0;
 170   virtual void do_ArithmeticOp   (ArithmeticOp*    x) = 0;
 171   virtual void do_ShiftOp        (ShiftOp*         x) = 0;
 172   virtual void do_LogicOp        (LogicOp*         x) = 0;
 173   virtual void do_CompareOp      (CompareOp*       x) = 0;
 174   virtual void do_IfOp           (IfOp*            x) = 0;
 175   virtual void do_Convert        (Convert*         x) = 0;
 176   virtual void do_NullCheck      (NullCheck*       x) = 0;
 177   virtual void do_TypeCast       (TypeCast*        x) = 0;
 178   virtual void do_Invoke         (Invoke*          x) = 0;
 179   virtual void do_NewInstance    (NewInstance*     x) = 0;

 180   virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
 181   virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
 182   virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
 183   virtual void do_CheckCast      (CheckCast*       x) = 0;
 184   virtual void do_InstanceOf     (InstanceOf*      x) = 0;
 185   virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
 186   virtual void do_MonitorExit    (MonitorExit*     x) = 0;
 187   virtual void do_Intrinsic      (Intrinsic*       x) = 0;
 188   virtual void do_BlockBegin     (BlockBegin*      x) = 0;
 189   virtual void do_Goto           (Goto*            x) = 0;
 190   virtual void do_If             (If*              x) = 0;
 191   virtual void do_IfInstanceOf   (IfInstanceOf*    x) = 0;
 192   virtual void do_TableSwitch    (TableSwitch*     x) = 0;
 193   virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
 194   virtual void do_Return         (Return*          x) = 0;
 195   virtual void do_Throw          (Throw*           x) = 0;
 196   virtual void do_Base           (Base*            x) = 0;
 197   virtual void do_OsrEntry       (OsrEntry*        x) = 0;
 198   virtual void do_ExceptionObject(ExceptionObject* x) = 0;
 199   virtual void do_RoundFP        (RoundFP*         x) = 0;


 340           _nonnull_state |= nth_bit(i);
 341         } else {
 342           _nonnull_state &= ~(nth_bit(i));
 343         }
 344       }
 345     }
 346   };
 347 
 348  public:
 349   void* operator new(size_t size) throw() {
 350     Compilation* c = Compilation::current();
 351     void* res = c->arena()->Amalloc(size);
 352     ((Instruction*)res)->_id = c->get_next_id();
 353     return res;
 354   }
 355 
 356   static const int no_bci = -99;
 357 
 358   enum InstructionFlag {
 359     NeedsNullCheckFlag = 0,

 360     CanTrapFlag,
 361     DirectCompareFlag,
 362     IsEliminatedFlag,
 363     IsSafepointFlag,
 364     IsStaticFlag,
 365     IsStrictfpFlag,
 366     NeedsStoreCheckFlag,
 367     NeedsWriteBarrierFlag,
 368     PreservesStateFlag,
 369     TargetIsFinalFlag,
 370     TargetIsLoadedFlag,
 371     TargetIsStrictfpFlag,
 372     UnorderedIsTrueFlag,
 373     NeedsPatchingFlag,
 374     ThrowIncompatibleClassChangeErrorFlag,
 375     InvokeSpecialReceiverCheckFlag,
 376     ProfileMDOFlag,
 377     IsLinkedInBlockFlag,
 378     NeedsRangeCheckFlag,
 379     InWorkListFlag,


 434   int id() const                                 { return _id; }
 435 #ifndef PRODUCT
 436   bool has_printable_bci() const                 { return _printable_bci != -99; }
 437   int printable_bci() const                      { assert(has_printable_bci(), "_printable_bci should have been set"); return _printable_bci; }
 438   void set_printable_bci(int bci)                { _printable_bci = bci; }
 439 #endif
 440   int dominator_depth();
 441   int use_count() const                          { return _use_count; }
 442   int pin_state() const                          { return _pin_state; }
 443   bool is_pinned() const                         { return _pin_state != 0 || PinAllInstructions; }
 444   ValueType* type() const                        { return _type; }
 445   BlockBegin *block() const                      { return _block; }
 446   Instruction* prev();                           // use carefully, expensive operation
 447   Instruction* next() const                      { return _next; }
 448   bool has_subst() const                         { return _subst != NULL; }
 449   Instruction* subst()                           { return _subst == NULL ? this : _subst->subst(); }
 450   LIR_Opr operand() const                        { return _operand; }
 451 
 452   void set_needs_null_check(bool f)              { set_flag(NeedsNullCheckFlag, f); }
 453   bool needs_null_check() const                  { return check_flag(NeedsNullCheckFlag); }


 454   bool is_linked() const                         { return check_flag(IsLinkedInBlockFlag); }
 455   bool can_be_linked()                           { return as_Local() == NULL && as_Phi() == NULL; }
 456 
 457   bool has_uses() const                          { return use_count() > 0; }
 458   ValueStack* state_before() const               { return _state_before; }
 459   ValueStack* exception_state() const            { return _exception_state; }
 460   virtual bool needs_exception_state() const     { return true; }
 461   XHandlers* exception_handlers() const          { return _exception_handlers; }
 462 
 463   // manipulation
 464   void pin(PinReason reason)                     { _pin_state |= reason; }
 465   void pin()                                     { _pin_state |= PinUnknown; }
 466   // DANGEROUS: only used by EliminateStores
 467   void unpin(PinReason reason)                   { assert((reason & PinUnknown) == 0, "can't unpin unknown state"); _pin_state &= ~reason; }
 468 
 469   Instruction* set_next(Instruction* next) {
 470     assert(next->has_printable_bci(), "_printable_bci should have been set");
 471     assert(next != NULL, "must not be NULL");
 472     assert(as_BlockEnd() == NULL, "BlockEnd instructions must have no next");
 473     assert(next->can_be_linked(), "shouldn't link these instructions into list");


 486 #endif
 487     return set_next(next);
 488   }
 489 
 490   // when blocks are merged
 491   void fixup_block_pointers() {
 492     Instruction *cur = next()->next(); // next()'s block is set in set_next
 493     while (cur && cur->_block != block()) {
 494       cur->_block = block();
 495       cur = cur->next();
 496     }
 497   }
 498 
 499   Instruction *insert_after(Instruction *i) {
 500     Instruction* n = _next;
 501     set_next(i);
 502     i->set_next(n);
 503     return _next;
 504   }
 505 





 506   Instruction *insert_after_same_bci(Instruction *i) {
 507 #ifndef PRODUCT
 508     i->set_printable_bci(printable_bci());
 509 #endif
 510     return insert_after(i);
 511   }
 512 
 513   void set_subst(Instruction* subst)             {
 514     assert(subst == NULL ||
 515            type()->base() == subst->type()->base() ||
 516            subst->type()->base() == illegalType, "type can't change");
 517     _subst = subst;
 518   }
 519   void set_exception_handlers(XHandlers *xhandlers) { _exception_handlers = xhandlers; }
 520   void set_exception_state(ValueStack* s)        { check_state(s); _exception_state = s; }
 521   void set_state_before(ValueStack* s)           { check_state(s); _state_before = s; }
 522 
 523   // machine-specifics
 524   void set_operand(LIR_Opr operand)              { assert(operand != LIR_OprFact::illegalOpr, "operand must exist"); _operand = operand; }
 525   void clear_operand()                           { _operand = LIR_OprFact::illegalOpr; }


 533   virtual LoadField*        as_LoadField()       { return NULL; }
 534   virtual StoreField*       as_StoreField()      { return NULL; }
 535   virtual AccessArray*      as_AccessArray()     { return NULL; }
 536   virtual ArrayLength*      as_ArrayLength()     { return NULL; }
 537   virtual AccessIndexed*    as_AccessIndexed()   { return NULL; }
 538   virtual LoadIndexed*      as_LoadIndexed()     { return NULL; }
 539   virtual StoreIndexed*     as_StoreIndexed()    { return NULL; }
 540   virtual NegateOp*         as_NegateOp()        { return NULL; }
 541   virtual Op2*              as_Op2()             { return NULL; }
 542   virtual ArithmeticOp*     as_ArithmeticOp()    { return NULL; }
 543   virtual ShiftOp*          as_ShiftOp()         { return NULL; }
 544   virtual LogicOp*          as_LogicOp()         { return NULL; }
 545   virtual CompareOp*        as_CompareOp()       { return NULL; }
 546   virtual IfOp*             as_IfOp()            { return NULL; }
 547   virtual Convert*          as_Convert()         { return NULL; }
 548   virtual NullCheck*        as_NullCheck()       { return NULL; }
 549   virtual OsrEntry*         as_OsrEntry()        { return NULL; }
 550   virtual StateSplit*       as_StateSplit()      { return NULL; }
 551   virtual Invoke*           as_Invoke()          { return NULL; }
 552   virtual NewInstance*      as_NewInstance()     { return NULL; }

 553   virtual NewArray*         as_NewArray()        { return NULL; }
 554   virtual NewTypeArray*     as_NewTypeArray()    { return NULL; }
 555   virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
 556   virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
 557   virtual TypeCheck*        as_TypeCheck()       { return NULL; }
 558   virtual CheckCast*        as_CheckCast()       { return NULL; }
 559   virtual InstanceOf*       as_InstanceOf()      { return NULL; }
 560   virtual TypeCast*         as_TypeCast()        { return NULL; }
 561   virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
 562   virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
 563   virtual MonitorExit*      as_MonitorExit()     { return NULL; }
 564   virtual Intrinsic*        as_Intrinsic()       { return NULL; }
 565   virtual BlockBegin*       as_BlockBegin()      { return NULL; }
 566   virtual BlockEnd*         as_BlockEnd()        { return NULL; }
 567   virtual Goto*             as_Goto()            { return NULL; }
 568   virtual If*               as_If()              { return NULL; }
 569   virtual IfInstanceOf*     as_IfInstanceOf()    { return NULL; }
 570   virtual TableSwitch*      as_TableSwitch()     { return NULL; }
 571   virtual LookupSwitch*     as_LookupSwitch()    { return NULL; }
 572   virtual Return*           as_Return()          { return NULL; }


 627 
 628 
 629 #ifdef ASSERT
 630 class AssertValues: public ValueVisitor {
 631   void visit(Value* x)             { assert((*x) != NULL, "value must exist"); }
 632 };
 633   #define ASSERT_VALUES                          { AssertValues assert_value; values_do(&assert_value); }
 634 #else
 635   #define ASSERT_VALUES
 636 #endif // ASSERT
 637 
 638 
 639 // A Phi is a phi function in the sense of SSA form. It stands for
 640 // the value of a local variable at the beginning of a join block.
 641 // A Phi consists of n operands, one for every incoming branch.
 642 
 643 LEAF(Phi, Instruction)
 644  private:
 645   int         _pf_flags; // the flags of the phi function
 646   int         _index;    // to value on operand stack (index < 0) or to local

 647  public:
 648   // creation
 649   Phi(ValueType* type, BlockBegin* b, int index)
 650   : Instruction(type->base())
 651   , _pf_flags(0)
 652   , _index(index)

 653   {
 654     _block = b;
 655     NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci()));
 656     if (type->is_illegal()) {
 657       make_illegal();
 658     }
 659   }
 660 








 661   // flags
 662   enum Flag {
 663     no_flag         = 0,
 664     visited         = 1 << 0,
 665     cannot_simplify = 1 << 1
 666   };
 667 
 668   // accessors
 669   bool  is_local() const          { return _index >= 0; }
 670   bool  is_on_stack() const       { return !is_local(); }
 671   int   local_index() const       { assert(is_local(), ""); return _index; }
 672   int   stack_index() const       { assert(is_on_stack(), ""); return -(_index+1); }
 673 
 674   Value operand_at(int i) const;
 675   int   operand_count() const;
 676 
 677   void   set(Flag f)              { _pf_flags |=  f; }
 678   void   clear(Flag f)            { _pf_flags &= ~f; }
 679   bool   is_set(Flag f) const     { return (_pf_flags & f) != 0; }
 680 


 686   }
 687 
 688   bool is_illegal() const {
 689     return type()->is_illegal();
 690   }
 691 
 692   // generic
 693   virtual void input_values_do(ValueVisitor* f) {
 694   }
 695 };
 696 
 697 
 698 // A local is a placeholder for an incoming argument to a function call.
 699 LEAF(Local, Instruction)
 700  private:
 701   int      _java_index;                          // the local index within the method to which the local belongs
 702   bool     _is_receiver;                         // if local variable holds the receiver: "this" for non-static methods
 703   ciType*  _declared_type;
 704  public:
 705   // creation
 706   Local(ciType* declared, ValueType* type, int index, bool receiver)
 707     : Instruction(type)
 708     , _java_index(index)
 709     , _is_receiver(receiver)
 710     , _declared_type(declared)
 711   {

 712     NOT_PRODUCT(set_printable_bci(-1));
 713   }
 714 
 715   // accessors
 716   int java_index() const                         { return _java_index; }
 717   bool is_receiver() const                       { return _is_receiver; }
 718 
 719   virtual ciType* declared_type() const          { return _declared_type; }
 720 
 721   // generic
 722   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
 723 };
 724 
 725 
 726 LEAF(Constant, Instruction)
 727  public:
 728   // creation
 729   Constant(ValueType* type):
 730       Instruction(type, NULL, /*type_is_constant*/ true)
 731   {


 808   // Technically it occurs at the Constant that materializes the base
 809   // of the static fields but it's simpler to model it here.
 810   bool is_init_point() const                     { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); }
 811 
 812   // manipulation
 813 
 814   // Under certain circumstances, if a previous NullCheck instruction
 815   // proved the target object non-null, we can eliminate the explicit
 816   // null check and do an implicit one, simply specifying the debug
 817   // information from the NullCheck. This field should only be consulted
 818   // if needs_null_check() is true.
 819   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 820 
 821   // generic
 822   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 823   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 824 };
 825 
 826 
 827 LEAF(LoadField, AccessField)


 828  public:
 829   // creation
 830   LoadField(Value obj, int offset, ciField* field, bool is_static,
 831             ValueStack* state_before, bool needs_patching)

 832   : AccessField(obj, offset, field, is_static, state_before, needs_patching)

 833   {}
 834 
 835   ciType* declared_type() const;
 836 
 837   // generic
 838   HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if needs patching or if volatile



 839 };
 840 
 841 
 842 LEAF(StoreField, AccessField)
 843  private:
 844   Value _value;
 845 
 846  public:
 847   // creation
 848   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 849              ValueStack* state_before, bool needs_patching)
 850   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 851   , _value(value)
 852   {
 853     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 854     ASSERT_VALUES
 855     pin();
 856   }
 857 
 858   // accessors


 930   }
 931 
 932   // accessors
 933   Value index() const                            { return _index; }
 934   Value length() const                           { return _length; }
 935   BasicType elt_type() const                     { return _elt_type; }
 936   bool mismatched() const                        { return _mismatched; }
 937 
 938   void clear_length()                            { _length = NULL; }
 939   // perform elimination of range checks involving constants
 940   bool compute_needs_range_check();
 941 
 942   // generic
 943   virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); }
 944 };
 945 
 946 
 947 LEAF(LoadIndexed, AccessIndexed)
 948  private:
 949   NullCheck*  _explicit_null_check;              // For explicit null check elimination

 950 
 951  public:
 952   // creation
 953   LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
 954   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 955   , _explicit_null_check(NULL) {}
 956 
 957   // accessors
 958   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 959 
 960   // setters
 961   // See LoadField::set_explicit_null_check for documentation
 962   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 963 
 964   ciType* exact_type() const;
 965   ciType* declared_type() const;
 966 



 967   // generic
 968   HASHING2(LoadIndexed, true, array()->subst(), index()->subst())
 969 };
 970 
 971 
 972 LEAF(StoreIndexed, AccessIndexed)
 973  private:
 974   Value       _value;
 975 
 976   ciMethod* _profiled_method;
 977   int       _profiled_bci;
 978   bool      _check_boolean;
 979 
 980  public:
 981   // creation
 982   StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
 983                bool check_boolean, bool mismatched = false)
 984   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 985   , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean)
 986   {
 987     set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
 988     set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
 989     ASSERT_VALUES
 990     pin();
 991   }
 992 
 993   // accessors
 994   Value value() const                            { return _value; }
 995   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
 996   bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
 997   bool check_boolean() const                     { return _check_boolean; }
 998   // Helpers for MethodData* profiling
 999   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1000   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1001   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1002   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1003   ciMethod* profiled_method() const                  { return _profiled_method;     }
1004   int       profiled_bci() const                     { return _profiled_bci;        }


1005   // generic
1006   virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
1007 };
1008 
1009 
1010 LEAF(NegateOp, Instruction)
1011  private:
1012   Value _x;
1013 
1014  public:
1015   // creation
1016   NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1017     ASSERT_VALUES
1018   }
1019 
1020   // accessors
1021   Value x() const                                { return _x; }
1022 
1023   // generic
1024   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }


1237   void set_state(ValueStack* state)              { assert(_state == NULL, "overwriting existing state"); check_state(state); _state = state; }
1238 
1239   // generic
1240   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
1241   virtual void state_values_do(ValueVisitor* f);
1242 };
1243 
1244 
1245 LEAF(Invoke, StateSplit)
1246  private:
1247   Bytecodes::Code _code;
1248   Value           _recv;
1249   Values*         _args;
1250   BasicTypeList*  _signature;
1251   int             _vtable_index;
1252   ciMethod*       _target;
1253 
1254  public:
1255   // creation
1256   Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
1257          int vtable_index, ciMethod* target, ValueStack* state_before);
1258 
1259   // accessors
1260   Bytecodes::Code code() const                   { return _code; }
1261   Value receiver() const                         { return _recv; }
1262   bool has_receiver() const                      { return receiver() != NULL; }
1263   int number_of_arguments() const                { return _args->length(); }
1264   Value argument_at(int i) const                 { return _args->at(i); }
1265   int vtable_index() const                       { return _vtable_index; }
1266   BasicTypeList* signature() const               { return _signature; }
1267   ciMethod* target() const                       { return _target; }
1268 
1269   ciType* declared_type() const;
1270 
1271   // Returns false if target is not loaded
1272   bool target_is_final() const                   { return check_flag(TargetIsFinalFlag); }
1273   bool target_is_loaded() const                  { return check_flag(TargetIsLoadedFlag); }
1274   // Returns false if target is not loaded
1275   bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
1276 
1277   // JSR 292 support


1298 
1299  public:
1300   // creation
1301   NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1302   : StateSplit(instanceType, state_before)
1303   , _klass(klass), _is_unresolved(is_unresolved)
1304   {}
1305 
1306   // accessors
1307   ciInstanceKlass* klass() const                 { return _klass; }
1308   bool is_unresolved() const                     { return _is_unresolved; }
1309 
1310   virtual bool needs_exception_state() const     { return false; }
1311 
1312   // generic
1313   virtual bool can_trap() const                  { return true; }
1314   ciType* exact_type() const;
1315   ciType* declared_type() const;
1316 };
1317 





































1318 
1319 BASE(NewArray, StateSplit)
1320  private:
1321   Value       _length;
1322 
1323  public:
1324   // creation
1325   NewArray(Value length, ValueStack* state_before)
1326   : StateSplit(objectType, state_before)
1327   , _length(length)
1328   {
1329     // Do not ASSERT_VALUES since length is NULL for NewMultiArray
1330   }
1331 
1332   // accessors
1333   Value length() const                           { return _length; }
1334 
1335   virtual bool needs_exception_state() const     { return false; }
1336 
1337   ciType* exact_type() const                     { return NULL; }


1384   NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) {
1385     ASSERT_VALUES
1386   }
1387 
1388   // accessors
1389   ciKlass* klass() const                         { return _klass; }
1390   Values* dims() const                           { return _dims; }
1391   int rank() const                               { return dims()->length(); }
1392 
1393   // generic
1394   virtual void input_values_do(ValueVisitor* f) {
1395     // NOTE: we do not call NewArray::input_values_do since "length"
1396     // is meaningless for a multi-dimensional array; passing the
1397     // zeroth element down to NewArray as its length is a bad idea
1398     // since there will be a copy in the "dims" array which doesn't
1399     // get updated, and the value must not be traversed twice. Was bug
1400     // - kbr 4/10/2001
1401     StateSplit::input_values_do(f);
1402     for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1403   }


1404 };
1405 
1406 
1407 BASE(TypeCheck, StateSplit)
1408  private:
1409   ciKlass*    _klass;
1410   Value       _obj;
1411 
1412   ciMethod* _profiled_method;
1413   int       _profiled_bci;
1414 
1415  public:
1416   // creation
1417   TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1418   : StateSplit(type, state_before), _klass(klass), _obj(obj),
1419     _profiled_method(NULL), _profiled_bci(0) {
1420     ASSERT_VALUES
1421     set_direct_compare(false);
1422   }
1423 


1430   // manipulation
1431   void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
1432 
1433   // generic
1434   virtual bool can_trap() const                  { return true; }
1435   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1436 
1437   // Helpers for MethodData* profiling
1438   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1439   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1440   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1441   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1442   ciMethod* profiled_method() const                  { return _profiled_method;     }
1443   int       profiled_bci() const                     { return _profiled_bci;        }
1444 };
1445 
1446 
1447 LEAF(CheckCast, TypeCheck)
1448  public:
1449   // creation
1450   CheckCast(ciKlass* klass, Value obj, ValueStack* state_before)
1451   : TypeCheck(klass, obj, objectType, state_before) {}


1452 
1453   void set_incompatible_class_change_check() {
1454     set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1455   }
1456   bool is_incompatible_class_change_check() const {
1457     return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1458   }
1459   void set_invokespecial_receiver_check() {
1460     set_flag(InvokeSpecialReceiverCheckFlag, true);
1461   }
1462   bool is_invokespecial_receiver_check() const {
1463     return check_flag(InvokeSpecialReceiverCheckFlag);
1464   }
1465 
1466   virtual bool needs_exception_state() const {
1467     return !is_invokespecial_receiver_check();
1468   }
1469 
1470   ciType* declared_type() const;
1471 };


1489   // creation
1490   AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = NULL)
1491   : StateSplit(illegalType, state_before)
1492   , _obj(obj)
1493   , _monitor_no(monitor_no)
1494   {
1495     set_needs_null_check(true);
1496     ASSERT_VALUES
1497   }
1498 
1499   // accessors
1500   Value obj() const                              { return _obj; }
1501   int monitor_no() const                         { return _monitor_no; }
1502 
1503   // generic
1504   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1505 };
1506 
1507 
1508 LEAF(MonitorEnter, AccessMonitor)

1509  public:
1510   // creation
1511   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before)
1512   : AccessMonitor(obj, monitor_no, state_before)

1513   {
1514     ASSERT_VALUES
1515   }



1516 
1517   // generic
1518   virtual bool can_trap() const                  { return true; }
1519 };
1520 
1521 
1522 LEAF(MonitorExit, AccessMonitor)
1523  public:
1524   // creation
1525   MonitorExit(Value obj, int monitor_no)
1526   : AccessMonitor(obj, monitor_no, NULL)
1527   {
1528     ASSERT_VALUES
1529   }
1530 };
1531 
1532 
1533 LEAF(Intrinsic, StateSplit)
1534  private:
1535   vmIntrinsics::ID _id;




  55 class   AccessArray;
  56 class     ArrayLength;
  57 class     AccessIndexed;
  58 class       LoadIndexed;
  59 class       StoreIndexed;
  60 class   NegateOp;
  61 class   Op2;
  62 class     ArithmeticOp;
  63 class     ShiftOp;
  64 class     LogicOp;
  65 class     CompareOp;
  66 class     IfOp;
  67 class   Convert;
  68 class   NullCheck;
  69 class   TypeCast;
  70 class   OsrEntry;
  71 class   ExceptionObject;
  72 class   StateSplit;
  73 class     Invoke;
  74 class     NewInstance;
  75 class     NewValueTypeInstance;
  76 class     NewArray;
  77 class       NewTypeArray;
  78 class       NewObjectArray;
  79 class       NewMultiArray;
  80 class     TypeCheck;
  81 class       CheckCast;
  82 class       InstanceOf;
  83 class     AccessMonitor;
  84 class       MonitorEnter;
  85 class       MonitorExit;
  86 class     Intrinsic;
  87 class     BlockBegin;
  88 class     BlockEnd;
  89 class       Goto;
  90 class       If;
  91 class       IfInstanceOf;
  92 class       Switch;
  93 class         TableSwitch;
  94 class         LookupSwitch;
  95 class       Return;


 161  public:
 162   virtual void do_Phi            (Phi*             x) = 0;
 163   virtual void do_Local          (Local*           x) = 0;
 164   virtual void do_Constant       (Constant*        x) = 0;
 165   virtual void do_LoadField      (LoadField*       x) = 0;
 166   virtual void do_StoreField     (StoreField*      x) = 0;
 167   virtual void do_ArrayLength    (ArrayLength*     x) = 0;
 168   virtual void do_LoadIndexed    (LoadIndexed*     x) = 0;
 169   virtual void do_StoreIndexed   (StoreIndexed*    x) = 0;
 170   virtual void do_NegateOp       (NegateOp*        x) = 0;
 171   virtual void do_ArithmeticOp   (ArithmeticOp*    x) = 0;
 172   virtual void do_ShiftOp        (ShiftOp*         x) = 0;
 173   virtual void do_LogicOp        (LogicOp*         x) = 0;
 174   virtual void do_CompareOp      (CompareOp*       x) = 0;
 175   virtual void do_IfOp           (IfOp*            x) = 0;
 176   virtual void do_Convert        (Convert*         x) = 0;
 177   virtual void do_NullCheck      (NullCheck*       x) = 0;
 178   virtual void do_TypeCast       (TypeCast*        x) = 0;
 179   virtual void do_Invoke         (Invoke*          x) = 0;
 180   virtual void do_NewInstance    (NewInstance*     x) = 0;
 181   virtual void do_NewValueTypeInstance(NewValueTypeInstance* x) = 0;
 182   virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
 183   virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
 184   virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
 185   virtual void do_CheckCast      (CheckCast*       x) = 0;
 186   virtual void do_InstanceOf     (InstanceOf*      x) = 0;
 187   virtual void do_MonitorEnter   (MonitorEnter*    x) = 0;
 188   virtual void do_MonitorExit    (MonitorExit*     x) = 0;
 189   virtual void do_Intrinsic      (Intrinsic*       x) = 0;
 190   virtual void do_BlockBegin     (BlockBegin*      x) = 0;
 191   virtual void do_Goto           (Goto*            x) = 0;
 192   virtual void do_If             (If*              x) = 0;
 193   virtual void do_IfInstanceOf   (IfInstanceOf*    x) = 0;
 194   virtual void do_TableSwitch    (TableSwitch*     x) = 0;
 195   virtual void do_LookupSwitch   (LookupSwitch*    x) = 0;
 196   virtual void do_Return         (Return*          x) = 0;
 197   virtual void do_Throw          (Throw*           x) = 0;
 198   virtual void do_Base           (Base*            x) = 0;
 199   virtual void do_OsrEntry       (OsrEntry*        x) = 0;
 200   virtual void do_ExceptionObject(ExceptionObject* x) = 0;
 201   virtual void do_RoundFP        (RoundFP*         x) = 0;


 342           _nonnull_state |= nth_bit(i);
 343         } else {
 344           _nonnull_state &= ~(nth_bit(i));
 345         }
 346       }
 347     }
 348   };
 349 
 350  public:
 351   void* operator new(size_t size) throw() {
 352     Compilation* c = Compilation::current();
 353     void* res = c->arena()->Amalloc(size);
 354     ((Instruction*)res)->_id = c->get_next_id();
 355     return res;
 356   }
 357 
 358   static const int no_bci = -99;
 359 
 360   enum InstructionFlag {
 361     NeedsNullCheckFlag = 0,
 362     NeverNullFlag,          // For "Q" signatures
 363     CanTrapFlag,
 364     DirectCompareFlag,
 365     IsEliminatedFlag,
 366     IsSafepointFlag,
 367     IsStaticFlag,
 368     IsStrictfpFlag,
 369     NeedsStoreCheckFlag,
 370     NeedsWriteBarrierFlag,
 371     PreservesStateFlag,
 372     TargetIsFinalFlag,
 373     TargetIsLoadedFlag,
 374     TargetIsStrictfpFlag,
 375     UnorderedIsTrueFlag,
 376     NeedsPatchingFlag,
 377     ThrowIncompatibleClassChangeErrorFlag,
 378     InvokeSpecialReceiverCheckFlag,
 379     ProfileMDOFlag,
 380     IsLinkedInBlockFlag,
 381     NeedsRangeCheckFlag,
 382     InWorkListFlag,


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


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


 543   virtual LoadField*        as_LoadField()       { return NULL; }
 544   virtual StoreField*       as_StoreField()      { return NULL; }
 545   virtual AccessArray*      as_AccessArray()     { return NULL; }
 546   virtual ArrayLength*      as_ArrayLength()     { return NULL; }
 547   virtual AccessIndexed*    as_AccessIndexed()   { return NULL; }
 548   virtual LoadIndexed*      as_LoadIndexed()     { return NULL; }
 549   virtual StoreIndexed*     as_StoreIndexed()    { return NULL; }
 550   virtual NegateOp*         as_NegateOp()        { return NULL; }
 551   virtual Op2*              as_Op2()             { return NULL; }
 552   virtual ArithmeticOp*     as_ArithmeticOp()    { return NULL; }
 553   virtual ShiftOp*          as_ShiftOp()         { return NULL; }
 554   virtual LogicOp*          as_LogicOp()         { return NULL; }
 555   virtual CompareOp*        as_CompareOp()       { return NULL; }
 556   virtual IfOp*             as_IfOp()            { return NULL; }
 557   virtual Convert*          as_Convert()         { return NULL; }
 558   virtual NullCheck*        as_NullCheck()       { return NULL; }
 559   virtual OsrEntry*         as_OsrEntry()        { return NULL; }
 560   virtual StateSplit*       as_StateSplit()      { return NULL; }
 561   virtual Invoke*           as_Invoke()          { return NULL; }
 562   virtual NewInstance*      as_NewInstance()     { return NULL; }
 563   virtual NewValueTypeInstance* as_NewValueTypeInstance() { return NULL; }
 564   virtual NewArray*         as_NewArray()        { return NULL; }
 565   virtual NewTypeArray*     as_NewTypeArray()    { return NULL; }
 566   virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
 567   virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
 568   virtual TypeCheck*        as_TypeCheck()       { return NULL; }
 569   virtual CheckCast*        as_CheckCast()       { return NULL; }
 570   virtual InstanceOf*       as_InstanceOf()      { return NULL; }
 571   virtual TypeCast*         as_TypeCast()        { return NULL; }
 572   virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
 573   virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
 574   virtual MonitorExit*      as_MonitorExit()     { return NULL; }
 575   virtual Intrinsic*        as_Intrinsic()       { return NULL; }
 576   virtual BlockBegin*       as_BlockBegin()      { return NULL; }
 577   virtual BlockEnd*         as_BlockEnd()        { return NULL; }
 578   virtual Goto*             as_Goto()            { return NULL; }
 579   virtual If*               as_If()              { return NULL; }
 580   virtual IfInstanceOf*     as_IfInstanceOf()    { return NULL; }
 581   virtual TableSwitch*      as_TableSwitch()     { return NULL; }
 582   virtual LookupSwitch*     as_LookupSwitch()    { return NULL; }
 583   virtual Return*           as_Return()          { return NULL; }


 638 
 639 
 640 #ifdef ASSERT
 641 class AssertValues: public ValueVisitor {
 642   void visit(Value* x)             { assert((*x) != NULL, "value must exist"); }
 643 };
 644   #define ASSERT_VALUES                          { AssertValues assert_value; values_do(&assert_value); }
 645 #else
 646   #define ASSERT_VALUES
 647 #endif // ASSERT
 648 
 649 
 650 // A Phi is a phi function in the sense of SSA form. It stands for
 651 // the value of a local variable at the beginning of a join block.
 652 // A Phi consists of n operands, one for every incoming branch.
 653 
 654 LEAF(Phi, Instruction)
 655  private:
 656   int         _pf_flags; // the flags of the phi function
 657   int         _index;    // to value on operand stack (index < 0) or to local
 658   ciType*     _exact_type; // currently is set only for flattened arrays, NULL otherwise.
 659  public:
 660   // creation
 661   Phi(ValueType* type, BlockBegin* b, int index, ciType* exact_type)
 662   : Instruction(type->base())
 663   , _pf_flags(0)
 664   , _index(index)
 665   , _exact_type(exact_type)
 666   {
 667     _block = b;
 668     NOT_PRODUCT(set_printable_bci(Value(b)->printable_bci()));
 669     if (type->is_illegal()) {
 670       make_illegal();
 671     }
 672   }
 673 
 674   virtual ciType* exact_type() const {
 675     return _exact_type;
 676   }
 677 
 678   virtual ciType* declared_type() const {
 679     return _exact_type;
 680   }
 681 
 682   // flags
 683   enum Flag {
 684     no_flag         = 0,
 685     visited         = 1 << 0,
 686     cannot_simplify = 1 << 1
 687   };
 688 
 689   // accessors
 690   bool  is_local() const          { return _index >= 0; }
 691   bool  is_on_stack() const       { return !is_local(); }
 692   int   local_index() const       { assert(is_local(), ""); return _index; }
 693   int   stack_index() const       { assert(is_on_stack(), ""); return -(_index+1); }
 694 
 695   Value operand_at(int i) const;
 696   int   operand_count() const;
 697 
 698   void   set(Flag f)              { _pf_flags |=  f; }
 699   void   clear(Flag f)            { _pf_flags &= ~f; }
 700   bool   is_set(Flag f) const     { return (_pf_flags & f) != 0; }
 701 


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


 830   // Technically it occurs at the Constant that materializes the base
 831   // of the static fields but it's simpler to model it here.
 832   bool is_init_point() const                     { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); }
 833 
 834   // manipulation
 835 
 836   // Under certain circumstances, if a previous NullCheck instruction
 837   // proved the target object non-null, we can eliminate the explicit
 838   // null check and do an implicit one, simply specifying the debug
 839   // information from the NullCheck. This field should only be consulted
 840   // if needs_null_check() is true.
 841   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 842 
 843   // generic
 844   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 845   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 846 };
 847 
 848 
 849 LEAF(LoadField, AccessField)
 850   ciValueKlass* _value_klass;
 851   Value _default_value;
 852  public:
 853   // creation
 854   LoadField(Value obj, int offset, ciField* field, bool is_static,
 855             ValueStack* state_before, bool needs_patching,
 856             ciValueKlass* value_klass = NULL, Value default_value = NULL )
 857   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 858   , _value_klass(value_klass), _default_value(default_value)
 859   {}
 860 
 861   ciType* declared_type() const;
 862 
 863   // generic
 864   HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if needs patching or if volatile
 865 
 866   ciValueKlass* value_klass() const { return _value_klass;}
 867   Value default_value() const { return _default_value; }
 868 };
 869 
 870 
 871 LEAF(StoreField, AccessField)
 872  private:
 873   Value _value;
 874 
 875  public:
 876   // creation
 877   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 878              ValueStack* state_before, bool needs_patching)
 879   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 880   , _value(value)
 881   {
 882     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 883     ASSERT_VALUES
 884     pin();
 885   }
 886 
 887   // accessors


 959   }
 960 
 961   // accessors
 962   Value index() const                            { return _index; }
 963   Value length() const                           { return _length; }
 964   BasicType elt_type() const                     { return _elt_type; }
 965   bool mismatched() const                        { return _mismatched; }
 966 
 967   void clear_length()                            { _length = NULL; }
 968   // perform elimination of range checks involving constants
 969   bool compute_needs_range_check();
 970 
 971   // generic
 972   virtual void input_values_do(ValueVisitor* f)   { AccessArray::input_values_do(f); f->visit(&_index); if (_length != NULL) f->visit(&_length); }
 973 };
 974 
 975 
 976 LEAF(LoadIndexed, AccessIndexed)
 977  private:
 978   NullCheck*  _explicit_null_check;              // For explicit null check elimination
 979   NewValueTypeInstance* _vt;
 980 
 981  public:
 982   // creation
 983   LoadIndexed(Value array, Value index, Value length, BasicType elt_type, ValueStack* state_before, bool mismatched = false)
 984   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
 985   , _explicit_null_check(NULL) {}
 986 
 987   // accessors
 988   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 989 
 990   // setters
 991   // See LoadField::set_explicit_null_check for documentation
 992   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 993 
 994   ciType* exact_type() const;
 995   ciType* declared_type() const;
 996 
 997   NewValueTypeInstance* vt() { return _vt; }
 998   void set_vt(NewValueTypeInstance* vt) { _vt = vt; }
 999 
1000   // generic
1001   HASHING2(LoadIndexed, true, array()->subst(), index()->subst())
1002 };
1003 
1004 
1005 LEAF(StoreIndexed, AccessIndexed)
1006  private:
1007   Value       _value;
1008 
1009   ciMethod* _profiled_method;
1010   int       _profiled_bci;
1011   bool      _check_boolean;
1012 
1013  public:
1014   // creation
1015   StoreIndexed(Value array, Value index, Value length, BasicType elt_type, Value value, ValueStack* state_before,
1016                bool check_boolean, bool mismatched = false)
1017   : AccessIndexed(array, index, length, elt_type, state_before, mismatched)
1018   , _value(value), _profiled_method(NULL), _profiled_bci(0), _check_boolean(check_boolean)
1019   {
1020     set_flag(NeedsWriteBarrierFlag, (as_ValueType(elt_type)->is_object()));
1021     set_flag(NeedsStoreCheckFlag, (as_ValueType(elt_type)->is_object()));
1022     ASSERT_VALUES
1023     pin();
1024   }
1025 
1026   // accessors
1027   Value value() const                            { return _value; }
1028   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
1029   bool needs_store_check() const                 { return check_flag(NeedsStoreCheckFlag); }
1030   bool check_boolean() const                     { return _check_boolean; }
1031   // Helpers for MethodData* profiling
1032   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1033   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1034   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1035   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1036   ciMethod* profiled_method() const                  { return _profiled_method;     }
1037   int       profiled_bci() const                     { return _profiled_bci;        }
1038   // Flattened array support
1039   bool is_exact_flattened_array_store() const;
1040   // generic
1041   virtual void input_values_do(ValueVisitor* f)   { AccessIndexed::input_values_do(f); f->visit(&_value); }
1042 };
1043 
1044 
1045 LEAF(NegateOp, Instruction)
1046  private:
1047   Value _x;
1048 
1049  public:
1050   // creation
1051   NegateOp(Value x) : Instruction(x->type()->base()), _x(x) {
1052     ASSERT_VALUES
1053   }
1054 
1055   // accessors
1056   Value x() const                                { return _x; }
1057 
1058   // generic
1059   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_x); }


1272   void set_state(ValueStack* state)              { assert(_state == NULL, "overwriting existing state"); check_state(state); _state = state; }
1273 
1274   // generic
1275   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
1276   virtual void state_values_do(ValueVisitor* f);
1277 };
1278 
1279 
1280 LEAF(Invoke, StateSplit)
1281  private:
1282   Bytecodes::Code _code;
1283   Value           _recv;
1284   Values*         _args;
1285   BasicTypeList*  _signature;
1286   int             _vtable_index;
1287   ciMethod*       _target;
1288 
1289  public:
1290   // creation
1291   Invoke(Bytecodes::Code code, ValueType* result_type, Value recv, Values* args,
1292          int vtable_index, ciMethod* target, ValueStack* state_before, bool never_null);
1293 
1294   // accessors
1295   Bytecodes::Code code() const                   { return _code; }
1296   Value receiver() const                         { return _recv; }
1297   bool has_receiver() const                      { return receiver() != NULL; }
1298   int number_of_arguments() const                { return _args->length(); }
1299   Value argument_at(int i) const                 { return _args->at(i); }
1300   int vtable_index() const                       { return _vtable_index; }
1301   BasicTypeList* signature() const               { return _signature; }
1302   ciMethod* target() const                       { return _target; }
1303 
1304   ciType* declared_type() const;
1305 
1306   // Returns false if target is not loaded
1307   bool target_is_final() const                   { return check_flag(TargetIsFinalFlag); }
1308   bool target_is_loaded() const                  { return check_flag(TargetIsLoadedFlag); }
1309   // Returns false if target is not loaded
1310   bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
1311 
1312   // JSR 292 support


1333 
1334  public:
1335   // creation
1336   NewInstance(ciInstanceKlass* klass, ValueStack* state_before, bool is_unresolved)
1337   : StateSplit(instanceType, state_before)
1338   , _klass(klass), _is_unresolved(is_unresolved)
1339   {}
1340 
1341   // accessors
1342   ciInstanceKlass* klass() const                 { return _klass; }
1343   bool is_unresolved() const                     { return _is_unresolved; }
1344 
1345   virtual bool needs_exception_state() const     { return false; }
1346 
1347   // generic
1348   virtual bool can_trap() const                  { return true; }
1349   ciType* exact_type() const;
1350   ciType* declared_type() const;
1351 };
1352 
1353 LEAF(NewValueTypeInstance, StateSplit)
1354   bool _is_unresolved;
1355   ciValueKlass* _klass;
1356   Value _depends_on;      // Link to instance on with withfield was called on
1357 
1358 public:
1359 
1360   // Default creation, always allocated for now
1361   NewValueTypeInstance(ciValueKlass* klass, ValueStack* state_before, bool is_unresolved, Value depends_on = NULL)
1362   : StateSplit(instanceType, state_before)
1363    , _is_unresolved(is_unresolved)
1364    , _klass(klass)
1365   {
1366     if (depends_on == NULL) {
1367       _depends_on = this;
1368     } else {
1369       _depends_on = depends_on;
1370     }
1371     set_never_null(true);
1372   }
1373 
1374   // accessors
1375   bool is_unresolved() const                     { return _is_unresolved; }
1376   Value depends_on();
1377 
1378   ciValueKlass* klass() const { return _klass; }
1379 
1380   virtual bool needs_exception_state() const     { return false; }
1381 
1382   // generic
1383   virtual bool can_trap() const                  { return true; }
1384   ciType* exact_type() const;
1385   ciType* declared_type() const;
1386 
1387   // Only done in LIR Generator -> map everything to object
1388   void set_to_object_type() { set_type(instanceType); }
1389 };
1390 
1391 BASE(NewArray, StateSplit)
1392  private:
1393   Value       _length;
1394 
1395  public:
1396   // creation
1397   NewArray(Value length, ValueStack* state_before)
1398   : StateSplit(objectType, state_before)
1399   , _length(length)
1400   {
1401     // Do not ASSERT_VALUES since length is NULL for NewMultiArray
1402   }
1403 
1404   // accessors
1405   Value length() const                           { return _length; }
1406 
1407   virtual bool needs_exception_state() const     { return false; }
1408 
1409   ciType* exact_type() const                     { return NULL; }


1456   NewMultiArray(ciKlass* klass, Values* dims, ValueStack* state_before) : NewArray(NULL, state_before), _klass(klass), _dims(dims) {
1457     ASSERT_VALUES
1458   }
1459 
1460   // accessors
1461   ciKlass* klass() const                         { return _klass; }
1462   Values* dims() const                           { return _dims; }
1463   int rank() const                               { return dims()->length(); }
1464 
1465   // generic
1466   virtual void input_values_do(ValueVisitor* f) {
1467     // NOTE: we do not call NewArray::input_values_do since "length"
1468     // is meaningless for a multi-dimensional array; passing the
1469     // zeroth element down to NewArray as its length is a bad idea
1470     // since there will be a copy in the "dims" array which doesn't
1471     // get updated, and the value must not be traversed twice. Was bug
1472     // - kbr 4/10/2001
1473     StateSplit::input_values_do(f);
1474     for (int i = 0; i < _dims->length(); i++) f->visit(_dims->adr_at(i));
1475   }
1476 
1477   ciType* exact_type() const;
1478 };
1479 
1480 
1481 BASE(TypeCheck, StateSplit)
1482  private:
1483   ciKlass*    _klass;
1484   Value       _obj;
1485 
1486   ciMethod* _profiled_method;
1487   int       _profiled_bci;
1488 
1489  public:
1490   // creation
1491   TypeCheck(ciKlass* klass, Value obj, ValueType* type, ValueStack* state_before)
1492   : StateSplit(type, state_before), _klass(klass), _obj(obj),
1493     _profiled_method(NULL), _profiled_bci(0) {
1494     ASSERT_VALUES
1495     set_direct_compare(false);
1496   }
1497 


1504   // manipulation
1505   void set_direct_compare(bool flag)             { set_flag(DirectCompareFlag, flag); }
1506 
1507   // generic
1508   virtual bool can_trap() const                  { return true; }
1509   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1510 
1511   // Helpers for MethodData* profiling
1512   void set_should_profile(bool value)                { set_flag(ProfileMDOFlag, value); }
1513   void set_profiled_method(ciMethod* method)         { _profiled_method = method;   }
1514   void set_profiled_bci(int bci)                     { _profiled_bci = bci;         }
1515   bool      should_profile() const                   { return check_flag(ProfileMDOFlag); }
1516   ciMethod* profiled_method() const                  { return _profiled_method;     }
1517   int       profiled_bci() const                     { return _profiled_bci;        }
1518 };
1519 
1520 
1521 LEAF(CheckCast, TypeCheck)
1522  public:
1523   // creation
1524   CheckCast(ciKlass* klass, Value obj, ValueStack* state_before, bool never_null = false)
1525   : TypeCheck(klass, obj, objectType, state_before) {
1526     set_never_null(never_null);
1527   }
1528 
1529   void set_incompatible_class_change_check() {
1530     set_flag(ThrowIncompatibleClassChangeErrorFlag, true);
1531   }
1532   bool is_incompatible_class_change_check() const {
1533     return check_flag(ThrowIncompatibleClassChangeErrorFlag);
1534   }
1535   void set_invokespecial_receiver_check() {
1536     set_flag(InvokeSpecialReceiverCheckFlag, true);
1537   }
1538   bool is_invokespecial_receiver_check() const {
1539     return check_flag(InvokeSpecialReceiverCheckFlag);
1540   }
1541 
1542   virtual bool needs_exception_state() const {
1543     return !is_invokespecial_receiver_check();
1544   }
1545 
1546   ciType* declared_type() const;
1547 };


1565   // creation
1566   AccessMonitor(Value obj, int monitor_no, ValueStack* state_before = NULL)
1567   : StateSplit(illegalType, state_before)
1568   , _obj(obj)
1569   , _monitor_no(monitor_no)
1570   {
1571     set_needs_null_check(true);
1572     ASSERT_VALUES
1573   }
1574 
1575   // accessors
1576   Value obj() const                              { return _obj; }
1577   int monitor_no() const                         { return _monitor_no; }
1578 
1579   // generic
1580   virtual void input_values_do(ValueVisitor* f)   { StateSplit::input_values_do(f); f->visit(&_obj); }
1581 };
1582 
1583 
1584 LEAF(MonitorEnter, AccessMonitor)
1585   bool _maybe_valuetype;
1586  public:
1587   // creation
1588   MonitorEnter(Value obj, int monitor_no, ValueStack* state_before, bool maybe_valuetype)
1589   : AccessMonitor(obj, monitor_no, state_before)
1590   , _maybe_valuetype(maybe_valuetype)
1591   {
1592     ASSERT_VALUES
1593   }
1594 
1595   // accessors
1596   bool maybe_valuetype() const                   { return _maybe_valuetype; }
1597 
1598   // generic
1599   virtual bool can_trap() const                  { return true; }
1600 };
1601 
1602 
1603 LEAF(MonitorExit, AccessMonitor)
1604  public:
1605   // creation
1606   MonitorExit(Value obj, int monitor_no)
1607   : AccessMonitor(obj, monitor_no, NULL)
1608   {
1609     ASSERT_VALUES
1610   }
1611 };
1612 
1613 
1614 LEAF(Intrinsic, StateSplit)
1615  private:
1616   vmIntrinsics::ID _id;


< prev index next >