| /* |
| * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. |
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| * |
| * This code is free software; you can redistribute it and/or modify it |
| * under the terms of the GNU General Public License version 2 only, as |
| * published by the Free Software Foundation. |
| * |
| * This code is distributed in the hope that it will be useful, but WITHOUT |
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| * version 2 for more details (a copy is included in the LICENSE file that |
| * accompanied this code). |
| * |
| * You should have received a copy of the GNU General Public License version |
| * 2 along with this work; if not, write to the Free Software Foundation, |
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| * |
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| * or visit www.oracle.com if you need additional information or have any |
| * questions. |
| * |
| */ |
| |
| #ifndef SHARE_RUNTIME_VMOPERATION_HPP |
| #define SHARE_RUNTIME_VMOPERATION_HPP |
| |
| #include "memory/allocation.hpp" |
| |
| // The following classes are used for operations |
| // initiated by a Java thread but that must |
| // take place in the VMThread. |
| |
| #define VM_OP_ENUM(type) VMOp_##type, |
| |
| // Note: When new VM_XXX comes up, add 'XXX' to the template table. |
| #define VM_OPS_DO(template) \ |
| template(Halt) \ |
| template(SafepointALot) \ |
| template(Cleanup) \ |
| template(ThreadDump) \ |
| template(PrintThreads) \ |
| template(FindDeadlocks) \ |
| template(ClearICs) \ |
| template(ForceSafepoint) \ |
| template(DeoptimizeFrame) \ |
| template(DeoptimizeAll) \ |
| template(ZombieAll) \ |
| template(Verify) \ |
| template(HeapDumper) \ |
| template(CollectForMetadataAllocation) \ |
| template(CollectForCodeCacheAllocation) \ |
| template(GC_HeapInspection) \ |
| template(GenCollectFull) \ |
| template(GenCollectForAllocation) \ |
| template(ParallelGCFailedAllocation) \ |
| template(ParallelGCSystemGC) \ |
| template(G1CollectForAllocation) \ |
| template(G1CollectFull) \ |
| template(G1PauseRemark) \ |
| template(G1PauseCleanup) \ |
| template(G1TryInitiateConcMark) \ |
| template(ZMarkEndOld) \ |
| template(ZMarkEndYoung) \ |
| template(ZMarkFlushOperation) \ |
| template(ZMarkStartYoung) \ |
| template(ZMarkStartYoungAndOld) \ |
| template(ZRelocateStartOld) \ |
| template(ZRelocateStartYoung) \ |
| template(ZRendezvousGCThreads) \ |
| template(ZVerifyOld) \ |
| template(XMarkStart) \ |
| template(XMarkEnd) \ |
| template(XRelocateStart) \ |
| template(XVerify) \ |
| template(HandshakeAllThreads) \ |
| template(PopulateDumpSharedSpace) \ |
| template(JNIFunctionTableCopier) \ |
| template(RedefineClasses) \ |
| template(GetObjectMonitorUsage) \ |
| template(GetAllStackTraces) \ |
| template(GetThreadListStackTraces) \ |
| template(VirtualThreadGetStackTrace) \ |
| template(VirtualThreadGetFrameCount) \ |
| template(ChangeBreakpoints) \ |
| template(GetOrSetLocal) \ |
| template(VirtualThreadGetOrSetLocal) \ |
| template(VirtualThreadGetCurrentLocation) \ |
| template(ChangeSingleStep) \ |
| template(SetNotifyJvmtiEventsMode) \ |
| template(HeapWalkOperation) \ |
| template(HeapIterateOperation) \ |
| template(ReportJavaOutOfMemory) \ |
| template(JFRCheckpoint) \ |
| template(ShenandoahFullGC) \ |
| template(ShenandoahInitMark) \ |
| template(ShenandoahFinalMarkStartEvac) \ |
| template(ShenandoahInitUpdateRefs) \ |
| template(ShenandoahFinalUpdateRefs) \ |
| template(ShenandoahFinalRoots) \ |
| template(ShenandoahDegeneratedGC) \ |
| template(Exit) \ |
| template(LinuxDllLoad) \ |
| template(WhiteBoxOperation) \ |
| template(JVMCIResizeCounters) \ |
| template(ClassLoaderStatsOperation) \ |
| template(ClassLoaderHierarchyOperation) \ |
| template(DumpHashtable) \ |
| template(CleanClassLoaderDataMetaspaces) \ |
| template(PrintCompileQueue) \ |
| template(PrintClassHierarchy) \ |
| template(PrintClasses) \ |
| template(ICBufferFull) \ |
| template(PrintMetadata) \ |
| template(GTestExecuteAtSafepoint) \ |
| template(GTestStopSafepoint) \ |
| template(JFROldObject) \ |
| template(JvmtiPostObjectFree) \ |
| template(RendezvousGCThreads) |
| |
| class Thread; |
| class outputStream; |
| |
| class VM_Operation : public StackObj { |
| public: |
| enum VMOp_Type { |
| VM_OPS_DO(VM_OP_ENUM) |
| VMOp_Terminating |
| }; |
| |
| private: |
| Thread* _calling_thread; |
| |
| // The VM operation name array |
| static const char* _names[]; |
| |
| public: |
| VM_Operation() : _calling_thread(nullptr) {} |
| |
| // VM operation support (used by VM thread) |
| Thread* calling_thread() const { return _calling_thread; } |
| void set_calling_thread(Thread* thread); |
| |
| // Called by VM thread - does in turn invoke doit(). Do not override this |
| void evaluate(); |
| |
| // evaluate() is called by the VMThread and in turn calls doit(). |
| // If the thread invoking VMThread::execute((VM_Operation*) is a JavaThread, |
| // doit_prologue() is called in that thread before transferring control to |
| // the VMThread. |
| // If doit_prologue() returns true the VM operation will proceed, and |
| // doit_epilogue() will be called by the JavaThread once the VM operation |
| // completes. If doit_prologue() returns false the VM operation is cancelled. |
| virtual void doit() = 0; |
| virtual bool doit_prologue() { return true; }; |
| virtual void doit_epilogue() {}; |
| |
| // Configuration. Override these appropriately in subclasses. |
| virtual VMOp_Type type() const = 0; |
| virtual bool allow_nested_vm_operations() const { return false; } |
| |
| // You may override skip_thread_oop_barriers to return true if the operation |
| // does not access thread-private oops (including frames). |
| virtual bool skip_thread_oop_barriers() const { return false; } |
| |
| // An operation can either be done inside a safepoint |
| // or concurrently with Java threads running. |
| virtual bool evaluate_at_safepoint() const { return true; } |
| |
| // Debugging |
| virtual void print_on_error(outputStream* st) const; |
| virtual const char* name() const { return _names[type()]; } |
| static const char* name(int type) { |
| assert(type >= 0 && type < VMOp_Terminating, "invalid VM operation type"); |
| return _names[type]; |
| } |
| // Extra information about what triggered this operation. |
| virtual const char* cause() const { return nullptr; } |
| #ifndef PRODUCT |
| void print_on(outputStream* st) const { print_on_error(st); } |
| #endif |
| }; |
| |
| #endif // SHARE_RUNTIME_VMOPERATION_HPP |