Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/code/exceptionHandlerTable.hpp
32285 views
/*1* Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP25#define SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP2627#include "memory/allocation.hpp"28#include "oops/method.hpp"2930// A HandlerTableEntry describes an individual entry of a subtable31// of ExceptionHandlerTable. An entry consists of a pair(bci, pco),32// where bci is the exception handler bci, and pco is the pc offset33// relative to the nmethod code start for the compiled exception34// handler corresponding to the (interpreted) exception handler35// starting at bci.36//37// The first HandlerTableEntry of each subtable holds the length38// and catch_pco for the subtable (the length is the number of39// subtable entries w/o header).4041class HandlerTableEntry {42private:43int _bci;44int _pco;45int _scope_depth;4647public:48HandlerTableEntry(int bci, int pco, int scope_depth) {49assert( 0 <= pco, "pco must be positive");50assert( 0 <= scope_depth, "scope_depth must be positive");51_bci = bci;52_pco = pco;53_scope_depth = scope_depth;54}5556int len() const { return _bci; } // for entry at subtable begin57int bci() const { return _bci; }58int pco() const { return _pco; }59int scope_depth() const { return _scope_depth; }60};616263// An ExceptionHandlerTable is an abstraction over a list of subtables64// of exception handlers for CatchNodes. Each subtable has a one-entry65// header holding length and catch_pco of the subtable, followed66// by 'length' entries for each exception handler that can be reached67// from the corresponding CatchNode. The catch_pco is the pc offset of68// the CatchNode in the corresponding nmethod. Empty subtables are dis-69// carded.70//71// Structure of the table:72//73// table = { subtable }.74// subtable = header entry { entry }.75// header = a pair (number of subtable entries, catch pc offset, [unused])76// entry = a pair (handler bci, handler pc offset, scope depth)77//78// An ExceptionHandlerTable can be created from scratch, in which case79// it is possible to add subtables. It can also be created from an80// nmethod (for lookup purposes) in which case the table cannot be81// modified.8283class nmethod;84class ExceptionHandlerTable VALUE_OBJ_CLASS_SPEC {85private:86HandlerTableEntry* _table; // the table87int _length; // the current length of the table88int _size; // the number of allocated entries89ReallocMark _nesting; // assertion check for reallocations9091// add the entry & grow the table if needed92void add_entry(HandlerTableEntry entry);93HandlerTableEntry* subtable_for(int catch_pco) const;9495public:96// (compile-time) construction within compiler97ExceptionHandlerTable(int initial_size = 8);9899// (run-time) construction from nmethod100ExceptionHandlerTable(const nmethod* nm);101102// (compile-time) add entries103void add_subtable(104int catch_pco, // the pc offset for the CatchNode105GrowableArray<intptr_t>* handler_bcis, // the exception handler entry point bcis106GrowableArray<intptr_t>* scope_depths_from_top_scope,107// if representing exception handlers in multiple108// inlined scopes, indicates which scope relative to109// the youngest/innermost one in which we are performing110// the lookup; zero (or null GrowableArray) indicates111// innermost scope112GrowableArray<intptr_t>* handler_pcos // pc offsets for the compiled handlers113);114115// nmethod support116int size_in_bytes() const { return round_to(_length * sizeof(HandlerTableEntry), oopSize); }117void copy_to(nmethod* nm);118119// lookup120HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const;121122// debugging123void print_subtable(HandlerTableEntry* t) const;124void print() const;125void print_subtable_for(int catch_pco) const;126};127128129// ----------------------------------------------------------------------------130// Implicit null exception tables. Maps an exception PC offset to a131// continuation PC offset. During construction it's a variable sized132// array with a max size and current length. When stored inside an133// nmethod a zero length table takes no space. This is detected by134// nul_chk_table_size() == 0. Otherwise the table has a length word135// followed by pairs of <excp-offset, const-offset>.136137// Use 32-bit representation for offsets138typedef uint implicit_null_entry;139140class ImplicitExceptionTable VALUE_OBJ_CLASS_SPEC {141uint _size;142uint _len;143implicit_null_entry *_data;144implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; }145ReallocMark _nesting; // assertion check for reallocations146public:147ImplicitExceptionTable( ) : _data(0), _size(0), _len(0) { }148// (run-time) construction from nmethod149ImplicitExceptionTable( const nmethod *nm );150151void set_size( uint size );152void append( uint exec_off, uint cont_off );153uint at( uint exec_off ) const;154155uint len() const { return _len; }156int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * sizeof(implicit_null_entry)); }157158void copy_to(nmethod* nm);159void print(address base) const;160void verify(nmethod *nm) const;161};162163#endif // SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP164165166