src/share/vm/gc_implementation/shared/concurrentGCThread.hpp

Wed, 31 Jul 2019 14:28:51 -0400

author
kbarrett
date
Wed, 31 Jul 2019 14:28:51 -0400
changeset 9787
9f28a4cac6d9
parent 7360
4e4ebe50c8e3
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

8048556: Unnecessary GCLocker-initiated young GCs
Summary: Fixed recognition of unnecessary GCLocker collections.
Reviewed-by: pliden, tschatzl
Contributed-by: johnc@azul.com

ysr@777 1 /*
mikael@6198 2 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
ysr@777 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ysr@777 4 *
ysr@777 5 * This code is free software; you can redistribute it and/or modify it
ysr@777 6 * under the terms of the GNU General Public License version 2 only, as
ysr@777 7 * published by the Free Software Foundation.
ysr@777 8 *
ysr@777 9 * This code is distributed in the hope that it will be useful, but WITHOUT
ysr@777 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ysr@777 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
ysr@777 12 * version 2 for more details (a copy is included in the LICENSE file that
ysr@777 13 * accompanied this code).
ysr@777 14 *
ysr@777 15 * You should have received a copy of the GNU General Public License version
ysr@777 16 * 2 along with this work; if not, write to the Free Software Foundation,
ysr@777 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ysr@777 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
ysr@777 22 *
ysr@777 23 */
ysr@777 24
stefank@2314 25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP
stefank@2314 26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP
stefank@2314 27
jprovino@4542 28 #include "utilities/macros.hpp"
pliden@6906 29 #include "gc_implementation/shared/suspendibleThreadSet.hpp"
stefank@2314 30 #include "runtime/thread.hpp"
ysr@777 31
ysr@777 32 class ConcurrentGCThread: public NamedThread {
ysr@777 33 friend class VMStructs;
ysr@777 34
ysr@777 35 protected:
iveresov@1229 36 bool _should_terminate;
iveresov@1229 37 bool _has_terminated;
ysr@777 38
ysr@777 39 enum CGC_flag_type {
ysr@777 40 CGC_nil = 0x0,
ysr@777 41 CGC_dont_suspend = 0x1,
ysr@777 42 CGC_CGC_safepoint = 0x2,
ysr@777 43 CGC_VM_safepoint = 0x4
ysr@777 44 };
ysr@777 45
ysr@777 46 static int _CGC_flag;
ysr@777 47
ysr@777 48 static bool CGC_flag_is_set(int b) { return (_CGC_flag & b) != 0; }
ysr@777 49 static int set_CGC_flag(int b) { return _CGC_flag |= b; }
ysr@777 50 static int reset_CGC_flag(int b) { return _CGC_flag &= ~b; }
ysr@777 51
ysr@777 52 // Create and start the thread (setting it's priority high.)
ysr@777 53 void create_and_start();
ysr@777 54
ysr@777 55 // Do initialization steps in the thread: record stack base and size,
ysr@777 56 // init thread local storage, set JNI handle block.
ysr@777 57 void initialize_in_thread();
ysr@777 58
ysr@777 59 // Wait until Universe::is_fully_initialized();
ysr@777 60 void wait_for_universe_init();
ysr@777 61
ysr@777 62 // Record that the current thread is terminating, and will do more
ysr@777 63 // concurrent work.
ysr@777 64 void terminate();
ysr@777 65
ysr@777 66 public:
ysr@777 67 // Constructor
ysr@777 68
ysr@777 69 ConcurrentGCThread();
ysr@777 70 ~ConcurrentGCThread() {} // Exists to call NamedThread destructor.
ysr@777 71
ysr@777 72 // Tester
ysr@777 73 bool is_ConcurrentGC_thread() const { return true; }
ysr@777 74 };
ysr@777 75
ysr@777 76 // The SurrogateLockerThread is used by concurrent GC threads for
ysr@777 77 // manipulating Java monitors, in particular, currently for
ysr@777 78 // manipulating the pending_list_lock. XXX
ysr@777 79 class SurrogateLockerThread: public JavaThread {
ysr@777 80 friend class VMStructs;
ysr@777 81 public:
ysr@777 82 enum SLT_msg_type {
ysr@777 83 empty = 0, // no message
ysr@777 84 acquirePLL, // acquire pending list lock
ysr@777 85 releaseAndNotifyPLL // notify and release pending list lock
ysr@777 86 };
ysr@777 87 private:
ysr@777 88 // the following are shared with the CMSThread
ysr@777 89 SLT_msg_type _buffer; // communication buffer
ysr@777 90 Monitor _monitor; // monitor controlling buffer
ysr@777 91 BasicLock _basicLock; // used for PLL locking
ysr@777 92
ysr@777 93 public:
ysr@777 94 static SurrogateLockerThread* make(TRAPS);
ysr@777 95
kbarrett@7360 96 // Terminate VM with error message that SLT needed but not yet created.
kbarrett@7360 97 static void report_missing_slt();
kbarrett@7360 98
ysr@777 99 SurrogateLockerThread();
ysr@777 100
ysr@777 101 bool is_hidden_from_external_view() const { return true; }
ysr@777 102
ysr@777 103 void loop(); // main method
ysr@777 104
ysr@777 105 void manipulatePLL(SLT_msg_type msg);
ysr@777 106
ysr@777 107 };
stefank@2314 108
stefank@2314 109 #endif // SHARE_VM_GC_IMPLEMENTATION_SHARED_CONCURRENTGCTHREAD_HPP

mercurial