annotate src/share/vm/code/exceptionHandlerTable.hpp @ 1972:f95d63e2154a

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