hotspot/src/share/vm/utilities/bitMap.inline.hpp
author kbarrett
Sun, 23 Apr 2017 15:02:46 -0400
changeset 46402 8147e17ad6fa
parent 40655 9f644073d3a0
child 46428 d577822ca75c
permissions -rw-r--r--
8179181: Cleanup BitMap search API Summary: Remove _inline suffixes and remove duplicate wrappers. Reviewed-by: dholmes, coleenp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
     2
 * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_UTILITIES_BITMAP_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_UTILITIES_BITMAP_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39219
diff changeset
    28
#include "runtime/atomic.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "utilities/bitMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    31
inline void BitMap::set_bit(idx_t bit) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    32
  verify_index(bit);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    33
  *word_addr(bit) |= bit_mask(bit);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    34
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    35
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    36
inline void BitMap::clear_bit(idx_t bit) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    37
  verify_index(bit);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    38
  *word_addr(bit) &= ~bit_mask(bit);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    39
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    40
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
inline bool BitMap::par_set_bit(idx_t bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  verify_index(bit);
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    43
  volatile bm_word_t* const addr = word_addr(bit);
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    44
  const bm_word_t mask = bit_mask(bit);
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    45
  bm_word_t old_val = *addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  do {
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    48
    const bm_word_t new_val = old_val | mask;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    if (new_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
      return false;     // Someone else beat us to it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    }
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    52
    const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
                                                      (volatile void*) addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
                                                      (void*) old_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    if (cur_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
      return true;      // Success.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
    old_val = cur_val;  // The value changed, try again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  } while (true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
inline bool BitMap::par_clear_bit(idx_t bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  verify_index(bit);
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    64
  volatile bm_word_t* const addr = word_addr(bit);
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    65
  const bm_word_t mask = ~bit_mask(bit);
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    66
  bm_word_t old_val = *addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  do {
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    69
    const bm_word_t new_val = old_val & mask;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    if (new_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
      return false;     // Someone else beat us to it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    }
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    73
    const bm_word_t cur_val = (bm_word_t) Atomic::cmpxchg_ptr((void*) new_val,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
                                                      (volatile void*) addr,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
                                                      (void*) old_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
    if (cur_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
      return true;      // Success.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    old_val = cur_val;  // The value changed, try again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  } while (true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    83
inline void BitMap::set_range(idx_t beg, idx_t end, RangeSizeHint hint) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    84
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    85
    set_bit(beg);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    86
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    87
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    88
      set_large_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    89
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    90
      set_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    91
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    92
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    93
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    94
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    95
inline void BitMap::clear_range(idx_t beg, idx_t end, RangeSizeHint hint) {
37264
d9b0f2b53b73 8152188: Allow CMSBitMapYieldQuantum for BitMap::clear_range and clear_large_range
sangheki
parents: 37059
diff changeset
    96
  if (end - beg == 1) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    97
    clear_bit(beg);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    98
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    99
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   100
      clear_large_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   101
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   102
      clear_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   103
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   104
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   105
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   106
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   107
inline void BitMap::par_set_range(idx_t beg, idx_t end, RangeSizeHint hint) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   108
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   109
    par_at_put(beg, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   110
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   111
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   112
      par_at_put_large_range(beg, end, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   113
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   114
      par_at_put_range(beg, end, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   115
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   116
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   117
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   119
inline void BitMap::set_range_of_words(idx_t beg, idx_t end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   120
  bm_word_t* map = _map;
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   121
  for (idx_t i = beg; i < end; ++i) map[i] = ~(bm_word_t)0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   122
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   123
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   124
inline void BitMap::clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   125
  for (idx_t i = beg; i < end; ++i) map[i] = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   126
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   127
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   128
inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) {
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   129
  clear_range_of_words(_map, beg, end);
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   130
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   131
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   132
inline void BitMap::clear() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   133
  clear_range_of_words(0, size_in_words());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   134
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   135
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   136
inline void BitMap::par_clear_range(idx_t beg, idx_t end, RangeSizeHint hint) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   137
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   138
    par_at_put(beg, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   139
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   140
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   141
      par_at_put_large_range(beg, end, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   142
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   143
      par_at_put_range(beg, end, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   144
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   145
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   146
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   147
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   148
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   149
BitMap::get_next_one_offset(idx_t l_offset, idx_t r_offset) const {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   150
  assert(l_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   151
  assert(r_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   152
  assert(l_offset <= r_offset, "l_offset > r_offset ?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   153
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   154
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   155
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   156
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   157
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   158
  idx_t r_index = word_index(r_offset-1) + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   159
  idx_t res_offset = l_offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  // check bits including and to the _left_ of offset's position
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   162
  idx_t pos = bit_in_word(res_offset);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   163
  bm_word_t res = map(index) >> pos;
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   164
  if (res != 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
    // find the position of the 1-bit
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   166
    for (; !(res & 1); res_offset++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
      res = res >> 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    }
11574
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   169
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   170
#ifdef ASSERT
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   171
    // In the following assert, if r_offset is not bitamp word aligned,
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   172
    // checking that res_offset is strictly less than r_offset is too
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   173
    // strong and will trip the assert.
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   174
    //
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   175
    // Consider the case where l_offset is bit 15 and r_offset is bit 17
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   176
    // of the same map word, and where bits [15:16:17:18] == [00:00:00:01].
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   177
    // All the bits in the range [l_offset:r_offset) are 0.
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   178
    // The loop that calculates res_offset, above, would yield the offset
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   179
    // of bit 18 because it's in the same map word as l_offset and there
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   180
    // is a set bit in that map word above l_offset (i.e. res != NoBits).
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   181
    //
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   182
    // In this case, however, we can assert is that res_offset is strictly
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   183
    // less than size() since we know that there is at least one set bit
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   184
    // at an offset above, but in the same map word as, r_offset.
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   185
    // Otherwise, if r_offset is word aligned then it will not be in the
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   186
    // same map word as l_offset (unless it equals l_offset). So either
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   187
    // there won't be a set bit between l_offset and the end of it's map
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   188
    // word (i.e. res == NoBits), or res_offset will be less than r_offset.
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   189
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   190
    idx_t limit = is_word_aligned(r_offset) ? r_offset : size();
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   191
    assert(res_offset >= l_offset && res_offset < limit, "just checking");
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   192
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   193
    return MIN2(res_offset, r_offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // skip over all word length 0-bit runs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  for (index++; index < r_index; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   198
    if (res != 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      // found a 1, return the offset
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   200
      for (res_offset = bit_index(index); !(res & 1); res_offset++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
        res = res >> 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
      assert(res & 1, "tautology; see loop condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   204
      assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   205
      return MIN2(res_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   206
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   207
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   208
  return r_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   209
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   210
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   211
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   212
BitMap::get_next_zero_offset(idx_t l_offset, idx_t r_offset) const {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   213
  assert(l_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   214
  assert(r_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   215
  assert(l_offset <= r_offset, "l_offset > r_offset ?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   216
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   217
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   218
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   219
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   220
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   221
  idx_t r_index = word_index(r_offset-1) + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   222
  idx_t res_offset = l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   223
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   224
  // check bits including and to the _left_ of offset's position
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   225
  idx_t pos = res_offset & (BitsPerWord - 1);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   226
  bm_word_t res = (map(index) >> pos) | left_n_bits((int)pos);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   227
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   228
  if (res != ~(bm_word_t)0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   229
    // find the position of the 0-bit
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   230
    for (; res & 1; res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   231
      res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   232
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   233
    assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   234
    return MIN2(res_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   235
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   236
  // skip over all word length 1-bit runs
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   237
  for (index++; index < r_index; index++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   238
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   239
    if (res != ~(bm_word_t)0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   240
      // found a 0, return the offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   241
      for (res_offset = index << LogBitsPerWord; res & 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   242
           res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   243
        res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   244
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   245
      assert(!(res & 1), "tautology; see loop condition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   246
      assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   247
      return MIN2(res_offset, r_offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   250
  return r_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   251
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   252
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   253
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   254
BitMap::get_next_one_offset_aligned_right(idx_t l_offset, idx_t r_offset) const
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   255
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   256
  verify_range(l_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   257
  assert(bit_in_word(r_offset) == 0, "r_offset not word-aligned");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   258
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   259
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   260
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   261
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   262
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   263
  idx_t r_index = word_index(r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   264
  idx_t res_offset = l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   265
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   266
  // check bits including and to the _left_ of offset's position
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   267
  bm_word_t res = map(index) >> bit_in_word(res_offset);
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   268
  if (res != 0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   269
    // find the position of the 1-bit
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   270
    for (; !(res & 1); res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   271
      res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   272
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   273
    assert(res_offset >= l_offset &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   274
           res_offset < r_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   275
    return res_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   276
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   277
  // skip over all word length 0-bit runs
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   278
  for (index++; index < r_index; index++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   279
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   280
    if (res != 0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   281
      // found a 1, return the offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   282
      for (res_offset = bit_index(index); !(res & 1); res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   283
        res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   284
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   285
      assert(res & 1, "tautology; see loop condition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   286
      assert(res_offset >= l_offset && res_offset < r_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   287
      return res_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   288
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   289
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   290
  return r_offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   292
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   293
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   294
// Returns a bit mask for a range of bits [beg, end) within a single word.  Each
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   295
// bit in the mask is 0 if the bit is in the range, 1 if not in the range.  The
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   296
// returned mask can be used directly to clear the range, or inverted to set the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   297
// range.  Note:  end must not be 0.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   298
inline BitMap::bm_word_t
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   299
BitMap::inverted_bit_mask_for_range(idx_t beg, idx_t end) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   300
  assert(end != 0, "does not work when end == 0");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   301
  assert(beg == end || word_index(beg) == word_index(end - 1),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   302
         "must be a single-word range");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   303
  bm_word_t mask = bit_mask(beg) - 1;   // low (right) bits
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   304
  if (bit_in_word(end) != 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   305
    mask |= ~(bit_mask(end) - 1);       // high (left) bits
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   306
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   307
  return mask;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   308
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   309
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   310
inline void BitMap::set_large_range_of_words(idx_t beg, idx_t end) {
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   311
  memset(_map + beg, ~(unsigned char)0, (end - beg) * sizeof(bm_word_t));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   312
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   313
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   314
inline void BitMap::clear_large_range_of_words(idx_t beg, idx_t end) {
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   315
  memset(_map + beg, 0, (end - beg) * sizeof(bm_word_t));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   316
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   317
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   318
inline BitMap::idx_t BitMap::word_index_round_up(idx_t bit) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   319
  idx_t bit_rounded_up = bit + (BitsPerWord - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   320
  // Check for integer arithmetic overflow.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   321
  return bit_rounded_up > bit ? word_index(bit_rounded_up) : size_in_words();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   322
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   323
37059
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   324
inline bool BitMap2D::is_valid_index(idx_t slot_index, idx_t bit_within_slot_index) {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   325
  verify_bit_within_slot_index(bit_within_slot_index);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   326
  return (bit_index(slot_index, bit_within_slot_index) < size_in_bits());
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   327
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   328
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   329
inline bool BitMap2D::at(idx_t slot_index, idx_t bit_within_slot_index) const {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   330
  verify_bit_within_slot_index(bit_within_slot_index);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   331
  return _map.at(bit_index(slot_index, bit_within_slot_index));
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   332
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   333
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   334
inline void BitMap2D::set_bit(idx_t slot_index, idx_t bit_within_slot_index) {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   335
  verify_bit_within_slot_index(bit_within_slot_index);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   336
  _map.set_bit(bit_index(slot_index, bit_within_slot_index));
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   337
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   338
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   339
inline void BitMap2D::clear_bit(idx_t slot_index, idx_t bit_within_slot_index) {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   340
  verify_bit_within_slot_index(bit_within_slot_index);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   341
  _map.clear_bit(bit_index(slot_index, bit_within_slot_index));
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   342
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   343
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   344
inline void BitMap2D::at_put(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   345
  verify_bit_within_slot_index(bit_within_slot_index);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   346
  _map.at_put(bit_index(slot_index, bit_within_slot_index), value);
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   347
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   348
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   349
inline void BitMap2D::at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) {
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   350
  verify_bit_within_slot_index(bit_within_slot_index);
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   351
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   352
  idx_t bit = bit_index(slot_index, bit_within_slot_index);
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   353
  if (bit >= _map.size()) {
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   354
    _map.resize(2 * MAX2(_map.size(), bit));
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   355
  }
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   356
  _map.at_put(bit, value);
37059
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   357
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   358
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   359
#endif // SHARE_VM_UTILITIES_BITMAP_INLINE_HPP