hotspot/src/share/vm/compiler/methodLiveness.hpp
changeset 38177 b0c9cb06506b
parent 7397 5b173b4ca846
equal deleted inserted replaced
38175:4e2bff1a5467 38177:b0c9cb06506b
    28 #include "utilities/bitMap.hpp"
    28 #include "utilities/bitMap.hpp"
    29 #include "utilities/growableArray.hpp"
    29 #include "utilities/growableArray.hpp"
    30 
    30 
    31 class ciMethod;
    31 class ciMethod;
    32 
    32 
    33 class MethodLivenessResult : public BitMap {
    33 class MethodLivenessResult : public ResourceBitMap {
    34  private:
    34  private:
    35   bool _is_valid;
    35   bool _is_valid;
    36 
    36 
    37  public:
    37  public:
    38   MethodLivenessResult(BitMap::bm_word_t* map, idx_t size_in_bits)
    38   MethodLivenessResult()
    39     : BitMap(map, size_in_bits)
    39     : ResourceBitMap()
    40     , _is_valid(false)
    40     , _is_valid(false)
    41   {}
    41   {}
    42 
    42 
    43   MethodLivenessResult(idx_t size_in_bits)
    43   MethodLivenessResult(idx_t size_in_bits)
    44     : BitMap(size_in_bits)
    44     : ResourceBitMap(size_in_bits)
    45     , _is_valid(false)
    45     , _is_valid(false)
    46   {}
    46   {}
    47 
    47 
    48   void set_is_valid() { _is_valid = true; }
    48   void set_is_valid() { _is_valid = true; }
    49   bool is_valid() { return _is_valid; }
    49   bool is_valid() { return _is_valid; }
    64     // The range of this basic block is [start_bci,limit_bci)
    64     // The range of this basic block is [start_bci,limit_bci)
    65     int _start_bci;
    65     int _start_bci;
    66     int _limit_bci;
    66     int _limit_bci;
    67 
    67 
    68     // The liveness at the start of the block;
    68     // The liveness at the start of the block;
    69     BitMap _entry;
    69     ArenaBitMap _entry;
    70 
    70 
    71     // The summarized liveness effects of our direct successors reached
    71     // The summarized liveness effects of our direct successors reached
    72     // by normal control flow
    72     // by normal control flow
    73     BitMap _normal_exit;
    73     ArenaBitMap _normal_exit;
    74 
    74 
    75     // The summarized liveness effects of our direct successors reached
    75     // The summarized liveness effects of our direct successors reached
    76     // by exceptional control flow
    76     // by exceptional control flow
    77     BitMap _exception_exit;
    77     ArenaBitMap _exception_exit;
    78 
    78 
    79     // These members hold the results of the last call to
    79     // These members hold the results of the last call to
    80     // compute_gen_kill_range().  _gen is the set of locals
    80     // compute_gen_kill_range().  _gen is the set of locals
    81     // used before they are defined in the range.  _kill is the
    81     // used before they are defined in the range.  _kill is the
    82     // set of locals defined before they are used.
    82     // set of locals defined before they are used.
    83     BitMap _gen;
    83     ArenaBitMap _gen;
    84     BitMap _kill;
    84     ArenaBitMap _kill;
    85     int    _last_bci;
    85     int         _last_bci;
    86 
    86 
    87     // A list of all blocks which could come directly before this one
    87     // A list of all blocks which could come directly before this one
    88     // in normal (non-exceptional) control flow.  We propagate liveness
    88     // in normal (non-exceptional) control flow.  We propagate liveness
    89     // information to these blocks.
    89     // information to these blocks.
    90     GrowableArray<BasicBlock*>* _normal_predecessors;
    90     GrowableArray<BasicBlock*>* _normal_predecessors;
    98     BasicBlock *_next;
    98     BasicBlock *_next;
    99     bool _on_work_list;
    99     bool _on_work_list;
   100 
   100 
   101     // Our successors call this method to merge liveness information into
   101     // Our successors call this method to merge liveness information into
   102     // our _normal_exit member.
   102     // our _normal_exit member.
   103     bool merge_normal(BitMap other);
   103     bool merge_normal(const BitMap& other);
   104 
   104 
   105     // Our successors call this method to merge liveness information into
   105     // Our successors call this method to merge liveness information into
   106     // our _exception_exit member.
   106     // our _exception_exit member.
   107     bool merge_exception(BitMap other);
   107     bool merge_exception(const BitMap& other);
   108 
   108 
   109     // This helper routine is used to help compute the gen/kill pair for
   109     // This helper routine is used to help compute the gen/kill pair for
   110     // the block.  It is also used to answer queries.
   110     // the block.  It is also used to answer queries.
   111     void compute_gen_kill_range(ciBytecodeStream *bytes);
   111     void compute_gen_kill_range(ciBytecodeStream *bytes);
   112 
   112 
   179   // We cache the length of the method.
   179   // We cache the length of the method.
   180   int _code_size;
   180   int _code_size;
   181 
   181 
   182   // The size of a BitMap.
   182   // The size of a BitMap.
   183   int _bit_map_size_bits;
   183   int _bit_map_size_bits;
   184   int _bit_map_size_words;
       
   185 
   184 
   186   // A list of all BasicBlocks.
   185   // A list of all BasicBlocks.
   187   BasicBlock **_block_list;
   186   BasicBlock **_block_list;
   188 
   187 
   189   // number of blocks
   188   // number of blocks
   196   // Our work list.
   195   // Our work list.
   197   BasicBlock *_work_list;
   196   BasicBlock *_work_list;
   198 
   197 
   199 #ifdef COMPILER1
   198 #ifdef COMPILER1
   200   // bcis where blocks start are marked
   199   // bcis where blocks start are marked
   201   BitMap _bci_block_start;
   200   ArenaBitMap _bci_block_start;
   202 #endif // COMPILER1
   201 #endif // COMPILER1
   203 
   202 
   204   // -- Graph construction & Analysis
   203   // -- Graph construction & Analysis
   205 
   204 
   206   // Compute ranges and predecessors for basic blocks.
   205   // Compute ranges and predecessors for basic blocks.
   216  // of our members.
   215  // of our members.
   217  friend class MethodLiveness::BasicBlock;
   216  friend class MethodLiveness::BasicBlock;
   218 
   217 
   219   // And accessors.
   218   // And accessors.
   220   int bit_map_size_bits() const { return _bit_map_size_bits; }
   219   int bit_map_size_bits() const { return _bit_map_size_bits; }
   221   int bit_map_size_words() const { return _bit_map_size_words; }
       
   222 
   220 
   223   // Work list manipulation routines.  Called internally by BasicBlock.
   221   // Work list manipulation routines.  Called internally by BasicBlock.
   224   BasicBlock *work_list_get();
   222   BasicBlock *work_list_get();
   225   void work_list_add(BasicBlock *block);
   223   void work_list_add(BasicBlock *block);
   226 
   224 
   268 
   266 
   269   // Find out which locals are live at a specific bci.
   267   // Find out which locals are live at a specific bci.
   270   MethodLivenessResult get_liveness_at(int bci);
   268   MethodLivenessResult get_liveness_at(int bci);
   271 
   269 
   272 #ifdef COMPILER1
   270 #ifdef COMPILER1
   273   const BitMap get_bci_block_start() const { return _bci_block_start; }
   271   const BitMap& get_bci_block_start() const { return _bci_block_start; }
   274 #endif // COMPILER1
   272 #endif // COMPILER1
   275 
   273 
   276   static void print_times() PRODUCT_RETURN;
   274   static void print_times() PRODUCT_RETURN;
   277 };
   275 };
   278 
   276