src/share/vm/code/exceptionHandlerTable.hpp

Mon, 19 Aug 2019 10:11:31 +0200

author
neugens
date
Mon, 19 Aug 2019 10:11:31 +0200
changeset 9861
a248d0be1309
parent 4037
da91efe96a93
child 6876
710a3c8b516e
permissions
-rw-r--r--

8229401: Fix JFR code cache test failures
8223689: Add JFR Thread Sampling Support
8223690: Add JFR BiasedLock Event Support
8223691: Add JFR G1 Region Type Change Event Support
8223692: Add JFR G1 Heap Summary Event Support
Summary: Backport JFR from JDK11, additional fixes
Reviewed-by: neugens, apetushkov
Contributed-by: denghui.ddh@alibaba-inc.com

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP
stefank@2314 26 #define SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP
stefank@2314 27
stefank@2314 28 #include "memory/allocation.hpp"
coleenp@4037 29 #include "oops/method.hpp"
stefank@2314 30
duke@435 31 // A HandlerTableEntry describes an individual entry of a subtable
duke@435 32 // of ExceptionHandlerTable. An entry consists of a pair(bci, pco),
duke@435 33 // where bci is the exception handler bci, and pco is the pc offset
duke@435 34 // relative to the nmethod code start for the compiled exception
duke@435 35 // handler corresponding to the (interpreted) exception handler
duke@435 36 // starting at bci.
duke@435 37 //
duke@435 38 // The first HandlerTableEntry of each subtable holds the length
duke@435 39 // and catch_pco for the subtable (the length is the number of
duke@435 40 // subtable entries w/o header).
duke@435 41
duke@435 42 class HandlerTableEntry {
duke@435 43 private:
duke@435 44 int _bci;
duke@435 45 int _pco;
duke@435 46 int _scope_depth;
duke@435 47
duke@435 48 public:
duke@435 49 HandlerTableEntry(int bci, int pco, int scope_depth) {
duke@435 50 assert( 0 <= pco, "pco must be positive");
duke@435 51 assert( 0 <= scope_depth, "scope_depth must be positive");
duke@435 52 _bci = bci;
duke@435 53 _pco = pco;
duke@435 54 _scope_depth = scope_depth;
duke@435 55 }
duke@435 56
duke@435 57 int len() const { return _bci; } // for entry at subtable begin
duke@435 58 int bci() const { return _bci; }
duke@435 59 int pco() const { return _pco; }
duke@435 60 int scope_depth() const { return _scope_depth; }
duke@435 61 };
duke@435 62
duke@435 63
duke@435 64 // An ExceptionHandlerTable is an abstraction over a list of subtables
duke@435 65 // of exception handlers for CatchNodes. Each subtable has a one-entry
duke@435 66 // header holding length and catch_pco of the subtable, followed
duke@435 67 // by 'length' entries for each exception handler that can be reached
duke@435 68 // from the corresponding CatchNode. The catch_pco is the pc offset of
duke@435 69 // the CatchNode in the corresponding nmethod. Empty subtables are dis-
duke@435 70 // carded.
duke@435 71 //
duke@435 72 // Structure of the table:
duke@435 73 //
duke@435 74 // table = { subtable }.
duke@435 75 // subtable = header entry { entry }.
duke@435 76 // header = a pair (number of subtable entries, catch pc offset, [unused])
duke@435 77 // entry = a pair (handler bci, handler pc offset, scope depth)
duke@435 78 //
duke@435 79 // An ExceptionHandlerTable can be created from scratch, in which case
duke@435 80 // it is possible to add subtables. It can also be created from an
duke@435 81 // nmethod (for lookup purposes) in which case the table cannot be
duke@435 82 // modified.
duke@435 83
duke@435 84 class nmethod;
duke@435 85 class ExceptionHandlerTable VALUE_OBJ_CLASS_SPEC {
duke@435 86 private:
duke@435 87 HandlerTableEntry* _table; // the table
duke@435 88 int _length; // the current length of the table
duke@435 89 int _size; // the number of allocated entries
duke@435 90 ReallocMark _nesting; // assertion check for reallocations
duke@435 91
duke@435 92 // add the entry & grow the table if needed
duke@435 93 void add_entry(HandlerTableEntry entry);
duke@435 94 HandlerTableEntry* subtable_for(int catch_pco) const;
duke@435 95
duke@435 96 public:
duke@435 97 // (compile-time) construction within compiler
duke@435 98 ExceptionHandlerTable(int initial_size = 8);
duke@435 99
duke@435 100 // (run-time) construction from nmethod
duke@435 101 ExceptionHandlerTable(const nmethod* nm);
duke@435 102
duke@435 103 // (compile-time) add entries
duke@435 104 void add_subtable(
duke@435 105 int catch_pco, // the pc offset for the CatchNode
duke@435 106 GrowableArray<intptr_t>* handler_bcis, // the exception handler entry point bcis
duke@435 107 GrowableArray<intptr_t>* scope_depths_from_top_scope,
duke@435 108 // if representing exception handlers in multiple
duke@435 109 // inlined scopes, indicates which scope relative to
duke@435 110 // the youngest/innermost one in which we are performing
duke@435 111 // the lookup; zero (or null GrowableArray) indicates
duke@435 112 // innermost scope
duke@435 113 GrowableArray<intptr_t>* handler_pcos // pc offsets for the compiled handlers
duke@435 114 );
duke@435 115
duke@435 116 // nmethod support
duke@435 117 int size_in_bytes() const { return round_to(_length * sizeof(HandlerTableEntry), oopSize); }
duke@435 118 void copy_to(nmethod* nm);
duke@435 119
duke@435 120 // lookup
duke@435 121 HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const;
duke@435 122
duke@435 123 // debugging
duke@435 124 void print_subtable(HandlerTableEntry* t) const;
duke@435 125 void print() const;
duke@435 126 void print_subtable_for(int catch_pco) const;
duke@435 127 };
duke@435 128
duke@435 129
duke@435 130 // ----------------------------------------------------------------------------
duke@435 131 // Implicit null exception tables. Maps an exception PC offset to a
duke@435 132 // continuation PC offset. During construction it's a variable sized
duke@435 133 // array with a max size and current length. When stored inside an
duke@435 134 // nmethod a zero length table takes no space. This is detected by
duke@435 135 // nul_chk_table_size() == 0. Otherwise the table has a length word
duke@435 136 // followed by pairs of <excp-offset, const-offset>.
duke@435 137
duke@435 138 // Use 32-bit representation for offsets
duke@435 139 typedef uint implicit_null_entry;
duke@435 140
duke@435 141 class ImplicitExceptionTable VALUE_OBJ_CLASS_SPEC {
duke@435 142 uint _size;
duke@435 143 uint _len;
duke@435 144 implicit_null_entry *_data;
duke@435 145 implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; }
duke@435 146 ReallocMark _nesting; // assertion check for reallocations
duke@435 147 public:
duke@435 148 ImplicitExceptionTable( ) : _data(0), _size(0), _len(0) { }
duke@435 149 // (run-time) construction from nmethod
duke@435 150 ImplicitExceptionTable( const nmethod *nm );
duke@435 151
duke@435 152 void set_size( uint size );
duke@435 153 void append( uint exec_off, uint cont_off );
duke@435 154 uint at( uint exec_off ) const;
duke@435 155
duke@435 156 uint len() const { return _len; }
duke@435 157 int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * sizeof(implicit_null_entry)); }
duke@435 158
duke@435 159 void copy_to(nmethod* nm);
duke@435 160 void print(address base) const;
duke@435 161 void verify(nmethod *nm) const;
duke@435 162 };
stefank@2314 163
stefank@2314 164 #endif // SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP

mercurial