1 /* 2 * Copyright (c) 2020, 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 #ifndef SHARE_COMPILER_COMPILEREVENT_HPP 25 #define SHARE_COMPILER_COMPILEREVENT_HPP 26 27 #include "jni.h" 28 #include "compiler/compilerDefinitions.hpp" 29 #include "jfr/jfrEvents.hpp" 30 #include "memory/allocation.hpp" 31 #include "utilities/macros.hpp" 32 #include "utilities/ticks.hpp" 33 34 #if INCLUDE_JFR 35 #include "jfr/utilities/jfrTime.hpp" 36 #endif 37 38 class ciMethod; 39 template <typename> 40 class GrowableArray; 41 class Method; 42 43 class CompilerEvent : AllStatic { 44 public: 45 static jlong ticksNow() { 46 // Using Ticks for consistent usage outside JFR folder. 47 JFR_ONLY(return JfrTime::is_ft_enabled() ? Ticks::now().ft_value() : Ticks::now().value();) NOT_JFR_RETURN_(0L); 48 } 49 50 class CompilationEvent : AllStatic { 51 public: 52 static void post(EventCompilation& event, int compile_id, CompilerType type, Method* method, int compile_level, bool success, bool is_osr, int code_size, int inlined_bytecodes) NOT_JFR_RETURN(); 53 }; 54 55 class CompilationFailureEvent : AllStatic { 56 public: 57 static void post(EventCompilationFailure& event, int compile_id, const char* reason) NOT_JFR_RETURN(); 58 }; 59 60 class PhaseEvent : AllStatic { 61 friend class CompilerPhaseTypeConstant; 62 public: 63 /** 64 * Register compiler phases for JFR type CompilerPhaseType serialization purposes. 65 * This method is called during compiler creation or during compilation. 66 * Registration will serialize the passed in phase constants, supporting bulk and/or incremental registrations. 67 * This method returns start index of new list that just got appended to phase_names. 68 * Param new_phases may contain duplicates. 69 * Return value could be used for mapping purpose at caller site, or caller can assume explicit order of registration. 70 */ 71 static int register_phases(GrowableArray<const char*>* new_phases) NOT_JFR_RETURN_(-1); 72 73 static void post(EventCompilerPhase& event, const Ticks& start_time, int phase, int compile_id, int level) NOT_JFR_RETURN(); 74 static void post(EventCompilerPhase& event, jlong start_time, int phase, int compile_id, int level) { 75 JFR_ONLY(post(event, Ticks(start_time), phase, compile_id, level);) 76 } 77 }; 78 79 class InlineEvent : AllStatic { 80 static void post(EventCompilerInlining& event, int compile_id, Method* caller, const JfrStructCalleeMethod& callee, bool success, const char* msg, int bci) NOT_JFR_RETURN(); 81 public: 82 static void post(EventCompilerInlining& event, int compile_id, Method* caller, Method* callee, bool success, const char* msg, int bci) NOT_JFR_RETURN(); 83 static void post(EventCompilerInlining& event, int compile_id, Method* caller, ciMethod* callee, bool success, const char* msg, int bci) NOT_JFR_RETURN(); 84 }; 85 }; 86 #endif // SHARE_COMPILER_COMPILEREVENT_HPP