1 /* 2 * Copyright (c) 1997, 2022, 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 */ 24 25 #ifndef SHARE_OOPS_METHOD_HPP 26 #define SHARE_OOPS_METHOD_HPP 27 28 #include "code/compressedStream.hpp" 29 #include "compiler/compilerDefinitions.hpp" 30 #include "interpreter/invocationCounter.hpp" 31 #include "oops/annotations.hpp" 32 #include "oops/constantPool.hpp" 33 #include "oops/methodCounters.hpp" 34 #include "oops/instanceKlass.hpp" 35 #include "oops/oop.hpp" 36 #include "oops/typeArrayOop.hpp" 37 #include "utilities/accessFlags.hpp" 38 #include "utilities/align.hpp" 39 #include "utilities/growableArray.hpp" 40 #include "utilities/macros.hpp" 41 #include "utilities/vmEnums.hpp" 42 #if INCLUDE_JFR 43 #include "jfr/support/jfrTraceIdExtension.hpp" 44 #endif 45 46 47 // A Method represents a Java method. 48 // 49 // Note that most applications load thousands of methods, so keeping the size of this 50 // class small has a big impact on footprint. 51 // 52 // Note that native_function and signature_handler have to be at fixed offsets 53 // (required by the interpreter) 54 // 55 // Method embedded field layout (after declared fields): 56 // [EMBEDDED native_function (present only if native) ] 57 // [EMBEDDED signature_handler (present only if native) ] 58 59 class CheckedExceptionElement; 60 class LocalVariableTableElement; 61 class AdapterHandlerEntry; 62 class MethodData; 63 class MethodCounters; 64 class ConstMethod; 65 class InlineTableSizes; 66 class CompiledMethod; 67 class InterpreterOopMap; 68 69 class Method : public Metadata { 70 friend class VMStructs; 71 friend class JVMCIVMStructs; 72 friend class MethodTest; 73 private: 74 // If you add a new field that points to any metaspace object, you 75 // must add this field to Method::metaspace_pointers_do(). 76 ConstMethod* _constMethod; // Method read-only data. 77 MethodData* _method_data; 78 MethodCounters* _method_counters; 79 AdapterHandlerEntry* _adapter; 80 AccessFlags _access_flags; // Access flags 81 int _vtable_index; // vtable index of this method (see VtableIndexFlag) 82 // note: can have vtables with >2**16 elements (because of inheritance) 83 u2 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) 84 85 // Flags 86 enum Flags { 87 _caller_sensitive = 1 << 0, 88 _force_inline = 1 << 1, 89 _dont_inline = 1 << 2, 90 _hidden = 1 << 3, 91 _has_injected_profile = 1 << 4, 92 _intrinsic_candidate = 1 << 5, 93 _reserved_stack_access = 1 << 6, 94 _scalarized_args = 1 << 7, 95 _scalarized_return = 1 << 8, 96 _c1_needs_stack_repair = 1 << 9, 97 _c2_needs_stack_repair = 1 << 10, 98 _scoped = 1 << 11, 99 _changes_current_thread = 1 << 12, 100 _jvmti_mount_transition = 1 << 13, 101 }; 102 mutable u2 _flags; 103 104 JFR_ONLY(DEFINE_TRACE_FLAG;) 105 106 #ifndef PRODUCT 107 int64_t _compiled_invocation_count; 108 109 Symbol* _name; 110 #endif 111 // Entry point for calling both from and to the interpreter. 112 address _i2i_entry; // All-args-on-stack calling convention 113 // Entry point for calling from compiled code, to compiled code if it exists 114 // or else the interpreter. 115 volatile address _from_compiled_entry; // Cache of: _code ? _code->verified_entry_point() : _adapter->c2i_entry() 116 volatile address _from_compiled_inline_ro_entry; // Cache of: _code ? _code->verified_inline_ro_entry_point() : _adapter->c2i_inline_ro_entry() 117 volatile address _from_compiled_inline_entry; // Cache of: _code ? _code->verified_inline_entry_point() : _adapter->c2i_inline_entry() 118 // The entry point for calling both from and to compiled code is 119 // "_code->entry_point()". Because of tiered compilation and de-opt, this 120 // field can come and go. It can transition from NULL to not-null at any 121 // time (whenever a compile completes). It can transition from not-null to 122 // NULL only at safepoints (because of a de-opt). 123 CompiledMethod* volatile _code; // Points to the corresponding piece of native code 124 volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry 125 126 // Constructor 127 Method(ConstMethod* xconst, AccessFlags access_flags, Symbol* name); 128 public: 129 130 static Method* allocate(ClassLoaderData* loader_data, 131 int byte_code_size, 132 AccessFlags access_flags, 133 InlineTableSizes* sizes, 134 ConstMethod::MethodType method_type, 135 Symbol* name, 136 TRAPS); 137 138 // CDS and vtbl checking can create an empty Method to get vtbl pointer. 139 Method(){} 140 141 virtual bool is_method() const { return true; } 142 143 #if INCLUDE_CDS 144 void remove_unshareable_info(); 145 void restore_unshareable_info(TRAPS); 146 #endif 147 148 // accessors for instance variables 149 150 ConstMethod* constMethod() const { return _constMethod; } 151 void set_constMethod(ConstMethod* xconst) { _constMethod = xconst; } 152 153 154 static address make_adapters(const methodHandle& mh, TRAPS); 155 address from_compiled_entry() const; 156 address from_compiled_inline_ro_entry() const; 157 address from_compiled_inline_entry() const; 158 address from_interpreted_entry() const; 159 160 // access flag 161 AccessFlags access_flags() const { return _access_flags; } 162 void set_access_flags(AccessFlags flags) { _access_flags = flags; } 163 164 // name 165 Symbol* name() const { return constants()->symbol_at(name_index()); } 166 int name_index() const { return constMethod()->name_index(); } 167 void set_name_index(int index) { constMethod()->set_name_index(index); } 168 169 // signature 170 Symbol* signature() const { return constants()->symbol_at(signature_index()); } 171 int signature_index() const { return constMethod()->signature_index(); } 172 void set_signature_index(int index) { constMethod()->set_signature_index(index); } 173 174 // generics support 175 Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)NULL); } 176 int generic_signature_index() const { return constMethod()->generic_signature_index(); } 177 void set_generic_signature_index(int index) { constMethod()->set_generic_signature_index(index); } 178 179 // annotations support 180 AnnotationArray* annotations() const { 181 return constMethod()->method_annotations(); 182 } 183 AnnotationArray* parameter_annotations() const { 184 return constMethod()->parameter_annotations(); 185 } 186 AnnotationArray* annotation_default() const { 187 return constMethod()->default_annotations(); 188 } 189 AnnotationArray* type_annotations() const { 190 return constMethod()->type_annotations(); 191 } 192 193 // Helper routine: get klass name + "." + method name + signature as 194 // C string, for the purpose of providing more useful 195 // fatal error handling. The string is allocated in resource 196 // area if a buffer is not provided by the caller. 197 char* name_and_sig_as_C_string() const; 198 char* name_and_sig_as_C_string(char* buf, int size) const; 199 200 // Static routine in the situations we don't have a Method* 201 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature); 202 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size); 203 204 // Get return type + klass name + "." + method name + ( parameters types ) 205 // as a C string or print it to an outputStream. 206 // This is to be used to assemble strings passed to Java, so that 207 // the text more resembles Java code. Used in exception messages. 208 // Memory is allocated in the resource area; the caller needs 209 // a ResourceMark. 210 const char* external_name() const; 211 void print_external_name(outputStream *os) const; 212 213 static const char* external_name( Klass* klass, Symbol* method_name, Symbol* signature); 214 static void print_external_name(outputStream *os, Klass* klass, Symbol* method_name, Symbol* signature); 215 216 Bytecodes::Code java_code_at(int bci) const { 217 return Bytecodes::java_code_at(this, bcp_from(bci)); 218 } 219 Bytecodes::Code code_at(int bci) const { 220 return Bytecodes::code_at(this, bcp_from(bci)); 221 } 222 223 // JVMTI breakpoints 224 #if !INCLUDE_JVMTI 225 Bytecodes::Code orig_bytecode_at(int bci) const { 226 ShouldNotReachHere(); 227 return Bytecodes::_shouldnotreachhere; 228 } 229 void set_orig_bytecode_at(int bci, Bytecodes::Code code) { 230 ShouldNotReachHere(); 231 }; 232 u2 number_of_breakpoints() const {return 0;} 233 #else // !INCLUDE_JVMTI 234 Bytecodes::Code orig_bytecode_at(int bci) const; 235 void set_orig_bytecode_at(int bci, Bytecodes::Code code); 236 void set_breakpoint(int bci); 237 void clear_breakpoint(int bci); 238 void clear_all_breakpoints(); 239 // Tracking number of breakpoints, for fullspeed debugging. 240 // Only mutated by VM thread. 241 u2 number_of_breakpoints() const { 242 MethodCounters* mcs = method_counters(); 243 if (mcs == NULL) { 244 return 0; 245 } else { 246 return mcs->number_of_breakpoints(); 247 } 248 } 249 void incr_number_of_breakpoints(Thread* current) { 250 MethodCounters* mcs = get_method_counters(current); 251 if (mcs != NULL) { 252 mcs->incr_number_of_breakpoints(); 253 } 254 } 255 void decr_number_of_breakpoints(Thread* current) { 256 MethodCounters* mcs = get_method_counters(current); 257 if (mcs != NULL) { 258 mcs->decr_number_of_breakpoints(); 259 } 260 } 261 // Initialization only 262 void clear_number_of_breakpoints() { 263 MethodCounters* mcs = method_counters(); 264 if (mcs != NULL) { 265 mcs->clear_number_of_breakpoints(); 266 } 267 } 268 #endif // !INCLUDE_JVMTI 269 270 // index into InstanceKlass methods() array 271 // note: also used by jfr 272 u2 method_idnum() const { return constMethod()->method_idnum(); } 273 void set_method_idnum(u2 idnum) { constMethod()->set_method_idnum(idnum); } 274 275 u2 orig_method_idnum() const { return constMethod()->orig_method_idnum(); } 276 void set_orig_method_idnum(u2 idnum) { constMethod()->set_orig_method_idnum(idnum); } 277 278 // code size 279 int code_size() const { return constMethod()->code_size(); } 280 281 // method size in words 282 int method_size() const { return sizeof(Method)/wordSize + ( is_native() ? 2 : 0 ); } 283 284 // constant pool for Klass* holding this method 285 ConstantPool* constants() const { return constMethod()->constants(); } 286 void set_constants(ConstantPool* c) { constMethod()->set_constants(c); } 287 288 // max stack 289 // return original max stack size for method verification 290 int verifier_max_stack() const { return constMethod()->max_stack(); } 291 int max_stack() const { return constMethod()->max_stack() + extra_stack_entries(); } 292 void set_max_stack(int size) { constMethod()->set_max_stack(size); } 293 294 // max locals 295 int max_locals() const { return constMethod()->max_locals(); } 296 void set_max_locals(int size) { constMethod()->set_max_locals(size); } 297 298 int highest_comp_level() const; 299 void set_highest_comp_level(int level); 300 int highest_osr_comp_level() const; 301 void set_highest_osr_comp_level(int level); 302 303 #if COMPILER2_OR_JVMCI 304 // Count of times method was exited via exception while interpreting 305 void interpreter_throwout_increment(Thread* current) { 306 MethodCounters* mcs = get_method_counters(current); 307 if (mcs != NULL) { 308 mcs->interpreter_throwout_increment(); 309 } 310 } 311 #endif 312 313 int interpreter_throwout_count() const { 314 MethodCounters* mcs = method_counters(); 315 if (mcs == NULL) { 316 return 0; 317 } else { 318 return mcs->interpreter_throwout_count(); 319 } 320 } 321 322 // Derive stuff from the signature at load time. 323 void compute_from_signature(Symbol* sig); 324 325 // size of parameters (receiver if any + arguments) 326 int size_of_parameters() const { return constMethod()->size_of_parameters(); } 327 void set_size_of_parameters(int size) { constMethod()->set_size_of_parameters(size); } 328 329 bool has_stackmap_table() const { 330 return constMethod()->has_stackmap_table(); 331 } 332 333 Array<u1>* stackmap_data() const { 334 return constMethod()->stackmap_data(); 335 } 336 337 void set_stackmap_data(Array<u1>* sd) { 338 constMethod()->set_stackmap_data(sd); 339 } 340 341 // exception handler table 342 bool has_exception_handler() const 343 { return constMethod()->has_exception_handler(); } 344 int exception_table_length() const 345 { return constMethod()->exception_table_length(); } 346 ExceptionTableElement* exception_table_start() const 347 { return constMethod()->exception_table_start(); } 348 349 // Finds the first entry point bci of an exception handler for an 350 // exception of klass ex_klass thrown at throw_bci. A value of NULL 351 // for ex_klass indicates that the exception klass is not known; in 352 // this case it matches any constraint class. Returns -1 if the 353 // exception cannot be handled in this method. The handler 354 // constraint classes are loaded if necessary. Note that this may 355 // throw an exception if loading of the constraint classes causes 356 // an IllegalAccessError (bugid 4307310) or an OutOfMemoryError. 357 // If an exception is thrown, returns the bci of the 358 // exception handler which caused the exception to be thrown, which 359 // is needed for proper retries. See, for example, 360 // InterpreterRuntime::exception_handler_for_exception. 361 static int fast_exception_handler_bci_for(const methodHandle& mh, Klass* ex_klass, int throw_bci, TRAPS); 362 363 static bool register_native(Klass* k, 364 Symbol* name, 365 Symbol* signature, 366 address entry, 367 TRAPS); 368 369 // method data access 370 MethodData* method_data() const { 371 return _method_data; 372 } 373 374 void set_method_data(MethodData* data); 375 376 MethodCounters* method_counters() const { 377 return _method_counters; 378 } 379 380 void clear_method_counters() { 381 _method_counters = NULL; 382 } 383 384 bool init_method_counters(MethodCounters* counters); 385 386 int prev_event_count() const { 387 MethodCounters* mcs = method_counters(); 388 return mcs == NULL ? 0 : mcs->prev_event_count(); 389 } 390 void set_prev_event_count(int count) { 391 MethodCounters* mcs = method_counters(); 392 if (mcs != NULL) { 393 mcs->set_prev_event_count(count); 394 } 395 } 396 jlong prev_time() const { 397 MethodCounters* mcs = method_counters(); 398 return mcs == NULL ? 0 : mcs->prev_time(); 399 } 400 void set_prev_time(jlong time) { 401 MethodCounters* mcs = method_counters(); 402 if (mcs != NULL) { 403 mcs->set_prev_time(time); 404 } 405 } 406 float rate() const { 407 MethodCounters* mcs = method_counters(); 408 return mcs == NULL ? 0 : mcs->rate(); 409 } 410 void set_rate(float rate) { 411 MethodCounters* mcs = method_counters(); 412 if (mcs != NULL) { 413 mcs->set_rate(rate); 414 } 415 } 416 417 int invocation_count() const; 418 int backedge_count() const; 419 420 bool was_executed_more_than(int n); 421 bool was_never_executed() { return !was_executed_more_than(0); } 422 423 static void build_profiling_method_data(const methodHandle& method, TRAPS); 424 425 static MethodCounters* build_method_counters(Thread* current, Method* m); 426 427 int interpreter_invocation_count() { return invocation_count(); } 428 429 #ifndef PRODUCT 430 int64_t compiled_invocation_count() const { return _compiled_invocation_count;} 431 void set_compiled_invocation_count(int count) { _compiled_invocation_count = (int64_t)count; } 432 #else 433 // for PrintMethodData in a product build 434 int64_t compiled_invocation_count() const { return 0; } 435 #endif // not PRODUCT 436 437 // nmethod/verified compiler entry 438 address verified_code_entry(); 439 address verified_inline_code_entry(); 440 address verified_inline_ro_code_entry(); 441 bool check_code() const; // Not inline to avoid circular ref 442 CompiledMethod* volatile code() const; 443 444 // Locks CompiledMethod_lock if not held. 445 void unlink_code(CompiledMethod *compare); 446 // Locks CompiledMethod_lock if not held. 447 void unlink_code(); 448 449 private: 450 // Either called with CompiledMethod_lock held or from constructor. 451 void clear_code(); 452 453 public: 454 static void set_code(const methodHandle& mh, CompiledMethod* code); 455 void set_adapter_entry(AdapterHandlerEntry* adapter) { 456 _adapter = adapter; 457 } 458 void set_from_compiled_entry(address entry) { 459 _from_compiled_entry = entry; 460 } 461 void set_from_compiled_inline_ro_entry(address entry) { 462 _from_compiled_inline_ro_entry = entry; 463 } 464 void set_from_compiled_inline_entry(address entry) { 465 _from_compiled_inline_entry = entry; 466 } 467 468 address get_i2c_entry(); 469 address get_c2i_entry(); 470 address get_c2i_inline_entry(); 471 address get_c2i_unverified_entry(); 472 address get_c2i_unverified_inline_entry(); 473 address get_c2i_no_clinit_check_entry(); 474 AdapterHandlerEntry* adapter() const { 475 return _adapter; 476 } 477 // setup entry points 478 void link_method(const methodHandle& method, TRAPS); 479 // clear entry points. Used by sharing code during dump time 480 void unlink_method() NOT_CDS_RETURN; 481 482 // the number of argument reg slots that the compiled method uses on the stack. 483 int num_stack_arg_slots() const { return constMethod()->num_stack_arg_slots(); } 484 485 virtual void metaspace_pointers_do(MetaspaceClosure* iter); 486 virtual MetaspaceObj::Type type() const { return MethodType; } 487 488 // vtable index 489 enum VtableIndexFlag { 490 // Valid vtable indexes are non-negative (>= 0). 491 // These few negative values are used as sentinels. 492 itable_index_max = -10, // first itable index, growing downward 493 pending_itable_index = -9, // itable index will be assigned 494 invalid_vtable_index = -4, // distinct from any valid vtable index 495 garbage_vtable_index = -3, // not yet linked; no vtable layout yet 496 nonvirtual_vtable_index = -2 // there is no need for vtable dispatch 497 // 6330203 Note: Do not use -1, which was overloaded with many meanings. 498 }; 499 DEBUG_ONLY(bool valid_vtable_index() const { return _vtable_index >= nonvirtual_vtable_index; }) 500 bool has_vtable_index() const { return _vtable_index >= 0; } 501 int vtable_index() const { return _vtable_index; } 502 void set_vtable_index(int index); 503 DEBUG_ONLY(bool valid_itable_index() const { return _vtable_index <= pending_itable_index; }) 504 bool has_itable_index() const { return _vtable_index <= itable_index_max; } 505 int itable_index() const { assert(valid_itable_index(), ""); 506 return itable_index_max - _vtable_index; } 507 void set_itable_index(int index); 508 509 // interpreter entry 510 address interpreter_entry() const { return _i2i_entry; } 511 // Only used when first initialize so we can set _i2i_entry and _from_interpreted_entry 512 void set_interpreter_entry(address entry) { 513 if (_i2i_entry != entry) { 514 _i2i_entry = entry; 515 } 516 if (_from_interpreted_entry != entry) { 517 _from_interpreted_entry = entry; 518 } 519 } 520 521 // native function (used for native methods only) 522 enum { 523 native_bind_event_is_interesting = true 524 }; 525 address native_function() const { return *(native_function_addr()); } 526 527 // Must specify a real function (not NULL). 528 // Use clear_native_function() to unregister. 529 void set_native_function(address function, bool post_event_flag); 530 bool has_native_function() const; 531 void clear_native_function(); 532 533 // signature handler (used for native methods only) 534 address signature_handler() const { return *(signature_handler_addr()); } 535 void set_signature_handler(address handler); 536 537 // Interpreter oopmap support 538 void mask_for(int bci, InterpreterOopMap* mask); 539 540 // operations on invocation counter 541 void print_invocation_count(); 542 543 // byte codes 544 void set_code(address code) { return constMethod()->set_code(code); } 545 address code_base() const { return constMethod()->code_base(); } 546 bool contains(address bcp) const { return constMethod()->contains(bcp); } 547 548 // prints byte codes 549 void print_codes(int flags = 0) const { print_codes_on(tty, flags); } 550 void print_codes_on(outputStream* st, int flags = 0) const; 551 void print_codes_on(int from, int to, outputStream* st, int flags = 0) const; 552 553 // method parameters 554 bool has_method_parameters() const 555 { return constMethod()->has_method_parameters(); } 556 int method_parameters_length() const 557 { return constMethod()->method_parameters_length(); } 558 MethodParametersElement* method_parameters_start() const 559 { return constMethod()->method_parameters_start(); } 560 561 // checked exceptions 562 int checked_exceptions_length() const 563 { return constMethod()->checked_exceptions_length(); } 564 CheckedExceptionElement* checked_exceptions_start() const 565 { return constMethod()->checked_exceptions_start(); } 566 567 // localvariable table 568 bool has_localvariable_table() const 569 { return constMethod()->has_localvariable_table(); } 570 int localvariable_table_length() const 571 { return constMethod()->localvariable_table_length(); } 572 LocalVariableTableElement* localvariable_table_start() const 573 { return constMethod()->localvariable_table_start(); } 574 575 bool has_linenumber_table() const 576 { return constMethod()->has_linenumber_table(); } 577 u_char* compressed_linenumber_table() const 578 { return constMethod()->compressed_linenumber_table(); } 579 580 // method holder (the Klass* holding this method) 581 InstanceKlass* method_holder() const { return constants()->pool_holder(); } 582 583 Symbol* klass_name() const; // returns the name of the method holder 584 BasicType result_type() const { return constMethod()->result_type(); } 585 bool is_returning_oop() const { BasicType r = result_type(); return is_reference_type(r); } 586 InlineKlass* returns_inline_type(Thread* thread) const; 587 588 // Checked exceptions thrown by this method (resolved to mirrors) 589 objArrayHandle resolved_checked_exceptions(TRAPS) { return resolved_checked_exceptions_impl(this, THREAD); } 590 591 // Access flags 592 bool is_public() const { return access_flags().is_public(); } 593 bool is_private() const { return access_flags().is_private(); } 594 bool is_protected() const { return access_flags().is_protected(); } 595 bool is_package_private() const { return !is_public() && !is_private() && !is_protected(); } 596 bool is_static() const { return access_flags().is_static(); } 597 bool is_final() const { return access_flags().is_final(); } 598 bool is_synchronized() const { return access_flags().is_synchronized();} 599 bool is_native() const { return access_flags().is_native(); } 600 bool is_abstract() const { return access_flags().is_abstract(); } 601 bool is_synthetic() const { return access_flags().is_synthetic(); } 602 603 // returns true if contains only return operation 604 bool is_empty_method() const; 605 606 // returns true if this is a vanilla constructor 607 bool is_vanilla_constructor() const; 608 609 // checks method and its method holder 610 bool is_final_method() const; 611 bool is_final_method(AccessFlags class_access_flags) const; 612 // interface method declared with 'default' - excludes private interface methods 613 bool is_default_method() const; 614 615 // true if method needs no dynamic dispatch (final and/or no vtable entry) 616 bool can_be_statically_bound() const; 617 bool can_be_statically_bound(InstanceKlass* context) const; 618 bool can_be_statically_bound(AccessFlags class_access_flags) const; 619 620 // true if method can omit stack trace in throw in compiled code. 621 bool can_omit_stack_trace(); 622 623 // returns true if the method has any backward branches. 624 bool has_loops() { 625 return access_flags().loops_flag_init() ? access_flags().has_loops() : compute_has_loops_flag(); 626 }; 627 628 bool compute_has_loops_flag(); 629 630 bool has_jsrs() { 631 return access_flags().has_jsrs(); 632 }; 633 void set_has_jsrs() { 634 _access_flags.set_has_jsrs(); 635 } 636 637 // returns true if the method has any monitors. 638 bool has_monitors() const { return is_synchronized() || access_flags().has_monitor_bytecodes(); } 639 bool has_monitor_bytecodes() const { return access_flags().has_monitor_bytecodes(); } 640 641 void set_has_monitor_bytecodes() { _access_flags.set_has_monitor_bytecodes(); } 642 643 // monitor matching. This returns a conservative estimate of whether the monitorenter/monitorexit bytecodes 644 // propererly nest in the method. It might return false, even though they actually nest properly, since the info. 645 // has not been computed yet. 646 bool guaranteed_monitor_matching() const { return access_flags().is_monitor_matching(); } 647 void set_guaranteed_monitor_matching() { _access_flags.set_monitor_matching(); } 648 649 // returns true if the method is an accessor function (setter/getter). 650 bool is_accessor() const; 651 652 // returns true if the method is a getter 653 bool is_getter() const; 654 655 // returns true if the method is a setter 656 bool is_setter() const; 657 658 // returns true if the method does nothing but return a constant of primitive type 659 bool is_constant_getter() const; 660 661 // returns true if the method name is <clinit> and the method has 662 // valid static initializer flags. 663 bool is_class_initializer() const; 664 665 // returns true if the method name is <init> and the method is not a static factory 666 bool is_object_constructor() const; 667 668 // returns true if the method is an object constructor or class initializer 669 // (non-static <init> or <clinit>), but false for factories (static <vnew>). 670 bool is_object_constructor_or_class_initializer() const; 671 672 // returns true if the method name is <vnew> and the method is static 673 bool is_static_vnew_factory() const; 674 675 // compiled code support 676 // NOTE: code() is inherently racy as deopt can be clearing code 677 // simultaneously. Use with caution. 678 bool has_compiled_code() const; 679 680 bool needs_clinit_barrier() const; 681 682 // sizing 683 static int header_size() { 684 return align_up((int)sizeof(Method), wordSize) / wordSize; 685 } 686 static int size(bool is_native); 687 int size() const { return method_size(); } 688 void log_touched(Thread* current); 689 static void print_touched_methods(outputStream* out); 690 691 // interpreter support 692 static ByteSize const_offset() { return byte_offset_of(Method, _constMethod ); } 693 static ByteSize access_flags_offset() { return byte_offset_of(Method, _access_flags ); } 694 static ByteSize from_compiled_offset() { return byte_offset_of(Method, _from_compiled_entry); } 695 static ByteSize from_compiled_inline_offset() { return byte_offset_of(Method, _from_compiled_inline_entry); } 696 static ByteSize from_compiled_inline_ro_offset(){ return byte_offset_of(Method, _from_compiled_inline_ro_entry); } 697 static ByteSize code_offset() { return byte_offset_of(Method, _code); } 698 static ByteSize flags_offset() { return byte_offset_of(Method, _flags); } 699 static ByteSize method_data_offset() { 700 return byte_offset_of(Method, _method_data); 701 } 702 static ByteSize method_counters_offset() { 703 return byte_offset_of(Method, _method_counters); 704 } 705 #ifndef PRODUCT 706 static ByteSize compiled_invocation_counter_offset() { return byte_offset_of(Method, _compiled_invocation_count); } 707 #endif // not PRODUCT 708 static ByteSize native_function_offset() { return in_ByteSize(sizeof(Method)); } 709 static ByteSize from_interpreted_offset() { return byte_offset_of(Method, _from_interpreted_entry ); } 710 static ByteSize interpreter_entry_offset() { return byte_offset_of(Method, _i2i_entry ); } 711 static ByteSize signature_handler_offset() { return in_ByteSize(sizeof(Method) + wordSize); } 712 static ByteSize itable_index_offset() { return byte_offset_of(Method, _vtable_index ); } 713 714 // for code generation 715 static int method_data_offset_in_bytes() { return offset_of(Method, _method_data); } 716 static int intrinsic_id_offset_in_bytes() { return offset_of(Method, _intrinsic_id); } 717 static int intrinsic_id_size_in_bytes() { return sizeof(u2); } 718 719 // Static methods that are used to implement member methods where an exposed this pointer 720 // is needed due to possible GCs 721 static objArrayHandle resolved_checked_exceptions_impl(Method* method, TRAPS); 722 723 // Returns the byte code index from the byte code pointer 724 int bci_from(address bcp) const; 725 address bcp_from(int bci) const; 726 address bcp_from(address bcp) const; 727 int validate_bci_from_bcp(address bcp) const; 728 int validate_bci(int bci) const; 729 730 // Returns the line number for a bci if debugging information for the method is prowided, 731 // -1 is returned otherwise. 732 int line_number_from_bci(int bci) const; 733 734 // Reflection support 735 bool is_overridden_in(Klass* k) const; 736 737 // Stack walking support 738 bool is_ignored_by_security_stack_walk() const; 739 740 // JSR 292 support 741 bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id) 742 bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm 743 bool has_member_arg() const; // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc. 744 static methodHandle make_method_handle_intrinsic(vmIntrinsicID iid, // _invokeBasic, _linkToVirtual 745 Symbol* signature, //anything at all 746 TRAPS); 747 // Some special methods don't need to be findable by nmethod iterators and are permanent. 748 bool can_be_allocated_in_NonNMethod_space() const { return is_method_handle_intrinsic(); } 749 750 // Continuation 751 inline bool is_continuation_enter_intrinsic() const; 752 inline bool is_continuation_yield_intrinsic() const; 753 inline bool is_continuation_native_intrinsic() const; 754 inline bool is_special_native_intrinsic() const; 755 756 static Klass* check_non_bcp_klass(Klass* klass); 757 758 enum { 759 // How many extra stack entries for invokedynamic 760 extra_stack_entries_for_jsr292 = 1 761 }; 762 763 // this operates only on invoke methods: 764 // presize interpreter frames for extra interpreter stack entries, if needed 765 // Account for the extra appendix argument for invokehandle/invokedynamic 766 static int extra_stack_entries() { return extra_stack_entries_for_jsr292; } 767 static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize 768 769 // RedefineClasses() support: 770 bool is_old() const { return access_flags().is_old(); } 771 void set_is_old() { _access_flags.set_is_old(); } 772 bool is_obsolete() const { return access_flags().is_obsolete(); } 773 void set_is_obsolete() { _access_flags.set_is_obsolete(); } 774 bool is_deleted() const { return access_flags().is_deleted(); } 775 void set_is_deleted() { _access_flags.set_is_deleted(); } 776 777 bool on_stack() const { return access_flags().on_stack(); } 778 void set_on_stack(const bool value); 779 780 void record_gc_epoch(); 781 782 // see the definition in Method*.cpp for the gory details 783 bool should_not_be_cached() const; 784 785 // JVMTI Native method prefixing support: 786 bool is_prefixed_native() const { return access_flags().is_prefixed_native(); } 787 void set_is_prefixed_native() { _access_flags.set_is_prefixed_native(); } 788 789 // Rewriting support 790 static methodHandle clone_with_new_data(const methodHandle& m, u_char* new_code, int new_code_length, 791 u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS); 792 793 // jmethodID handling 794 // Because the useful life-span of a jmethodID cannot be determined, 795 // once created they are never reclaimed. The methods to which they refer, 796 // however, can be GC'ed away if the class is unloaded or if the method is 797 // made obsolete or deleted -- in these cases, the jmethodID 798 // refers to NULL (as is the case for any weak reference). 799 static jmethodID make_jmethod_id(ClassLoaderData* cld, Method* mh); 800 static void destroy_jmethod_id(ClassLoaderData* cld, jmethodID mid); 801 802 // Ensure there is enough capacity in the internal tracking data 803 // structures to hold the number of jmethodIDs you plan to generate. 804 // This saves substantial time doing allocations. 805 static void ensure_jmethod_ids(ClassLoaderData* cld, int capacity); 806 807 // Use resolve_jmethod_id() in situations where the caller is expected 808 // to provide a valid jmethodID; the only sanity checks are in asserts; 809 // result guaranteed not to be NULL. 810 inline static Method* resolve_jmethod_id(jmethodID mid) { 811 assert(mid != NULL, "JNI method id should not be null"); 812 return *((Method**)mid); 813 } 814 815 // Use checked_resolve_jmethod_id() in situations where the caller 816 // should provide a valid jmethodID, but might not. NULL is returned 817 // when the jmethodID does not refer to a valid method. 818 static Method* checked_resolve_jmethod_id(jmethodID mid); 819 820 static void change_method_associated_with_jmethod_id(jmethodID old_jmid_ptr, Method* new_method); 821 static bool is_method_id(jmethodID mid); 822 823 // Clear methods 824 static void clear_jmethod_ids(ClassLoaderData* loader_data); 825 static void print_jmethod_ids_count(const ClassLoaderData* loader_data, outputStream* out) PRODUCT_RETURN; 826 827 // Get this method's jmethodID -- allocate if it doesn't exist 828 jmethodID jmethod_id(); 829 830 // Lookup the jmethodID for this method. Return NULL if not found. 831 // NOTE that this function can be called from a signal handler 832 // (see AsyncGetCallTrace support for Forte Analyzer) and this 833 // needs to be async-safe. No allocation should be done and 834 // so handles are not used to avoid deadlock. 835 jmethodID find_jmethod_id_or_null() { return method_holder()->jmethod_id_or_null(this); } 836 837 // Support for inlining of intrinsic methods 838 vmIntrinsicID intrinsic_id() const { return (vmIntrinsicID) _intrinsic_id; } 839 void set_intrinsic_id(vmIntrinsicID id) { _intrinsic_id = (u2) id; } 840 841 // Helper routines for intrinsic_id() and vmIntrinsics::method(). 842 void init_intrinsic_id(vmSymbolID klass_id); // updates from _none if a match 843 static vmSymbolID klass_id_for_intrinsics(const Klass* holder); 844 845 bool caller_sensitive() { 846 return (_flags & _caller_sensitive) != 0; 847 } 848 void set_caller_sensitive(bool x) { 849 _flags = x ? (_flags | _caller_sensitive) : (_flags & ~_caller_sensitive); 850 } 851 852 bool force_inline() { 853 return (_flags & _force_inline) != 0; 854 } 855 void set_force_inline(bool x) { 856 _flags = x ? (_flags | _force_inline) : (_flags & ~_force_inline); 857 } 858 859 bool dont_inline() { 860 return (_flags & _dont_inline) != 0; 861 } 862 void set_dont_inline(bool x) { 863 _flags = x ? (_flags | _dont_inline) : (_flags & ~_dont_inline); 864 } 865 866 bool changes_current_thread() { 867 return (_flags & _changes_current_thread) != 0; 868 } 869 void set_changes_current_thread(bool x) { 870 _flags = x ? (_flags | _changes_current_thread) : (_flags & ~_changes_current_thread); 871 } 872 873 bool jvmti_mount_transition() { 874 return (_flags & _jvmti_mount_transition) != 0; 875 } 876 void set_jvmti_mount_transition(bool x) { 877 _flags = x ? (_flags | _jvmti_mount_transition) : (_flags & ~_jvmti_mount_transition); 878 } 879 880 bool is_hidden() const { 881 return (_flags & _hidden) != 0; 882 } 883 884 void set_hidden(bool x) { 885 _flags = x ? (_flags | _hidden) : (_flags & ~_hidden); 886 } 887 888 bool is_scoped() const { 889 return (_flags & _scoped) != 0; 890 } 891 892 void set_scoped(bool x) { 893 _flags = x ? (_flags | _scoped) : (_flags & ~_scoped); 894 } 895 896 bool intrinsic_candidate() { 897 return (_flags & _intrinsic_candidate) != 0; 898 } 899 void set_intrinsic_candidate(bool x) { 900 _flags = x ? (_flags | _intrinsic_candidate) : (_flags & ~_intrinsic_candidate); 901 } 902 903 bool has_injected_profile() { 904 return (_flags & _has_injected_profile) != 0; 905 } 906 void set_has_injected_profile(bool x) { 907 _flags = x ? (_flags | _has_injected_profile) : (_flags & ~_has_injected_profile); 908 } 909 910 bool has_reserved_stack_access() { 911 return (_flags & _reserved_stack_access) != 0; 912 } 913 914 void set_has_reserved_stack_access(bool x) { 915 _flags = x ? (_flags | _reserved_stack_access) : (_flags & ~_reserved_stack_access); 916 } 917 918 bool has_scalarized_args() const { 919 return (_flags & _scalarized_args) != 0; 920 } 921 922 void set_has_scalarized_args(bool x) { 923 _flags = x ? (_flags | _scalarized_args) : (_flags & ~_scalarized_args); 924 } 925 926 bool has_scalarized_return() const { 927 return (_flags & _scalarized_return) != 0; 928 } 929 930 void set_has_scalarized_return(bool x) { 931 _flags = x ? (_flags | _scalarized_return) : (_flags & ~_scalarized_return); 932 } 933 934 bool is_scalarized_arg(int idx) const; 935 936 bool c1_needs_stack_repair() { 937 return (_flags & _c1_needs_stack_repair) != 0; 938 } 939 940 bool c2_needs_stack_repair() { 941 return (_flags & _c2_needs_stack_repair) != 0; 942 } 943 944 void set_c1_needs_stack_repair(bool x) { 945 _flags = x ? (_flags | _c1_needs_stack_repair) : (_flags & ~_c1_needs_stack_repair); 946 } 947 948 void set_c2_needs_stack_repair(bool x) { 949 _flags = x ? (_flags | _c2_needs_stack_repair) : (_flags & ~_c2_needs_stack_repair); 950 } 951 952 JFR_ONLY(DEFINE_TRACE_FLAG_ACCESSOR;) 953 954 ConstMethod::MethodType method_type() const { 955 return _constMethod->method_type(); 956 } 957 bool is_overpass() const { return method_type() == ConstMethod::OVERPASS; } 958 959 // On-stack replacement support 960 bool has_osr_nmethod(int level, bool match_level) { 961 return method_holder()->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL; 962 } 963 964 int mark_osr_nmethods() { 965 return method_holder()->mark_osr_nmethods(this); 966 } 967 968 nmethod* lookup_osr_nmethod_for(int bci, int level, bool match_level) { 969 return method_holder()->lookup_osr_nmethod(this, bci, level, match_level); 970 } 971 972 // Find if klass for method is loaded 973 bool is_klass_loaded_by_klass_index(int klass_index) const; 974 bool is_klass_loaded(int refinfo_index, bool must_be_resolved = false) const; 975 976 // Indicates whether compilation failed earlier for this method, or 977 // whether it is not compilable for another reason like having a 978 // breakpoint set in it. 979 bool is_not_compilable(int comp_level = CompLevel_any) const; 980 void set_not_compilable(const char* reason, int comp_level = CompLevel_all, bool report = true); 981 void set_not_compilable_quietly(const char* reason, int comp_level = CompLevel_all) { 982 set_not_compilable(reason, comp_level, false); 983 } 984 bool is_not_osr_compilable(int comp_level = CompLevel_any) const; 985 void set_not_osr_compilable(const char* reason, int comp_level = CompLevel_all, bool report = true); 986 void set_not_osr_compilable_quietly(const char* reason, int comp_level = CompLevel_all) { 987 set_not_osr_compilable(reason, comp_level, false); 988 } 989 bool is_always_compilable() const; 990 991 private: 992 void print_made_not_compilable(int comp_level, bool is_osr, bool report, const char* reason); 993 994 public: 995 MethodCounters* get_method_counters(Thread* current) { 996 if (_method_counters == NULL) { 997 build_method_counters(current, this); 998 } 999 return _method_counters; 1000 } 1001 1002 bool is_not_c1_compilable() const { return access_flags().is_not_c1_compilable(); } 1003 void set_not_c1_compilable() { _access_flags.set_not_c1_compilable(); } 1004 void clear_not_c1_compilable() { _access_flags.clear_not_c1_compilable(); } 1005 bool is_not_c2_compilable() const { return access_flags().is_not_c2_compilable(); } 1006 void set_not_c2_compilable() { _access_flags.set_not_c2_compilable(); } 1007 void clear_not_c2_compilable() { _access_flags.clear_not_c2_compilable(); } 1008 1009 bool is_not_c1_osr_compilable() const { return is_not_c1_compilable(); } // don't waste an accessFlags bit 1010 void set_not_c1_osr_compilable() { set_not_c1_compilable(); } // don't waste an accessFlags bit 1011 void clear_not_c1_osr_compilable() { clear_not_c1_compilable(); } // don't waste an accessFlags bit 1012 bool is_not_c2_osr_compilable() const { return access_flags().is_not_c2_osr_compilable(); } 1013 void set_not_c2_osr_compilable() { _access_flags.set_not_c2_osr_compilable(); } 1014 void clear_not_c2_osr_compilable() { _access_flags.clear_not_c2_osr_compilable(); } 1015 1016 // Background compilation support 1017 bool queued_for_compilation() const { return access_flags().queued_for_compilation(); } 1018 void set_queued_for_compilation() { _access_flags.set_queued_for_compilation(); } 1019 void clear_queued_for_compilation() { _access_flags.clear_queued_for_compilation(); } 1020 1021 // Resolve all classes in signature, return 'true' if successful 1022 static bool load_signature_classes(const methodHandle& m, TRAPS); 1023 1024 // Printing 1025 void print_short_name(outputStream* st = tty) const; // prints as klassname::methodname; Exposed so field engineers can debug VM 1026 #if INCLUDE_JVMTI 1027 void print_name(outputStream* st = tty) const; // prints as "virtual void foo(int)"; exposed for -Xlog:redefine+class 1028 #else 1029 void print_name(outputStream* st = tty) const PRODUCT_RETURN; // prints as "virtual void foo(int)" 1030 #endif 1031 1032 typedef int (*method_comparator_func)(Method* a, Method* b); 1033 1034 // Helper routine used for method sorting 1035 static void sort_methods(Array<Method*>* methods, bool set_idnums = true, method_comparator_func func = NULL); 1036 1037 // Deallocation function for redefine classes or if an error occurs 1038 void deallocate_contents(ClassLoaderData* loader_data); 1039 1040 void release_C_heap_structures(); 1041 1042 Method* get_new_method() const { 1043 InstanceKlass* holder = method_holder(); 1044 Method* new_method = holder->method_with_idnum(orig_method_idnum()); 1045 1046 assert(new_method != NULL, "method_with_idnum() should not be NULL"); 1047 assert(this != new_method, "sanity check"); 1048 return new_method; 1049 } 1050 1051 // Printing 1052 #ifndef PRODUCT 1053 void print_on(outputStream* st) const; 1054 #endif 1055 void print_value_on(outputStream* st) const; 1056 void print_linkage_flags(outputStream* st) PRODUCT_RETURN; 1057 1058 const char* internal_name() const { return "{method}"; } 1059 1060 // Check for valid method pointer 1061 static bool has_method_vptr(const void* ptr); 1062 static bool is_valid_method(const Method* m); 1063 1064 // Verify 1065 void verify() { verify_on(tty); } 1066 void verify_on(outputStream* st); 1067 1068 private: 1069 1070 // Inlined elements 1071 address* native_function_addr() const { assert(is_native(), "must be native"); return (address*) (this+1); } 1072 address* signature_handler_addr() const { return native_function_addr() + 1; } 1073 1074 void set_num_stack_arg_slots(int n) { constMethod()->set_num_stack_arg_slots(n); } 1075 }; 1076 1077 1078 // Utility class for compressing line number tables 1079 1080 class CompressedLineNumberWriteStream: public CompressedWriteStream { 1081 private: 1082 int _bci; 1083 int _line; 1084 public: 1085 // Constructor 1086 CompressedLineNumberWriteStream(int initial_size) : CompressedWriteStream(initial_size), _bci(0), _line(0) {} 1087 CompressedLineNumberWriteStream(u_char* buffer, int initial_size) : CompressedWriteStream(buffer, initial_size), _bci(0), _line(0) {} 1088 1089 // Write (bci, line number) pair to stream 1090 void write_pair_regular(int bci_delta, int line_delta); 1091 1092 // If (bci delta, line delta) fits in (5-bit unsigned, 3-bit unsigned) 1093 // we save it as one byte, otherwise we write a 0xFF escape character 1094 // and use regular compression. 0x0 is used as end-of-stream terminator. 1095 void write_pair_inline(int bci, int line); 1096 1097 void write_pair(int bci, int line); 1098 1099 // Write end-of-stream marker 1100 void write_terminator() { write_byte(0); } 1101 }; 1102 1103 1104 // Utility class for decompressing line number tables 1105 1106 class CompressedLineNumberReadStream: public CompressedReadStream { 1107 private: 1108 int _bci; 1109 int _line; 1110 public: 1111 // Constructor 1112 CompressedLineNumberReadStream(u_char* buffer); 1113 // Read (bci, line number) pair from stream. Returns false at end-of-stream. 1114 bool read_pair(); 1115 // Accessing bci and line number (after calling read_pair) 1116 int bci() const { return _bci; } 1117 int line() const { return _line; } 1118 }; 1119 1120 1121 #if INCLUDE_JVMTI 1122 1123 /// Fast Breakpoints. 1124 1125 // If this structure gets more complicated (because bpts get numerous), 1126 // move it into its own header. 1127 1128 // There is presently no provision for concurrent access 1129 // to breakpoint lists, which is only OK for JVMTI because 1130 // breakpoints are written only at safepoints, and are read 1131 // concurrently only outside of safepoints. 1132 1133 class BreakpointInfo : public CHeapObj<mtClass> { 1134 friend class VMStructs; 1135 private: 1136 Bytecodes::Code _orig_bytecode; 1137 int _bci; 1138 u2 _name_index; // of method 1139 u2 _signature_index; // of method 1140 BreakpointInfo* _next; // simple storage allocation 1141 1142 public: 1143 BreakpointInfo(Method* m, int bci); 1144 1145 // accessors 1146 Bytecodes::Code orig_bytecode() { return _orig_bytecode; } 1147 void set_orig_bytecode(Bytecodes::Code code) { _orig_bytecode = code; } 1148 int bci() { return _bci; } 1149 1150 BreakpointInfo* next() const { return _next; } 1151 void set_next(BreakpointInfo* n) { _next = n; } 1152 1153 // helps for searchers 1154 bool match(const Method* m, int bci) { 1155 return bci == _bci && match(m); 1156 } 1157 1158 bool match(const Method* m) { 1159 return _name_index == m->name_index() && 1160 _signature_index == m->signature_index(); 1161 } 1162 1163 void set(Method* method); 1164 void clear(Method* method); 1165 }; 1166 1167 #endif // INCLUDE_JVMTI 1168 1169 // Utility class for access exception handlers 1170 class ExceptionTable : public StackObj { 1171 private: 1172 ExceptionTableElement* _table; 1173 u2 _length; 1174 1175 public: 1176 ExceptionTable(const Method* m) { 1177 if (m->has_exception_handler()) { 1178 _table = m->exception_table_start(); 1179 _length = m->exception_table_length(); 1180 } else { 1181 _table = NULL; 1182 _length = 0; 1183 } 1184 } 1185 1186 int length() const { 1187 return _length; 1188 } 1189 1190 u2 start_pc(int idx) const { 1191 assert(idx < _length, "out of bounds"); 1192 return _table[idx].start_pc; 1193 } 1194 1195 void set_start_pc(int idx, u2 value) { 1196 assert(idx < _length, "out of bounds"); 1197 _table[idx].start_pc = value; 1198 } 1199 1200 u2 end_pc(int idx) const { 1201 assert(idx < _length, "out of bounds"); 1202 return _table[idx].end_pc; 1203 } 1204 1205 void set_end_pc(int idx, u2 value) { 1206 assert(idx < _length, "out of bounds"); 1207 _table[idx].end_pc = value; 1208 } 1209 1210 u2 handler_pc(int idx) const { 1211 assert(idx < _length, "out of bounds"); 1212 return _table[idx].handler_pc; 1213 } 1214 1215 void set_handler_pc(int idx, u2 value) { 1216 assert(idx < _length, "out of bounds"); 1217 _table[idx].handler_pc = value; 1218 } 1219 1220 u2 catch_type_index(int idx) const { 1221 assert(idx < _length, "out of bounds"); 1222 return _table[idx].catch_type_index; 1223 } 1224 1225 void set_catch_type_index(int idx, u2 value) { 1226 assert(idx < _length, "out of bounds"); 1227 _table[idx].catch_type_index = value; 1228 } 1229 }; 1230 1231 #endif // SHARE_OOPS_METHOD_HPP