1 /*
   2  * Copyright (c) 2014, 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 package jdk.vm.ci.hotspot.events;
  24 
  25 /**
  26  * A provider that provides a specific implementation for events that can be logged in the compiler.
  27  */
  28 public interface EventProvider {
  29 
  30     /**
  31      * An instant event is an event that is not considered to have taken any time.
  32      */
  33     interface InstantEvent {
  34         /**
  35          * Commits the event.
  36          */
  37         void commit();
  38 
  39         /**
  40          * Determines if this particular event instance would be committed to the data stream right
  41          * now if application called {@link #commit()}. This in turn depends on whether the event is
  42          * enabled and possible other factors.
  43          *
  44          * @return if this event would be committed on a call to {@link #commit()}.
  45          */
  46         boolean shouldWrite();
  47     }
  48 
  49     /**
  50      * Timed events describe an operation that somehow consumes time.
  51      */
  52     interface TimedEvent extends InstantEvent {
  53         /**
  54          * Starts the timing for this event.
  55          */
  56         void begin();
  57 
  58         /**
  59          * Ends the timing period for this event.
  60          */
  61         void end();
  62     }
  63 
  64     /**
  65      * Creates a new {@link CompilationEvent}.
  66      *
  67      * @return a compilation event
  68      */
  69     CompilationEvent newCompilationEvent();
  70 
  71     /**
  72      * A compilation event.
  73      */
  74     interface CompilationEvent extends TimedEvent {
  75         void setMethod(String method);
  76 
  77         void setCompileId(int compileId);
  78 
  79         void setCompileLevel(int compileLevel);
  80 
  81         void setSucceeded(boolean succeeded);
  82 
  83         void setIsOsr(boolean isOsr);
  84 
  85         void setCodeSize(int codeSize);
  86 
  87         void setInlinedBytes(int inlinedBytes);
  88     }
  89 
  90     /**
  91      * Creates a new {@link CompilerFailureEvent}.
  92      *
  93      * @return a compiler failure event
  94      */
  95     CompilerFailureEvent newCompilerFailureEvent();
  96 
  97     /**
  98      * A compiler failure event.
  99      */
 100     interface CompilerFailureEvent extends InstantEvent {
 101         void setCompileId(int compileId);
 102 
 103         void setMessage(String message);
 104     }
 105 }