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; 24 25 import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilationEvent; 26 import jdk.vm.ci.hotspot.EmptyEventProvider.EmptyCompilerFailureEvent; 27 import jdk.vm.ci.services.JVMCIPermission; 28 29 /** 30 * Service-provider class for logging compiler related events. 31 */ 32 public interface EventProvider { 33 34 /** 35 * Creates and returns an empty implementation for {@link EventProvider}. This implementation 36 * can be used when no logging is requested. 37 */ 38 static EventProvider createEmptyEventProvider() { 39 return new EmptyEventProvider(); 40 } 41 42 /** 43 * Creates and returns an empty implementation for {@link CompilationEvent}. 44 */ 45 static CompilationEvent createEmptyCompilationEvent() { 46 return new EmptyCompilationEvent(); 47 } 48 49 /** 50 * Creates and returns an empty implementation for {@link CompilationEvent}. 51 */ 52 static CompilerFailureEvent createEmptyCompilerFailureEvent() { 53 return new EmptyCompilerFailureEvent(); 54 } 55 56 /** 57 * An instant event is an event that is not considered to have taken any time. 58 */ 59 public interface InstantEvent { 60 /** 61 * Commits the event. 62 */ 63 void commit(); 64 65 /** 66 * Determines if this particular event instance would be committed to the data stream right 67 * now if application called {@link #commit()}. This in turn depends on whether the event is 68 * enabled and possible other factors. 69 * 70 * @return if this event would be committed on a call to {@link #commit()}. 71 */ 72 boolean shouldWrite(); 73 } 74 75 /** 76 * Timed events describe an operation that somehow consumes time. 77 */ 78 public interface TimedEvent extends InstantEvent { 79 /** 80 * Starts the timing for this event. 81 */ 82 void begin(); 83 84 /** 85 * Ends the timing period for this event. 86 */ 87 void end(); 88 } 89 90 /** 91 * Creates a new {@link CompilationEvent}. 92 * 93 * @return a compilation event 94 */ 95 public abstract CompilationEvent newCompilationEvent(); 96 97 /** 98 * A compilation event. 99 */ 100 public interface CompilationEvent extends TimedEvent { 101 void setMethod(String method); 102 103 void setCompileId(int compileId); 104 105 void setCompileLevel(int compileLevel); 106 107 void setSucceeded(boolean succeeded); 108 109 void setIsOsr(boolean isOsr); 110 111 void setCodeSize(int codeSize); 112 113 void setInlinedBytes(int inlinedBytes); 114 } 115 116 /** 117 * Creates a new {@link CompilerFailureEvent}. 118 * 119 * @return a compiler failure event 120 */ 121 public abstract CompilerFailureEvent newCompilerFailureEvent(); 122 123 /** 124 * A compiler failure event. 125 */ 126 public interface CompilerFailureEvent extends InstantEvent { 127 void setCompileId(int compileId); 128 129 void setMessage(String message); 130 } 131 }