src/hotspot/share/gc/shared/markBitMap.inline.hpp
author rkennke
Wed, 29 Aug 2018 20:15:09 +0200
changeset 51578 31b159f30fb2
child 53244 9807daeb47c4
permissions -rw-r--r--
8180193: Make marking bitmap code available to other GCs Reviewed-by: shade, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51578
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     1
/*
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     4
 *
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     8
 *
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    13
 * accompanied this code).
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    14
 *
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    18
 *
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    21
 * questions.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    22
 *
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    23
 */
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    24
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    26
#define SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    27
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    28
#include "gc/shared/collectedHeap.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    29
#include "gc/shared/markBitMap.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    30
#include "memory/memRegion.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    31
#include "memory/universe.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    32
#include "utilities/align.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    33
#include "utilities/bitMap.inline.hpp"
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    34
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    35
inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* addr,
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    36
                                                const HeapWord* limit) const {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    37
  assert(limit != NULL, "limit must not be NULL");
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    38
  // Round addr up to a possible object boundary to be safe.
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    39
  size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter));
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    40
  size_t const limit_offset = addr_to_offset(limit);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    41
  size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    42
  return offset_to_addr(nextOffset);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    43
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    44
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    45
inline void MarkBitMap::mark(HeapWord* addr) {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    46
  check_mark(addr);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    47
  _bm.set_bit(addr_to_offset(addr));
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    48
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    49
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    50
inline void MarkBitMap::clear(HeapWord* addr) {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    51
  check_mark(addr);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    52
  _bm.clear_bit(addr_to_offset(addr));
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    53
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    54
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    55
inline bool MarkBitMap::par_mark(HeapWord* addr) {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    56
  check_mark(addr);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    57
  return _bm.par_set_bit(addr_to_offset(addr));
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    58
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    59
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    60
inline bool MarkBitMap::par_mark(oop obj) {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    61
  return par_mark((HeapWord*) obj);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    62
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    63
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    64
inline bool MarkBitMap::is_marked(oop obj) const{
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    65
  return is_marked((HeapWord*) obj);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    66
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    67
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    68
inline void MarkBitMap::clear(oop obj) {
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    69
  clear((HeapWord*) obj);
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    70
}
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    71
31b159f30fb2 8180193: Make marking bitmap code available to other GCs
rkennke
parents:
diff changeset
    72
#endif // SHARE_VM_GC_SHARED_MARKBITMAP_INLINE_HPP