Mon, 12 Aug 2019 18:30:40 +0300
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
aoqi@0 | 1 | /* |
apetushkov@9858 | 2 | * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "runtime/os.hpp" |
apetushkov@9858 | 27 | #include "utilities/ticks.hpp" |
aoqi@0 | 28 | |
apetushkov@9858 | 29 | #ifdef X86 |
apetushkov@9858 | 30 | #include "rdtsc_x86.hpp" |
aoqi@0 | 31 | #endif |
aoqi@0 | 32 | |
apetushkov@9858 | 33 | template <typename TimeSource, const int unit> |
apetushkov@9858 | 34 | inline double conversion(typename TimeSource::Type& value) { |
apetushkov@9858 | 35 | return (double)value * ((double)unit / (double)TimeSource::frequency()); |
aoqi@0 | 36 | } |
aoqi@0 | 37 | |
apetushkov@9858 | 38 | uint64_t ElapsedCounterSource::frequency() { |
apetushkov@9858 | 39 | static const uint64_t freq = (uint64_t)os::elapsed_frequency(); |
apetushkov@9858 | 40 | return freq; |
aoqi@0 | 41 | } |
aoqi@0 | 42 | |
apetushkov@9858 | 43 | ElapsedCounterSource::Type ElapsedCounterSource::now() { |
apetushkov@9858 | 44 | return os::elapsed_counter(); |
aoqi@0 | 45 | } |
aoqi@0 | 46 | |
apetushkov@9858 | 47 | double ElapsedCounterSource::seconds(Type value) { |
apetushkov@9858 | 48 | return conversion<ElapsedCounterSource, 1>(value); |
aoqi@0 | 49 | } |
aoqi@0 | 50 | |
apetushkov@9858 | 51 | uint64_t ElapsedCounterSource::milliseconds(Type value) { |
apetushkov@9858 | 52 | return (uint64_t)conversion<ElapsedCounterSource, MILLIUNITS>(value); |
aoqi@0 | 53 | } |
aoqi@0 | 54 | |
apetushkov@9858 | 55 | uint64_t ElapsedCounterSource::microseconds(Type value) { |
apetushkov@9858 | 56 | return (uint64_t)conversion<ElapsedCounterSource, MICROUNITS>(value); |
aoqi@0 | 57 | } |
apetushkov@9858 | 58 | |
apetushkov@9858 | 59 | uint64_t ElapsedCounterSource::nanoseconds(Type value) { |
apetushkov@9858 | 60 | return (uint64_t)conversion<ElapsedCounterSource, NANOUNITS>(value); |
apetushkov@9858 | 61 | } |
apetushkov@9858 | 62 | |
apetushkov@9858 | 63 | uint64_t FastUnorderedElapsedCounterSource::frequency() { |
apetushkov@9858 | 64 | #ifdef X86 |
apetushkov@9858 | 65 | static bool valid_rdtsc = Rdtsc::initialize(); |
apetushkov@9858 | 66 | if (valid_rdtsc) { |
apetushkov@9858 | 67 | static const uint64_t freq = (uint64_t)Rdtsc::frequency(); |
apetushkov@9858 | 68 | return freq; |
apetushkov@9858 | 69 | } |
apetushkov@9858 | 70 | #endif |
apetushkov@9858 | 71 | static const uint64_t freq = (uint64_t)os::elapsed_frequency(); |
apetushkov@9858 | 72 | return freq; |
apetushkov@9858 | 73 | } |
apetushkov@9858 | 74 | |
apetushkov@9858 | 75 | FastUnorderedElapsedCounterSource::Type FastUnorderedElapsedCounterSource::now() { |
apetushkov@9858 | 76 | #ifdef X86 |
apetushkov@9858 | 77 | static bool valid_rdtsc = Rdtsc::initialize(); |
apetushkov@9858 | 78 | if (valid_rdtsc) { |
apetushkov@9858 | 79 | return Rdtsc::elapsed_counter(); |
apetushkov@9858 | 80 | } |
apetushkov@9858 | 81 | #endif |
apetushkov@9858 | 82 | return os::elapsed_counter(); |
apetushkov@9858 | 83 | } |
apetushkov@9858 | 84 | |
apetushkov@9858 | 85 | double FastUnorderedElapsedCounterSource::seconds(Type value) { |
apetushkov@9858 | 86 | return conversion<FastUnorderedElapsedCounterSource, 1>(value); |
apetushkov@9858 | 87 | } |
apetushkov@9858 | 88 | |
apetushkov@9858 | 89 | uint64_t FastUnorderedElapsedCounterSource::milliseconds(Type value) { |
apetushkov@9858 | 90 | return (uint64_t)conversion<FastUnorderedElapsedCounterSource, MILLIUNITS>(value); |
apetushkov@9858 | 91 | } |
apetushkov@9858 | 92 | |
apetushkov@9858 | 93 | uint64_t FastUnorderedElapsedCounterSource::microseconds(Type value) { |
apetushkov@9858 | 94 | return (uint64_t)conversion<FastUnorderedElapsedCounterSource, MICROUNITS>(value); |
apetushkov@9858 | 95 | } |
apetushkov@9858 | 96 | |
apetushkov@9858 | 97 | uint64_t FastUnorderedElapsedCounterSource::nanoseconds(Type value) { |
apetushkov@9858 | 98 | return (uint64_t)conversion<FastUnorderedElapsedCounterSource, NANOUNITS>(value); |
apetushkov@9858 | 99 | } |
apetushkov@9858 | 100 | |
apetushkov@9858 | 101 | uint64_t CompositeElapsedCounterSource::frequency() { |
apetushkov@9858 | 102 | return ElapsedCounterSource::frequency(); |
apetushkov@9858 | 103 | } |
apetushkov@9858 | 104 | |
apetushkov@9858 | 105 | CompositeElapsedCounterSource::Type CompositeElapsedCounterSource::now() { |
apetushkov@9858 | 106 | CompositeTime ct; |
apetushkov@9858 | 107 | ct.val1 = ElapsedCounterSource::now(); |
apetushkov@9858 | 108 | #ifdef X86 |
apetushkov@9858 | 109 | static bool initialized = false; |
apetushkov@9858 | 110 | static bool valid_rdtsc = false; |
apetushkov@9858 | 111 | if (!initialized) { |
apetushkov@9858 | 112 | valid_rdtsc = Rdtsc::initialize(); |
apetushkov@9858 | 113 | initialized = true; |
apetushkov@9858 | 114 | } |
apetushkov@9858 | 115 | if (valid_rdtsc) { |
apetushkov@9858 | 116 | ct.val2 = Rdtsc::elapsed_counter(); |
apetushkov@9858 | 117 | } |
apetushkov@9858 | 118 | #endif |
apetushkov@9858 | 119 | return ct; |
apetushkov@9858 | 120 | } |
apetushkov@9858 | 121 | |
apetushkov@9858 | 122 | double CompositeElapsedCounterSource::seconds(Type value) { |
apetushkov@9858 | 123 | return conversion<ElapsedCounterSource, 1>(value.val1); |
apetushkov@9858 | 124 | } |
apetushkov@9858 | 125 | |
apetushkov@9858 | 126 | uint64_t CompositeElapsedCounterSource::milliseconds(Type value) { |
apetushkov@9858 | 127 | return (uint64_t)conversion<ElapsedCounterSource, MILLIUNITS>(value.val1); |
apetushkov@9858 | 128 | } |
apetushkov@9858 | 129 | |
apetushkov@9858 | 130 | uint64_t CompositeElapsedCounterSource::microseconds(Type value) { |
apetushkov@9858 | 131 | return (uint64_t)conversion<ElapsedCounterSource, MICROUNITS>(value.val1); |
apetushkov@9858 | 132 | } |
apetushkov@9858 | 133 | |
apetushkov@9858 | 134 | uint64_t CompositeElapsedCounterSource::nanoseconds(Type value) { |
apetushkov@9858 | 135 | return (uint64_t)conversion<ElapsedCounterSource, NANOUNITS>(value.val1); |
apetushkov@9858 | 136 | } |