--- old/src/hotspot/share/c1/c1_GraphBuilder.cpp 2020-05-13 10:15:01.608042336 -0700 +++ new/src/hotspot/share/c1/c1_GraphBuilder.cpp 2020-05-13 10:15:01.480037517 -0700 @@ -37,6 +37,7 @@ #include "compiler/compileBroker.hpp" #include "compiler/compilerEvent.hpp" #include "interpreter/bytecode.hpp" +#include "jfr/jfrEvents.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" #include "runtime/sharedRuntime.hpp" --- old/src/hotspot/share/ci/ciEnv.cpp 2020-05-13 10:15:02.156062964 -0700 +++ new/src/hotspot/share/ci/ciEnv.cpp 2020-05-13 10:15:02.028058146 -0700 @@ -44,6 +44,7 @@ #include "compiler/disassembler.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "interpreter/linkResolver.hpp" +#include "jfr/jfrEvents.hpp" #include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "memory/oopFactory.hpp" --- old/src/hotspot/share/compiler/compileBroker.cpp 2020-05-13 10:15:02.680082689 -0700 +++ new/src/hotspot/share/compiler/compileBroker.cpp 2020-05-13 10:15:02.552077871 -0700 @@ -37,6 +37,7 @@ #include "compiler/compilerOracle.hpp" #include "compiler/directivesParser.hpp" #include "interpreter/linkResolver.hpp" +#include "jfr/jfrEvents.hpp" #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" --- old/src/hotspot/share/compiler/compilerEvent.cpp 2020-05-13 10:15:03.220103017 -0700 +++ new/src/hotspot/share/compiler/compilerEvent.cpp 2020-05-13 10:15:03.088098048 -0700 @@ -25,6 +25,7 @@ #include "ci/ciMethod.hpp" #include "compiler/compilerEvent.hpp" #include "jfr/jfr.hpp" +#include "jfr/jfrEvents.hpp" #include "jfr/metadata/jfrSerializer.hpp" #include "runtime/semaphore.inline.hpp" #include "utilities/growableArray.hpp" --- old/src/hotspot/share/compiler/compilerEvent.hpp 2020-05-13 10:15:03.736122441 -0700 +++ new/src/hotspot/share/compiler/compilerEvent.hpp 2020-05-13 10:15:03.608117622 -0700 @@ -26,7 +26,6 @@ #include "jni.h" #include "compiler/compilerDefinitions.hpp" -#include "jfr/jfrEvents.hpp" #include "memory/allocation.hpp" #include "utilities/macros.hpp" #include "utilities/ticks.hpp" @@ -39,6 +38,11 @@ template class GrowableArray; class Method; +class EventCompilation; +class EventCompilationFailure; +class EventCompilerInlining; +class EventCompilerPhase; +struct JfrStructCalleeMethod; class CompilerEvent : AllStatic { public: --- old/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-05-13 10:15:04.252141865 -0700 +++ new/src/hotspot/share/gc/g1/g1CollectedHeap.cpp 2020-05-13 10:15:04.124137046 -0700 @@ -41,6 +41,7 @@ #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1FullCollector.hpp" +#include "gc/g1/g1GCParPhaseTimesTracker.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HeapSizingPolicy.hpp" #include "gc/g1/g1HeapTransition.hpp" --- old/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2020-05-13 10:15:04.800162493 -0700 +++ new/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2020-05-13 10:15:04.676157825 -0700 @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1GCParPhaseTimesTracker.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" --- old/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp 2020-05-13 10:15:05.316181917 -0700 +++ new/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp 2020-05-13 10:15:05.188177098 -0700 @@ -27,7 +27,6 @@ #include "gc/shared/referenceProcessorPhaseTimes.hpp" #include "gc/shared/weakProcessorPhaseTimes.hpp" -#include "jfr/jfrEvents.hpp" #include "logging/logLevel.hpp" #include "memory/allocation.hpp" #include "utilities/macros.hpp" @@ -457,28 +456,4 @@ void stop(); }; -class G1GCParPhaseTimesTracker : public CHeapObj { -protected: - Ticks _start_time; - G1GCPhaseTimes::GCParPhases _phase; - G1GCPhaseTimes* _phase_times; - uint _worker_id; - EventGCPhaseParallel _event; - bool _must_record; - -public: - G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id, bool must_record = true); - virtual ~G1GCParPhaseTimesTracker(); -}; - -class G1EvacPhaseTimesTracker : public G1GCParPhaseTimesTracker { - Tickspan _total_time; - Tickspan _trim_time; - - G1EvacPhaseWithTrimTimeTracker _trim_tracker; -public: - G1EvacPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1ParScanThreadState* pss, G1GCPhaseTimes::GCParPhases phase, uint worker_id); - virtual ~G1EvacPhaseTimesTracker(); -}; - #endif // SHARE_GC_G1_G1GCPHASETIMES_HPP --- old/src/hotspot/share/gc/g1/g1RemSet.cpp 2020-05-13 10:15:05.832201341 -0700 +++ new/src/hotspot/share/gc/g1/g1RemSet.cpp 2020-05-13 10:15:05.708196673 -0700 @@ -31,6 +31,7 @@ #include "gc/g1/g1ConcurrentRefine.hpp" #include "gc/g1/g1DirtyCardQueue.hpp" #include "gc/g1/g1FromCardCache.hpp" +#include "gc/g1/g1GCParPhaseTimesTracker.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1OopClosures.inline.hpp" --- old/src/hotspot/share/gc/g1/g1RootProcessor.cpp 2020-05-13 10:15:06.360221216 -0700 +++ new/src/hotspot/share/gc/g1/g1RootProcessor.cpp 2020-05-13 10:15:06.236216548 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, 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 @@ -32,6 +32,7 @@ #include "gc/g1/g1CodeBlobClosure.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1GCParPhaseTimesTracker.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" #include "gc/g1/g1Policy.hpp" --- old/src/hotspot/share/gc/g1/heapRegionManager.cpp 2020-05-13 10:15:06.876240640 -0700 +++ new/src/hotspot/share/gc/g1/heapRegionManager.cpp 2020-05-13 10:15:06.748235822 -0700 @@ -31,6 +31,7 @@ #include "gc/g1/heapRegionManager.inline.hpp" #include "gc/g1/heapRegionSet.inline.hpp" #include "gc/g1/heterogeneousHeapRegionManager.hpp" +#include "jfr/jfrEvents.hpp" #include "logging/logStream.hpp" #include "memory/allocation.hpp" #include "runtime/atomic.hpp" --- old/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp 2020-05-13 10:15:07.400260365 -0700 +++ new/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp 2020-05-13 10:15:07.272255547 -0700 @@ -32,6 +32,7 @@ #include "compiler/disassembler.hpp" #include "interpreter/linkResolver.hpp" #include "interpreter/bytecodeStream.hpp" +#include "jfr/jfrEvents.hpp" #include "jvmci/jvmciCompilerToVM.hpp" #include "jvmci/jvmciCodeInstaller.hpp" #include "jvmci/jvmciRuntime.hpp" --- old/src/hotspot/share/opto/bytecodeInfo.cpp 2020-05-13 10:15:07.940280692 -0700 +++ new/src/hotspot/share/opto/bytecodeInfo.cpp 2020-05-13 10:15:07.812275874 -0700 @@ -30,6 +30,7 @@ #include "compiler/compilerEvent.hpp" #include "compiler/compileLog.hpp" #include "interpreter/linkResolver.hpp" +#include "jfr/jfrEvents.hpp" #include "oops/objArrayKlass.hpp" #include "opto/callGenerator.hpp" #include "opto/parse.hpp" --- old/src/hotspot/share/opto/compile.cpp 2020-05-13 10:15:08.396297858 -0700 +++ new/src/hotspot/share/opto/compile.cpp 2020-05-13 10:15:08.268293039 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2020, 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 @@ -35,6 +35,7 @@ #include "compiler/oopMap.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/c2/barrierSetC2.hpp" +#include "jfr/jfrEvents.hpp" #include "memory/resourceArea.hpp" #include "opto/addnode.hpp" #include "opto/block.hpp" @@ -4562,6 +4563,39 @@ } } +void Compile::print_method(CompilerPhaseType cpt, int level, int idx) { + EventCompilerPhase event; + if (event.should_commit()) { + CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level); + } + +#ifndef PRODUCT + if (should_print(level)) { + char output[1024]; + if (idx != 0) { + jio_snprintf(output, sizeof(output), "%s:%d", CompilerPhaseTypeHelper::to_string(cpt), idx); + } else { + jio_snprintf(output, sizeof(output), "%s", CompilerPhaseTypeHelper::to_string(cpt)); + } + _printer->print_method(output, level); + } +#endif + C->_latest_stage_start_counter.stamp(); +} + +void Compile::end_method(int level) { + EventCompilerPhase event; + if (event.should_commit()) { + CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, PHASE_END, C->_compile_id, level); + } + +#ifndef PRODUCT + if (_printer && _printer->should_print(level)) { + _printer->end_method(); + } +#endif +} + #ifndef PRODUCT IdealGraphPrinter* Compile::_debug_file_printer = NULL; --- old/src/hotspot/share/opto/compile.hpp 2020-05-13 10:15:08.832314270 -0700 +++ new/src/hotspot/share/opto/compile.hpp 2020-05-13 10:15:08.704309452 -0700 @@ -631,25 +631,7 @@ #endif } - void print_method(CompilerPhaseType cpt, int level = 1, int idx = 0) { - EventCompilerPhase event; - if (event.should_commit()) { - CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level); - } - -#ifndef PRODUCT - if (should_print(level)) { - char output[1024]; - if (idx != 0) { - jio_snprintf(output, sizeof(output), "%s:%d", CompilerPhaseTypeHelper::to_string(cpt), idx); - } else { - jio_snprintf(output, sizeof(output), "%s", CompilerPhaseTypeHelper::to_string(cpt)); - } - _printer->print_method(output, level); - } -#endif - C->_latest_stage_start_counter.stamp(); - } + void print_method(CompilerPhaseType cpt, int level = 1, int idx = 0); #ifndef PRODUCT void igv_print_method_to_file(const char* phase_name = "Debug", bool append = false); @@ -658,18 +640,7 @@ static IdealGraphPrinter* debug_network_printer() { return _debug_network_printer; } #endif - void end_method(int level = 1) { - EventCompilerPhase event; - if (event.should_commit()) { - CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, PHASE_END, C->_compile_id, level); - } - -#ifndef PRODUCT - if (_printer && _printer->should_print(level)) { - _printer->end_method(); - } -#endif - } + void end_method(int level = 1); int macro_count() const { return _macro_nodes->length(); } int predicate_count() const { return _predicate_opaqs->length();} --- /dev/null 2019-11-19 22:05:02.069813242 -0800 +++ new/src/hotspot/share/gc/g1/g1GCParPhaseTimesTracker.hpp 2020-05-13 10:15:09.104324509 -0700 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020, 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_GC_G1_G1GCPARPHASETIMESTRACKER_HPP +#define SHARE_GC_G1_G1GCPARPHASETIMESTRACKER_HPP + +#include "gc/g1/g1GCPhaseTimes.hpp" +#include "jfr/jfrEvents.hpp" +#include "utilities/ticks.hpp" + +class G1GCParPhaseTimesTracker : public CHeapObj { +protected: + Ticks _start_time; + G1GCPhaseTimes::GCParPhases _phase; + G1GCPhaseTimes* _phase_times; + uint _worker_id; + EventGCPhaseParallel _event; + bool _must_record; + +public: + G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id, bool must_record = true); + virtual ~G1GCParPhaseTimesTracker(); +}; + +class G1EvacPhaseTimesTracker : public G1GCParPhaseTimesTracker { + Tickspan _total_time; + Tickspan _trim_time; + + G1EvacPhaseWithTrimTimeTracker _trim_tracker; +public: + G1EvacPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1ParScanThreadState* pss, G1GCPhaseTimes::GCParPhases phase, uint worker_id); + virtual ~G1EvacPhaseTimesTracker(); +}; + +#endif