src/hotspot/share/gc/shared/oopStorageParState.inline.hpp
author eosterlund
Tue, 16 Oct 2018 13:18:22 +0200
changeset 52142 ca0c25e01c5b
parent 49977 9f758f0bb058
permissions -rw-r--r--
8210498: nmethod entry barriers Reviewed-by: kvn, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     1
/*
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     4
 *
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     8
 *
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    13
 * accompanied this code).
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    14
 *
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    18
 *
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    21
 * questions.
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    22
 *
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    23
 */
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    24
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    25
#ifndef SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    26
#define SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    27
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    28
#include "gc/shared/oopStorage.inline.hpp"
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    29
#include "gc/shared/oopStorageParState.hpp"
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    30
#include "metaprogramming/conditional.hpp"
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    31
#include "utilities/macros.hpp"
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    32
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    33
template<typename F>
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 49005
diff changeset
    34
class OopStorage::BasicParState::AlwaysTrueFn {
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    35
  F _f;
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    36
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    37
public:
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    38
  AlwaysTrueFn(F f) : _f(f) {}
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    39
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    40
  template<typename OopPtr>     // [const] oop*
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    41
  bool operator()(OopPtr ptr) const { _f(ptr); return true; }
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    42
};
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    43
49977
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    44
struct OopStorage::BasicParState::IterationData {
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    45
  size_t _segment_start;
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    46
  size_t _segment_end;
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    47
  size_t _processed;
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    48
};
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    49
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    50
template<bool is_const, typename F>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    51
inline void OopStorage::BasicParState::iterate(F f) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    52
  // Wrap f in ATF so we can use Block::iterate.
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    53
  AlwaysTrueFn<F> atf_f(f);
49977
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    54
  IterationData data = {};      // zero initialize.
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    55
  while (claim_next_segment(&data)) {
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    56
    assert(data._segment_start < data._segment_end, "invariant");
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    57
    assert(data._segment_end <= _block_count, "invariant");
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    58
    typedef typename Conditional<is_const, const Block*, Block*>::type BlockPtr;
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    59
    size_t i = data._segment_start;
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    60
    do {
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    61
      BlockPtr block = _active_array->at(i);
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    62
      block->iterate(atf_f);
9f758f0bb058 8200557: OopStorage parallel iteration scales poorly
kbarrett
parents: 49711
diff changeset
    63
    } while (++i < data._segment_end);
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    64
  }
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    65
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    66
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    67
template<bool concurrent, bool is_const>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    68
template<typename F>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    69
inline void OopStorage::ParState<concurrent, is_const>::iterate(F f) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    70
  _basic_state.template iterate<is_const>(f);
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    71
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    72
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    73
template<bool concurrent, bool is_const>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    74
template<typename Closure>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    75
inline void OopStorage::ParState<concurrent, is_const>::oops_do(Closure* cl) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    76
  this->iterate(oop_fn(cl));
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    77
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    78
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    79
template<typename F>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    80
inline void OopStorage::ParState<false, false>::iterate(F f) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    81
  _basic_state.template iterate<false>(f);
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    82
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    83
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    84
template<typename Closure>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    85
inline void OopStorage::ParState<false, false>::oops_do(Closure* cl) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    86
  this->iterate(oop_fn(cl));
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    87
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    88
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    89
template<typename Closure>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    90
inline void OopStorage::ParState<false, false>::weak_oops_do(Closure* cl) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    91
  this->iterate(skip_null_fn(oop_fn(cl)));
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    92
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    93
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    94
template<typename IsAliveClosure, typename Closure>
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    95
inline void OopStorage::ParState<false, false>::weak_oops_do(IsAliveClosure* is_alive, Closure* cl) {
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    96
  this->iterate(if_alive_fn(is_alive, oop_fn(cl)));
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    97
}
48816
3495d6050efe 8194898: Move OopStorage inline definitions to an .inline.hpp
kbarrett
parents:
diff changeset
    98
49005
cc2b457f2589 8197992: Move the OopStorage::ParState type out of inline.hpp
pliden
parents: 48816
diff changeset
    99
#endif // SHARE_GC_SHARED_OOPSTORAGEPARSTATE_INLINE_HPP