1 /* 2 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #include "precompiled.hpp" 25 #include "gc/z/zStat.hpp" 26 #include "gc/z/zTracer.hpp" 27 #include "gc/shared/gcId.hpp" 28 #include "gc/shared/gcLocker.hpp" 29 #include "jfr/jfrEvents.hpp" 30 #include "runtime/safepointVerifiers.hpp" 31 32 ZTracer* ZTracer::_tracer = NULL; 33 34 ZTracer::ZTracer() : 35 GCTracer(Z) {} 36 37 void ZTracer::initialize() { 38 _tracer = new (ResourceObj::C_HEAP, mtGC) ZTracer(); 39 } 40 41 void ZTracer::send_stat_counter(uint32_t counter_id, uint64_t increment, uint64_t value) { 42 NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint()); 43 44 EventZStatisticsCounter e; 45 if (e.should_commit()) { 46 e.set_id(counter_id); 47 e.set_increment(increment); 48 e.set_value(value); 49 e.commit(); 50 } 51 } 52 53 void ZTracer::send_stat_sampler(uint32_t sampler_id, uint64_t value) { 54 NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint()); 55 56 EventZStatisticsSampler e; 57 if (e.should_commit()) { 58 e.set_id(sampler_id); 59 e.set_value(value); 60 e.commit(); 61 } 62 } 63 64 void ZTracer::send_thread_phase(const char* name, const Ticks& start, const Ticks& end) { 65 NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint()); 66 67 EventZThreadPhase e(UNTIMED); 68 if (e.should_commit()) { 69 e.set_gcId(GCId::current_or_undefined()); 70 e.set_name(name); 71 e.set_starttime(start); 72 e.set_endtime(end); 73 e.commit(); 74 } 75 } 76 77 void ZTracer::send_page_alloc(size_t size, size_t used, size_t free, size_t cache, bool nonblocking, bool noreserve) { 78 NoSafepointVerifier nsv(true, !SafepointSynchronize::is_at_safepoint()); 79 80 EventZPageAllocation e; 81 if (e.should_commit()) { 82 e.set_pageSize(size); 83 e.set_usedAfter(used); 84 e.set_freeAfter(free); 85 e.set_inCacheAfter(cache); 86 e.set_nonBlocking(nonblocking); 87 e.set_noReserve(noreserve); 88 e.commit(); 89 } 90 } 91 92 void ZTracer::report_stat_counter(const ZStatCounter& counter, uint64_t increment, uint64_t value) { 93 send_stat_counter(counter.id(), increment, value); 94 } 95 96 void ZTracer::report_stat_sampler(const ZStatSampler& sampler, uint64_t value) { 97 send_stat_sampler(sampler.id(), value); 98 } 99 100 void ZTracer::report_thread_phase(const ZStatPhase& phase, const Ticks& start, const Ticks& end) { 101 send_thread_phase(phase.name(), start, end); 102 } 103 104 void ZTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) { 105 send_thread_phase(name, start, end); 106 } 107 108 void ZTracer::report_page_alloc(size_t size, size_t used, size_t free, size_t cache, ZAllocationFlags flags) { 109 send_page_alloc(size, used, free, cache, flags.non_blocking(), flags.no_reserve()); 110 }