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

     1 /*
     2  * Copyright (c) 1998, 2012, 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP
    26 #define SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP
    28 #include "memory/allocation.hpp"
    29 #include "oops/method.hpp"
    31 // A HandlerTableEntry describes an individual entry of a subtable
    32 // of ExceptionHandlerTable. An entry consists of a pair(bci, pco),
    33 // where bci is the exception handler bci, and pco is the pc offset
    34 // relative to the nmethod code start for the compiled exception
    35 // handler corresponding to the (interpreted) exception handler
    36 // starting at bci.
    37 //
    38 // The first HandlerTableEntry of each subtable holds the length
    39 // and catch_pco for the subtable (the length is the number of
    40 // subtable entries w/o header).
    42 class HandlerTableEntry {
    43  private:
    44   int _bci;
    45   int _pco;
    46   int _scope_depth;
    48  public:
    49   HandlerTableEntry(int bci, int pco, int scope_depth) {
    50     assert( 0 <= pco, "pco must be positive");
    51     assert( 0 <= scope_depth, "scope_depth must be positive");
    52     _bci = bci;
    53     _pco = pco;
    54     _scope_depth = scope_depth;
    55   }
    57   int len() const { return _bci; } // for entry at subtable begin
    58   int bci() const { return _bci; }
    59   int pco() const { return _pco; }
    60   int scope_depth() const { return _scope_depth; }
    61 };
    64 // An ExceptionHandlerTable is an abstraction over a list of subtables
    65 // of exception handlers for CatchNodes. Each subtable has a one-entry
    66 // header holding length and catch_pco of the subtable, followed
    67 // by 'length' entries for each exception handler that can be reached
    68 // from the corresponding CatchNode. The catch_pco is the pc offset of
    69 // the CatchNode in the corresponding nmethod. Empty subtables are dis-
    70 // carded.
    71 //
    72 // Structure of the table:
    73 //
    74 // table    = { subtable }.
    75 // subtable = header entry { entry }.
    76 // header   = a pair (number of subtable entries, catch pc offset, [unused])
    77 // entry    = a pair (handler bci, handler pc offset, scope depth)
    78 //
    79 // An ExceptionHandlerTable can be created from scratch, in which case
    80 // it is possible to add subtables. It can also be created from an
    81 // nmethod (for lookup purposes) in which case the table cannot be
    82 // modified.
    84 class nmethod;
    85 class ExceptionHandlerTable VALUE_OBJ_CLASS_SPEC {
    86  private:
    87   HandlerTableEntry* _table;    // the table
    88   int                _length;   // the current length of the table
    89   int                _size;     // the number of allocated entries
    90   ReallocMark        _nesting;  // assertion check for reallocations
    92   // add the entry & grow the table if needed
    93   void add_entry(HandlerTableEntry entry);
    94   HandlerTableEntry* subtable_for(int catch_pco) const;
    96  public:
    97   // (compile-time) construction within compiler
    98   ExceptionHandlerTable(int initial_size = 8);
   100   // (run-time) construction from nmethod
   101   ExceptionHandlerTable(const nmethod* nm);
   103   // (compile-time) add entries
   104   void add_subtable(
   105     int                 catch_pco, // the pc offset for the CatchNode
   106     GrowableArray<intptr_t>* handler_bcis, // the exception handler entry point bcis
   107     GrowableArray<intptr_t>* scope_depths_from_top_scope,
   108                                            // if representing exception handlers in multiple
   109                                            // inlined scopes, indicates which scope relative to
   110                                            // the youngest/innermost one in which we are performing
   111                                            // the lookup; zero (or null GrowableArray) indicates
   112                                            // innermost scope
   113     GrowableArray<intptr_t>* handler_pcos  // pc offsets for the compiled handlers
   114   );
   116   // nmethod support
   117   int  size_in_bytes() const { return round_to(_length * sizeof(HandlerTableEntry), oopSize); }
   118   void copy_to(nmethod* nm);
   120   // lookup
   121   HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const;
   123   // debugging
   124   void print_subtable(HandlerTableEntry* t) const;
   125   void print() const;
   126   void print_subtable_for(int catch_pco) const;
   127 };
   130 // ----------------------------------------------------------------------------
   131 // Implicit null exception tables.  Maps an exception PC offset to a
   132 // continuation PC offset.  During construction it's a variable sized
   133 // array with a max size and current length.  When stored inside an
   134 // nmethod a zero length table takes no space.  This is detected by
   135 // nul_chk_table_size() == 0.  Otherwise the table has a length word
   136 // followed by pairs of <excp-offset, const-offset>.
   138 // Use 32-bit representation for offsets
   139 typedef  uint              implicit_null_entry;
   141 class ImplicitExceptionTable VALUE_OBJ_CLASS_SPEC {
   142   uint _size;
   143   uint _len;
   144   implicit_null_entry *_data;
   145   implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; }
   146   ReallocMark          _nesting;  // assertion check for reallocations
   147 public:
   148   ImplicitExceptionTable( ) :  _data(0), _size(0), _len(0) { }
   149   // (run-time) construction from nmethod
   150   ImplicitExceptionTable( const nmethod *nm );
   152   void set_size( uint size );
   153   void append( uint exec_off, uint cont_off );
   154   uint at( uint exec_off ) const;
   156   uint len() const { return _len; }
   157   int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * sizeof(implicit_null_entry)); }
   159   void copy_to(nmethod* nm);
   160   void print(address base) const;
   161   void verify(nmethod *nm) const;
   162 };
   164 #endif // SHARE_VM_CODE_EXCEPTIONHANDLERTABLE_HPP

mercurial