< prev index next >

src/hotspot/share/code/exceptionHandlerTable.hpp

Print this page

 67 // header holding length and catch_pco of the subtable, followed
 68 // by 'length' entries for each exception handler that can be reached
 69 // from the corresponding CatchNode. The catch_pco is the pc offset of
 70 // the CatchNode in the corresponding nmethod. Empty subtables are dis-
 71 // carded.
 72 //
 73 // Structure of the table:
 74 //
 75 // table    = { subtable }.
 76 // subtable = header entry { entry }.
 77 // header   = a pair (number of subtable entries, catch pc offset, [unused])
 78 // entry    = a pair (handler bci, handler pc offset, scope depth)
 79 //
 80 // An ExceptionHandlerTable can be created from scratch, in which case
 81 // it is possible to add subtables. It can also be created from an
 82 // nmethod (for lookup purposes) in which case the table cannot be
 83 // modified.
 84 
 85 class nmethod;
 86 class ExceptionHandlerTable {



 87  private:
 88   HandlerTableEntry* _table;    // the table
 89   int                _length;   // the current length of the table
 90   int                _size;     // the number of allocated entries
 91   ReallocMark        _nesting;  // assertion check for reallocations
 92 


 93  public:
 94   // add the entry & grow the table if needed
 95   void add_entry(HandlerTableEntry entry);
 96   HandlerTableEntry* subtable_for(int catch_pco) const;
 97 
 98   // (compile-time) construction within compiler
 99   ExceptionHandlerTable(int initial_size = 8);
100 
101   // (run-time) construction from nmethod
102   ExceptionHandlerTable(const CompiledMethod* nm);
103 
104   // (compile-time) add entries
105   void add_subtable(
106     int                 catch_pco, // the pc offset for the CatchNode
107     GrowableArray<intptr_t>* handler_bcis, // the exception handler entry point bcis
108     GrowableArray<intptr_t>* scope_depths_from_top_scope,
109                                            // if representing exception handlers in multiple
110                                            // inlined scopes, indicates which scope relative to
111                                            // the youngest/innermost one in which we are performing
112                                            // the lookup; zero (or null GrowableArray) indicates
113                                            // innermost scope
114     GrowableArray<intptr_t>* handler_pcos  // pc offsets for the compiled handlers
115   );
116 

117   // nmethod support
118   int  size_in_bytes() const { return align_up(_length * (int)sizeof(HandlerTableEntry), oopSize); }
119   void copy_to(CompiledMethod* nm);
120   void copy_bytes_to(address addr);
121 
122   // lookup
123   HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const;
124 
125   // debugging
126   void print_subtable(HandlerTableEntry* t, address base = nullptr) const;
127   void print(address base = nullptr) const;
128   void print_subtable_for(int catch_pco) const;
129 };
130 
131 
132 // ----------------------------------------------------------------------------
133 // Implicit null exception tables.  Maps an exception PC offset to a
134 // continuation PC offset.  During construction it's a variable sized
135 // array with a max size and current length.  When stored inside an
136 // nmethod a zero length table takes no space.  This is detected by
137 // nul_chk_table_size() == 0.  Otherwise the table has a length word
138 // followed by pairs of <excp-offset, const-offset>.
139 
140 // Use 32-bit representation for offsets
141 typedef  uint              implicit_null_entry;
142 
143 class ImplicitExceptionTable {



144   uint _size;
145   uint _len;
146   implicit_null_entry *_data;
147   implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; }
148   ReallocMark          _nesting;  // assertion check for reallocations
149 


150 public:
151   ImplicitExceptionTable( ) :  _size(0), _len(0), _data(0) { }
152   // (run-time) construction from nmethod
153   ImplicitExceptionTable( const CompiledMethod *nm );
154 
155   void set_size( uint size );
156   void append( uint exec_off, uint cont_off );
157 
158 #if INCLUDE_JVMCI
159   void add_deoptimize(uint exec_off) {
160     // Use the same offset as a marker value for deoptimization
161     append(exec_off, exec_off);
162   }
163 #endif
164 
165   // Returns the offset to continue execution at.  If the returned
166   // value equals exec_off then the dispatch is expected to be a
167   // deoptimization instead.
168   uint continuation_offset( uint exec_off ) const;
169 
170   uint len() const { return _len; }


