src/share/vm/runtime/vmThread.hpp

Mon, 12 Aug 2019 18:30:40 +0300

author
apetushkov
date
Mon, 12 Aug 2019 18:30:40 +0300
changeset 9858
b985cbb00e68
parent 6973
4af19b914f53
child 7535
7ae4e26cb1e0
child 9904
4698900b8221
permissions
-rw-r--r--

8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens

duke@435 1 /*
mikael@4153 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 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.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_RUNTIME_VMTHREAD_HPP
stefank@2314 26 #define SHARE_VM_RUNTIME_VMTHREAD_HPP
stefank@2314 27
stefank@2314 28 #include "runtime/perfData.hpp"
stefank@4299 29 #include "runtime/thread.inline.hpp"
stefank@2314 30 #include "runtime/vm_operations.hpp"
stefank@2314 31
duke@435 32 //
duke@435 33 // Prioritized queue of VM operations.
duke@435 34 //
duke@435 35 // Encapsulates both queue management and
duke@435 36 // and priority policy
duke@435 37 //
zgu@3900 38 class VMOperationQueue : public CHeapObj<mtInternal> {
duke@435 39 private:
duke@435 40 enum Priorities {
duke@435 41 SafepointPriority, // Highest priority (operation executed at a safepoint)
duke@435 42 MediumPriority, // Medium priority
duke@435 43 nof_priorities
duke@435 44 };
duke@435 45
duke@435 46 // We maintain a doubled linked list, with explicit count.
duke@435 47 int _queue_length[nof_priorities];
duke@435 48 int _queue_counter;
duke@435 49 VM_Operation* _queue [nof_priorities];
duke@435 50 // we also allow the vmThread to register the ops it has drained so we
duke@435 51 // can scan them from oops_do
duke@435 52 VM_Operation* _drain_list;
duke@435 53
duke@435 54 // Double-linked non-empty list insert.
duke@435 55 void insert(VM_Operation* q,VM_Operation* n);
duke@435 56 void unlink(VM_Operation* q);
duke@435 57
duke@435 58 // Basic queue manipulation
duke@435 59 bool queue_empty (int prio);
duke@435 60 void queue_add_front (int prio, VM_Operation *op);
duke@435 61 void queue_add_back (int prio, VM_Operation *op);
duke@435 62 VM_Operation* queue_remove_front(int prio);
duke@435 63 void queue_oops_do(int queue, OopClosure* f);
duke@435 64 void drain_list_oops_do(OopClosure* f);
duke@435 65 VM_Operation* queue_drain(int prio);
duke@435 66 // lock-free query: may return the wrong answer but must not break
duke@435 67 bool queue_peek(int prio) { return _queue_length[prio] > 0; }
duke@435 68
duke@435 69 public:
duke@435 70 VMOperationQueue();
duke@435 71
duke@435 72 // Highlevel operations. Encapsulates policy
duke@435 73 bool add(VM_Operation *op);
duke@435 74 VM_Operation* remove_next(); // Returns next or null
duke@435 75 VM_Operation* remove_next_at_safepoint_priority() { return queue_remove_front(SafepointPriority); }
duke@435 76 VM_Operation* drain_at_safepoint_priority() { return queue_drain(SafepointPriority); }
duke@435 77 void set_drain_list(VM_Operation* list) { _drain_list = list; }
duke@435 78 bool peek_at_safepoint_priority() { return queue_peek(SafepointPriority); }
duke@435 79
duke@435 80 // GC support
duke@435 81 void oops_do(OopClosure* f);
duke@435 82
duke@435 83 void verify_queue(int prio) PRODUCT_RETURN;
duke@435 84 };
duke@435 85
duke@435 86
duke@435 87 //
duke@435 88 // A single VMThread (the primordial thread) spawns all other threads
duke@435 89 // and is itself used by other threads to offload heavy vm operations
duke@435 90 // like scavenge, garbage_collect etc.
duke@435 91 //
duke@435 92
minqi@1554 93 class VMThread: public NamedThread {
duke@435 94 private:
duke@435 95 static ThreadPriority _current_priority;
duke@435 96
duke@435 97 static bool _should_terminate;
duke@435 98 static bool _terminated;
duke@435 99 static Monitor * _terminate_lock;
duke@435 100 static PerfCounter* _perf_accumulated_vm_operation_time;
duke@435 101
duke@435 102 void evaluate_operation(VM_Operation* op);
duke@435 103 public:
duke@435 104 // Constructor
duke@435 105 VMThread();
duke@435 106
duke@435 107 // Tester
duke@435 108 bool is_VM_thread() const { return true; }
duke@435 109 bool is_GC_thread() const { return true; }
duke@435 110
duke@435 111 // The ever running loop for the VMThread
duke@435 112 void loop();
duke@435 113
duke@435 114 // Called to stop the VM thread
duke@435 115 static void wait_for_vm_thread_exit();
duke@435 116 static bool should_terminate() { return _should_terminate; }
duke@435 117 static bool is_terminated() { return _terminated == true; }
duke@435 118
duke@435 119 // Execution of vm operation
duke@435 120 static void execute(VM_Operation* op);
duke@435 121
duke@435 122 // Returns the current vm operation if any.
duke@435 123 static VM_Operation* vm_operation() { return _cur_vm_operation; }
duke@435 124
duke@435 125 // Returns the single instance of VMThread.
duke@435 126 static VMThread* vm_thread() { return _vm_thread; }
duke@435 127
duke@435 128 // GC support
stefank@6973 129 void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
duke@435 130
duke@435 131 // Debugging
duke@435 132 void print_on(outputStream* st) const;
duke@435 133 void print() const { print_on(tty); }
duke@435 134 void verify();
duke@435 135
duke@435 136 // Performance measurement
duke@435 137 static PerfCounter* perf_accumulated_vm_operation_time() { return _perf_accumulated_vm_operation_time; }
duke@435 138
duke@435 139 // Entry for starting vm thread
duke@435 140 virtual void run();
duke@435 141
duke@435 142 // Creations/Destructions
duke@435 143 static void create();
duke@435 144 static void destroy();
duke@435 145
duke@435 146 private:
duke@435 147 // VM_Operation support
duke@435 148 static VM_Operation* _cur_vm_operation; // Current VM operation
duke@435 149 static VMOperationQueue* _vm_queue; // Queue (w/ policy) of VM operations
duke@435 150
duke@435 151 // Pointer to single-instance of VM thread
duke@435 152 static VMThread* _vm_thread;
duke@435 153 };
stefank@2314 154
stefank@2314 155 #endif // SHARE_VM_RUNTIME_VMTHREAD_HPP

mercurial