comparison src/share/vm/oops/methodOop.hpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 70f715dfbb41 93c71eb28866
children
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
62 // |------------------------------------------------------| 62 // |------------------------------------------------------|
63 // | header | 63 // | header |
64 // | klass | 64 // | klass |
65 // |------------------------------------------------------| 65 // |------------------------------------------------------|
66 // | constMethodOop (oop) | 66 // | constMethodOop (oop) |
67 // | constants (oop) |
68 // |------------------------------------------------------| 67 // |------------------------------------------------------|
69 // | methodData (oop) | 68 // | methodData (oop) |
70 // | interp_invocation_count | 69 // | interp_invocation_count |
71 // |------------------------------------------------------| 70 // |------------------------------------------------------|
72 // | access_flags | 71 // | access_flags |
108 class methodOopDesc : public oopDesc { 107 class methodOopDesc : public oopDesc {
109 friend class methodKlass; 108 friend class methodKlass;
110 friend class VMStructs; 109 friend class VMStructs;
111 private: 110 private:
112 constMethodOop _constMethod; // Method read-only data. 111 constMethodOop _constMethod; // Method read-only data.
113 constantPoolOop _constants; // Constant pool
114 methodDataOop _method_data; 112 methodDataOop _method_data;
115 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered) 113 int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered)
116 AccessFlags _access_flags; // Access flags 114 AccessFlags _access_flags; // Access flags
117 int _vtable_index; // vtable index of this method (see VtableIndexFlag) 115 int _vtable_index; // vtable index of this method (see VtableIndexFlag)
118 // note: can have vtables with >2**16 elements (because of inheritance) 116 // note: can have vtables with >2**16 elements (because of inheritance)
122 u2 _method_size; // size of this object 120 u2 _method_size; // size of this object
123 u2 _max_stack; // Maximum number of entries on the expression stack 121 u2 _max_stack; // Maximum number of entries on the expression stack
124 u2 _max_locals; // Number of local variables used by this method 122 u2 _max_locals; // Number of local variables used by this method
125 u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words 123 u2 _size_of_parameters; // size of the parameter block (receiver + arguments) in words
126 u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none) 124 u1 _intrinsic_id; // vmSymbols::intrinsic_id (0 == _none)
127 u1 _jfr_towrite : 1, // Flags 125 u1 _jfr_towrite : 1, // Flags
128 : 7; 126 _force_inline : 1,
127 _hidden : 1,
128 _dont_inline : 1,
129 : 4;
129 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting 130 u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting
130 u2 _number_of_breakpoints; // fullspeed debugging support 131 u2 _number_of_breakpoints; // fullspeed debugging support
131 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations 132 InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations
132 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations 133 InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations
133 134
173 // access flag 174 // access flag
174 AccessFlags access_flags() const { return _access_flags; } 175 AccessFlags access_flags() const { return _access_flags; }
175 void set_access_flags(AccessFlags flags) { _access_flags = flags; } 176 void set_access_flags(AccessFlags flags) { _access_flags = flags; }
176 177
177 // name 178 // name
178 Symbol* name() const { return _constants->symbol_at(name_index()); } 179 Symbol* name() const { return constants()->symbol_at(name_index()); }
179 int name_index() const { return constMethod()->name_index(); } 180 int name_index() const { return constMethod()->name_index(); }
180 void set_name_index(int index) { constMethod()->set_name_index(index); } 181 void set_name_index(int index) { constMethod()->set_name_index(index); }
181 182
182 // signature 183 // signature
183 Symbol* signature() const { return _constants->symbol_at(signature_index()); } 184 Symbol* signature() const { return constants()->symbol_at(signature_index()); }
184 int signature_index() const { return constMethod()->signature_index(); } 185 int signature_index() const { return constMethod()->signature_index(); }
185 void set_signature_index(int index) { constMethod()->set_signature_index(index); } 186 void set_signature_index(int index) { constMethod()->set_signature_index(index); }
186 187
187 // generics support 188 // generics support
188 Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? _constants->symbol_at(idx) : (Symbol*)NULL); } 189 Symbol* generic_signature() const { int idx = generic_signature_index(); return ((idx != 0) ? constants()->symbol_at(idx) : (Symbol*)NULL); }
189 int generic_signature_index() const { return constMethod()->generic_signature_index(); } 190 int generic_signature_index() const { return constMethod()->generic_signature_index(); }
190 void set_generic_signature_index(int index) { constMethod()->set_generic_signature_index(index); } 191 void set_generic_signature_index(int index) { constMethod()->set_generic_signature_index(index); }
191 192
192 // annotations support 193 // annotations support
193 typeArrayOop annotations() const { return instanceKlass::cast(method_holder())->get_method_annotations_of(method_idnum()); } 194 typeArrayOop annotations() const { return instanceKlass::cast(method_holder())->get_method_annotations_of(method_idnum()); }
201 202
202 // Helper routine: get klass name + "." + method name + signature as 203 // Helper routine: get klass name + "." + method name + signature as
203 // C string, for the purpose of providing more useful NoSuchMethodErrors 204 // C string, for the purpose of providing more useful NoSuchMethodErrors
204 // and fatal error handling. The string is allocated in resource 205 // and fatal error handling. The string is allocated in resource
205 // area if a buffer is not provided by the caller. 206 // area if a buffer is not provided by the caller.
206 char* name_and_sig_as_C_string(); 207 char* name_and_sig_as_C_string() const;
207 char* name_and_sig_as_C_string(char* buf, int size); 208 char* name_and_sig_as_C_string(char* buf, int size) const;
208 209
209 // Static routine in the situations we don't have a methodOop 210 // Static routine in the situations we don't have a methodOop
210 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature); 211 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature);
211 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size); 212 static char* name_and_sig_as_C_string(Klass* klass, Symbol* method_name, Symbol* signature, char* buf, int size);
212 213
245 assert(0 <= size && size < (1 << 16), "invalid method size"); 246 assert(0 <= size && size < (1 << 16), "invalid method size");
246 _method_size = size; 247 _method_size = size;
247 } 248 }
248 249
249 // constant pool for klassOop holding this method 250 // constant pool for klassOop holding this method
250 constantPoolOop constants() const { return _constants; } 251 constantPoolOop constants() const { return constMethod()->constants(); }
251 void set_constants(constantPoolOop c) { oop_store_without_check((oop*)&_constants, c); } 252 void set_constants(constantPoolOop c) { constMethod()->set_constants(c); }
252 253
253 // max stack 254 // max stack
254 int max_stack() const { return _max_stack; } 255 // return original max stack size for method verification
255 void set_max_stack(int size) { _max_stack = size; } 256 int verifier_max_stack() const { return _max_stack; }
257 int max_stack() const { return _max_stack + extra_stack_entries(); }
258 void set_max_stack(int size) { _max_stack = size; }
256 259
257 // max locals 260 // max locals
258 int max_locals() const { return _max_locals; } 261 int max_locals() const { return _max_locals; }
259 void set_max_locals(int size) { _max_locals = size; } 262 void set_max_locals(int size) { _max_locals = size; }
260 263
287 void set_stackmap_data(typeArrayOop sd) { 290 void set_stackmap_data(typeArrayOop sd) {
288 constMethod()->set_stackmap_data(sd); 291 constMethod()->set_stackmap_data(sd);
289 } 292 }
290 293
291 // exception handler table 294 // exception handler table
292 typeArrayOop exception_table() const
293 { return constMethod()->exception_table(); }
294 void set_exception_table(typeArrayOop e)
295 { constMethod()->set_exception_table(e); }
296 bool has_exception_handler() const 295 bool has_exception_handler() const
297 { return constMethod()->has_exception_handler(); } 296 { return constMethod()->has_exception_handler(); }
297 int exception_table_length() const
298 { return constMethod()->exception_table_length(); }
299 ExceptionTableElement* exception_table_start() const
300 { return constMethod()->exception_table_start(); }
298 301
299 // Finds the first entry point bci of an exception handler for an 302 // Finds the first entry point bci of an exception handler for an
300 // exception of klass ex_klass thrown at throw_bci. A value of NULL 303 // exception of klass ex_klass thrown at throw_bci. A value of NULL
301 // for ex_klass indicates that the exception klass is not known; in 304 // for ex_klass indicates that the exception klass is not known; in
302 // this case it matches any constraint class. Returns -1 if the 305 // this case it matches any constraint class. Returns -1 if the
468 { return constMethod()->has_linenumber_table(); } 471 { return constMethod()->has_linenumber_table(); }
469 u_char* compressed_linenumber_table() const 472 u_char* compressed_linenumber_table() const
470 { return constMethod()->compressed_linenumber_table(); } 473 { return constMethod()->compressed_linenumber_table(); }
471 474
472 // method holder (the klassOop holding this method) 475 // method holder (the klassOop holding this method)
473 klassOop method_holder() const { return _constants->pool_holder(); } 476 klassOop method_holder() const { return constants()->pool_holder(); }
474 477
475 void compute_size_of_parameters(Thread *thread); // word size of parameters (receiver if any + arguments) 478 void compute_size_of_parameters(Thread *thread); // word size of parameters (receiver if any + arguments)
476 Symbol* klass_name() const; // returns the name of the method holder 479 Symbol* klass_name() const; // returns the name of the method holder
477 BasicType result_type() const; // type of the method result 480 BasicType result_type() const; // type of the method result
478 int result_type_index() const; // type index of the method result 481 int result_type_index() const; // type index of the method result
559 562
560 bool object_is_parsable() const { return method_size() > 0; } 563 bool object_is_parsable() const { return method_size() > 0; }
561 564
562 // interpreter support 565 // interpreter support
563 static ByteSize const_offset() { return byte_offset_of(methodOopDesc, _constMethod ); } 566 static ByteSize const_offset() { return byte_offset_of(methodOopDesc, _constMethod ); }
564 static ByteSize constants_offset() { return byte_offset_of(methodOopDesc, _constants ); }
565 static ByteSize access_flags_offset() { return byte_offset_of(methodOopDesc, _access_flags ); } 567 static ByteSize access_flags_offset() { return byte_offset_of(methodOopDesc, _access_flags ); }
566 #ifdef CC_INTERP 568 #ifdef CC_INTERP
567 static ByteSize result_index_offset() { return byte_offset_of(methodOopDesc, _result_index ); } 569 static ByteSize result_index_offset() { return byte_offset_of(methodOopDesc, _result_index ); }
568 #endif /* CC_INTERP */ 570 #endif /* CC_INTERP */
569 static ByteSize size_of_locals_offset() { return byte_offset_of(methodOopDesc, _max_locals ); } 571 static ByteSize size_of_locals_offset() { return byte_offset_of(methodOopDesc, _max_locals ); }
611 613
612 // Reflection support 614 // Reflection support
613 bool is_overridden_in(klassOop k) const; 615 bool is_overridden_in(klassOop k) const;
614 616
615 // JSR 292 support 617 // JSR 292 support
616 bool is_method_handle_invoke() const { return access_flags().is_method_handle_invoke(); } 618 bool is_method_handle_intrinsic() const; // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
617 static bool is_method_handle_invoke_name(vmSymbols::SID name_sid); 619 bool is_compiled_lambda_form() const; // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
618 static bool is_method_handle_invoke_name(Symbol* name) { 620 bool has_member_arg() const; // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
619 return is_method_handle_invoke_name(vmSymbols::find_sid(name)); 621 static methodHandle make_method_handle_intrinsic(vmIntrinsics::ID iid, // _invokeBasic, _linkToVirtual
620 } 622 Symbol* signature, //anything at all
621 // Tests if this method is an internal adapter frame from the 623 TRAPS);
622 // MethodHandleCompiler.
623 bool is_method_handle_adapter() const;
624 static methodHandle make_invoke_method(KlassHandle holder,
625 Symbol* name, //invokeExact or invokeGeneric
626 Symbol* signature, //anything at all
627 Handle method_type,
628 TRAPS);
629 static klassOop check_non_bcp_klass(klassOop klass); 624 static klassOop check_non_bcp_klass(klassOop klass);
630 // these operate only on invoke methods: 625 // these operate only on invoke methods:
631 oop method_handle_type() const;
632 static jint* method_type_offsets_chain(); // series of pointer-offsets, terminated by -1
633 // presize interpreter frames for extra interpreter stack entries, if needed 626 // presize interpreter frames for extra interpreter stack entries, if needed
634 // method handles want to be able to push a few extra values (e.g., a bound receiver), and 627 // method handles want to be able to push a few extra values (e.g., a bound receiver), and
635 // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist, 628 // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist,
636 // all without checking for a stack overflow 629 // all without checking for a stack overflow
637 static int extra_stack_entries() { return EnableInvokeDynamic ? (int) MethodHandlePushLimit + 3 : 0; } 630 static int extra_stack_entries() { return EnableInvokeDynamic ? 2 : 0; }
638 static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize() 631 static int extra_stack_words(); // = extra_stack_entries() * Interpreter::stackElementSize()
639 632
640 // RedefineClasses() support: 633 // RedefineClasses() support:
641 bool is_old() const { return access_flags().is_old(); } 634 bool is_old() const { return access_flags().is_old(); }
642 void set_is_old() { _access_flags.set_is_old(); } 635 void set_is_old() { _access_flags.set_is_old(); }
677 static vmSymbols::SID klass_id_for_intrinsics(klassOop holder); 670 static vmSymbols::SID klass_id_for_intrinsics(klassOop holder);
678 671
679 bool jfr_towrite() { return _jfr_towrite; } 672 bool jfr_towrite() { return _jfr_towrite; }
680 void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; } 673 void set_jfr_towrite(bool towrite) { _jfr_towrite = towrite; }
681 674
675 bool force_inline() { return _force_inline; }
676 void set_force_inline(bool x) { _force_inline = x; }
677 bool dont_inline() { return _dont_inline; }
678 void set_dont_inline(bool x) { _dont_inline = x; }
679 bool is_hidden() { return _hidden; }
680 void set_hidden(bool x) { _hidden = x; }
681
682 // On-stack replacement support 682 // On-stack replacement support
683 bool has_osr_nmethod(int level, bool match_level) { 683 bool has_osr_nmethod(int level, bool match_level) {
684 return instanceKlass::cast(method_holder())->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL; 684 return instanceKlass::cast(method_holder())->lookup_osr_nmethod(this, InvocationEntryBci, level, match_level) != NULL;
685 } 685 }
686 686
722 722
723 // Return if true if not all classes references in signature, including return type, has been loaded 723 // Return if true if not all classes references in signature, including return type, has been loaded
724 static bool has_unloaded_classes_in_signature(methodHandle m, TRAPS); 724 static bool has_unloaded_classes_in_signature(methodHandle m, TRAPS);
725 725
726 // Printing 726 // Printing
727 void print_short_name(outputStream* st) /*PRODUCT_RETURN*/; // prints as klassname::methodname; Exposed so field engineers can debug VM 727 void print_short_name(outputStream* st = tty) /*PRODUCT_RETURN*/; // prints as klassname::methodname; Exposed so field engineers can debug VM
728 void print_name(outputStream* st) PRODUCT_RETURN; // prints as "virtual void foo(int)" 728 void print_name(outputStream* st = tty) PRODUCT_RETURN; // prints as "virtual void foo(int)"
729 729
730 // Helper routine used for method sorting 730 // Helper routine used for method sorting
731 static void sort_methods(objArrayOop methods, 731 static void sort_methods(objArrayOop methods,
732 objArrayOop methods_annotations, 732 objArrayOop methods_annotations,
733 objArrayOop methods_parameter_annotations, 733 objArrayOop methods_parameter_annotations,
742 address* native_function_addr() const { assert(is_native(), "must be native"); return (address*) (this+1); } 742 address* native_function_addr() const { assert(is_native(), "must be native"); return (address*) (this+1); }
743 address* signature_handler_addr() const { return native_function_addr() + 1; } 743 address* signature_handler_addr() const { return native_function_addr() + 1; }
744 744
745 // Garbage collection support 745 // Garbage collection support
746 oop* adr_constMethod() const { return (oop*)&_constMethod; } 746 oop* adr_constMethod() const { return (oop*)&_constMethod; }
747 oop* adr_constants() const { return (oop*)&_constants; }
748 oop* adr_method_data() const { return (oop*)&_method_data; } 747 oop* adr_method_data() const { return (oop*)&_method_data; }
749 #ifdef GRAAL 748 #ifdef GRAAL
750 oop* adr_graal_mirror() const { return (oop*)&_graal_mirror; } 749 oop* adr_graal_mirror() const { return (oop*)&_graal_mirror; }
751 #endif 750 #endif
752 }; 751 };
827 // There is presently no provision for concurrent access 826 // There is presently no provision for concurrent access
828 // to breakpoint lists, which is only OK for JVMTI because 827 // to breakpoint lists, which is only OK for JVMTI because
829 // breakpoints are written only at safepoints, and are read 828 // breakpoints are written only at safepoints, and are read
830 // concurrently only outside of safepoints. 829 // concurrently only outside of safepoints.
831 830
832 class BreakpointInfo : public CHeapObj { 831 class BreakpointInfo : public CHeapObj<mtClass> {
833 friend class VMStructs; 832 friend class VMStructs;
834 private: 833 private:
835 Bytecodes::Code _orig_bytecode; 834 Bytecodes::Code _orig_bytecode;
836 int _bci; 835 int _bci;
837 u2 _name_index; // of method 836 u2 _name_index; // of method
861 860
862 void set(methodOop method); 861 void set(methodOop method);
863 void clear(methodOop method); 862 void clear(methodOop method);
864 }; 863 };
865 864
865 // Utility class for access exception handlers
866 class ExceptionTable : public StackObj {
867 private:
868 ExceptionTableElement* _table;
869 u2 _length;
870
871 public:
872 ExceptionTable(methodOop m) {
873 if (m->has_exception_handler()) {
874 _table = m->exception_table_start();
875 _length = m->exception_table_length();
876 } else {
877 _table = NULL;
878 _length = 0;
879 }
880 }
881
882 int length() const {
883 return _length;
884 }
885
886 u2 start_pc(int idx) const {
887 assert(idx < _length, "out of bounds");
888 return _table[idx].start_pc;
889 }
890
891 void set_start_pc(int idx, u2 value) {
892 assert(idx < _length, "out of bounds");
893 _table[idx].start_pc = value;
894 }
895
896 u2 end_pc(int idx) const {
897 assert(idx < _length, "out of bounds");
898 return _table[idx].end_pc;
899 }
900
901 void set_end_pc(int idx, u2 value) {
902 assert(idx < _length, "out of bounds");
903 _table[idx].end_pc = value;
904 }
905
906 u2 handler_pc(int idx) const {
907 assert(idx < _length, "out of bounds");
908 return _table[idx].handler_pc;
909 }
910
911 void set_handler_pc(int idx, u2 value) {
912 assert(idx < _length, "out of bounds");
913 _table[idx].handler_pc = value;
914 }
915
916 u2 catch_type_index(int idx) const {
917 assert(idx < _length, "out of bounds");
918 return _table[idx].catch_type_index;
919 }
920
921 void set_catch_type_index(int idx, u2 value) {
922 assert(idx < _length, "out of bounds");
923 _table[idx].catch_type_index = value;
924 }
925 };
926
866 #endif // SHARE_VM_OOPS_METHODOOP_HPP 927 #endif // SHARE_VM_OOPS_METHODOOP_HPP