src/share/vm/oops/method.hpp

Print this page
rev 4376 : 8010460: Interpreter on some platforms loads ConstMethod::_max_stack and misses extra stack slots for JSR 292
Summary: ConstMethod::max_stack() doesn't account for JSR 292 appendix.
Reviewed-by:


 137 #ifndef PRODUCT
 138   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 139 #endif
 140   // Entry point for calling both from and to the interpreter.
 141   address _i2i_entry;           // All-args-on-stack calling convention
 142   // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
 143   AdapterHandlerEntry* _adapter;
 144   // Entry point for calling from compiled code, to compiled code if it exists
 145   // or else the interpreter.
 146   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 147   // The entry point for calling both from and to compiled code is
 148   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 149   // field can come and go.  It can transition from NULL to not-null at any
 150   // time (whenever a compile completes).  It can transition from not-null to
 151   // NULL only at safepoints (because of a de-opt).
 152   nmethod* volatile _code;                       // Points to the corresponding piece of native code
 153   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 154 
 155   // Constructor
 156   Method(ConstMethod* xconst, AccessFlags access_flags, int size);






 157  public:
 158 
 159   static Method* allocate(ClassLoaderData* loader_data,
 160                           int byte_code_size,
 161                           AccessFlags access_flags,
 162                           InlineTableSizes* sizes,
 163                           ConstMethod::MethodType method_type,
 164                           TRAPS);
 165 
 166   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 167   Method(){}
 168 
 169   // The Method vtable is restored by this call when the Method is in the
 170   // shared archive.  See patch_klass_vtables() in metaspaceShared.cpp for
 171   // all the gory details.  SA, dtrace and pstack helpers distinguish metadata
 172   // by their vtable.
 173   void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
 174   bool is_method() const volatile { return true; }
 175 
 176   // accessors for instance variables


 257   // note: also used by jfr
 258   u2 method_idnum() const           { return constMethod()->method_idnum(); }
 259   void set_method_idnum(u2 idnum)   { constMethod()->set_method_idnum(idnum); }
 260 
 261   // code size
 262   int code_size() const                  { return constMethod()->code_size(); }
 263 
 264   // method size
 265   int method_size() const                        { return _method_size; }
 266   void set_method_size(int size) {
 267     assert(0 <= size && size < (1 << 16), "invalid method size");
 268     _method_size = size;
 269   }
 270 
 271   // constant pool for Klass* holding this method
 272   ConstantPool* constants() const              { return constMethod()->constants(); }
 273   void set_constants(ConstantPool* c)          { constMethod()->set_constants(c); }
 274 
 275   // max stack
 276   // return original max stack size for method verification
 277   int  verifier_max_stack() const                { return constMethod()->max_stack(); }
 278   int           max_stack() const                { return constMethod()->max_stack() + extra_stack_entries(); }
 279   void      set_max_stack(int size)              {        constMethod()->set_max_stack(size); }
 280 
 281   // max locals
 282   int  max_locals() const                        { return constMethod()->max_locals(); }
 283   void set_max_locals(int size)                  { constMethod()->set_max_locals(size); }
 284 
 285   int highest_comp_level() const;
 286   void set_highest_comp_level(int level);
 287   int highest_osr_comp_level() const;
 288   void set_highest_osr_comp_level(int level);
 289 
 290   // Count of times method was exited via exception while interpreting
 291   void interpreter_throwout_increment() {
 292     if (_interpreter_throwout_count < 65534) {
 293       _interpreter_throwout_count++;
 294     }
 295   }
 296 
 297   int  interpreter_throwout_count() const        { return _interpreter_throwout_count; }
 298   void set_interpreter_throwout_count(int count) { _interpreter_throwout_count = count; }
 299 


 613   int validate_bci_from_bcx(intptr_t bcx) const;
 614 
 615   // Returns the line number for a bci if debugging information for the method is prowided,
 616   // -1 is returned otherwise.
 617   int line_number_from_bci(int bci) const;
 618 
 619   // Reflection support
 620   bool is_overridden_in(Klass* k) const;
 621 
 622   // Stack walking support
 623   bool is_ignored_by_security_stack_walk() const;
 624 
 625   // JSR 292 support
 626   bool is_method_handle_intrinsic() const;          // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
 627   bool is_compiled_lambda_form() const;             // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
 628   bool has_member_arg() const;                      // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
 629   static methodHandle make_method_handle_intrinsic(vmIntrinsics::ID iid, // _invokeBasic, _linkToVirtual
 630                                                    Symbol* signature, //anything at all
 631                                                    TRAPS);
 632   static Klass* check_non_bcp_klass(Klass* klass);
 633   // these operate only on invoke methods:
 634   // presize interpreter frames for extra interpreter stack entries, if needed
 635   // method handles want to be able to push a few extra values (e.g., a bound receiver), and
 636   // invokedynamic sometimes needs to push a bootstrap method, call site, and arglist,
 637   // all without checking for a stack overflow
 638   static int extra_stack_entries() { return EnableInvokeDynamic ? 2 : 0; }
 639   static int extra_stack_words();  // = extra_stack_entries() * Interpreter::stackElementSize()
 640 
 641   // RedefineClasses() support:
 642   bool is_old() const                               { return access_flags().is_old(); }
 643   void set_is_old()                                 { _access_flags.set_is_old(); }
 644   bool is_obsolete() const                          { return access_flags().is_obsolete(); }
 645   void set_is_obsolete()                            { _access_flags.set_is_obsolete(); }
 646   bool on_stack() const                             { return access_flags().on_stack(); }
 647   void set_on_stack(const bool value);
 648 
 649   // see the definition in Method*.cpp for the gory details
 650   bool should_not_be_cached() const;
 651 
 652   // JVMTI Native method prefixing support:
 653   bool is_prefixed_native() const                   { return access_flags().is_prefixed_native(); }
 654   void set_is_prefixed_native()                     { _access_flags.set_is_prefixed_native(); }
 655 
 656   // Rewriting support
 657   static methodHandle clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
 658                                           u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS);
 659 




 137 #ifndef PRODUCT
 138   int               _compiled_invocation_count;  // Number of nmethod invocations so far (for perf. debugging)
 139 #endif
 140   // Entry point for calling both from and to the interpreter.
 141   address _i2i_entry;           // All-args-on-stack calling convention
 142   // Adapter blob (i2c/c2i) for this Method*. Set once when method is linked.
 143   AdapterHandlerEntry* _adapter;
 144   // Entry point for calling from compiled code, to compiled code if it exists
 145   // or else the interpreter.
 146   volatile address _from_compiled_entry;        // Cache of: _code ? _code->entry_point() : _adapter->c2i_entry()
 147   // The entry point for calling both from and to compiled code is
 148   // "_code->entry_point()".  Because of tiered compilation and de-opt, this
 149   // field can come and go.  It can transition from NULL to not-null at any
 150   // time (whenever a compile completes).  It can transition from not-null to
 151   // NULL only at safepoints (because of a de-opt).
 152   nmethod* volatile _code;                       // Points to the corresponding piece of native code
 153   volatile address           _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry
 154 
 155   // Constructor
 156   Method(ConstMethod* xconst, AccessFlags access_flags, int size);
 157 
 158   // this operates only on invoke methods:
 159   // presize interpreter frames for extra interpreter stack entries, if needed
 160   // Account for the extra appendix argument for invokehandle/invokedynamic
 161   static int extra_stack_entries() { return EnableInvokeDynamic ? 1 : 0; }
 162 
 163  public:
 164 
 165   static Method* allocate(ClassLoaderData* loader_data,
 166                           int byte_code_size,
 167                           AccessFlags access_flags,
 168                           InlineTableSizes* sizes,
 169                           ConstMethod::MethodType method_type,
 170                           TRAPS);
 171 
 172   // CDS and vtbl checking can create an empty Method to get vtbl pointer.
 173   Method(){}
 174 
 175   // The Method vtable is restored by this call when the Method is in the
 176   // shared archive.  See patch_klass_vtables() in metaspaceShared.cpp for
 177   // all the gory details.  SA, dtrace and pstack helpers distinguish metadata
 178   // by their vtable.
 179   void restore_vtable() { guarantee(is_method(), "vtable restored by this call"); }
 180   bool is_method() const volatile { return true; }
 181 
 182   // accessors for instance variables


 263   // note: also used by jfr
 264   u2 method_idnum() const           { return constMethod()->method_idnum(); }
 265   void set_method_idnum(u2 idnum)   { constMethod()->set_method_idnum(idnum); }
 266 
 267   // code size
 268   int code_size() const                  { return constMethod()->code_size(); }
 269 
 270   // method size
 271   int method_size() const                        { return _method_size; }
 272   void set_method_size(int size) {
 273     assert(0 <= size && size < (1 << 16), "invalid method size");
 274     _method_size = size;
 275   }
 276 
 277   // constant pool for Klass* holding this method
 278   ConstantPool* constants() const              { return constMethod()->constants(); }
 279   void set_constants(ConstantPool* c)          { constMethod()->set_constants(c); }
 280 
 281   // max stack
 282   // return original max stack size for method verification
 283   int  verifier_max_stack() const                { return constMethod()->max_stack() - extra_stack_entries(); }
 284   int           max_stack() const                { return constMethod()->max_stack(); }
 285   void      set_max_stack(int size)              {        constMethod()->set_max_stack(size + extra_stack_entries()); }
 286 
 287   // max locals
 288   int  max_locals() const                        { return constMethod()->max_locals(); }
 289   void set_max_locals(int size)                  { constMethod()->set_max_locals(size); }
 290 
 291   int highest_comp_level() const;
 292   void set_highest_comp_level(int level);
 293   int highest_osr_comp_level() const;
 294   void set_highest_osr_comp_level(int level);
 295 
 296   // Count of times method was exited via exception while interpreting
 297   void interpreter_throwout_increment() {
 298     if (_interpreter_throwout_count < 65534) {
 299       _interpreter_throwout_count++;
 300     }
 301   }
 302 
 303   int  interpreter_throwout_count() const        { return _interpreter_throwout_count; }
 304   void set_interpreter_throwout_count(int count) { _interpreter_throwout_count = count; }
 305 


 619   int validate_bci_from_bcx(intptr_t bcx) const;
 620 
 621   // Returns the line number for a bci if debugging information for the method is prowided,
 622   // -1 is returned otherwise.
 623   int line_number_from_bci(int bci) const;
 624 
 625   // Reflection support
 626   bool is_overridden_in(Klass* k) const;
 627 
 628   // Stack walking support
 629   bool is_ignored_by_security_stack_walk() const;
 630 
 631   // JSR 292 support
 632   bool is_method_handle_intrinsic() const;          // MethodHandles::is_signature_polymorphic_intrinsic(intrinsic_id)
 633   bool is_compiled_lambda_form() const;             // intrinsic_id() == vmIntrinsics::_compiledLambdaForm
 634   bool has_member_arg() const;                      // intrinsic_id() == vmIntrinsics::_linkToSpecial, etc.
 635   static methodHandle make_method_handle_intrinsic(vmIntrinsics::ID iid, // _invokeBasic, _linkToVirtual
 636                                                    Symbol* signature, //anything at all
 637                                                    TRAPS);
 638   static Klass* check_non_bcp_klass(Klass* klass);







 639 
 640   // RedefineClasses() support:
 641   bool is_old() const                               { return access_flags().is_old(); }
 642   void set_is_old()                                 { _access_flags.set_is_old(); }
 643   bool is_obsolete() const                          { return access_flags().is_obsolete(); }
 644   void set_is_obsolete()                            { _access_flags.set_is_obsolete(); }
 645   bool on_stack() const                             { return access_flags().on_stack(); }
 646   void set_on_stack(const bool value);
 647 
 648   // see the definition in Method*.cpp for the gory details
 649   bool should_not_be_cached() const;
 650 
 651   // JVMTI Native method prefixing support:
 652   bool is_prefixed_native() const                   { return access_flags().is_prefixed_native(); }
 653   void set_is_prefixed_native()                     { _access_flags.set_is_prefixed_native(); }
 654 
 655   // Rewriting support
 656   static methodHandle clone_with_new_data(methodHandle m, u_char* new_code, int new_code_length,
 657                                           u_char* new_compressed_linenumber_table, int new_compressed_linenumber_size, TRAPS);
 658