1 /* 2 * Copyright (c) 2009, 2015, 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20 * CA 95054 USA or visit www.sun.com if you need additional information or 21 * have any questions. 22 * 23 */ 24 package com.sun.hotspot.tools.compiler; 25 26 import java.io.PrintStream; 27 28 /** 29 * An instance of this class represents an uncommon trap associated with a 30 * given bytecode instruction. An uncommon trap is described in terms of its 31 * reason and action to be taken. An instance of this class is always relative 32 * to a specific method and only contains the relevant bytecode instruction 33 * index. 34 */ 35 class UncommonTrap { 36 37 private int bci; 38 private String reason; 39 private String action; 40 private String bytecode; 41 42 public UncommonTrap(int b, String r, String a, String bc) { 43 bci = b; 44 reason = r; 45 action = a; 46 bytecode = bc; 47 } 48 49 public int getBCI() { 50 return bci; 51 } 52 53 public String getReason() { 54 return reason; 55 } 56 57 public String getAction() { 58 return action; 59 } 60 61 public String getBytecode() { 62 return bytecode; 63 } 64 65 void emit(PrintStream stream, int indent) { 66 for (int i = 0; i < indent; i++) { 67 stream.print(' '); 68 } 69 } 70 71 public void print(PrintStream stream, int indent) { 72 emit(stream, indent); 73 stream.println(this); 74 } 75 76 public String toString() { 77 return "@ " + bci + " " + getBytecode() + " uncommon trap " + getReason() + " " + getAction(); 78 } 79 }