Wed, 03 Jul 2019 20:42:37 +0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #ifndef SHARE_VM_CI_CISTREAMS_HPP |
aoqi@0 | 26 | #define SHARE_VM_CI_CISTREAMS_HPP |
aoqi@0 | 27 | |
aoqi@0 | 28 | #include "ci/ciClassList.hpp" |
aoqi@0 | 29 | #include "ci/ciExceptionHandler.hpp" |
aoqi@0 | 30 | #include "ci/ciInstanceKlass.hpp" |
aoqi@0 | 31 | #include "ci/ciMethod.hpp" |
aoqi@0 | 32 | #include "interpreter/bytecode.hpp" |
aoqi@0 | 33 | |
aoqi@0 | 34 | // ciBytecodeStream |
aoqi@0 | 35 | // |
aoqi@0 | 36 | // The class is used to iterate over the bytecodes of a method. |
aoqi@0 | 37 | // It hides the details of constant pool structure/access by |
aoqi@0 | 38 | // providing accessors for constant pool items. It returns only pure |
aoqi@0 | 39 | // Java bytecodes; VM-internal _fast bytecodes are translated back to |
aoqi@0 | 40 | // their original form during iteration. |
aoqi@0 | 41 | class ciBytecodeStream : StackObj { |
aoqi@0 | 42 | private: |
aoqi@0 | 43 | // Handling for the weird bytecodes |
aoqi@0 | 44 | Bytecodes::Code next_wide_or_table(Bytecodes::Code); // Handle _wide & complicated inline table |
aoqi@0 | 45 | |
aoqi@0 | 46 | static Bytecodes::Code check_java(Bytecodes::Code c) { |
aoqi@0 | 47 | assert(Bytecodes::is_java_code(c), "should not return _fast bytecodes"); |
aoqi@0 | 48 | return c; |
aoqi@0 | 49 | } |
aoqi@0 | 50 | |
aoqi@0 | 51 | static Bytecodes::Code check_defined(Bytecodes::Code c) { |
aoqi@0 | 52 | assert(Bytecodes::is_defined(c), ""); |
aoqi@0 | 53 | return c; |
aoqi@0 | 54 | } |
aoqi@0 | 55 | |
aoqi@0 | 56 | ciMethod* _method; // the method |
aoqi@0 | 57 | ciInstanceKlass* _holder; |
aoqi@0 | 58 | address _bc_start; // Start of current bytecode for table |
aoqi@0 | 59 | address _was_wide; // Address past last wide bytecode |
aoqi@0 | 60 | jint* _table_base; // Aligned start of last table or switch |
aoqi@0 | 61 | |
aoqi@0 | 62 | address _start; // Start of bytecodes |
aoqi@0 | 63 | address _end; // Past end of bytecodes |
aoqi@0 | 64 | address _pc; // Current PC |
aoqi@0 | 65 | Bytecodes::Code _bc; // Current bytecode |
aoqi@0 | 66 | Bytecodes::Code _raw_bc; // Current bytecode, raw form |
aoqi@0 | 67 | |
aoqi@0 | 68 | void reset( address base, unsigned int size ) { |
aoqi@0 | 69 | _bc_start =_was_wide = 0; |
aoqi@0 | 70 | _start = _pc = base; _end = base + size; |
aoqi@0 | 71 | } |
aoqi@0 | 72 | |
aoqi@0 | 73 | void assert_wide(bool require_wide) const { |
aoqi@0 | 74 | if (require_wide) |
aoqi@0 | 75 | { assert(is_wide(), "must be a wide instruction"); } |
aoqi@0 | 76 | else { assert(!is_wide(), "must not be a wide instruction"); } |
aoqi@0 | 77 | } |
aoqi@0 | 78 | |
aoqi@0 | 79 | Bytecode bytecode() const { return Bytecode(this, _bc_start); } |
aoqi@0 | 80 | Bytecode next_bytecode() const { return Bytecode(this, _pc); } |
aoqi@0 | 81 | |
aoqi@0 | 82 | public: |
aoqi@0 | 83 | // End-Of-Bytecodes |
aoqi@0 | 84 | static Bytecodes::Code EOBC() { |
aoqi@0 | 85 | return Bytecodes::_illegal; |
aoqi@0 | 86 | } |
aoqi@0 | 87 | |
aoqi@0 | 88 | ciBytecodeStream(ciMethod* m) { |
aoqi@0 | 89 | reset_to_method(m); |
aoqi@0 | 90 | } |
aoqi@0 | 91 | |
aoqi@0 | 92 | ciBytecodeStream() { |
aoqi@0 | 93 | reset_to_method(NULL); |
aoqi@0 | 94 | } |
aoqi@0 | 95 | |
aoqi@0 | 96 | ciMethod* method() const { return _method; } |
aoqi@0 | 97 | |
aoqi@0 | 98 | void reset_to_method(ciMethod* m) { |
aoqi@0 | 99 | _method = m; |
aoqi@0 | 100 | if (m == NULL) { |
aoqi@0 | 101 | _holder = NULL; |
aoqi@0 | 102 | reset(NULL, 0); |
aoqi@0 | 103 | } else { |
aoqi@0 | 104 | _holder = m->holder(); |
aoqi@0 | 105 | reset(m->code(), m->code_size()); |
aoqi@0 | 106 | } |
aoqi@0 | 107 | } |
aoqi@0 | 108 | |
aoqi@0 | 109 | void reset_to_bci( int bci ); |
aoqi@0 | 110 | |
aoqi@0 | 111 | // Force the iterator to report a certain bci. |
aoqi@0 | 112 | void force_bci(int bci); |
aoqi@0 | 113 | |
aoqi@0 | 114 | void set_max_bci( int max ) { |
aoqi@0 | 115 | _end = _start + max; |
aoqi@0 | 116 | } |
aoqi@0 | 117 | |
aoqi@0 | 118 | address cur_bcp() const { return _bc_start; } // Returns bcp to current instruction |
aoqi@0 | 119 | int next_bci() const { return _pc - _start; } |
aoqi@0 | 120 | int cur_bci() const { return _bc_start - _start; } |
aoqi@0 | 121 | int instruction_size() const { return _pc - _bc_start; } |
aoqi@0 | 122 | |
aoqi@0 | 123 | Bytecodes::Code cur_bc() const{ return check_java(_bc); } |
aoqi@0 | 124 | Bytecodes::Code cur_bc_raw() const { return check_defined(_raw_bc); } |
aoqi@0 | 125 | Bytecodes::Code next_bc() { return Bytecodes::java_code((Bytecodes::Code)* _pc); } |
aoqi@0 | 126 | |
aoqi@0 | 127 | // Return current ByteCode and increment PC to next bytecode, skipping all |
aoqi@0 | 128 | // intermediate constants. Returns EOBC at end. |
aoqi@0 | 129 | // Expected usage: |
aoqi@0 | 130 | // ciBytecodeStream iter(m); |
aoqi@0 | 131 | // while (iter.next() != ciBytecodeStream::EOBC()) { ... } |
aoqi@0 | 132 | Bytecodes::Code next() { |
aoqi@0 | 133 | _bc_start = _pc; // Capture start of bc |
aoqi@0 | 134 | if( _pc >= _end ) return EOBC(); // End-Of-Bytecodes |
aoqi@0 | 135 | |
aoqi@0 | 136 | // Fetch Java bytecode |
aoqi@0 | 137 | // All rewritten bytecodes maintain the size of original bytecode. |
aoqi@0 | 138 | _bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)*_pc); |
aoqi@0 | 139 | int csize = Bytecodes::length_for(_bc); // Expected size |
aoqi@0 | 140 | _pc += csize; // Bump PC past bytecode |
aoqi@0 | 141 | if (csize == 0) { |
aoqi@0 | 142 | _bc = next_wide_or_table(_bc); |
aoqi@0 | 143 | } |
aoqi@0 | 144 | return check_java(_bc); |
aoqi@0 | 145 | } |
aoqi@0 | 146 | |
aoqi@0 | 147 | bool is_wide() const { return ( _pc == _was_wide ); } |
aoqi@0 | 148 | |
aoqi@0 | 149 | // Does this instruction contain an index which refes into the CP cache? |
aoqi@0 | 150 | bool has_cache_index() const { return Bytecodes::uses_cp_cache(cur_bc_raw()); } |
aoqi@0 | 151 | |
aoqi@0 | 152 | bool has_optional_appendix() { return Bytecodes::has_optional_appendix(cur_bc_raw()); } |
aoqi@0 | 153 | |
aoqi@0 | 154 | int get_index_u1() const { |
aoqi@0 | 155 | return bytecode().get_index_u1(cur_bc_raw()); |
aoqi@0 | 156 | } |
aoqi@0 | 157 | |
aoqi@0 | 158 | int get_index_u1_cpcache() const { |
aoqi@0 | 159 | return bytecode().get_index_u1_cpcache(cur_bc_raw()); |
aoqi@0 | 160 | } |
aoqi@0 | 161 | |
aoqi@0 | 162 | // Get a byte index following this bytecode. |
aoqi@0 | 163 | // If prefixed with a wide bytecode, get a wide index. |
aoqi@0 | 164 | int get_index() const { |
aoqi@0 | 165 | assert(!has_cache_index(), "else use cpcache variant"); |
aoqi@0 | 166 | return (_pc == _was_wide) // was widened? |
aoqi@0 | 167 | ? get_index_u2(true) // yes, return wide index |
aoqi@0 | 168 | : get_index_u1(); // no, return narrow index |
aoqi@0 | 169 | } |
aoqi@0 | 170 | |
aoqi@0 | 171 | // Get 2-byte index (byte swapping depending on which bytecode) |
aoqi@0 | 172 | int get_index_u2(bool is_wide = false) const { |
aoqi@0 | 173 | return bytecode().get_index_u2(cur_bc_raw(), is_wide); |
aoqi@0 | 174 | } |
aoqi@0 | 175 | |
aoqi@0 | 176 | // Get 2-byte index in native byte order. (Rewriter::rewrite makes these.) |
aoqi@0 | 177 | int get_index_u2_cpcache() const { |
aoqi@0 | 178 | return bytecode().get_index_u2_cpcache(cur_bc_raw()); |
aoqi@0 | 179 | } |
aoqi@0 | 180 | |
aoqi@0 | 181 | // Get 4-byte index, for invokedynamic. |
aoqi@0 | 182 | int get_index_u4() const { |
aoqi@0 | 183 | return bytecode().get_index_u4(cur_bc_raw()); |
aoqi@0 | 184 | } |
aoqi@0 | 185 | |
aoqi@0 | 186 | bool has_index_u4() const { |
aoqi@0 | 187 | return bytecode().has_index_u4(cur_bc_raw()); |
aoqi@0 | 188 | } |
aoqi@0 | 189 | |
aoqi@0 | 190 | // Get dimensions byte (multinewarray) |
aoqi@0 | 191 | int get_dimensions() const { return *(unsigned char*)(_pc-1); } |
aoqi@0 | 192 | |
aoqi@0 | 193 | // Sign-extended index byte/short, no widening |
aoqi@0 | 194 | int get_constant_u1() const { return bytecode().get_constant_u1(instruction_size()-1, cur_bc_raw()); } |
aoqi@0 | 195 | int get_constant_u2(bool is_wide = false) const { return bytecode().get_constant_u2(instruction_size()-2, cur_bc_raw(), is_wide); } |
aoqi@0 | 196 | |
aoqi@0 | 197 | // Get a byte signed constant for "iinc". Invalid for other bytecodes. |
aoqi@0 | 198 | // If prefixed with a wide bytecode, get a wide constant |
aoqi@0 | 199 | int get_iinc_con() const {return (_pc==_was_wide) ? (jshort) get_constant_u2(true) : (jbyte) get_constant_u1();} |
aoqi@0 | 200 | |
aoqi@0 | 201 | // 2-byte branch offset from current pc |
aoqi@0 | 202 | int get_dest() const { |
aoqi@0 | 203 | return cur_bci() + bytecode().get_offset_s2(cur_bc_raw()); |
aoqi@0 | 204 | } |
aoqi@0 | 205 | |
aoqi@0 | 206 | // 2-byte branch offset from next pc |
aoqi@0 | 207 | int next_get_dest() const { |
aoqi@0 | 208 | assert(_pc < _end, ""); |
aoqi@0 | 209 | return next_bci() + next_bytecode().get_offset_s2(Bytecodes::_ifeq); |
aoqi@0 | 210 | } |
aoqi@0 | 211 | |
aoqi@0 | 212 | // 4-byte branch offset from current pc |
aoqi@0 | 213 | int get_far_dest() const { |
aoqi@0 | 214 | return cur_bci() + bytecode().get_offset_s4(cur_bc_raw()); |
aoqi@0 | 215 | } |
aoqi@0 | 216 | |
aoqi@0 | 217 | // For a lookup or switch table, return target destination |
aoqi@0 | 218 | int get_int_table( int index ) const { |
aoqi@0 | 219 | return Bytes::get_Java_u4((address)&_table_base[index]); } |
aoqi@0 | 220 | |
aoqi@0 | 221 | // For tableswitch - get length of offset part |
aoqi@0 | 222 | int get_tableswitch_length() { return get_int_table(2)-get_int_table(1)+1; } |
aoqi@0 | 223 | |
aoqi@0 | 224 | int get_dest_table( int index ) const { |
aoqi@0 | 225 | return cur_bci() + get_int_table(index); } |
aoqi@0 | 226 | |
aoqi@0 | 227 | // --- Constant pool access --- |
aoqi@0 | 228 | int get_constant_raw_index() const; |
aoqi@0 | 229 | int get_constant_pool_index() const; |
aoqi@0 | 230 | int get_constant_cache_index() const; |
aoqi@0 | 231 | int get_field_index(); |
aoqi@0 | 232 | int get_method_index(); |
aoqi@0 | 233 | |
aoqi@0 | 234 | // If this bytecode is a new, newarray, multianewarray, instanceof, |
aoqi@0 | 235 | // or checkcast, get the referenced klass. |
aoqi@0 | 236 | ciKlass* get_klass(bool& will_link); |
aoqi@0 | 237 | int get_klass_index() const; |
aoqi@0 | 238 | |
aoqi@0 | 239 | // If this bytecode is one of the ldc variants, get the referenced |
aoqi@0 | 240 | // constant. Do not attempt to resolve it, since that would require |
aoqi@0 | 241 | // execution of Java code. If it is not resolved, return an unloaded |
aoqi@0 | 242 | // object (ciConstant.as_object()->is_loaded() == false). |
aoqi@0 | 243 | ciConstant get_constant(); |
aoqi@0 | 244 | constantTag get_constant_pool_tag(int index) const; |
aoqi@0 | 245 | |
aoqi@0 | 246 | // True if the klass-using bytecode points to an unresolved klass |
aoqi@0 | 247 | bool is_unresolved_klass() const { |
aoqi@0 | 248 | constantTag tag = get_constant_pool_tag(get_klass_index()); |
aoqi@0 | 249 | return tag.is_unresolved_klass(); |
aoqi@0 | 250 | } |
aoqi@0 | 251 | |
aoqi@0 | 252 | // If this bytecode is one of get_field, get_static, put_field, |
aoqi@0 | 253 | // or put_static, get the referenced field. |
aoqi@0 | 254 | ciField* get_field(bool& will_link); |
aoqi@0 | 255 | |
aoqi@0 | 256 | ciInstanceKlass* get_declared_field_holder(); |
aoqi@0 | 257 | int get_field_holder_index(); |
aoqi@0 | 258 | int get_field_signature_index(); |
aoqi@0 | 259 | |
aoqi@0 | 260 | ciMethod* get_method(bool& will_link, ciSignature* *declared_signature_result); |
aoqi@0 | 261 | bool has_appendix(); |
aoqi@0 | 262 | ciObject* get_appendix(); |
aoqi@0 | 263 | bool has_method_type(); |
aoqi@0 | 264 | ciMethodType* get_method_type(); |
aoqi@0 | 265 | ciKlass* get_declared_method_holder(); |
aoqi@0 | 266 | int get_method_holder_index(); |
aoqi@0 | 267 | int get_method_signature_index(); |
aoqi@0 | 268 | |
aoqi@0 | 269 | // Get the resolved references arrays from the constant pool |
aoqi@0 | 270 | ciObjArray* get_resolved_references(); |
aoqi@0 | 271 | }; |
aoqi@0 | 272 | |
aoqi@0 | 273 | |
aoqi@0 | 274 | // ciSignatureStream |
aoqi@0 | 275 | // |
aoqi@0 | 276 | // The class is used to iterate over the elements of a method signature. |
aoqi@0 | 277 | class ciSignatureStream : public StackObj { |
aoqi@0 | 278 | private: |
aoqi@0 | 279 | ciSignature* _sig; |
aoqi@0 | 280 | int _pos; |
aoqi@0 | 281 | // holder is a method's holder |
aoqi@0 | 282 | ciKlass* _holder; |
aoqi@0 | 283 | public: |
aoqi@0 | 284 | ciSignatureStream(ciSignature* signature, ciKlass* holder = NULL) { |
aoqi@0 | 285 | _sig = signature; |
aoqi@0 | 286 | _pos = 0; |
aoqi@0 | 287 | _holder = holder; |
aoqi@0 | 288 | } |
aoqi@0 | 289 | |
aoqi@0 | 290 | bool at_return_type() { return _pos == _sig->count(); } |
aoqi@0 | 291 | |
aoqi@0 | 292 | bool is_done() { return _pos > _sig->count(); } |
aoqi@0 | 293 | |
aoqi@0 | 294 | void next() { |
aoqi@0 | 295 | if (_pos <= _sig->count()) { |
aoqi@0 | 296 | _pos++; |
aoqi@0 | 297 | } |
aoqi@0 | 298 | } |
aoqi@0 | 299 | |
aoqi@0 | 300 | ciType* type() { |
aoqi@0 | 301 | if (at_return_type()) { |
aoqi@0 | 302 | return _sig->return_type(); |
aoqi@0 | 303 | } else { |
aoqi@0 | 304 | return _sig->type_at(_pos); |
aoqi@0 | 305 | } |
aoqi@0 | 306 | } |
aoqi@0 | 307 | |
aoqi@0 | 308 | // next klass in the signature |
aoqi@0 | 309 | ciKlass* next_klass() { |
aoqi@0 | 310 | ciKlass* sig_k; |
aoqi@0 | 311 | if (_holder != NULL) { |
aoqi@0 | 312 | sig_k = _holder; |
aoqi@0 | 313 | _holder = NULL; |
aoqi@0 | 314 | } else { |
aoqi@0 | 315 | while (!type()->is_klass()) { |
aoqi@0 | 316 | next(); |
aoqi@0 | 317 | } |
aoqi@0 | 318 | assert(!at_return_type(), "passed end of signature"); |
aoqi@0 | 319 | sig_k = type()->as_klass(); |
aoqi@0 | 320 | next(); |
aoqi@0 | 321 | } |
aoqi@0 | 322 | return sig_k; |
aoqi@0 | 323 | } |
aoqi@0 | 324 | }; |
aoqi@0 | 325 | |
aoqi@0 | 326 | |
aoqi@0 | 327 | // ciExceptionHandlerStream |
aoqi@0 | 328 | // |
aoqi@0 | 329 | // The class is used to iterate over the exception handlers of |
aoqi@0 | 330 | // a method. |
aoqi@0 | 331 | class ciExceptionHandlerStream : public StackObj { |
aoqi@0 | 332 | private: |
aoqi@0 | 333 | // The method whose handlers we are traversing |
aoqi@0 | 334 | ciMethod* _method; |
aoqi@0 | 335 | |
aoqi@0 | 336 | // Our current position in the list of handlers |
aoqi@0 | 337 | int _pos; |
aoqi@0 | 338 | int _end; |
aoqi@0 | 339 | |
aoqi@0 | 340 | ciInstanceKlass* _exception_klass; |
aoqi@0 | 341 | int _bci; |
aoqi@0 | 342 | bool _is_exact; |
aoqi@0 | 343 | |
aoqi@0 | 344 | public: |
aoqi@0 | 345 | ciExceptionHandlerStream(ciMethod* method) { |
aoqi@0 | 346 | _method = method; |
aoqi@0 | 347 | |
aoqi@0 | 348 | // Force loading of method code and handlers. |
aoqi@0 | 349 | _method->code(); |
aoqi@0 | 350 | |
aoqi@0 | 351 | _pos = 0; |
aoqi@0 | 352 | _end = _method->_handler_count; |
aoqi@0 | 353 | _exception_klass = NULL; |
aoqi@0 | 354 | _bci = -1; |
aoqi@0 | 355 | _is_exact = false; |
aoqi@0 | 356 | } |
aoqi@0 | 357 | |
aoqi@0 | 358 | ciExceptionHandlerStream(ciMethod* method, int bci, |
aoqi@0 | 359 | ciInstanceKlass* exception_klass = NULL, |
aoqi@0 | 360 | bool is_exact = false) { |
aoqi@0 | 361 | _method = method; |
aoqi@0 | 362 | |
aoqi@0 | 363 | // Force loading of method code and handlers. |
aoqi@0 | 364 | _method->code(); |
aoqi@0 | 365 | |
aoqi@0 | 366 | _pos = -1; |
aoqi@0 | 367 | _end = _method->_handler_count + 1; // include the rethrow handler |
aoqi@0 | 368 | _exception_klass = (exception_klass != NULL && exception_klass->is_loaded() |
aoqi@0 | 369 | ? exception_klass |
aoqi@0 | 370 | : NULL); |
aoqi@0 | 371 | _bci = bci; |
aoqi@0 | 372 | assert(_bci >= 0, "bci out of range"); |
aoqi@0 | 373 | _is_exact = is_exact; |
aoqi@0 | 374 | next(); |
aoqi@0 | 375 | } |
aoqi@0 | 376 | |
aoqi@0 | 377 | // These methods are currently implemented in an odd way. |
aoqi@0 | 378 | // Count the number of handlers the iterator has ever produced |
aoqi@0 | 379 | // or will ever produce. Do not include the final rethrow handler. |
aoqi@0 | 380 | // That is, a trivial exception handler stream will have a count |
aoqi@0 | 381 | // of zero and produce just the rethrow handler. |
aoqi@0 | 382 | int count(); |
aoqi@0 | 383 | |
aoqi@0 | 384 | // Count the number of handlers this stream will produce from now on. |
aoqi@0 | 385 | // Include the current handler, and the final rethrow handler. |
aoqi@0 | 386 | // The remaining count will be zero iff is_done() is true, |
aoqi@0 | 387 | int count_remaining(); |
aoqi@0 | 388 | |
aoqi@0 | 389 | bool is_done() { |
aoqi@0 | 390 | return (_pos >= _end); |
aoqi@0 | 391 | } |
aoqi@0 | 392 | |
aoqi@0 | 393 | void next() { |
aoqi@0 | 394 | _pos++; |
aoqi@0 | 395 | if (_bci != -1) { |
aoqi@0 | 396 | // We are not iterating over all handlers... |
aoqi@0 | 397 | while (!is_done()) { |
aoqi@0 | 398 | ciExceptionHandler* handler = _method->_exception_handlers[_pos]; |
aoqi@0 | 399 | if (handler->is_in_range(_bci)) { |
aoqi@0 | 400 | if (handler->is_catch_all()) { |
aoqi@0 | 401 | // Found final active catch block. |
aoqi@0 | 402 | _end = _pos+1; |
aoqi@0 | 403 | return; |
aoqi@0 | 404 | } else if (_exception_klass == NULL || !handler->catch_klass()->is_loaded()) { |
aoqi@0 | 405 | // We cannot do any type analysis here. Must conservatively assume |
aoqi@0 | 406 | // catch block is reachable. |
aoqi@0 | 407 | return; |
aoqi@0 | 408 | } else if (_exception_klass->is_subtype_of(handler->catch_klass())) { |
aoqi@0 | 409 | // This catch clause will definitely catch the exception. |
aoqi@0 | 410 | // Final candidate. |
aoqi@0 | 411 | _end = _pos+1; |
aoqi@0 | 412 | return; |
aoqi@0 | 413 | } else if (!_is_exact && |
aoqi@0 | 414 | handler->catch_klass()->is_subtype_of(_exception_klass)) { |
aoqi@0 | 415 | // This catch block may be reachable. |
aoqi@0 | 416 | return; |
aoqi@0 | 417 | } |
aoqi@0 | 418 | } |
aoqi@0 | 419 | |
aoqi@0 | 420 | // The catch block was not pertinent. Go on. |
aoqi@0 | 421 | _pos++; |
aoqi@0 | 422 | } |
aoqi@0 | 423 | } else { |
aoqi@0 | 424 | // This is an iteration over all handlers. |
aoqi@0 | 425 | return; |
aoqi@0 | 426 | } |
aoqi@0 | 427 | } |
aoqi@0 | 428 | |
aoqi@0 | 429 | ciExceptionHandler* handler() { |
aoqi@0 | 430 | return _method->_exception_handlers[_pos]; |
aoqi@0 | 431 | } |
aoqi@0 | 432 | }; |
aoqi@0 | 433 | |
aoqi@0 | 434 | |
aoqi@0 | 435 | |
aoqi@0 | 436 | // Implementation for declarations in bytecode.hpp |
aoqi@0 | 437 | Bytecode::Bytecode(const ciBytecodeStream* stream, address bcp): _bcp(bcp != NULL ? bcp : stream->cur_bcp()), _code(Bytecodes::code_at(NULL, addr_at(0))) {} |
aoqi@0 | 438 | Bytecode_lookupswitch::Bytecode_lookupswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); } |
aoqi@0 | 439 | Bytecode_tableswitch::Bytecode_tableswitch(const ciBytecodeStream* stream): Bytecode(stream) { verify(); } |
aoqi@0 | 440 | |
aoqi@0 | 441 | #endif // SHARE_VM_CI_CISTREAMS_HPP |