aoqi@0: /* aoqi@0: * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_CI_CIEXCEPTIONHANDLER_HPP aoqi@0: #define SHARE_VM_CI_CIEXCEPTIONHANDLER_HPP aoqi@0: aoqi@0: #include "ci/ciClassList.hpp" aoqi@0: #include "ci/ciInstanceKlass.hpp" aoqi@0: aoqi@0: // ciExceptionHandler aoqi@0: // aoqi@0: // This class represents an exception handler for a method. aoqi@0: class ciExceptionHandler : public ResourceObj { aoqi@0: private: aoqi@0: friend class ciMethod; aoqi@0: aoqi@0: // The loader to be used for resolving the exception aoqi@0: // klass. aoqi@0: ciInstanceKlass* _loading_klass; aoqi@0: aoqi@0: // Handler data. aoqi@0: int _start; aoqi@0: int _limit; aoqi@0: int _handler_bci; aoqi@0: int _catch_klass_index; aoqi@0: aoqi@0: // The exception klass that this handler catches. aoqi@0: ciInstanceKlass* _catch_klass; aoqi@0: aoqi@0: public: aoqi@0: ciExceptionHandler(ciInstanceKlass* loading_klass, aoqi@0: int start, int limit, aoqi@0: int handler_bci, int klass_index) { aoqi@0: _loading_klass = loading_klass; aoqi@0: _start = start; aoqi@0: _limit = limit; aoqi@0: _handler_bci = handler_bci; aoqi@0: _catch_klass_index = klass_index; aoqi@0: _catch_klass = NULL; aoqi@0: } aoqi@0: aoqi@0: int start() { return _start; } aoqi@0: int limit() { return _limit; } aoqi@0: int handler_bci() { return _handler_bci; } aoqi@0: int catch_klass_index() { return _catch_klass_index; } aoqi@0: aoqi@0: // Get the exception klass that this handler catches. aoqi@0: ciInstanceKlass* catch_klass(); aoqi@0: aoqi@0: bool is_catch_all() { return catch_klass_index() == 0; } aoqi@0: bool is_in_range(int bci) { aoqi@0: return start() <= bci && bci < limit(); aoqi@0: } aoqi@0: bool catches(ciInstanceKlass *exc) { aoqi@0: return is_catch_all() || exc->is_subtype_of(catch_klass()); aoqi@0: } aoqi@0: bool is_rethrow() { return handler_bci() == -1; } aoqi@0: aoqi@0: void print(); aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_CI_CIEXCEPTIONHANDLER_HPP