< prev index next >

src/share/vm/ci/ciMethod.hpp

Print this page
rev 8910 : full patch for jfr
   1 /*
   2  * Copyright (c) 1999, 2016, 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_VM_CI_CIMETHOD_HPP
  26 #define SHARE_VM_CI_CIMETHOD_HPP
  27 
  28 #include "ci/ciFlags.hpp"
  29 #include "ci/ciInstanceKlass.hpp"
  30 #include "ci/ciObject.hpp"
  31 #include "ci/ciSignature.hpp"
  32 #include "compiler/methodLiveness.hpp"
  33 #include "prims/methodHandles.hpp"
  34 #include "utilities/bitMap.hpp"

  35 
  36 class ciMethodBlocks;
  37 class MethodLiveness;
  38 class BitMap;
  39 class Arena;
  40 class BCEscapeAnalyzer;
  41 
  42 
  43 // ciMethod
  44 //
  45 // This class represents a Method* in the HotSpot virtual
  46 // machine.
  47 class ciMethod : public ciMetadata {
  48   friend class CompileBroker;
  49   CI_PACKAGE_ACCESS
  50   friend class ciEnv;
  51   friend class ciExceptionHandlerStream;
  52   friend class ciBytecodeStream;
  53   friend class ciMethodHandle;
  54   friend class ciReplay;


  76   bool _uses_monitors;
  77   bool _balanced_monitors;
  78   bool _is_c1_compilable;
  79   bool _is_c2_compilable;
  80   bool _can_be_statically_bound;
  81 
  82   // Lazy fields, filled in on demand
  83   address              _code;
  84   ciExceptionHandler** _exception_handlers;
  85 
  86   // Optional liveness analyzer.
  87   MethodLiveness* _liveness;
  88 #if defined(COMPILER2) || defined(SHARK)
  89   ciTypeFlow*         _flow;
  90   BCEscapeAnalyzer*   _bcea;
  91 #endif
  92 
  93   ciMethod(methodHandle h_m, ciInstanceKlass* holder);
  94   ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
  95 
  96   Method* get_Method() const {
  97     Method* m = (Method*)_metadata;
  98     assert(m != NULL, "illegal use of unloaded method");
  99     return m;
 100   }
 101 
 102   oop loader() const                             { return _holder->loader(); }
 103 
 104   const char* type_string()                      { return "ciMethod"; }
 105 
 106   void print_impl(outputStream* st);
 107 
 108   void load_code();
 109 
 110   void check_is_loaded() const                   { assert(is_loaded(), "not loaded"); }
 111 
 112   bool ensure_method_data(methodHandle h_m);
 113 
 114   void code_at_put(int bci, Bytecodes::Code code) {
 115     Bytecodes::check(code);
 116     assert(0 <= bci && bci < code_size(), "valid bci");
 117     address bcp = _code + bci;
 118     *bcp = code;
 119   }
 120 
 121   // Check bytecode and profile data collected are compatible


 139     check_is_loaded();
 140     return _signature->size() + (_flags.is_static() ? 0 : 1);
 141   }
 142   // Report the number of elements on stack when invoking this method.
 143   // This is different than the regular arg_size because invokedynamic
 144   // has an implicit receiver.
 145   int invoke_arg_size(Bytecodes::Code code) const {
 146     if (is_loaded()) {
 147       return arg_size();
 148     } else {
 149       int arg_size = _signature->size();
 150       // Add a receiver argument, maybe:
 151       if (code != Bytecodes::_invokestatic &&
 152           code != Bytecodes::_invokedynamic) {
 153         arg_size++;
 154       }
 155       return arg_size;
 156     }
 157   }
 158 





 159 
 160   // Method code and related information.
 161   address code()                                 { if (_code == NULL) load_code(); return _code; }
 162   int code_size() const                          { check_is_loaded(); return _code_size; }
 163   int max_stack() const                          { check_is_loaded(); return _max_stack; }
 164   int max_locals() const                         { check_is_loaded(); return _max_locals; }
 165   vmIntrinsics::ID intrinsic_id() const          { check_is_loaded(); return _intrinsic_id; }
 166   bool has_exception_handlers() const            { check_is_loaded(); return _handler_count > 0; }
 167   int exception_table_length() const             { check_is_loaded(); return _handler_count; }
 168   int interpreter_invocation_count() const       { check_is_loaded(); return _interpreter_invocation_count; }
 169   int interpreter_throwout_count() const         { check_is_loaded(); return _interpreter_throwout_count; }
 170   int size_of_parameters() const                 { check_is_loaded(); return _size_of_parameters; }
 171 
 172   // Code size for inlining decisions.
 173   int code_size_for_inlining();
 174 
 175   bool caller_sensitive()   const { return get_Method()->caller_sensitive();   }
 176   bool force_inline()       const { return get_Method()->force_inline();       }
 177   bool dont_inline()        const { return get_Method()->dont_inline();        }
 178 


 330   bool is_initializer () const;
 331   bool can_be_statically_bound() const           { return _can_be_statically_bound; }
 332   bool is_boxing_method() const;
 333   bool is_unboxing_method() const;
 334   bool is_object_initializer() const;
 335 
 336   // Replay data methods
 337   void dump_name_as_ascii(outputStream* st);
 338   void dump_replay_data(outputStream* st);
 339 
 340   // Print the bytecodes of this method.
 341   void print_codes_on(outputStream* st);
 342   void print_codes() {
 343     print_codes_on(tty);
 344   }
 345   void print_codes_on(int from, int to, outputStream* st);
 346 
 347   // Print the name of this method in various incarnations.
 348   void print_name(outputStream* st = tty);
 349   void print_short_name(outputStream* st = tty);




 350 };
 351 
 352 #endif // SHARE_VM_CI_CIMETHOD_HPP
   1 /*
   2  * Copyright (c) 1999, 2019, 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_VM_CI_CIMETHOD_HPP
  26 #define SHARE_VM_CI_CIMETHOD_HPP
  27 
  28 #include "ci/ciFlags.hpp"
  29 #include "ci/ciInstanceKlass.hpp"
  30 #include "ci/ciObject.hpp"
  31 #include "ci/ciSignature.hpp"
  32 #include "compiler/methodLiveness.hpp"
  33 #include "prims/methodHandles.hpp"
  34 #include "utilities/bitMap.hpp"
  35 #include "trace/tracing.hpp"
  36 
  37 class ciMethodBlocks;
  38 class MethodLiveness;
  39 class BitMap;
  40 class Arena;
  41 class BCEscapeAnalyzer;
  42 
  43 
  44 // ciMethod
  45 //
  46 // This class represents a Method* in the HotSpot virtual
  47 // machine.
  48 class ciMethod : public ciMetadata {
  49   friend class CompileBroker;
  50   CI_PACKAGE_ACCESS
  51   friend class ciEnv;
  52   friend class ciExceptionHandlerStream;
  53   friend class ciBytecodeStream;
  54   friend class ciMethodHandle;
  55   friend class ciReplay;


  77   bool _uses_monitors;
  78   bool _balanced_monitors;
  79   bool _is_c1_compilable;
  80   bool _is_c2_compilable;
  81   bool _can_be_statically_bound;
  82 
  83   // Lazy fields, filled in on demand
  84   address              _code;
  85   ciExceptionHandler** _exception_handlers;
  86 
  87   // Optional liveness analyzer.
  88   MethodLiveness* _liveness;
  89 #if defined(COMPILER2) || defined(SHARK)
  90   ciTypeFlow*         _flow;
  91   BCEscapeAnalyzer*   _bcea;
  92 #endif
  93 
  94   ciMethod(methodHandle h_m, ciInstanceKlass* holder);
  95   ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
  96 






  97   oop loader() const                             { return _holder->loader(); }
  98 
  99   const char* type_string()                      { return "ciMethod"; }
 100 
 101   void print_impl(outputStream* st);
 102 
 103   void load_code();
 104 
 105   void check_is_loaded() const                   { assert(is_loaded(), "not loaded"); }
 106 
 107   bool ensure_method_data(methodHandle h_m);
 108 
 109   void code_at_put(int bci, Bytecodes::Code code) {
 110     Bytecodes::check(code);
 111     assert(0 <= bci && bci < code_size(), "valid bci");
 112     address bcp = _code + bci;
 113     *bcp = code;
 114   }
 115 
 116   // Check bytecode and profile data collected are compatible


 134     check_is_loaded();
 135     return _signature->size() + (_flags.is_static() ? 0 : 1);
 136   }
 137   // Report the number of elements on stack when invoking this method.
 138   // This is different than the regular arg_size because invokedynamic
 139   // has an implicit receiver.
 140   int invoke_arg_size(Bytecodes::Code code) const {
 141     if (is_loaded()) {
 142       return arg_size();
 143     } else {
 144       int arg_size = _signature->size();
 145       // Add a receiver argument, maybe:
 146       if (code != Bytecodes::_invokestatic &&
 147           code != Bytecodes::_invokedynamic) {
 148         arg_size++;
 149       }
 150       return arg_size;
 151     }
 152   }
 153 
 154   Method* get_Method() const {
 155     Method* m = (Method*)_metadata;
 156     assert(m != NULL, "illegal use of unloaded method");
 157     return m;
 158   }
 159 
 160   // Method code and related information.
 161   address code()                                 { if (_code == NULL) load_code(); return _code; }
 162   int code_size() const                          { check_is_loaded(); return _code_size; }
 163   int max_stack() const                          { check_is_loaded(); return _max_stack; }
 164   int max_locals() const                         { check_is_loaded(); return _max_locals; }
 165   vmIntrinsics::ID intrinsic_id() const          { check_is_loaded(); return _intrinsic_id; }
 166   bool has_exception_handlers() const            { check_is_loaded(); return _handler_count > 0; }
 167   int exception_table_length() const             { check_is_loaded(); return _handler_count; }
 168   int interpreter_invocation_count() const       { check_is_loaded(); return _interpreter_invocation_count; }
 169   int interpreter_throwout_count() const         { check_is_loaded(); return _interpreter_throwout_count; }
 170   int size_of_parameters() const                 { check_is_loaded(); return _size_of_parameters; }
 171 
 172   // Code size for inlining decisions.
 173   int code_size_for_inlining();
 174 
 175   bool caller_sensitive()   const { return get_Method()->caller_sensitive();   }
 176   bool force_inline()       const { return get_Method()->force_inline();       }
 177   bool dont_inline()        const { return get_Method()->dont_inline();        }
 178 


 330   bool is_initializer () const;
 331   bool can_be_statically_bound() const           { return _can_be_statically_bound; }
 332   bool is_boxing_method() const;
 333   bool is_unboxing_method() const;
 334   bool is_object_initializer() const;
 335 
 336   // Replay data methods
 337   void dump_name_as_ascii(outputStream* st);
 338   void dump_replay_data(outputStream* st);
 339 
 340   // Print the bytecodes of this method.
 341   void print_codes_on(outputStream* st);
 342   void print_codes() {
 343     print_codes_on(tty);
 344   }
 345   void print_codes_on(int from, int to, outputStream* st);
 346 
 347   // Print the name of this method in various incarnations.
 348   void print_name(outputStream* st = tty);
 349   void print_short_name(outputStream* st = tty);
 350 
 351 #if INCLUDE_TRACE
 352   TraceStructCalleeMethod to_trace_struct() const;
 353 #endif
 354 };
 355 
 356 #endif // SHARE_VM_CI_CIMETHOD_HPP
< prev index next >