< prev index next >

src/hotspot/share/gc/g1/g1CardSetContainers.inline.hpp

Print this page

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP
 26 #define SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP
 27 
 28 #include "gc/g1/g1CardSetContainers.hpp"
 29 #include "gc/g1/g1GCPhaseTimes.hpp"

 30 
 31 inline G1CardSetInlinePtr::CardSetPtr G1CardSetInlinePtr::merge(CardSetPtr orig_value, uint card_in_region, uint idx, uint bits_per_card) {
 32   assert((idx & (SizeFieldMask >> SizeFieldPos)) == idx, "Index %u too large to fit into size field", idx);
 33   assert(card_in_region < ((uint)1 << bits_per_card), "Card %u too large to fit into card value field", card_in_region);
 34 
 35   uint8_t card_pos = card_pos_for(idx, bits_per_card);
 36   assert(card_pos + bits_per_card < BitsInValue, "Putting card at pos %u with %u bits would extend beyond pointer", card_pos, bits_per_card);
 37 
 38   // Check that we do not touch any fields we do not own.
 39   uintptr_t mask = ((((uintptr_t)1 << bits_per_card) - 1) << card_pos);
 40   assert(((uintptr_t)orig_value & mask) == 0, "The bits in the new range should be empty; orig_value " PTR_FORMAT " mask " PTR_FORMAT, p2i(orig_value), mask);
 41 
 42   uintptr_t value = ((uintptr_t)(idx + 1) << SizeFieldPos) | ((uintptr_t)card_in_region << card_pos);
 43   uintptr_t res = (((uintptr_t)orig_value & ~SizeFieldMask) | value);
 44   return (CardSetPtr)res;
 45 }
 46 
 47 inline G1AddCardResult G1CardSetInlinePtr::add(uint card_idx, uint bits_per_card, uint max_cards_in_inline_ptr) {
 48   assert(_value_addr != nullptr, "No value address available, cannot add to set.");
 49 

 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP
 26 #define SHARE_GC_G1_G1CARDSETCONTAINERS_INLINE_HPP
 27 
 28 #include "gc/g1/g1CardSetContainers.hpp"
 29 #include "gc/g1/g1GCPhaseTimes.hpp"
 30 #include "utilities/bitMap.inline.hpp"
 31 
 32 inline G1CardSetInlinePtr::CardSetPtr G1CardSetInlinePtr::merge(CardSetPtr orig_value, uint card_in_region, uint idx, uint bits_per_card) {
 33   assert((idx & (SizeFieldMask >> SizeFieldPos)) == idx, "Index %u too large to fit into size field", idx);
 34   assert(card_in_region < ((uint)1 << bits_per_card), "Card %u too large to fit into card value field", card_in_region);
 35 
 36   uint8_t card_pos = card_pos_for(idx, bits_per_card);
 37   assert(card_pos + bits_per_card < BitsInValue, "Putting card at pos %u with %u bits would extend beyond pointer", card_pos, bits_per_card);
 38 
 39   // Check that we do not touch any fields we do not own.
 40   uintptr_t mask = ((((uintptr_t)1 << bits_per_card) - 1) << card_pos);
 41   assert(((uintptr_t)orig_value & mask) == 0, "The bits in the new range should be empty; orig_value " PTR_FORMAT " mask " PTR_FORMAT, p2i(orig_value), mask);
 42 
 43   uintptr_t value = ((uintptr_t)(idx + 1) << SizeFieldPos) | ((uintptr_t)card_in_region << card_pos);
 44   uintptr_t res = (((uintptr_t)orig_value & ~SizeFieldMask) | value);
 45   return (CardSetPtr)res;
 46 }
 47 
 48 inline G1AddCardResult G1CardSetInlinePtr::add(uint card_idx, uint bits_per_card, uint max_cards_in_inline_ptr) {
 49   assert(_value_addr != nullptr, "No value address available, cannot add to set.");
 50 
< prev index next >