Wed, 03 Jul 2019 20:42:37 +0800
Merge
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 1999, 2012, 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 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "ci/ciCallSite.hpp" |
aoqi@0 | 27 | #include "ci/ciConstant.hpp" |
aoqi@0 | 28 | #include "ci/ciField.hpp" |
aoqi@0 | 29 | #include "ci/ciStreams.hpp" |
aoqi@0 | 30 | #include "ci/ciUtilities.hpp" |
aoqi@0 | 31 | |
aoqi@0 | 32 | // ciExceptionHandlerStream |
aoqi@0 | 33 | // |
aoqi@0 | 34 | // Walk over some selected set of a methods exception handlers. |
aoqi@0 | 35 | |
aoqi@0 | 36 | // ------------------------------------------------------------------ |
aoqi@0 | 37 | // ciExceptionHandlerStream::count |
aoqi@0 | 38 | // |
aoqi@0 | 39 | // How many exception handlers are there in this stream? |
aoqi@0 | 40 | // |
aoqi@0 | 41 | // Implementation note: Compiler2 needs this functionality, so I had |
aoqi@0 | 42 | int ciExceptionHandlerStream::count() { |
aoqi@0 | 43 | int save_pos = _pos; |
aoqi@0 | 44 | int save_end = _end; |
aoqi@0 | 45 | |
aoqi@0 | 46 | int count = 0; |
aoqi@0 | 47 | |
aoqi@0 | 48 | _pos = -1; |
aoqi@0 | 49 | _end = _method->_handler_count; |
aoqi@0 | 50 | |
aoqi@0 | 51 | |
aoqi@0 | 52 | next(); |
aoqi@0 | 53 | while (!is_done()) { |
aoqi@0 | 54 | count++; |
aoqi@0 | 55 | next(); |
aoqi@0 | 56 | } |
aoqi@0 | 57 | |
aoqi@0 | 58 | _pos = save_pos; |
aoqi@0 | 59 | _end = save_end; |
aoqi@0 | 60 | |
aoqi@0 | 61 | return count; |
aoqi@0 | 62 | } |
aoqi@0 | 63 | |
aoqi@0 | 64 | int ciExceptionHandlerStream::count_remaining() { |
aoqi@0 | 65 | int save_pos = _pos; |
aoqi@0 | 66 | int save_end = _end; |
aoqi@0 | 67 | |
aoqi@0 | 68 | int count = 0; |
aoqi@0 | 69 | |
aoqi@0 | 70 | while (!is_done()) { |
aoqi@0 | 71 | count++; |
aoqi@0 | 72 | next(); |
aoqi@0 | 73 | } |
aoqi@0 | 74 | |
aoqi@0 | 75 | _pos = save_pos; |
aoqi@0 | 76 | _end = save_end; |
aoqi@0 | 77 | |
aoqi@0 | 78 | return count; |
aoqi@0 | 79 | } |
aoqi@0 | 80 | |
aoqi@0 | 81 | // ciBytecodeStream |
aoqi@0 | 82 | // |
aoqi@0 | 83 | // The class is used to iterate over the bytecodes of a method. |
aoqi@0 | 84 | // It hides the details of constant pool structure/access by |
aoqi@0 | 85 | // providing accessors for constant pool items. |
aoqi@0 | 86 | |
aoqi@0 | 87 | // ------------------------------------------------------------------ |
aoqi@0 | 88 | // ciBytecodeStream::next_wide_or_table |
aoqi@0 | 89 | // |
aoqi@0 | 90 | // Special handling for switch ops |
aoqi@0 | 91 | Bytecodes::Code ciBytecodeStream::next_wide_or_table(Bytecodes::Code bc) { |
aoqi@0 | 92 | switch (bc) { // Check for special bytecode handling |
aoqi@0 | 93 | case Bytecodes::_wide: |
aoqi@0 | 94 | // Special handling for the wide bytcode |
aoqi@0 | 95 | // Get following bytecode; do not return wide |
aoqi@0 | 96 | assert(Bytecodes::Code(_pc[0]) == Bytecodes::_wide, ""); |
aoqi@0 | 97 | bc = Bytecodes::java_code(_raw_bc = (Bytecodes::Code)_pc[1]); |
aoqi@0 | 98 | assert(Bytecodes::wide_length_for(bc) > 2, "must make progress"); |
aoqi@0 | 99 | _pc += Bytecodes::wide_length_for(bc); |
aoqi@0 | 100 | _was_wide = _pc; // Flag last wide bytecode found |
aoqi@0 | 101 | assert(is_wide(), "accessor works right"); |
aoqi@0 | 102 | break; |
aoqi@0 | 103 | |
aoqi@0 | 104 | case Bytecodes::_lookupswitch: |
aoqi@0 | 105 | _pc++; // Skip wide bytecode |
aoqi@0 | 106 | _pc += (_start-_pc)&3; // Word align |
aoqi@0 | 107 | _table_base = (jint*)_pc; // Capture for later usage |
aoqi@0 | 108 | // table_base[0] is default far_dest |
aoqi@0 | 109 | // Table has 2 lead elements (default, length), then pairs of u4 values. |
aoqi@0 | 110 | // So load table length, and compute address at end of table |
aoqi@0 | 111 | _pc = (address)&_table_base[2+ 2*Bytes::get_Java_u4((address)&_table_base[1])]; |
aoqi@0 | 112 | break; |
aoqi@0 | 113 | |
aoqi@0 | 114 | case Bytecodes::_tableswitch: { |
aoqi@0 | 115 | _pc++; // Skip wide bytecode |
aoqi@0 | 116 | _pc += (_start-_pc)&3; // Word align |
aoqi@0 | 117 | _table_base = (jint*)_pc; // Capture for later usage |
aoqi@0 | 118 | // table_base[0] is default far_dest |
aoqi@0 | 119 | int lo = Bytes::get_Java_u4((address)&_table_base[1]);// Low bound |
aoqi@0 | 120 | int hi = Bytes::get_Java_u4((address)&_table_base[2]);// High bound |
aoqi@0 | 121 | int len = hi - lo + 1; // Dense table size |
aoqi@0 | 122 | _pc = (address)&_table_base[3+len]; // Skip past table |
aoqi@0 | 123 | break; |
aoqi@0 | 124 | } |
aoqi@0 | 125 | |
aoqi@0 | 126 | default: |
aoqi@0 | 127 | fatal("unhandled bytecode"); |
aoqi@0 | 128 | } |
aoqi@0 | 129 | return bc; |
aoqi@0 | 130 | } |
aoqi@0 | 131 | |
aoqi@0 | 132 | // ------------------------------------------------------------------ |
aoqi@0 | 133 | // ciBytecodeStream::reset_to_bci |
aoqi@0 | 134 | void ciBytecodeStream::reset_to_bci( int bci ) { |
aoqi@0 | 135 | _bc_start=_was_wide=0; |
aoqi@0 | 136 | _pc = _start+bci; |
aoqi@0 | 137 | } |
aoqi@0 | 138 | |
aoqi@0 | 139 | // ------------------------------------------------------------------ |
aoqi@0 | 140 | // ciBytecodeStream::force_bci |
aoqi@0 | 141 | void ciBytecodeStream::force_bci(int bci) { |
aoqi@0 | 142 | if (bci < 0) { |
aoqi@0 | 143 | reset_to_bci(0); |
aoqi@0 | 144 | _bc_start = _start + bci; |
aoqi@0 | 145 | _bc = EOBC(); |
aoqi@0 | 146 | } else { |
aoqi@0 | 147 | reset_to_bci(bci); |
aoqi@0 | 148 | next(); |
aoqi@0 | 149 | } |
aoqi@0 | 150 | } |
aoqi@0 | 151 | |
aoqi@0 | 152 | |
aoqi@0 | 153 | // ------------------------------------------------------------------ |
aoqi@0 | 154 | // Constant pool access |
aoqi@0 | 155 | // ------------------------------------------------------------------ |
aoqi@0 | 156 | |
aoqi@0 | 157 | // ------------------------------------------------------------------ |
aoqi@0 | 158 | // ciBytecodeStream::get_klass_index |
aoqi@0 | 159 | // |
aoqi@0 | 160 | // If this bytecodes references a klass, return the index of the |
aoqi@0 | 161 | // referenced klass. |
aoqi@0 | 162 | int ciBytecodeStream::get_klass_index() const { |
aoqi@0 | 163 | switch(cur_bc()) { |
aoqi@0 | 164 | case Bytecodes::_ldc: |
aoqi@0 | 165 | return get_index_u1(); |
aoqi@0 | 166 | case Bytecodes::_ldc_w: |
aoqi@0 | 167 | case Bytecodes::_ldc2_w: |
aoqi@0 | 168 | case Bytecodes::_checkcast: |
aoqi@0 | 169 | case Bytecodes::_instanceof: |
aoqi@0 | 170 | case Bytecodes::_anewarray: |
aoqi@0 | 171 | case Bytecodes::_multianewarray: |
aoqi@0 | 172 | case Bytecodes::_new: |
aoqi@0 | 173 | case Bytecodes::_newarray: |
aoqi@0 | 174 | return get_index_u2(); |
aoqi@0 | 175 | default: |
aoqi@0 | 176 | ShouldNotReachHere(); |
aoqi@0 | 177 | return 0; |
aoqi@0 | 178 | } |
aoqi@0 | 179 | } |
aoqi@0 | 180 | |
aoqi@0 | 181 | // ------------------------------------------------------------------ |
aoqi@0 | 182 | // ciBytecodeStream::get_klass |
aoqi@0 | 183 | // |
aoqi@0 | 184 | // If this bytecode is a new, newarray, multianewarray, instanceof, |
aoqi@0 | 185 | // or checkcast, get the referenced klass. |
aoqi@0 | 186 | ciKlass* ciBytecodeStream::get_klass(bool& will_link) { |
aoqi@0 | 187 | VM_ENTRY_MARK; |
aoqi@0 | 188 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 189 | return CURRENT_ENV->get_klass_by_index(cpool, get_klass_index(), will_link, _holder); |
aoqi@0 | 190 | } |
aoqi@0 | 191 | |
aoqi@0 | 192 | // ------------------------------------------------------------------ |
aoqi@0 | 193 | // ciBytecodeStream::get_constant_raw_index |
aoqi@0 | 194 | // |
aoqi@0 | 195 | // If this bytecode is one of the ldc variants, get the index of the |
aoqi@0 | 196 | // referenced constant. |
aoqi@0 | 197 | int ciBytecodeStream::get_constant_raw_index() const { |
aoqi@0 | 198 | // work-alike for Bytecode_loadconstant::raw_index() |
aoqi@0 | 199 | switch (cur_bc()) { |
aoqi@0 | 200 | case Bytecodes::_ldc: |
aoqi@0 | 201 | return get_index_u1(); |
aoqi@0 | 202 | case Bytecodes::_ldc_w: |
aoqi@0 | 203 | case Bytecodes::_ldc2_w: |
aoqi@0 | 204 | return get_index_u2(); |
aoqi@0 | 205 | default: |
aoqi@0 | 206 | ShouldNotReachHere(); |
aoqi@0 | 207 | return 0; |
aoqi@0 | 208 | } |
aoqi@0 | 209 | } |
aoqi@0 | 210 | |
aoqi@0 | 211 | // ------------------------------------------------------------------ |
aoqi@0 | 212 | // ciBytecodeStream::get_constant_pool_index |
aoqi@0 | 213 | // Decode any reference index into a regular pool index. |
aoqi@0 | 214 | int ciBytecodeStream::get_constant_pool_index() const { |
aoqi@0 | 215 | // work-alike for Bytecode_loadconstant::pool_index() |
aoqi@0 | 216 | int index = get_constant_raw_index(); |
aoqi@0 | 217 | if (has_cache_index()) { |
aoqi@0 | 218 | VM_ENTRY_MARK; |
aoqi@0 | 219 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 220 | return cpool->object_to_cp_index(index); |
aoqi@0 | 221 | } |
aoqi@0 | 222 | return index; |
aoqi@0 | 223 | } |
aoqi@0 | 224 | |
aoqi@0 | 225 | // ------------------------------------------------------------------ |
aoqi@0 | 226 | // ciBytecodeStream::get_constant_cache_index |
aoqi@0 | 227 | // Return the CP cache index, or -1 if there isn't any. |
aoqi@0 | 228 | int ciBytecodeStream::get_constant_cache_index() const { |
aoqi@0 | 229 | // work-alike for Bytecode_loadconstant::cache_index() |
aoqi@0 | 230 | return has_cache_index() ? get_constant_raw_index() : -1; |
aoqi@0 | 231 | } |
aoqi@0 | 232 | |
aoqi@0 | 233 | // ------------------------------------------------------------------ |
aoqi@0 | 234 | // ciBytecodeStream::get_constant |
aoqi@0 | 235 | // |
aoqi@0 | 236 | // If this bytecode is one of the ldc variants, get the referenced |
aoqi@0 | 237 | // constant. |
aoqi@0 | 238 | ciConstant ciBytecodeStream::get_constant() { |
aoqi@0 | 239 | int pool_index = get_constant_raw_index(); |
aoqi@0 | 240 | int cache_index = -1; |
aoqi@0 | 241 | if (has_cache_index()) { |
aoqi@0 | 242 | cache_index = pool_index; |
aoqi@0 | 243 | pool_index = -1; |
aoqi@0 | 244 | } |
aoqi@0 | 245 | VM_ENTRY_MARK; |
aoqi@0 | 246 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 247 | return CURRENT_ENV->get_constant_by_index(cpool, pool_index, cache_index, _holder); |
aoqi@0 | 248 | } |
aoqi@0 | 249 | |
aoqi@0 | 250 | // ------------------------------------------------------------------ |
aoqi@0 | 251 | // ciBytecodeStream::get_constant_pool_tag |
aoqi@0 | 252 | // |
aoqi@0 | 253 | // If this bytecode is one of the ldc variants, get the referenced |
aoqi@0 | 254 | // constant. |
aoqi@0 | 255 | constantTag ciBytecodeStream::get_constant_pool_tag(int index) const { |
aoqi@0 | 256 | VM_ENTRY_MARK; |
aoqi@0 | 257 | return _method->get_Method()->constants()->tag_at(index); |
aoqi@0 | 258 | } |
aoqi@0 | 259 | |
aoqi@0 | 260 | // ------------------------------------------------------------------ |
aoqi@0 | 261 | // ciBytecodeStream::get_field_index |
aoqi@0 | 262 | // |
aoqi@0 | 263 | // If this is a field access bytecode, get the constant pool |
aoqi@0 | 264 | // index of the referenced field. |
aoqi@0 | 265 | int ciBytecodeStream::get_field_index() { |
aoqi@0 | 266 | assert(cur_bc() == Bytecodes::_getfield || |
aoqi@0 | 267 | cur_bc() == Bytecodes::_putfield || |
aoqi@0 | 268 | cur_bc() == Bytecodes::_getstatic || |
aoqi@0 | 269 | cur_bc() == Bytecodes::_putstatic, "wrong bc"); |
aoqi@0 | 270 | return get_index_u2_cpcache(); |
aoqi@0 | 271 | } |
aoqi@0 | 272 | |
aoqi@0 | 273 | |
aoqi@0 | 274 | // ------------------------------------------------------------------ |
aoqi@0 | 275 | // ciBytecodeStream::get_field |
aoqi@0 | 276 | // |
aoqi@0 | 277 | // If this bytecode is one of get_field, get_static, put_field, |
aoqi@0 | 278 | // or put_static, get the referenced field. |
aoqi@0 | 279 | ciField* ciBytecodeStream::get_field(bool& will_link) { |
aoqi@0 | 280 | ciField* f = CURRENT_ENV->get_field_by_index(_holder, get_field_index()); |
aoqi@0 | 281 | will_link = f->will_link(_holder, _bc); |
aoqi@0 | 282 | return f; |
aoqi@0 | 283 | } |
aoqi@0 | 284 | |
aoqi@0 | 285 | |
aoqi@0 | 286 | // ------------------------------------------------------------------ |
aoqi@0 | 287 | // ciBytecodeStream::get_declared_field_holder |
aoqi@0 | 288 | // |
aoqi@0 | 289 | // Get the declared holder of the currently referenced field. |
aoqi@0 | 290 | // |
aoqi@0 | 291 | // Usage note: the holder() of a ciField class returns the canonical |
aoqi@0 | 292 | // holder of the field, rather than the holder declared in the |
aoqi@0 | 293 | // bytecodes. |
aoqi@0 | 294 | // |
aoqi@0 | 295 | // There is no "will_link" result passed back. The user is responsible |
aoqi@0 | 296 | // for checking linkability when retrieving the associated field. |
aoqi@0 | 297 | ciInstanceKlass* ciBytecodeStream::get_declared_field_holder() { |
aoqi@0 | 298 | VM_ENTRY_MARK; |
aoqi@0 | 299 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 300 | int holder_index = get_field_holder_index(); |
aoqi@0 | 301 | bool ignore; |
aoqi@0 | 302 | return CURRENT_ENV->get_klass_by_index(cpool, holder_index, ignore, _holder) |
aoqi@0 | 303 | ->as_instance_klass(); |
aoqi@0 | 304 | } |
aoqi@0 | 305 | |
aoqi@0 | 306 | // ------------------------------------------------------------------ |
aoqi@0 | 307 | // ciBytecodeStream::get_field_holder_index |
aoqi@0 | 308 | // |
aoqi@0 | 309 | // Get the constant pool index of the declared holder of the field |
aoqi@0 | 310 | // referenced by the current bytecode. Used for generating |
aoqi@0 | 311 | // deoptimization information. |
aoqi@0 | 312 | int ciBytecodeStream::get_field_holder_index() { |
aoqi@0 | 313 | GUARDED_VM_ENTRY( |
aoqi@0 | 314 | ConstantPool* cpool = _holder->get_instanceKlass()->constants(); |
aoqi@0 | 315 | return cpool->klass_ref_index_at(get_field_index()); |
aoqi@0 | 316 | ) |
aoqi@0 | 317 | } |
aoqi@0 | 318 | |
aoqi@0 | 319 | // ------------------------------------------------------------------ |
aoqi@0 | 320 | // ciBytecodeStream::get_field_signature_index |
aoqi@0 | 321 | // |
aoqi@0 | 322 | // Get the constant pool index of the signature of the field |
aoqi@0 | 323 | // referenced by the current bytecode. Used for generating |
aoqi@0 | 324 | // deoptimization information. |
aoqi@0 | 325 | int ciBytecodeStream::get_field_signature_index() { |
aoqi@0 | 326 | VM_ENTRY_MARK; |
aoqi@0 | 327 | ConstantPool* cpool = _holder->get_instanceKlass()->constants(); |
aoqi@0 | 328 | int nt_index = cpool->name_and_type_ref_index_at(get_field_index()); |
aoqi@0 | 329 | return cpool->signature_ref_index_at(nt_index); |
aoqi@0 | 330 | } |
aoqi@0 | 331 | |
aoqi@0 | 332 | // ------------------------------------------------------------------ |
aoqi@0 | 333 | // ciBytecodeStream::get_method_index |
aoqi@0 | 334 | // |
aoqi@0 | 335 | // If this is a method invocation bytecode, get the constant pool |
aoqi@0 | 336 | // index of the invoked method. |
aoqi@0 | 337 | int ciBytecodeStream::get_method_index() { |
aoqi@0 | 338 | #ifdef ASSERT |
aoqi@0 | 339 | switch (cur_bc()) { |
aoqi@0 | 340 | case Bytecodes::_invokeinterface: |
aoqi@0 | 341 | case Bytecodes::_invokevirtual: |
aoqi@0 | 342 | case Bytecodes::_invokespecial: |
aoqi@0 | 343 | case Bytecodes::_invokestatic: |
aoqi@0 | 344 | case Bytecodes::_invokedynamic: |
aoqi@0 | 345 | break; |
aoqi@0 | 346 | default: |
aoqi@0 | 347 | ShouldNotReachHere(); |
aoqi@0 | 348 | } |
aoqi@0 | 349 | #endif |
aoqi@0 | 350 | if (has_index_u4()) |
aoqi@0 | 351 | return get_index_u4(); // invokedynamic |
aoqi@0 | 352 | return get_index_u2_cpcache(); |
aoqi@0 | 353 | } |
aoqi@0 | 354 | |
aoqi@0 | 355 | // ------------------------------------------------------------------ |
aoqi@0 | 356 | // ciBytecodeStream::get_method |
aoqi@0 | 357 | // |
aoqi@0 | 358 | // If this is a method invocation bytecode, get the invoked method. |
aoqi@0 | 359 | // Additionally return the declared signature to get more concrete |
aoqi@0 | 360 | // type information if required (Cf. invokedynamic and invokehandle). |
aoqi@0 | 361 | ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_signature_result) { |
aoqi@0 | 362 | VM_ENTRY_MARK; |
aoqi@0 | 363 | ciEnv* env = CURRENT_ENV; |
aoqi@0 | 364 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 365 | ciMethod* m = env->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder); |
aoqi@0 | 366 | will_link = m->is_loaded(); |
aoqi@0 | 367 | |
aoqi@0 | 368 | // Use the MethodType stored in the CP cache to create a signature |
aoqi@0 | 369 | // with correct types (in respect to class loaders). |
aoqi@0 | 370 | if (has_method_type()) { |
aoqi@0 | 371 | ciSymbol* sig_sym = env->get_symbol(cpool->symbol_at(get_method_signature_index())); |
aoqi@0 | 372 | ciKlass* pool_holder = env->get_klass(cpool->pool_holder()); |
aoqi@0 | 373 | ciMethodType* method_type = get_method_type(); |
aoqi@0 | 374 | ciSignature* declared_signature = new (env->arena()) ciSignature(pool_holder, sig_sym, method_type); |
aoqi@0 | 375 | (*declared_signature_result) = declared_signature; |
aoqi@0 | 376 | } else { |
aoqi@0 | 377 | (*declared_signature_result) = m->signature(); |
aoqi@0 | 378 | } |
aoqi@0 | 379 | return m; |
aoqi@0 | 380 | } |
aoqi@0 | 381 | |
aoqi@0 | 382 | // ------------------------------------------------------------------ |
aoqi@0 | 383 | // ciBytecodeStream::has_appendix |
aoqi@0 | 384 | // |
aoqi@0 | 385 | // Returns true if there is an appendix argument stored in the |
aoqi@0 | 386 | // constant pool cache at the current bci. |
aoqi@0 | 387 | bool ciBytecodeStream::has_appendix() { |
aoqi@0 | 388 | VM_ENTRY_MARK; |
aoqi@0 | 389 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 390 | return ConstantPool::has_appendix_at_if_loaded(cpool, get_method_index()); |
aoqi@0 | 391 | } |
aoqi@0 | 392 | |
aoqi@0 | 393 | // ------------------------------------------------------------------ |
aoqi@0 | 394 | // ciBytecodeStream::get_appendix |
aoqi@0 | 395 | // |
aoqi@0 | 396 | // Return the appendix argument stored in the constant pool cache at |
aoqi@0 | 397 | // the current bci. |
aoqi@0 | 398 | ciObject* ciBytecodeStream::get_appendix() { |
aoqi@0 | 399 | VM_ENTRY_MARK; |
aoqi@0 | 400 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 401 | oop appendix_oop = ConstantPool::appendix_at_if_loaded(cpool, get_method_index()); |
aoqi@0 | 402 | return CURRENT_ENV->get_object(appendix_oop); |
aoqi@0 | 403 | } |
aoqi@0 | 404 | |
aoqi@0 | 405 | // ------------------------------------------------------------------ |
aoqi@0 | 406 | // ciBytecodeStream::has_method_type |
aoqi@0 | 407 | // |
aoqi@0 | 408 | // Returns true if there is a MethodType argument stored in the |
aoqi@0 | 409 | // constant pool cache at the current bci. |
aoqi@0 | 410 | bool ciBytecodeStream::has_method_type() { |
aoqi@0 | 411 | GUARDED_VM_ENTRY( |
aoqi@0 | 412 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 413 | return ConstantPool::has_method_type_at_if_loaded(cpool, get_method_index()); |
aoqi@0 | 414 | ) |
aoqi@0 | 415 | } |
aoqi@0 | 416 | |
aoqi@0 | 417 | // ------------------------------------------------------------------ |
aoqi@0 | 418 | // ciBytecodeStream::get_method_type |
aoqi@0 | 419 | // |
aoqi@0 | 420 | // Return the MethodType stored in the constant pool cache at |
aoqi@0 | 421 | // the current bci. |
aoqi@0 | 422 | ciMethodType* ciBytecodeStream::get_method_type() { |
aoqi@0 | 423 | GUARDED_VM_ENTRY( |
aoqi@0 | 424 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 425 | oop method_type_oop = ConstantPool::method_type_at_if_loaded(cpool, get_method_index()); |
aoqi@0 | 426 | return CURRENT_ENV->get_object(method_type_oop)->as_method_type(); |
aoqi@0 | 427 | ) |
aoqi@0 | 428 | } |
aoqi@0 | 429 | |
aoqi@0 | 430 | // ------------------------------------------------------------------ |
aoqi@0 | 431 | // ciBytecodeStream::get_declared_method_holder |
aoqi@0 | 432 | // |
aoqi@0 | 433 | // Get the declared holder of the currently referenced method. |
aoqi@0 | 434 | // |
aoqi@0 | 435 | // Usage note: the holder() of a ciMethod class returns the canonical |
aoqi@0 | 436 | // holder of the method, rather than the holder declared in the |
aoqi@0 | 437 | // bytecodes. |
aoqi@0 | 438 | // |
aoqi@0 | 439 | // There is no "will_link" result passed back. The user is responsible |
aoqi@0 | 440 | // for checking linkability when retrieving the associated method. |
aoqi@0 | 441 | ciKlass* ciBytecodeStream::get_declared_method_holder() { |
aoqi@0 | 442 | VM_ENTRY_MARK; |
aoqi@0 | 443 | constantPoolHandle cpool(_method->get_Method()->constants()); |
aoqi@0 | 444 | bool ignore; |
aoqi@0 | 445 | // report as MethodHandle for invokedynamic, which is syntactically classless |
aoqi@0 | 446 | if (cur_bc() == Bytecodes::_invokedynamic) |
aoqi@0 | 447 | return CURRENT_ENV->get_klass_by_name(_holder, ciSymbol::java_lang_invoke_MethodHandle(), false); |
aoqi@0 | 448 | return CURRENT_ENV->get_klass_by_index(cpool, get_method_holder_index(), ignore, _holder); |
aoqi@0 | 449 | } |
aoqi@0 | 450 | |
aoqi@0 | 451 | // ------------------------------------------------------------------ |
aoqi@0 | 452 | // ciBytecodeStream::get_method_holder_index |
aoqi@0 | 453 | // |
aoqi@0 | 454 | // Get the constant pool index of the declared holder of the method |
aoqi@0 | 455 | // referenced by the current bytecode. Used for generating |
aoqi@0 | 456 | // deoptimization information. |
aoqi@0 | 457 | int ciBytecodeStream::get_method_holder_index() { |
aoqi@0 | 458 | ConstantPool* cpool = _method->get_Method()->constants(); |
aoqi@0 | 459 | return cpool->klass_ref_index_at(get_method_index()); |
aoqi@0 | 460 | } |
aoqi@0 | 461 | |
aoqi@0 | 462 | // ------------------------------------------------------------------ |
aoqi@0 | 463 | // ciBytecodeStream::get_method_signature_index |
aoqi@0 | 464 | // |
aoqi@0 | 465 | // Get the constant pool index of the signature of the method |
aoqi@0 | 466 | // referenced by the current bytecode. Used for generating |
aoqi@0 | 467 | // deoptimization information. |
aoqi@0 | 468 | int ciBytecodeStream::get_method_signature_index() { |
aoqi@0 | 469 | GUARDED_VM_ENTRY( |
aoqi@0 | 470 | ConstantPool* cpool = _holder->get_instanceKlass()->constants(); |
aoqi@0 | 471 | const int method_index = get_method_index(); |
aoqi@0 | 472 | const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index); |
aoqi@0 | 473 | return cpool->signature_ref_index_at(name_and_type_index); |
aoqi@0 | 474 | ) |
aoqi@0 | 475 | } |
aoqi@0 | 476 | |
aoqi@0 | 477 | // ------------------------------------------------------------------ |
aoqi@0 | 478 | // ciBytecodeStream::get_resolved_references |
aoqi@0 | 479 | ciObjArray* ciBytecodeStream::get_resolved_references() { |
aoqi@0 | 480 | VM_ENTRY_MARK; |
aoqi@0 | 481 | // Get the constant pool. |
aoqi@0 | 482 | ConstantPool* cpool = _holder->get_instanceKlass()->constants(); |
aoqi@0 | 483 | |
aoqi@0 | 484 | // Create a resolved references array and return it. |
aoqi@0 | 485 | return CURRENT_ENV->get_object(cpool->resolved_references())->as_obj_array(); |
aoqi@0 | 486 | } |