# HG changeset patch # User Thomas Wuerthinger # Date 1339256143 -7200 # Node ID 20e390e09717a20d9d7c824ecee5e50a3ea41b76 # Parent 25d561cfdcfa01eca966b56881e1adcecec0b46a Convert ExceptionHandler class from interface to final data class. Remove CiExceptionHandler and HotSpotExceptionHandler classes and replace usages with ExceptionHandler class. diff -r 25d561cfdcfa -r 20e390e09717 graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiExceptionHandler.java --- a/graal/com.oracle.graal.api.code/src/com/oracle/graal/api/code/CiExceptionHandler.java Sat Jun 09 17:24:23 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.api.code; - -import com.oracle.graal.api.meta.*; - -/** - * An implementation of the {@link ExceptionHandler} interface. - */ -public class CiExceptionHandler implements ExceptionHandler { - - public static final CiExceptionHandler[] NONE = {}; - - public final int startBCI; - public final int endBCI; - public final int handlerBCI; - public final int catchTypeCPI; - public final JavaType catchType; - - /** - * Creates a new exception handler with the specified ranges. - * @param startBCI the start index of the protected range - * @param endBCI the end index of the protected range - * @param catchBCI the index of the handler - * @param catchTypeCPI the index of the throwable class in the constant pool - * @param catchType the type caught by this exception handler - */ - public CiExceptionHandler(int startBCI, int endBCI, int catchBCI, int catchTypeCPI, JavaType catchType) { - this.startBCI = startBCI; - this.endBCI = endBCI; - this.handlerBCI = catchBCI; - this.catchTypeCPI = catchTypeCPI; - this.catchType = catchType; - } - - public int startBCI() { - return startBCI; - } - - public int endBCI() { - return endBCI; - } - - public int handlerBCI() { - return handlerBCI; - } - - public int catchTypeCPI() { - return catchTypeCPI; - } - - public boolean isCatchAll() { - return catchTypeCPI == 0; - } - - public JavaType catchType() { - return catchType; - } - - @Override - public String toString() { - return new StringBuilder(20). - append('['). - append(startBCI). - append(" - "). - append(endBCI). - append(") -> "). - append(handlerBCI). - append(" type="). - append(catchType == null ? "*any*" : catchType.name()). - toString(); - } -} diff -r 25d561cfdcfa -r 20e390e09717 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantPool.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantPool.java Sat Jun 09 17:24:23 2012 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ConstantPool.java Sat Jun 09 17:35:43 2012 +0200 @@ -24,8 +24,8 @@ /** * Represents the runtime representation of the constant pool that is - * used by the compiler when parsing bytecode. The {@code lookupXXX} methods look up a constant - * pool entry without performing resolution, and are used during compilation. + * used by the compiler when parsing bytecode. Provides methods to look up a constant + * pool entry without performing resolution. They are used during compilation. */ public interface ConstantPool { diff -r 25d561cfdcfa -r 20e390e09717 graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java --- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java Sat Jun 09 17:24:23 2012 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/ExceptionHandler.java Sat Jun 09 17:35:43 2012 +0200 @@ -25,43 +25,76 @@ /** * Represents an exception handler within the bytecode. */ -public interface ExceptionHandler { +public final class ExceptionHandler { + private final int startBCI; + private final int endBCI; + private final int handlerBCI; + private final int catchTypeCPI; + private final JavaType catchType; + + /** + * Creates a new exception handler with the specified ranges. + * @param startBCI the start index of the protected range + * @param endBCI the end index of the protected range + * @param catchBCI the index of the handler + * @param catchTypeCPI the index of the throwable class in the constant pool + * @param catchType the type caught by this exception handler + */ + public ExceptionHandler(int startBCI, int endBCI, int catchBCI, int catchTypeCPI, JavaType catchType) { + this.startBCI = startBCI; + this.endBCI = endBCI; + this.handlerBCI = catchBCI; + this.catchTypeCPI = catchTypeCPI; + this.catchType = catchType; + } /** * Gets the start bytecode index of the protected range of this handler. * @return the start bytecode index */ - int startBCI(); + public int startBCI() { + return startBCI; + } /** * Gets the end bytecode index of the protected range of this handler. * @return the end bytecode index */ - int endBCI(); + public int endBCI() { + return endBCI; + } /** * Gets the bytecode index of the handler block of this handler. * @return the handler block bytecode index */ - int handlerBCI(); + public int handlerBCI() { + return handlerBCI; + } /** * Gets the index into the constant pool representing the type of exception * caught by this handler. * @return the constant pool index of the catch type */ - int catchTypeCPI(); + public int catchTypeCPI() { + return catchTypeCPI; + } /** * Checks whether this handler catches all exceptions. * @return {@code true} if this handler catches all exceptions */ - boolean isCatchAll(); + public boolean isCatchAll() { + return catchTypeCPI == 0; + } /** * The type of exception caught by this exception handler. * * @return the exception type */ - JavaType catchType(); + public JavaType catchType() { + return catchType; + } } diff -r 25d561cfdcfa -r 20e390e09717 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotExceptionHandler.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/ri/HotSpotExceptionHandler.java Sat Jun 09 17:24:23 2012 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.hotspot.ri; - -import com.oracle.graal.api.meta.*; -import com.oracle.graal.hotspot.*; - - -public final class HotSpotExceptionHandler extends CompilerObject implements ExceptionHandler { - private static final long serialVersionUID = 7110038548061733686L; - private int startBci; - private int endBci; - private int handlerBci; - private int catchClassIndex; - private JavaType catchClass; - - private HotSpotExceptionHandler() { - } - - @Override - public int startBCI() { - return startBci; - } - - @Override - public int endBCI() { - return endBci; - } - - @Override - public int handlerBCI() { - return handlerBci; - } - - @Override - public int catchTypeCPI() { - return catchClassIndex; - } - - @Override - public boolean isCatchAll() { - return catchClassIndex == 0; - } - - @Override - public JavaType catchType() { - return catchClass; - } - - @Override - public String toString() { - return String.format("HotSpotExceptionHandler[startBci=%d, endBci=%d, handlerBci=%d, catchClassIndex=%d, catchClass=%s", startBci, endBci, handlerBci, catchClassIndex, catchClass); - } -} diff -r 25d561cfdcfa -r 20e390e09717 src/share/vm/classfile/vmSymbols.hpp --- a/src/share/vm/classfile/vmSymbols.hpp Sat Jun 09 17:24:23 2012 +0200 +++ b/src/share/vm/classfile/vmSymbols.hpp Sat Jun 09 17:35:43 2012 +0200 @@ -280,7 +280,7 @@ template(com_oracle_graal_hotspot_HotSpotTypeResolved, "com/oracle/graal/hotspot/ri/HotSpotTypeResolvedImpl") \ template(com_oracle_graal_hotspot_HotSpotType, "com/oracle/graal/hotspot/ri/HotSpotType") \ template(com_oracle_graal_hotspot_HotSpotKlassOop, "com/oracle/graal/hotspot/ri/HotSpotKlassOop") \ - template(com_oracle_graal_hotspot_HotSpotExceptionHandler, "com/oracle/graal/hotspot/ri/HotSpotExceptionHandler") \ + template(com_oracle_graal_hotspot_HotSpotExceptionHandler, "com/oracle/graal/api/meta/ExceptionHandler") \ template(com_oracle_graal_hotspot_HotSpotProxy, "com/oracle/graal/hotspot/HotSpotProxy") \ template(com_oracle_graal_hotspot_CompilerImpl, "com/oracle/graal/hotspot/HotSpotGraalRuntime") \ template(com_oracle_max_cri_ri_RiMethod, "com/oracle/graal/api/meta/JavaMethod") \ diff -r 25d561cfdcfa -r 20e390e09717 src/share/vm/graal/graalCompilerToVM.cpp --- a/src/share/vm/graal/graalCompilerToVM.cpp Sat Jun 09 17:24:23 2012 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Sat Jun 09 17:35:43 2012 +0200 @@ -110,23 +110,23 @@ // exception handlers are stored as four integers: start bci, end bci, handler bci, catch class constant pool index int base = i * 4; Handle entry = instanceKlass::cast(HotSpotExceptionHandler::klass())->allocate_instance(CHECK_NULL); - HotSpotExceptionHandler::set_startBci(entry, handlers->int_at(base + 0)); - HotSpotExceptionHandler::set_endBci(entry, handlers->int_at(base + 1)); - HotSpotExceptionHandler::set_handlerBci(entry, handlers->int_at(base + 2)); + HotSpotExceptionHandler::set_startBCI(entry, handlers->int_at(base + 0)); + HotSpotExceptionHandler::set_endBCI(entry, handlers->int_at(base + 1)); + HotSpotExceptionHandler::set_handlerBCI(entry, handlers->int_at(base + 2)); int catch_class_index = handlers->int_at(base + 3); - HotSpotExceptionHandler::set_catchClassIndex(entry, catch_class_index); + HotSpotExceptionHandler::set_catchTypeCPI(entry, catch_class_index); if (catch_class_index == 0) { - HotSpotExceptionHandler::set_catchClass(entry, NULL); + HotSpotExceptionHandler::set_catchType(entry, NULL); } else { constantPoolOop cp = instanceKlass::cast(method->method_holder())->constants(); KlassHandle loading_klass = method->method_holder(); Handle catch_class = GraalCompiler::get_RiType(cp, catch_class_index, loading_klass, CHECK_NULL); if (catch_class->klass() == HotSpotTypeResolved::klass() && java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(catch_class)) == SystemDictionary::Throwable_klass()) { - HotSpotExceptionHandler::set_catchClass(entry, NULL); - HotSpotExceptionHandler::set_catchClassIndex(entry, 0); + HotSpotExceptionHandler::set_catchType(entry, NULL); + HotSpotExceptionHandler::set_catchTypeCPI(entry, 0); } else { - HotSpotExceptionHandler::set_catchClass(entry, catch_class()); + HotSpotExceptionHandler::set_catchType(entry, catch_class()); } } array->obj_at_put(i, entry()); diff -r 25d561cfdcfa -r 20e390e09717 src/share/vm/graal/graalJavaAccess.hpp --- a/src/share/vm/graal/graalJavaAccess.hpp Sat Jun 09 17:24:23 2012 +0200 +++ b/src/share/vm/graal/graalJavaAccess.hpp Sat Jun 09 17:35:43 2012 +0200 @@ -103,11 +103,11 @@ oop_field(HotSpotTargetMethod, exceptionHandlers, "[Lcom/oracle/graal/api/code/CiTargetMethod$ExceptionHandler;") \ end_class \ start_class(HotSpotExceptionHandler) \ - int_field(HotSpotExceptionHandler, startBci) \ - int_field(HotSpotExceptionHandler, endBci) \ - int_field(HotSpotExceptionHandler, handlerBci) \ - int_field(HotSpotExceptionHandler, catchClassIndex) \ - oop_field(HotSpotExceptionHandler, catchClass, "Lcom/oracle/graal/api/meta/JavaType;") \ + int_field(HotSpotExceptionHandler, startBCI) \ + int_field(HotSpotExceptionHandler, endBCI) \ + int_field(HotSpotExceptionHandler, handlerBCI) \ + int_field(HotSpotExceptionHandler, catchTypeCPI) \ + oop_field(HotSpotExceptionHandler, catchType, "Lcom/oracle/graal/api/meta/JavaType;") \ end_class \ start_class(CiTargetMethod) \ int_field(CiTargetMethod, frameSize) \