src/share/vm/c1/c1_Instruction.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 6965570 Sdiff src/share/vm/c1

src/share/vm/c1/c1_Instruction.hpp

Print this page




 306   void set_type(ValueType* type) {
 307     assert(type != NULL, "type must exist");
 308     _type = type;
 309   }
 310 
 311  public:
 312   void* operator new(size_t size) {
 313     Compilation* c = Compilation::current();
 314     void* res = c->arena()->Amalloc(size);
 315     ((Instruction*)res)->_id = c->get_next_id();
 316     return res;
 317   }
 318 
 319   static const int no_bci = -99;
 320 
 321   enum InstructionFlag {
 322     NeedsNullCheckFlag = 0,
 323     CanTrapFlag,
 324     DirectCompareFlag,
 325     IsEliminatedFlag,
 326     IsInitializedFlag,
 327     IsLoadedFlag,
 328     IsSafepointFlag,
 329     IsStaticFlag,
 330     IsStrictfpFlag,
 331     NeedsStoreCheckFlag,
 332     NeedsWriteBarrierFlag,
 333     PreservesStateFlag,
 334     TargetIsFinalFlag,
 335     TargetIsLoadedFlag,
 336     TargetIsStrictfpFlag,
 337     UnorderedIsTrueFlag,
 338     NeedsPatchingFlag,
 339     ThrowIncompatibleClassChangeErrorFlag,
 340     ProfileMDOFlag,
 341     IsLinkedInBlockFlag,
 342     InstructionLastFlag
 343   };
 344 
 345  public:
 346   bool check_flag(InstructionFlag id) const      { return (_flags & (1 << id)) != 0;    }
 347   void set_flag(InstructionFlag id, bool f)      { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); };


 676     case cond_true:
 677       return true_sux;
 678     default:
 679       ShouldNotReachHere();
 680       return NULL;
 681     }
 682   }
 683 };
 684 
 685 
 686 BASE(AccessField, Instruction)
 687  private:
 688   Value       _obj;
 689   int         _offset;
 690   ciField*    _field;
 691   NullCheck*  _explicit_null_check;              // For explicit null check elimination
 692 
 693  public:
 694   // creation
 695   AccessField(Value obj, int offset, ciField* field, bool is_static,
 696               ValueStack* state_before, bool is_loaded, bool is_initialized)
 697   : Instruction(as_ValueType(field->type()->basic_type()), state_before)
 698   , _obj(obj)
 699   , _offset(offset)
 700   , _field(field)
 701   , _explicit_null_check(NULL)
 702   {
 703     set_needs_null_check(!is_static);
 704     set_flag(IsLoadedFlag, is_loaded);
 705     set_flag(IsInitializedFlag, is_initialized);
 706     set_flag(IsStaticFlag, is_static);

 707     ASSERT_VALUES
 708       if (!is_loaded || (PatchALot && !field->is_volatile())) {
 709       // need to patch if the holder wasn't loaded or we're testing
 710       // using PatchALot.  Don't allow PatchALot for fields which are
 711       // known to be volatile they aren't patchable.
 712       set_flag(NeedsPatchingFlag, true);
 713     }
 714     // pin of all instructions with memory access
 715     pin();
 716   }
 717 
 718   // accessors
 719   Value obj() const                              { return _obj; }
 720   int offset() const                             { return _offset; }
 721   ciField* field() const                         { return _field; }
 722   BasicType field_type() const                   { return _field->type()->basic_type(); }
 723   bool is_static() const                         { return check_flag(IsStaticFlag); }
 724   bool is_loaded() const                         { return check_flag(IsLoadedFlag); }
 725   bool is_initialized() const                    { return check_flag(IsInitializedFlag); }
 726   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 727   bool needs_patching() const                    { return check_flag(NeedsPatchingFlag); }
 728 





 729   // manipulation
 730 
 731   // Under certain circumstances, if a previous NullCheck instruction
 732   // proved the target object non-null, we can eliminate the explicit
 733   // null check and do an implicit one, simply specifying the debug
 734   // information from the NullCheck. This field should only be consulted
 735   // if needs_null_check() is true.
 736   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 737 
 738   // generic
 739   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 740   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 741 };
 742 
 743 
 744 LEAF(LoadField, AccessField)
 745  public:
 746   // creation
 747   LoadField(Value obj, int offset, ciField* field, bool is_static,
 748             ValueStack* state_before, bool is_loaded, bool is_initialized)
 749   : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
 750   {}
 751 
 752   ciType* declared_type() const;
 753   ciType* exact_type() const;
 754 
 755   // generic
 756   HASHING2(LoadField, is_loaded() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if not yet loaded or if volatile
 757 };
 758 
 759 
 760 LEAF(StoreField, AccessField)
 761  private:
 762   Value _value;
 763 
 764  public:
 765   // creation
 766   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 767              ValueStack* state_before, bool is_loaded, bool is_initialized)
 768   : AccessField(obj, offset, field, is_static, state_before, is_loaded, is_initialized)
 769   , _value(value)
 770   {
 771     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 772     ASSERT_VALUES
 773     pin();
 774   }
 775 
 776   // accessors
 777   Value value() const                            { return _value; }
 778   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
 779 
 780   // generic
 781   virtual void input_values_do(ValueVisitor* f)   { AccessField::input_values_do(f); f->visit(&_value); }
 782 };
 783 
 784 
 785 BASE(AccessArray, Instruction)
 786  private:
 787   Value       _array;
 788 




 306   void set_type(ValueType* type) {
 307     assert(type != NULL, "type must exist");
 308     _type = type;
 309   }
 310 
 311  public:
 312   void* operator new(size_t size) {
 313     Compilation* c = Compilation::current();
 314     void* res = c->arena()->Amalloc(size);
 315     ((Instruction*)res)->_id = c->get_next_id();
 316     return res;
 317   }
 318 
 319   static const int no_bci = -99;
 320 
 321   enum InstructionFlag {
 322     NeedsNullCheckFlag = 0,
 323     CanTrapFlag,
 324     DirectCompareFlag,
 325     IsEliminatedFlag,


 326     IsSafepointFlag,
 327     IsStaticFlag,
 328     IsStrictfpFlag,
 329     NeedsStoreCheckFlag,
 330     NeedsWriteBarrierFlag,
 331     PreservesStateFlag,
 332     TargetIsFinalFlag,
 333     TargetIsLoadedFlag,
 334     TargetIsStrictfpFlag,
 335     UnorderedIsTrueFlag,
 336     NeedsPatchingFlag,
 337     ThrowIncompatibleClassChangeErrorFlag,
 338     ProfileMDOFlag,
 339     IsLinkedInBlockFlag,
 340     InstructionLastFlag
 341   };
 342 
 343  public:
 344   bool check_flag(InstructionFlag id) const      { return (_flags & (1 << id)) != 0;    }
 345   void set_flag(InstructionFlag id, bool f)      { _flags = f ? (_flags | (1 << id)) : (_flags & ~(1 << id)); };


 674     case cond_true:
 675       return true_sux;
 676     default:
 677       ShouldNotReachHere();
 678       return NULL;
 679     }
 680   }
 681 };
 682 
 683 
 684 BASE(AccessField, Instruction)
 685  private:
 686   Value       _obj;
 687   int         _offset;
 688   ciField*    _field;
 689   NullCheck*  _explicit_null_check;              // For explicit null check elimination
 690 
 691  public:
 692   // creation
 693   AccessField(Value obj, int offset, ciField* field, bool is_static,
 694               ValueStack* state_before, bool needs_patching)
 695   : Instruction(as_ValueType(field->type()->basic_type()), state_before)
 696   , _obj(obj)
 697   , _offset(offset)
 698   , _field(field)
 699   , _explicit_null_check(NULL)
 700   {
 701     set_needs_null_check(!is_static);


 702     set_flag(IsStaticFlag, is_static);
 703     set_flag(NeedsPatchingFlag, needs_patching);
 704     ASSERT_VALUES






 705     // pin of all instructions with memory access
 706     pin();
 707   }
 708 
 709   // accessors
 710   Value obj() const                              { return _obj; }
 711   int offset() const                             { return _offset; }
 712   ciField* field() const                         { return _field; }
 713   BasicType field_type() const                   { return _field->type()->basic_type(); }
 714   bool is_static() const                         { return check_flag(IsStaticFlag); }


 715   NullCheck* explicit_null_check() const         { return _explicit_null_check; }
 716   bool needs_patching() const                    { return check_flag(NeedsPatchingFlag); }
 717 
 718   // Unresolved getstatic and putstatic can cause initialization.
 719   // Technically it occurs at the Constant that materializes the base
 720   // of the static fields but it's simpler to model it here.
 721   bool is_init_point() const                     { return is_static() && (needs_patching() || !_field->holder()->is_initialized()); }
 722 
 723   // manipulation
 724 
 725   // Under certain circumstances, if a previous NullCheck instruction
 726   // proved the target object non-null, we can eliminate the explicit
 727   // null check and do an implicit one, simply specifying the debug
 728   // information from the NullCheck. This field should only be consulted
 729   // if needs_null_check() is true.
 730   void set_explicit_null_check(NullCheck* check) { _explicit_null_check = check; }
 731 
 732   // generic
 733   virtual bool can_trap() const                  { return needs_null_check() || needs_patching(); }
 734   virtual void input_values_do(ValueVisitor* f)   { f->visit(&_obj); }
 735 };
 736 
 737 
 738 LEAF(LoadField, AccessField)
 739  public:
 740   // creation
 741   LoadField(Value obj, int offset, ciField* field, bool is_static,
 742             ValueStack* state_before, bool needs_patching)
 743   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 744   {}
 745 
 746   ciType* declared_type() const;
 747   ciType* exact_type() const;
 748 
 749   // generic
 750   HASHING2(LoadField, !needs_patching() && !field()->is_volatile(), obj()->subst(), offset())  // cannot be eliminated if needs patching or if volatile
 751 };
 752 
 753 
 754 LEAF(StoreField, AccessField)
 755  private:
 756   Value _value;
 757 
 758  public:
 759   // creation
 760   StoreField(Value obj, int offset, ciField* field, Value value, bool is_static,
 761              ValueStack* state_before, bool needs_patching)
 762   : AccessField(obj, offset, field, is_static, state_before, needs_patching)
 763   , _value(value)
 764   {
 765     set_flag(NeedsWriteBarrierFlag, as_ValueType(field_type())->is_object());
 766     ASSERT_VALUES
 767     pin();
 768   }
 769 
 770   // accessors
 771   Value value() const                            { return _value; }
 772   bool needs_write_barrier() const               { return check_flag(NeedsWriteBarrierFlag); }
 773 
 774   // generic
 775   virtual void input_values_do(ValueVisitor* f)   { AccessField::input_values_do(f); f->visit(&_value); }
 776 };
 777 
 778 
 779 BASE(AccessArray, Instruction)
 780  private:
 781   Value       _array;
 782 


src/share/vm/c1/c1_Instruction.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File