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 "gc/shared/isGCActiveMark.hpp" 28 #include "gc/shared/vmGCOperations.hpp" 29 #include "gc/shenandoah/shenandoahPhaseTimings.hpp" 30 #include "memory/allocation.hpp" 31 #include "runtime/safepoint.hpp" 32 #include "runtime/vmThread.hpp" 33 #include "runtime/vm_operations.hpp" 34 #include "services/memoryService.hpp" 35 36 class GCTimer; 37 38 class ShenandoahGCSession : public StackObj { 39 private: 40 GCTimer* _timer; 41 TraceMemoryManagerStats _trace_cycle; 42 public: 43 ShenandoahGCSession(); 44 ~ShenandoahGCSession(); 45 }; 46 47 class ShenandoahGCPhase : public StackObj { 48 private: 49 const ShenandoahPhaseTimings::Phase _phase; 50 public: 51 ShenandoahGCPhase(ShenandoahPhaseTimings::Phase phase); 52 ~ShenandoahGCPhase(); 53 }; 54 55 // Aggregates all the things that should happen before/after the pause. 56 class ShenandoahGCPauseMark : public StackObj { 57 private: 58 const GCIdMark _gc_id_mark; 59 const SvcGCMarker _svc_gc_mark; 60 const IsGCActiveMark _is_gc_active_mark; 61 TraceMemoryManagerStats _trace_pause; 62 public: 63 ShenandoahGCPauseMark(uint gc_id, SvcGCMarker::reason_type type); 64 ~ShenandoahGCPauseMark(); 65 }; 66 67 class ShenandoahAllocTrace : public StackObj { 68 private: 69 double _start; 70 size_t _size; 71 ShenandoahHeap::AllocType _alloc_type; 72 public: 73 ShenandoahAllocTrace(size_t words_size, ShenandoahHeap::AllocType alloc_type); 74 ~ShenandoahAllocTrace(); 75 }; 76 77 class ShenandoahSafepoint : public AllStatic { 78 public: 79 // check if Shenandoah GC safepoint is in progress 80 static inline bool is_at_shenandoah_safepoint() { 81 if (!SafepointSynchronize::is_at_safepoint()) return false; 82 83 VM_Operation* vm_op = VMThread::vm_operation(); 84 if (vm_op == NULL) return false; 85 86 VM_Operation::VMOp_Type type = vm_op->type(); 87 return type == VM_Operation::VMOp_ShenandoahInitMark || 88 type == VM_Operation::VMOp_ShenandoahFinalMarkStartEvac || 89 type == VM_Operation::VMOp_ShenandoahFinalEvac || 90 type == VM_Operation::VMOp_ShenandoahInitTraversalGC || 91 type == VM_Operation::VMOp_ShenandoahFinalTraversalGC || 92 type == VM_Operation::VMOp_ShenandoahInitUpdateRefs || 93 type == VM_Operation::VMOp_ShenandoahFinalUpdateRefs || 94 type == VM_Operation::VMOp_ShenandoahFullGC || 95 type == VM_Operation::VMOp_ShenandoahDegeneratedGC; 96 } 97 }; 98 99 #endif // SHARE_VM_GC_SHENANDOAHUTILS_HPP