src/hotspot/share/utilities/bitMap.inline.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46958 hotspot/src/share/vm/utilities/bitMap.inline.hpp@a13bd8c6b7a2
child 52394 96bd0f70ef99
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
    }
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46428
diff changeset
    52
    const bm_word_t cur_val = Atomic::cmpxchg(new_val, addr, old_val);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    if (cur_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
      return true;      // Success.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
    old_val = cur_val;  // The value changed, try again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  } while (true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
inline bool BitMap::par_clear_bit(idx_t bit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  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
    62
  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
    63
  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
    64
  bm_word_t old_val = *addr;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  do {
19998
c18a7b05127a 8024914: Swapped usage of idx_t and bm_word_t types in bitMap.inline.hpp
tschatzl
parents: 11574
diff changeset
    67
    const bm_word_t new_val = old_val & mask;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    if (new_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
      return false;     // Someone else beat us to it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    }
46958
a13bd8c6b7a2 8186166: Generalize Atomic::cmpxchg with templates
eosterlund
parents: 46428
diff changeset
    71
    const bm_word_t cur_val = Atomic::cmpxchg(new_val, addr, old_val);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    if (cur_val == old_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
      return true;      // Success.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
    old_val = cur_val;  // The value changed, try again.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  } while (true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    79
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
    80
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    81
    set_bit(beg);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    82
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    83
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    84
      set_large_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    85
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    86
      set_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    87
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    88
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    89
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    90
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    91
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
    92
  if (end - beg == 1) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    93
    clear_bit(beg);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    94
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    95
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    96
      clear_large_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    97
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    98
      clear_range(beg, end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
    99
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   100
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   101
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   102
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   103
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
   104
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   105
    par_at_put(beg, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   106
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   107
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   108
      par_at_put_large_range(beg, end, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   109
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   110
      par_at_put_range(beg, end, true);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   111
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   112
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   113
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   115
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
   116
  bm_word_t* map = _map;
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   117
  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
   118
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   119
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   120
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
   121
  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
   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(idx_t beg, idx_t end) {
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   125
  clear_range_of_words(_map, beg, end);
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   126
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   127
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   128
inline void BitMap::clear() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   129
  clear_range_of_words(0, size_in_words());
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   130
}
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::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
   133
  if (hint == small_range && end - beg == 1) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   134
    par_at_put(beg, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   135
  } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   136
    if (hint == large_range) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   137
      par_at_put_large_range(beg, end, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   138
    } else {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   139
      par_at_put_range(beg, end, false);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   140
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   141
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   142
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   143
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   144
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   145
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
   146
  assert(l_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   147
  assert(r_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   148
  assert(l_offset <= r_offset, "l_offset > r_offset ?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   149
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   150
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   151
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   152
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   153
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   154
  idx_t r_index = word_index(r_offset-1) + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   155
  idx_t res_offset = l_offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // 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
   158
  idx_t pos = bit_in_word(res_offset);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   159
  bm_word_t res = map(index) >> pos;
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   160
  if (res != 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    // find the position of the 1-bit
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   162
    for (; !(res & 1); res_offset++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
      res = res >> 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
    }
11574
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   165
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   166
#ifdef ASSERT
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   167
    // 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
   168
    // 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
   169
    // strong and will trip the assert.
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   170
    //
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   171
    // 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
   172
    // 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
   173
    // 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
   174
    // 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
   175
    // 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
   176
    // 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
   177
    //
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   178
    // 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
   179
    // 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
   180
    // 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
   181
    // 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
   182
    // 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
   183
    // 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
   184
    // 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
   185
8a7fe61966c0 7121547: G1: High number mispredicted branches while iterating over the marking bitmap
johnc
parents: 7397
diff changeset
   186
    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
   187
    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
   188
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   189
    return MIN2(res_offset, r_offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // skip over all word length 0-bit runs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  for (index++; index < r_index; index++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   194
    if (res != 0) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
      // found a 1, return the offset
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   196
      for (res_offset = bit_index(index); !(res & 1); res_offset++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
        res = res >> 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
      assert(res & 1, "tautology; see loop condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   200
      assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   201
      return MIN2(res_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   202
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   203
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   204
  return r_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   205
}
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
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   208
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
   209
  assert(l_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   210
  assert(r_offset <= size(), "BitMap index out of bounds");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   211
  assert(l_offset <= r_offset, "l_offset > r_offset ?");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   212
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   213
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   214
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   215
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   216
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   217
  idx_t r_index = word_index(r_offset-1) + 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   218
  idx_t res_offset = 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
  // check bits including and to the _left_ of offset's position
46428
d577822ca75c 8178352: BitMap::get_next_zero_offset may give wrong result on Mac
kbarrett
parents: 46402
diff changeset
   221
  idx_t pos = bit_in_word(res_offset);
d577822ca75c 8178352: BitMap::get_next_zero_offset may give wrong result on Mac
kbarrett
parents: 46402
diff changeset
   222
  bm_word_t res = ~map(index) >> pos; // flip bits and shift for l_offset
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   223
46428
d577822ca75c 8178352: BitMap::get_next_zero_offset may give wrong result on Mac
kbarrett
parents: 46402
diff changeset
   224
  if (res != 0) {
d577822ca75c 8178352: BitMap::get_next_zero_offset may give wrong result on Mac
kbarrett
parents: 46402
diff changeset
   225
    // find the position of the 1-bit
d577822ca75c 8178352: BitMap::get_next_zero_offset may give wrong result on Mac
kbarrett
parents: 46402
diff changeset
   226
    for (; !(res & 1); res_offset++) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   227
      res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   228
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   229
    assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   230
    return MIN2(res_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   231
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   232
  // skip over all word length 1-bit runs
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   233
  for (index++; index < r_index; index++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   234
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   235
    if (res != ~(bm_word_t)0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   236
      // found a 0, return the offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   237
      for (res_offset = index << LogBitsPerWord; res & 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   238
           res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   239
        res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   240
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   241
      assert(!(res & 1), "tautology; see loop condition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   242
      assert(res_offset >= l_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   243
      return MIN2(res_offset, r_offset);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   246
  return r_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   247
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   248
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   249
inline BitMap::idx_t
46402
8147e17ad6fa 8179181: Cleanup BitMap search API
kbarrett
parents: 40655
diff changeset
   250
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
   251
{
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   252
  verify_range(l_offset, r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   253
  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
   254
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   255
  if (l_offset == r_offset) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   256
    return l_offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   257
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   258
  idx_t   index = word_index(l_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   259
  idx_t r_index = word_index(r_offset);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   260
  idx_t res_offset = 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
  // 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
   263
  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
   264
  if (res != 0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   265
    // find the position of the 1-bit
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   266
    for (; !(res & 1); res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   267
      res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   268
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   269
    assert(res_offset >= l_offset &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   270
           res_offset < r_offset, "just checking");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   271
    return res_offset;
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
  // skip over all word length 0-bit runs
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   274
  for (index++; index < r_index; index++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   275
    res = map(index);
26937
dd2b0f6de283 8059474: Clean up vm/utilities/Bitmap type uses
shade
parents: 25351
diff changeset
   276
    if (res != 0) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   277
      // found a 1, return the offset
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   278
      for (res_offset = bit_index(index); !(res & 1); res_offset++) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   279
        res = res >> 1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   280
      }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   281
      assert(res & 1, "tautology; see loop condition");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   282
      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
   283
      return res_offset;
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
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   286
  return r_offset;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
}
1374
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
// 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
   291
// 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
   292
// 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
   293
// range.  Note:  end must not be 0.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   294
inline BitMap::bm_word_t
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   295
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
   296
  assert(end != 0, "does not work when end == 0");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   297
  assert(beg == end || word_index(beg) == word_index(end - 1),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   298
         "must be a single-word range");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   299
  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
   300
  if (bit_in_word(end) != 0) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   301
    mask |= ~(bit_mask(end) - 1);       // high (left) bits
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   302
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   303
  return mask;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   304
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   305
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   306
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
   307
  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
   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::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
   311
  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
   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 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
   315
  idx_t bit_rounded_up = bit + (BitsPerWord - 1);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   316
  // Check for integer arithmetic overflow.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   317
  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
   318
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   319
37059
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   320
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
   321
  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
   322
  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
   323
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   324
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   325
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
   326
  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
   327
  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
   328
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   329
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   330
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
   331
  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
   332
  _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
   333
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   334
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   335
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
   336
  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
   337
  _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
   338
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   339
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   340
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
   341
  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
   342
  _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
   343
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   344
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   345
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
   346
  verify_bit_within_slot_index(bit_within_slot_index);
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   347
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   348
  idx_t bit = bit_index(slot_index, bit_within_slot_index);
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   349
  if (bit >= _map.size()) {
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 37264
diff changeset
   350
    _map.resize(2 * MAX2(_map.size(), bit));
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
  _map.at_put(bit, value);
37059
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   353
}
c482915a21aa 8151440: Move BitMap verfication inline functions out from bitMap.hpp
stefank
parents: 26937
diff changeset
   354
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   355
#endif // SHARE_VM_UTILITIES_BITMAP_INLINE_HPP