171 
172   uint get_exec_offset(uint i) { assert(i < _len, "oob"); return *adr(i); }
173   uint get_cont_offset(uint i) { assert(i < _len, "oob"); return *(adr(i) + 1); }
174 
175   int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * (int)sizeof(implicit_null_entry)); }
176 
177   void copy_to(nmethod* nm);
178   void copy_bytes_to(address addr, int size);
179   void print(address base) const;
180   void verify(nmethod *nm) const;
181 };
182 
183 #endif // SHARE_CODE_EXCEPTIONHANDLERTABLE_HPP

 67 // header holding length and catch_pco of the subtable, followed
 68 // by 'length' entries for each exception handler that can be reached
 69 // from the corresponding CatchNode. The catch_pco is the pc offset of
 70 // the CatchNode in the corresponding nmethod. Empty subtables are dis-
 71 // carded.
 72 //
 73 // Structure of the table:
 74 //
 75 // table    = { subtable }.
 76 // subtable = header entry { entry }.
 77 // header   = a pair (number of subtable entries, catch pc offset, [unused])
 78 // entry    = a pair (handler bci, handler pc offset, scope depth)
 79 //
 80 // An ExceptionHandlerTable can be created from scratch, in which case
 81 // it is possible to add subtables. It can also be created from an
 82 // nmethod (for lookup purposes) in which case the table cannot be
 83 // modified.
 84 
 85 class nmethod;
 86 class ExceptionHandlerTable {
 87   friend class SCCache;
 88   friend class SCCReader;
 89 
 90  private:
 91   HandlerTableEntry* _table;    // the table
 92   int                _length;   // the current length of the table
 93   int                _size;     // the number of allocated entries
 94   ReallocMark        _nesting;  // assertion check for reallocations
 95 
 96   int length() const { return _length; }
 97   void set_length(int length) { _length = length; }
 98  public:
 99   // add the entry & grow the table if needed
100   void add_entry(HandlerTableEntry entry);
101   HandlerTableEntry* subtable_for(int catch_pco) const;
102 
103   // (compile-time) construction within compiler
104   ExceptionHandlerTable(int initial_size = 8);
105 
106   // (run-time) construction from nmethod
107   ExceptionHandlerTable(const CompiledMethod* nm);
108 
109   // (compile-time) add entries
110   void add_subtable(
111     int                 catch_pco, // the pc offset for the CatchNode
112     GrowableArray<intptr_t>* handler_bcis, // the exception handler entry point bcis
113     GrowableArray<intptr_t>* scope_depths_from_top_scope,
114                                            // if representing exception handlers in multiple
115                                            // inlined scopes, indicates which scope relative to
116                                            // the youngest/innermost one in which we are performing
117                                            // the lookup; zero (or null GrowableArray) indicates
118                                            // innermost scope
119     GrowableArray<intptr_t>* handler_pcos  // pc offsets for the compiled handlers
120   );
121 
122   HandlerTableEntry* table() const { return _table; }
123   // nmethod support
124   int  size_in_bytes() const { return align_up(_length * (int)sizeof(HandlerTableEntry), oopSize); }
125   void copy_to(CompiledMethod* nm);
126   void copy_bytes_to(address addr);
127 
128   // lookup
129   HandlerTableEntry* entry_for(int catch_pco, int handler_bci, int scope_depth) const;
130 
131   // debugging
132   void print_subtable(HandlerTableEntry* t, address base = nullptr) const;
133   void print(address base = nullptr) const;
134   void print_subtable_for(int catch_pco) const;
135 };
136 
137 
138 // ----------------------------------------------------------------------------
139 // Implicit null exception tables.  Maps an exception PC offset to a
140 // continuation PC offset.  During construction it's a variable sized
141 // array with a max size and current length.  When stored inside an
142 // nmethod a zero length table takes no space.  This is detected by
143 // nul_chk_table_size() == 0.  Otherwise the table has a length word
144 // followed by pairs of <excp-offset, const-offset>.
145 
146 // Use 32-bit representation for offsets
147 typedef  uint              implicit_null_entry;
148 
149 class ImplicitExceptionTable {
150   friend class SCCache;
151   friend class SCCReader;
152  private:
153   uint _size;
154   uint _len;
155   implicit_null_entry *_data;
156   implicit_null_entry *adr( uint idx ) const { return &_data[2*idx]; }
157   ReallocMark          _nesting;  // assertion check for reallocations
158 
159   void set_len(int length) { _len = length; }
160 
161 public:
162   ImplicitExceptionTable( ) :  _size(0), _len(0), _data(0) { }
163   // (run-time) construction from nmethod
164   ImplicitExceptionTable( const CompiledMethod *nm );
165 
166   void set_size( uint size );
167   void append( uint exec_off, uint cont_off );
168 
169 #if INCLUDE_JVMCI
170   void add_deoptimize(uint exec_off) {
171     // Use the same offset as a marker value for deoptimization
172     append(exec_off, exec_off);
173   }
174 #endif
175 
176   // Returns the offset to continue execution at.  If the returned
177   // value equals exec_off then the dispatch is expected to be a
178   // deoptimization instead.
179   uint continuation_offset( uint exec_off ) const;
180 
181   uint len() const { return _len; }
182   
183   implicit_null_entry* data() const { return _data; }
184 
185   uint get_exec_offset(uint i) { assert(i < _len, "oob"); return *adr(i); }
186   uint get_cont_offset(uint i) { assert(i < _len, "oob"); return *(adr(i) + 1); }
187 
188   int size_in_bytes() const { return len() == 0 ? 0 : ((2 * len() + 1) * (int)sizeof(implicit_null_entry)); }
189 
190   void copy_to(nmethod* nm);
191   void copy_bytes_to(address addr, int size);
192   void print(address base) const;
193   void verify(nmethod *nm) const;
194 };
195 
196 #endif // SHARE_CODE_EXCEPTIONHANDLERTABLE_HPP
< prev index next >