bitMap.hpp revision 4573
2362N/A * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. 2362N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// Operations for bitmaps represented as arrays of unsigned integers. 0N/A// Bit offsets are numbered from 0 to size-1. 0N/A // Hints for range sizes. 0N/A // Puts the given value at the given offset, using resize() to size 0N/A // the bitmap appropriately if needed using factor-of-two expansion. 0N/A // Return the position of bit within the word that contains it (e.g., if 0N/A // bitmap words are 32 bits, return a number 0 <= n <= 31). 0N/A // Return a mask that will select the specified bit, when applied to the word 0N/A // containing the bit. 0N/A // Return the index of the word containing the specified bit. 0N/A // Return the bit number of the first bit in the specified word. 0N/A // Return the array of bitmap words, or a specific word from it. 0N/A // Return a pointer to the word containing the specified bit. 0N/A // Set a word to a specified value or to all ones; clear a word. 0N/A // Utilities for ranges of bits. Ranges are half-open [beg, end). 0N/A // Ranges within a single word. 0N/A // Ranges spanning entire words. 0N/A // The index of the first full word in a range. 0N/A // Constructs a bitmap with no map, and size 0. 0N/A // Constructs a bitmap with the given map and size. 0N/A // Constructs an empty bitmap of the given size (that is, this clears the 0N/A // new bitmap). Allocates the map array in resource area if 0N/A // "in_resource_area" is true, else in the C heap. 0N/A // Set the map and size. 0N/A // Allocates necessary data structure, either in the resource area 0N/A // or in the C heap, as indicated by "in_resource_area." 0N/A // Preserves state currently in bit map by copying data. 0N/A // Zeros any newly-addressable bits. 0N/A // If "in_resource_area" is false, frees the current map. 0N/A // (Note that this assumes that all calls to "resize" on the same BitMap 0N/A // use the same value for "in_resource_area".) 0N/A // Align bit index up or down to the next bitmap word boundary, or check 0N/A // Set or clear the specified bit. 0N/A // Atomically set or clear the specified bit. 0N/A // Put the given value at the given offset. The parallel version 0N/A // will CAS the value into the bitmap and is quite a bit slower. 0N/A // The parallel version also returns a value indicating if the 0N/A // calling thread was the one that changed the value of the bit. 0N/A // Update a range of bits. Ranges are half-open [beg, end). 0N/A // Update a range of bits, using a hint about the size. Currently only 0N/A // inlines the predominant case of a 1-bit range. Works best when hint is a 0N/A // compile-time constant. 0N/A // Iteration support. Returns "true" if the iteration completed, false 0N/A // if the iteration terminated early (because the closure "blk" returned 0N/A // call the version that takes an interval 0N/A // Looking for 1's and 0's at indices equal to or greater than "l_index", 0N/A // stopping if none has been found before "r_index", and returning 0N/A // "r_index" (which must be at most "size") in that case. 0N/A // Like "get_next_one_offset_inline", except requires that "r_index" is 0N/A // aligned to bitsizeof(bm_word_t). 0N/A // Non-inline versionsof the above. 0N/A // Returns the number of bits set in the bitmap. 0N/A // Returns true iff "this" is a superset of "bits". 0N/A // Returns true iff "this and "bits" have a non-empty intersection. 0N/A // Returns result of whether this map changed 0N/A // during the operation 0N/A // Requires the submap of "bits" starting at offset to be at least as 0N/A // large as "this". Modifies "this" to be the intersection of its 0N/A // current contents and the submap of "bits" starting at "offset" of the 0N/A // 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 // Convenience class wrapping BitMap which provides multiple bits per slot. // represents the bitmap. // Construction. bits_per_slot must be greater than 0. // Allocates necessary data structure in resource area. bits_per_slot must be greater than 0. // Returns number of full slots that have been allocated // Closure for iterating over BitMaps // 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