src/hotspot/share/gc/shared/concurrentGCThread.hpp
author tschatzl
Tue, 29 May 2018 09:26:00 +0200
changeset 50605 7f63c74f0974
parent 47216 71c04702a3d5
child 53244 9807daeb47c4
permissions -rw-r--r--
8202845: Refactor reference processing for improved parallelism Summary: Fold reference processing's nine phases into four to decrease startup and termination time of this phase. Reviewed-by: kbarrett, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
36082
e734f3a55bdf 8136854: G1 ConcurrentG1RefineThread::stop delays JVM shutdown for >150ms
tschatzl
parents: 33123
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 27678
diff changeset
    25
#ifndef SHARE_VM_GC_SHARED_CONCURRENTGCTHREAD_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 27678
diff changeset
    26
#define SHARE_VM_GC_SHARED_CONCURRENTGCTHREAD_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 27678
diff changeset
    28
#include "runtime/thread.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 9990
diff changeset
    29
#include "utilities/macros.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    30
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    31
class ConcurrentGCThread: public NamedThread {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    32
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
36082
e734f3a55bdf 8136854: G1 ConcurrentG1RefineThread::stop delays JVM shutdown for >150ms
tschatzl
parents: 33123
diff changeset
    34
  bool volatile _should_terminate;
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 1374
diff changeset
    35
  bool _has_terminated;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
  // Do initialization steps in the thread: record stack base and size,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
  // init thread local storage, set JNI handle block.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
  void initialize_in_thread();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
  // Wait until Universe::is_fully_initialized();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
  void wait_for_universe_init();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
  // Record that the current thread is terminating, and will do more
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
  // concurrent work.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
  void terminate();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    48
protected:
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    49
  // Create and start the thread (setting it's priority.)
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    50
  void create_and_start(ThreadPriority prio = NearMaxPriority);
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    51
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    52
  // Do the specific GC work. Called by run() after initialization complete.
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    53
  virtual void run_service() = 0;
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    54
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    55
  // Shut down the specific GC work. Called by stop() as part of termination protocol.
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    56
  virtual void stop_service()  = 0;
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    57
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
  ConcurrentGCThread();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
  // Tester
33123
8a67e36f19d3 8138846: Remove unused enum ConcurrentGCThread::CGC_flag_type
pliden
parents: 30770
diff changeset
    62
  bool is_ConcurrentGC_thread() const { return true; }
37081
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    63
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    64
  virtual void run();
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    65
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    66
  // shutdown following termination protocol
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    67
  virtual void stop();
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    68
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    69
  bool should_terminate() { return _should_terminate; }
7656f5356a5d 8140257: Add support for "gc service threads" to ConcurrentGCThread
drwhite
parents: 36082
diff changeset
    70
  bool has_terminated()   { return _has_terminated; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 27678
diff changeset
    73
#endif // SHARE_VM_GC_SHARED_CONCURRENTGCTHREAD_HPP