1 /* 2 * Copyright (c) 2017, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11 * version 2 for more details (a copy is included in the LICENSE file that 12 * accompanied this code). 13 * 14 * You should have received a copy of the GNU General Public License version 15 * 2 along with this work; if not, write to the Free Software Foundation, 16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19 * or visit www.oracle.com if you need additional information or have any 20 * questions. 21 * 22 */ 23 24 #ifndef SHARE_VM_GC_SHENANDOAHUTILS_HPP 25 #define SHARE_VM_GC_SHENANDOAHUTILS_HPP 26 27 #include "runtime/vmThread.hpp" 28 #include "gc_implementation/shared/isGCActiveMark.hpp" 29 #include "gc_implementation/shared/vmGCOperations.hpp" 30 #include "memory/allocation.hpp" 31 #include "gc_implementation/shenandoah/shenandoahPhaseTimings.hpp" 32 33 class GCTimer; 34 35 class ShenandoahGCSession : public StackObj { 36 private: 37 GCTimer* _timer; 38 TraceMemoryManagerStats _trace_cycle; 39 public: 40 ShenandoahGCSession(); 41 ~ShenandoahGCSession(); 42 }; 43 44 class ShenandoahGCPhase : public StackObj { 45 private: 46 const ShenandoahPhaseTimings::Phase _phase; 47 public: 48 ShenandoahGCPhase(ShenandoahPhaseTimings::Phase phase); 49 ~ShenandoahGCPhase(); 50 }; 51 52 // Aggregates all the things that should happen before/after the pause. 53 class ShenandoahGCPauseMark : public StackObj { 54 private: 55 const SvcGCMarker _svc_gc_mark; 56 const IsGCActiveMark _is_gc_active_mark; 57 TraceMemoryManagerStats _trace_pause; 58 public: 59 ShenandoahGCPauseMark(SvcGCMarker::reason_type type); 60 ~ShenandoahGCPauseMark(); 61 }; 62 63 class ShenandoahAllocTrace : public StackObj { 64 private: 65 double _start; 66 size_t _size; 67 ShenandoahHeap::AllocType _alloc_type; 68 public: 69 ShenandoahAllocTrace(size_t words_size, ShenandoahHeap::AllocType alloc_type); 70 ~ShenandoahAllocTrace(); 71 }; 72 73 class ShenandoahSafepoint : public AllStatic { 74 public: 75 // check if Shenandoah GC safepoint is in progress 76 static inline bool is_at_shenandoah_safepoint() { 77 if (!SafepointSynchronize::is_at_safepoint()) return false; 78 79 VM_Operation* vm_op = VMThread::vm_operation(); 80 if (vm_op == NULL) return false; 81 82 VM_Operation::VMOp_Type type = vm_op->type(); 83 return type == VM_Operation::VMOp_ShenandoahInitMark || 84 type == VM_Operation::VMOp_ShenandoahFinalMarkStartEvac || 85 type == VM_Operation::VMOp_ShenandoahFinalEvac || 86 type == VM_Operation::VMOp_ShenandoahInitUpdateRefs || 87 type == VM_Operation::VMOp_ShenandoahFinalUpdateRefs || 88 type == VM_Operation::VMOp_ShenandoahFullGC || 89 type == VM_Operation::VMOp_ShenandoahDegeneratedGC; 90 } 91 }; 92 93 #endif // SHARE_VM_GC_SHENANDOAHUTILS_HPP