/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_UTILITIES_BITMAP_HPP
#define SHARE_VM_UTILITIES_BITMAP_HPP
#include "memory/allocation.hpp"
// Forward decl;
class BitMapClosure;
// Operations for bitmaps represented as arrays of unsigned integers.
// Bit offsets are numbered from 0 to size-1.
friend class BitMap2D;
public:
// the bitmap.
// Hints for range sizes.
typedef enum {
private:
// Puts the given value at the given offset, using resize() to size
// the bitmap appropriately if needed using factor-of-two expansion.
protected:
// Return the position of bit within the word that contains it (e.g., if
// bitmap words are 32 bits, return a number 0 <= n <= 31).
// Return a mask that will select the specified bit, when applied to the word
// containing the bit.
// Return the index of the word containing the specified bit.
// Return the bit number of the first bit in the specified word.
// Return the array of bitmap words, or a specific word from it.
// Return a pointer to the word containing the specified bit.
// Set a word to a specified value or to all ones; clear a word.
// Utilities for ranges of bits. Ranges are half-open [beg, end).
// Ranges within a single word.
// Ranges spanning entire words.
// The index of the first full word in a range.
// Verification.
// Statistics.
static void init_pop_count_table();
static idx_t num_set_bits_from_table(unsigned char c);
public:
// Constructs a bitmap with no map, and size 0.
// Constructs a bitmap with the given map and size.
// Constructs an empty bitmap of the given size (that is, this clears the
// new bitmap). Allocates the map array in resource area if
// "in_resource_area" is true, else in the C heap.
// Set the map and size.
// Allocates necessary data structure, either in the resource area
// or in the C heap, as indicated by "in_resource_area."
// Preserves state currently in bit map by copying data.
// Zeros any newly-addressable bits.
// If "in_resource_area" is false, frees the current map.
// (Note that this assumes that all calls to "resize" on the same BitMap
// use the same value for "in_resource_area".)
// Accessing
}
}
// Align bit index up or down to the next bitmap word boundary, or check
// alignment.
}
}
}
// Set or clear the specified bit.
// Atomically set or clear the specified bit.
// Put the given value at the given offset. The parallel version
// will CAS the value into the bitmap and is quite a bit slower.
// The parallel version also returns a value indicating if the
// calling thread was the one that changed the value of the bit.
// Update a range of bits. Ranges are half-open [beg, end).
// Update a range of bits, using a hint about the size. Currently only
// inlines the predominant case of a 1-bit range. Works best when hint is a
// compile-time constant.
// Clearing
void clear_large();
inline void clear();
// Iteration support. Returns "true" if the iteration completed, false
// if the iteration terminated early (because the closure "blk" returned
// false).
// call the version that takes an interval
}
// Looking for 1's and 0's at indices equal to or greater than "l_index",
// stopping if none has been found before "r_index", and returning
// "r_index" (which must be at most "size") in that case.
// Like "get_next_one_offset_inline", except requires that "r_index" is
// aligned to bitsizeof(bm_word_t).
// Non-inline versionsof the above.
}
}
// Returns the number of bits set in the bitmap.
idx_t count_one_bits() const;
// Set operations.
// Returns true iff "this" is a superset of "bits".
// Returns true iff "this and "bits" have a non-empty intersection.
// Returns result of whether this map changed
// during the operation
// Requires the submap of "bits" starting at offset to be at least as
// large as "this". Modifies "this" to be the intersection of its
// current contents and the submap of "bits" starting at "offset" of the
// same length as "this."
// (For expedience, currently requires the offset to be aligned to the
// bitsize of a uintptr_t. This should go away in the future though it
// will probably remain a good case to optimize.)
// Test if all bits are set or cleared
bool is_full() const;
bool is_empty() const;
#ifndef PRODUCT
public:
// Printing
#endif
};
// Convenience class wrapping BitMap which provides multiple bits per slot.
public:
// represents the bitmap.
private:
}
}
public:
// Construction. bits_per_slot must be greater than 0.
// Allocates necessary data structure in resource area. bits_per_slot must be greater than 0.
idx_t size_in_bits() {
}
// Returns number of full slots that have been allocated
idx_t size_in_slots() {
// Round down
}
}
}
}
}
}
}
void clear();
};
// Closure for iterating over BitMaps
class BitMapClosure VALUE_OBJ_CLASS_SPEC {
public:
// Callback when bit in map is set. Should normally return "true";
// return of false indicates that the bitmap iteration should terminate.
};
#endif // SHARE_VM_UTILITIES_BITMAP_HPP