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 /** 26 * An empty implementation for {@link EventProvider}. This implementation is used when no logging is 27 * requested. 28 */ 29 final class EmptyEventProvider implements EventProvider { 30 31 static InternalError shouldNotReachHere() { 32 throw new InternalError("should not reach here"); 33 } 34 35 @Override 36 public CompilationEvent newCompilationEvent() { 37 return new EmptyCompilationEvent(); 38 } 39 40 static class EmptyCompilationEvent implements CompilationEvent { 41 public void commit() { 42 throw shouldNotReachHere(); 43 } 44 45 public boolean shouldWrite() { 46 // Events of this class should never been written. 47 return false; 48 } 49 50 public void begin() { 51 } 52 53 public void end() { 54 } 55 56 public void setMethod(String method) { 57 throw shouldNotReachHere(); 58 } 59 60 public void setCompileId(int compileId) { 61 throw shouldNotReachHere(); 62 } 63 64 public void setCompileLevel(int compileLevel) { 65 throw shouldNotReachHere(); 66 } 67 68 public void setSucceeded(boolean succeeded) { 69 throw shouldNotReachHere(); 70 } 71 72 public void setIsOsr(boolean isOsr) { 73 throw shouldNotReachHere(); 74 } 75 76 public void setCodeSize(int codeSize) { 77 throw shouldNotReachHere(); 78 } 79 80 public void setInlinedBytes(int inlinedBytes) { 81 throw shouldNotReachHere(); 82 } 83 } 84 85 @Override 86 public CompilerFailureEvent newCompilerFailureEvent() { 87 return new EmptyCompilerFailureEvent(); 88 } 89 90 static class EmptyCompilerFailureEvent implements CompilerFailureEvent { 91 public void commit() { 92 throw shouldNotReachHere(); 93 } 94 95 public boolean shouldWrite() { 96 // Events of this class should never been written. 97 return false; 98 } 99 100 public void setCompileId(int compileId) { 101 throw shouldNotReachHere(); 102 } 103 104 public void setMessage(String message) { 105 throw shouldNotReachHere(); 106 } 107 } 108 109 }