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 
  25 #ifndef SHARE_OPTO_COMPILE_INLINE_HPP
  26 #define SHARE_OPTO_COMPILE_INLINE__HPP
  27 
  28 #include "jfr/jfrEvents.hpp"
  29 #include "opto/compile.hpp"
  30 
  31 void Compile::print_method(CompilerPhaseType cpt, int level, int idx) {
  32   EventCompilerPhase event;
  33   if (event.should_commit()) {
  34     CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, cpt, C->_compile_id, level);
  35   }
  36 
  37 #ifndef PRODUCT
  38   if (should_print(level)) {
  39     char output[1024];
  40     if (idx != 0) {
  41       jio_snprintf(output, sizeof(output), "%s:%d", CompilerPhaseTypeHelper::to_string(cpt), idx);
  42     } else {
  43       jio_snprintf(output, sizeof(output), "%s", CompilerPhaseTypeHelper::to_string(cpt));
  44     }
  45     _printer->print_method(output, level);
  46   }
  47 #endif
  48   C->_latest_stage_start_counter.stamp();
  49 }
  50 
  51 void Compile::end_method(int level) {
  52   EventCompilerPhase event;
  53   if (event.should_commit()) {
  54     CompilerEvent::PhaseEvent::post(event, C->_latest_stage_start_counter, PHASE_END, C->_compile_id, level);
  55   }
  56 
  57 #ifndef PRODUCT
  58   if (_printer && _printer->should_print(level)) {
  59     _printer->end_method();
  60   }
  61 #endif
  62 }
  63 
  64 #endif