src/hotspot/share/gc/g1/g1RegionMarkStatsCache.inline.hpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49606 9ae8719efcae
child 53244 9807daeb47c4
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49606
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     1
/*
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     4
 *
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     8
 *
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    14
 *
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    18
 *
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    21
 * questions.
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    22
 *
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    23
 */
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    24
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1REGIONMARKSTATSCACHE_INLINE_HPP
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_G1REGIONMARKSTATSCACHE_INLINE_HPP
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    27
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    28
#include "gc/g1/g1RegionMarkStatsCache.hpp"
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    29
#include "runtime/atomic.hpp"
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    30
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    31
inline G1RegionMarkStatsCache::G1RegionMarkStatsCacheEntry* G1RegionMarkStatsCache::find_for_add(uint region_idx) {
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    32
  uint const cache_idx = hash(region_idx);
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    33
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    34
  G1RegionMarkStatsCacheEntry* cur = &_cache[cache_idx];
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    35
  if (cur->_region_idx != region_idx) {
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    36
    evict(cache_idx);
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    37
    cur->_region_idx = region_idx;
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    38
    _cache_misses++;
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    39
  } else {
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    40
    _cache_hits++;
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    41
  }
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    42
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    43
  return cur;
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    44
}
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    45
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    46
inline void G1RegionMarkStatsCache::evict(uint idx) {
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    47
  G1RegionMarkStatsCacheEntry* cur = &_cache[idx];
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    48
  if (cur->_stats._live_words != 0) {
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    49
    Atomic::add(cur->_stats._live_words, &_target[cur->_region_idx]._live_words);
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    50
  }
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    51
  cur->clear();
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    52
}
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    53
9ae8719efcae 8197850: Calculate liveness in regions during marking
tschatzl
parents:
diff changeset
    54
#endif // SHARE_VM_GC_G1_G1REGIONMARKSTATSCACHE_INLINE_HPP