--- old/src/share/vm/utilities/bitMap.hpp 2014-11-06 00:05:10.298893863 +0300 +++ new/src/share/vm/utilities/bitMap.hpp 2014-11-06 00:05:10.246893861 +0300 @@ -36,6 +36,7 @@ class BitMap VALUE_OBJ_CLASS_SPEC { friend class BitMap2D; + friend class BitMapIterator; public: typedef size_t idx_t; // Type used for bit and word indices. @@ -115,7 +116,7 @@ // Constructs a bitmap with no map, and size 0. BitMap() : _map(NULL), _size(0), _map_allocator(false) {} - + // Constructs a bitmap with the given map and size. BitMap(bm_word_t* map, idx_t size_in_bits); @@ -164,6 +165,10 @@ inline void set_bit(idx_t bit); inline void clear_bit(idx_t bit); + // Set or clear the specified bit with result + inline bool set_bit_with_result(idx_t bit); + inline bool clear_bit_with_result(idx_t bit); + // Atomically set or clear the specified bit. inline bool par_set_bit(idx_t bit); inline bool par_clear_bit(idx_t bit); @@ -272,6 +277,39 @@ #endif }; +class BitMapIterator VALUE_OBJ_CLASS_SPEC { + friend class BitMap; + + typedef BitMap::idx_t idx_t; // Type used for bit and word indices. + typedef BitMap::bm_word_t bm_word_t; // Element type of array that + // represents the bitmap. + + // We walk over the bits in a word in chunks of size window_size. + enum { window_size = 8, + window_mask = right_n_bits(window_size), + table_size = (1 << window_size) }; + + // For an integer of length window_size, what is the first set bit? + static const uint8_t _first_bit[table_size]; + + // For an integer of length window_size, what is the first set bit? + static const uint8_t _second_bit[table_size]; + + + BitMap* _bs; + bm_word_t _current; + idx_t _value; + idx_t _last_word; + idx_t _max_word; + + public: + BitMapIterator(BitMap* bs); + + // Return the next element of the set. Return 0 when done. + + uint next(); +}; + // Convenience class wrapping BitMap which provides multiple bits per slot. class BitMap2D VALUE_OBJ_CLASS_SPEC { public: