src/hotspot/share/gc/shared/weakProcessor.hpp
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 53244 9807daeb47c4
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
     2
 * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     4
 *
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     8
 *
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    13
 * accompanied this code).
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    14
 *
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    18
 *
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    21
 * questions.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    22
 *
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    23
 */
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
    25
#ifndef SHARE_GC_SHARED_WEAKPROCESSOR_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
    26
#define SHARE_GC_SHARED_WEAKPROCESSOR_HPP
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    27
51546
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    28
#include "gc/shared/oopStorageParState.hpp"
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    29
#include "gc/shared/workgroup.hpp"
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    30
#include "memory/allocation.hpp"
51546
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    31
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    32
class WeakProcessorPhaseTimes;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    33
class WorkGang;
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    34
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    35
// Helper class to aid in root scanning and cleaning of weak oops in the VM.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    36
//
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    37
// New containers of weak oops added to this class will automatically
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    38
// be cleaned by all GCs, including the young generation GCs.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    39
class WeakProcessor : AllStatic {
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    40
public:
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    41
  // Visit all oop*s and apply the keep_alive closure if the referenced
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    42
  // object is considered alive by the is_alive closure, otherwise do some
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    43
  // container specific cleanup of element holding the oop.
47676
b1c020fc35a3 8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents: 47648
diff changeset
    44
  static void weak_oops_do(BoolObjectClosure* is_alive, OopClosure* keep_alive);
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    45
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    46
  // Visit all oop*s and apply the given closure.
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    47
  static void oops_do(OopClosure* closure);
51546
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    48
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    49
  // Parallel version.  Uses ergo_workers(), active workers, and
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    50
  // phase_time's max_threads to determine the number of threads to use.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    51
  // IsAlive must be derived from BoolObjectClosure.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    52
  // KeepAlive must be derived from OopClosure.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    53
  template<typename IsAlive, typename KeepAlive>
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    54
  static void weak_oops_do(WorkGang* workers,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    55
                           IsAlive* is_alive,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    56
                           KeepAlive* keep_alive,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    57
                           WeakProcessorPhaseTimes* phase_times);
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    58
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    59
  // Convenience parallel version.  Uses ergo_workers() and active workers
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    60
  // to determine the number of threads to run.  Implicitly logs phase times.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    61
  // IsAlive must be derived from BoolObjectClosure.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    62
  // KeepAlive must be derived from OopClosure.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    63
  template<typename IsAlive, typename KeepAlive>
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    64
  static void weak_oops_do(WorkGang* workers,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    65
                           IsAlive* is_alive,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    66
                           KeepAlive* keep_alive,
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    67
                           uint indent_log);
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    68
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    69
  static uint ergo_workers(uint max_workers);
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    70
  class Task;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    71
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    72
private:
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    73
  class GangTask;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    74
};
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    75
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    76
class WeakProcessor::Task {
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    77
  typedef OopStorage::ParState<false, false> StorageState;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    78
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    79
  WeakProcessorPhaseTimes* _phase_times;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    80
  uint _nworkers;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    81
  SubTasksDone _serial_phases_done;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    82
  StorageState* _storage_states;
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    83
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    84
  void initialize();
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    85
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    86
public:
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    87
  Task(uint nworkers);          // No time tracking.
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    88
  Task(WeakProcessorPhaseTimes* phase_times, uint nworkers);
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    89
  ~Task();
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    90
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    91
  template<typename IsAlive, typename KeepAlive>
b9f6a4427da9 8072498: Multi-thread JNI weak reference processing
kbarrett
parents: 47676
diff changeset
    92
  void work(uint worker_id, IsAlive* is_alive, KeepAlive* keep_alive);
47648
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    93
};
226b1fc611b9 8189359: Move native weak oops cleaning out of ReferenceProcessor
stefank
parents:
diff changeset
    94
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 51546
diff changeset
    95
#endif // SHARE_GC_SHARED_WEAKPROCESSOR_HPP