hotspot/src/share/vm/c1/c1_Instruction.hpp
changeset 13391 30245956af37
parent 12947 ba8ba6c2dd83
child 13728 882756847a04
equal deleted inserted replaced
13309:50c604cb0d5f 13391:30245956af37
    64 class     LogicOp;
    64 class     LogicOp;
    65 class     CompareOp;
    65 class     CompareOp;
    66 class     IfOp;
    66 class     IfOp;
    67 class   Convert;
    67 class   Convert;
    68 class   NullCheck;
    68 class   NullCheck;
       
    69 class   TypeCast;
    69 class   OsrEntry;
    70 class   OsrEntry;
    70 class   ExceptionObject;
    71 class   ExceptionObject;
    71 class   StateSplit;
    72 class   StateSplit;
    72 class     Invoke;
    73 class     Invoke;
    73 class     NewInstance;
    74 class     NewInstance;
   172   virtual void do_LogicOp        (LogicOp*         x) = 0;
   173   virtual void do_LogicOp        (LogicOp*         x) = 0;
   173   virtual void do_CompareOp      (CompareOp*       x) = 0;
   174   virtual void do_CompareOp      (CompareOp*       x) = 0;
   174   virtual void do_IfOp           (IfOp*            x) = 0;
   175   virtual void do_IfOp           (IfOp*            x) = 0;
   175   virtual void do_Convert        (Convert*         x) = 0;
   176   virtual void do_Convert        (Convert*         x) = 0;
   176   virtual void do_NullCheck      (NullCheck*       x) = 0;
   177   virtual void do_NullCheck      (NullCheck*       x) = 0;
       
   178   virtual void do_TypeCast       (TypeCast*        x) = 0;
   177   virtual void do_Invoke         (Invoke*          x) = 0;
   179   virtual void do_Invoke         (Invoke*          x) = 0;
   178   virtual void do_NewInstance    (NewInstance*     x) = 0;
   180   virtual void do_NewInstance    (NewInstance*     x) = 0;
   179   virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
   181   virtual void do_NewTypeArray   (NewTypeArray*    x) = 0;
   180   virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
   182   virtual void do_NewObjectArray (NewObjectArray*  x) = 0;
   181   virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
   183   virtual void do_NewMultiArray  (NewMultiArray*   x) = 0;
   300   friend class UseCountComputer;
   302   friend class UseCountComputer;
   301   friend class BlockBegin;
   303   friend class BlockBegin;
   302 
   304 
   303   void update_exception_state(ValueStack* state);
   305   void update_exception_state(ValueStack* state);
   304 
   306 
   305  protected:
   307  //protected:
       
   308  public:
   306   void set_type(ValueType* type) {
   309   void set_type(ValueType* type) {
   307     assert(type != NULL, "type must exist");
   310     assert(type != NULL, "type must exist");
   308     _type = type;
   311     _type = type;
   309   }
   312   }
   310 
   313 
   483   virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
   486   virtual NewObjectArray*   as_NewObjectArray()  { return NULL; }
   484   virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
   487   virtual NewMultiArray*    as_NewMultiArray()   { return NULL; }
   485   virtual TypeCheck*        as_TypeCheck()       { return NULL; }
   488   virtual TypeCheck*        as_TypeCheck()       { return NULL; }
   486   virtual CheckCast*        as_CheckCast()       { return NULL; }
   489   virtual CheckCast*        as_CheckCast()       { return NULL; }
   487   virtual InstanceOf*       as_InstanceOf()      { return NULL; }
   490   virtual InstanceOf*       as_InstanceOf()      { return NULL; }
       
   491   virtual TypeCast*         as_TypeCast()        { return NULL; }
   488   virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
   492   virtual AccessMonitor*    as_AccessMonitor()   { return NULL; }
   489   virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
   493   virtual MonitorEnter*     as_MonitorEnter()    { return NULL; }
   490   virtual MonitorExit*      as_MonitorExit()     { return NULL; }
   494   virtual MonitorExit*      as_MonitorExit()     { return NULL; }
   491   virtual Intrinsic*        as_Intrinsic()       { return NULL; }
   495   virtual Intrinsic*        as_Intrinsic()       { return NULL; }
   492   virtual BlockBegin*       as_BlockBegin()      { return NULL; }
   496   virtual BlockBegin*       as_BlockBegin()      { return NULL; }
   636   }
   640   }
   637 
   641 
   638   // accessors
   642   // accessors
   639   int java_index() const                         { return _java_index; }
   643   int java_index() const                         { return _java_index; }
   640 
   644 
   641   ciType* declared_type() const                  { return _declared_type; }
   645   virtual ciType* declared_type() const          { return _declared_type; }
   642   ciType* exact_type() const;
   646   virtual ciType* exact_type() const;
   643 
   647 
   644   // generic
   648   // generic
   645   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
   649   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
   646 };
   650 };
   647 
   651 
   648 
   652 
   649 LEAF(Constant, Instruction)
   653 LEAF(Constant, Instruction)
   650  public:
   654  public:
   651   // creation
   655   // creation
   652   Constant(ValueType* type):
   656   Constant(ValueType* type):
   653       Instruction(type, NULL, true)
   657       Instruction(type, NULL, /*type_is_constant*/ true)
   654   {
   658   {
   655     assert(type->is_constant(), "must be a constant");
   659     assert(type->is_constant(), "must be a constant");
   656   }
   660   }
   657 
   661 
   658   Constant(ValueType* type, ValueStack* state_before):
   662   Constant(ValueType* type, ValueStack* state_before):
   659     Instruction(type, state_before, true)
   663     Instruction(type, state_before, /*type_is_constant*/ true)
   660   {
   664   {
   661     assert(state_before != NULL, "only used for constants which need patching");
   665     assert(state_before != NULL, "only used for constants which need patching");
   662     assert(type->is_constant(), "must be a constant");
   666     assert(type->is_constant(), "must be a constant");
   663     // since it's patching it needs to be pinned
   667     // since it's patching it needs to be pinned
   664     pin();
   668     pin();
   668   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
   672   virtual void input_values_do(ValueVisitor* f)   { /* no values */ }
   669 
   673 
   670   virtual intx hash() const;
   674   virtual intx hash() const;
   671   virtual bool is_equal(Value v) const;
   675   virtual bool is_equal(Value v) const;
   672 
   676 
       
   677   virtual ciType* exact_type() const;
   673 
   678 
   674   enum CompareResult { not_comparable = -1, cond_false, cond_true };
   679   enum CompareResult { not_comparable = -1, cond_false, cond_true };
   675 
   680 
   676   virtual CompareResult compare(Instruction::Condition condition, Value right) const;
   681   virtual CompareResult compare(Instruction::Condition condition, Value right) const;
   677   BlockBegin* compare(Instruction::Condition cond, Value right,
   682   BlockBegin* compare(Instruction::Condition cond, Value right,
  1101   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
  1106   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
  1102   HASHING1(NullCheck, true, obj()->subst())
  1107   HASHING1(NullCheck, true, obj()->subst())
  1103 };
  1108 };
  1104 
  1109 
  1105 
  1110 
       
  1111 // This node is supposed to cast the type of another node to a more precise
       
  1112 // declared type.
       
  1113 LEAF(TypeCast, Instruction)
       
  1114  private:
       
  1115   ciType* _declared_type;
       
  1116   Value   _obj;
       
  1117 
       
  1118  public:
       
  1119   // The type of this node is the same type as the object type (and it might be constant).
       
  1120   TypeCast(ciType* type, Value obj, ValueStack* state_before)
       
  1121   : Instruction(obj->type(), state_before, obj->type()->is_constant()),
       
  1122     _declared_type(type),
       
  1123     _obj(obj) {}
       
  1124 
       
  1125   // accessors
       
  1126   ciType* declared_type() const                  { return _declared_type; }
       
  1127   Value   obj() const                            { return _obj; }
       
  1128 
       
  1129   // generic
       
  1130   virtual void input_values_do(ValueVisitor* f)  { f->visit(&_obj); }
       
  1131 };
       
  1132 
       
  1133 
  1106 BASE(StateSplit, Instruction)
  1134 BASE(StateSplit, Instruction)
  1107  private:
  1135  private:
  1108   ValueStack* _state;
  1136   ValueStack* _state;
  1109 
  1137 
  1110  protected:
  1138  protected:
  1164   // Returns false if target is not loaded
  1192   // Returns false if target is not loaded
  1165   bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
  1193   bool target_is_strictfp() const                { return check_flag(TargetIsStrictfpFlag); }
  1166 
  1194 
  1167   // JSR 292 support
  1195   // JSR 292 support
  1168   bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
  1196   bool is_invokedynamic() const                  { return code() == Bytecodes::_invokedynamic; }
       
  1197   bool is_method_handle_intrinsic() const        { return target()->is_method_handle_intrinsic(); }
  1169 
  1198 
  1170   virtual bool needs_exception_state() const     { return false; }
  1199   virtual bool needs_exception_state() const     { return false; }
  1171 
  1200 
  1172   // generic
  1201   // generic
  1173   virtual bool can_trap() const                  { return true; }
  1202   virtual bool can_trap() const                  { return true; }
  2275 
  2304 
  2276 LEAF(ProfileCall, Instruction)
  2305 LEAF(ProfileCall, Instruction)
  2277  private:
  2306  private:
  2278   ciMethod* _method;
  2307   ciMethod* _method;
  2279   int       _bci_of_invoke;
  2308   int       _bci_of_invoke;
       
  2309   ciMethod* _callee;         // the method that is called at the given bci
  2280   Value     _recv;
  2310   Value     _recv;
  2281   ciKlass*  _known_holder;
  2311   ciKlass*  _known_holder;
  2282 
  2312 
  2283  public:
  2313  public:
  2284   ProfileCall(ciMethod* method, int bci, Value recv, ciKlass* known_holder)
  2314   ProfileCall(ciMethod* method, int bci, ciMethod* callee, Value recv, ciKlass* known_holder)
  2285     : Instruction(voidType)
  2315     : Instruction(voidType)
  2286     , _method(method)
  2316     , _method(method)
  2287     , _bci_of_invoke(bci)
  2317     , _bci_of_invoke(bci)
       
  2318     , _callee(callee)
  2288     , _recv(recv)
  2319     , _recv(recv)
  2289     , _known_holder(known_holder)
  2320     , _known_holder(known_holder)
  2290   {
  2321   {
  2291     // The ProfileCall has side-effects and must occur precisely where located
  2322     // The ProfileCall has side-effects and must occur precisely where located
  2292     pin();
  2323     pin();
  2293   }
  2324   }
  2294 
  2325 
  2295   ciMethod* method()      { return _method; }
  2326   ciMethod* method()      { return _method; }
  2296   int bci_of_invoke()     { return _bci_of_invoke; }
  2327   int bci_of_invoke()     { return _bci_of_invoke; }
       
  2328   ciMethod* callee()      { return _callee; }
  2297   Value recv()            { return _recv; }
  2329   Value recv()            { return _recv; }
  2298   ciKlass* known_holder() { return _known_holder; }
  2330   ciKlass* known_holder() { return _known_holder; }
  2299 
  2331 
  2300   virtual void input_values_do(ValueVisitor* f)   { if (_recv != NULL) f->visit(&_recv); }
  2332   virtual void input_values_do(ValueVisitor* f)   { if (_recv != NULL) f->visit(&_recv); }
  2301 };
  2333 };