src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.cpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46751 hotspot/src/share/vm/gc/g1/g1ConcurrentMarkBitMap.cpp@d2e0cecdbcb0
child 47885 5caa1d5f74c1
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:
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     1
/*
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     4
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     8
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    14
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    18
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    21
 * questions.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    22
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    23
 */
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    24
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    27
#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    28
#include "memory/virtualspace.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    29
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    30
void G1CMBitMap::print_on_error(outputStream* st, const char* prefix) const {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    31
  _bm.print_on_error(st, prefix);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    32
}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    33
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    34
size_t G1CMBitMap::compute_size(size_t heap_size) {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    35
  return ReservedSpace::allocation_align_size_up(heap_size / mark_distance());
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    36
}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    37
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    38
size_t G1CMBitMap::mark_distance() {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    39
  return MinObjAlignmentInBytes * BitsPerByte;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    40
}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    41
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    42
void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    43
  _covered = heap;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    44
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    45
  _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _covered.word_size() >> _shifter);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    46
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    47
  storage->set_mapping_changed_listener(&_listener);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    48
}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    49
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    50
void G1CMBitMapMappingChangedListener::on_commit(uint start_region, size_t num_regions, bool zero_filled) {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    51
  if (zero_filled) {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    52
    return;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    53
  }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    54
  // We need to clear the bitmap on commit, removing any existing information.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    55
  MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_region), num_regions * HeapRegion::GrainWords);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    56
  _bm->clear_range(mr);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    57
}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    58
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    59
void G1CMBitMap::clear_range(MemRegion mr) {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    60
  MemRegion intersection = mr.intersection(_covered);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    61
  assert(!intersection.is_empty(),
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    62
         "Given range from " PTR_FORMAT " to " PTR_FORMAT " is completely outside the heap",
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    63
         p2i(mr.start()), p2i(mr.end()));
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    64
  // convert address range into offset range
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    65
  _bm.at_put_range(addr_to_offset(intersection.start()),
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    66
                   addr_to_offset(intersection.end()), false);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    67
}