src/share/vm/ci/ciMethod.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/ci/ciMethod.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,333 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_CI_CIMETHOD_HPP
    1.29 +#define SHARE_VM_CI_CIMETHOD_HPP
    1.30 +
    1.31 +#include "ci/ciFlags.hpp"
    1.32 +#include "ci/ciInstanceKlass.hpp"
    1.33 +#include "ci/ciObject.hpp"
    1.34 +#include "ci/ciSignature.hpp"
    1.35 +#include "compiler/methodLiveness.hpp"
    1.36 +#include "prims/methodHandles.hpp"
    1.37 +#include "utilities/bitMap.hpp"
    1.38 +
    1.39 +class ciMethodBlocks;
    1.40 +class MethodLiveness;
    1.41 +class BitMap;
    1.42 +class Arena;
    1.43 +class BCEscapeAnalyzer;
    1.44 +
    1.45 +
    1.46 +// ciMethod
    1.47 +//
    1.48 +// This class represents a Method* in the HotSpot virtual
    1.49 +// machine.
    1.50 +class ciMethod : public ciMetadata {
    1.51 +  friend class CompileBroker;
    1.52 +  CI_PACKAGE_ACCESS
    1.53 +  friend class ciEnv;
    1.54 +  friend class ciExceptionHandlerStream;
    1.55 +  friend class ciBytecodeStream;
    1.56 +  friend class ciMethodHandle;
    1.57 +  friend class ciReplay;
    1.58 +
    1.59 + private:
    1.60 +  // General method information.
    1.61 +  ciFlags          _flags;
    1.62 +  ciSymbol*        _name;
    1.63 +  ciInstanceKlass* _holder;
    1.64 +  ciSignature*     _signature;
    1.65 +  ciMethodData*    _method_data;
    1.66 +  ciMethodBlocks*   _method_blocks;
    1.67 +
    1.68 +  // Code attributes.
    1.69 +  int _code_size;
    1.70 +  int _max_stack;
    1.71 +  int _max_locals;
    1.72 +  vmIntrinsics::ID _intrinsic_id;
    1.73 +  int _handler_count;
    1.74 +  int _interpreter_invocation_count;
    1.75 +  int _interpreter_throwout_count;
    1.76 +  int _instructions_size;
    1.77 +  int _size_of_parameters;
    1.78 +
    1.79 +  bool _uses_monitors;
    1.80 +  bool _balanced_monitors;
    1.81 +  bool _is_c1_compilable;
    1.82 +  bool _is_c2_compilable;
    1.83 +  bool _can_be_statically_bound;
    1.84 +
    1.85 +  // Lazy fields, filled in on demand
    1.86 +  address              _code;
    1.87 +  ciExceptionHandler** _exception_handlers;
    1.88 +
    1.89 +  // Optional liveness analyzer.
    1.90 +  MethodLiveness* _liveness;
    1.91 +#if defined(COMPILER2) || defined(SHARK)
    1.92 +  ciTypeFlow*         _flow;
    1.93 +  BCEscapeAnalyzer*   _bcea;
    1.94 +#endif
    1.95 +
    1.96 +  ciMethod(methodHandle h_m);
    1.97 +  ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
    1.98 +
    1.99 +  Method* get_Method() const {
   1.100 +    Method* m = (Method*)_metadata;
   1.101 +    assert(m != NULL, "illegal use of unloaded method");
   1.102 +    return m;
   1.103 +  }
   1.104 +
   1.105 +  oop loader() const                             { return _holder->loader(); }
   1.106 +
   1.107 +  const char* type_string()                      { return "ciMethod"; }
   1.108 +
   1.109 +  void print_impl(outputStream* st);
   1.110 +
   1.111 +  void load_code();
   1.112 +
   1.113 +  void check_is_loaded() const                   { assert(is_loaded(), "not loaded"); }
   1.114 +
   1.115 +  bool ensure_method_data(methodHandle h_m);
   1.116 +
   1.117 +  void code_at_put(int bci, Bytecodes::Code code) {
   1.118 +    Bytecodes::check(code);
   1.119 +    assert(0 <= bci && bci < code_size(), "valid bci");
   1.120 +    address bcp = _code + bci;
   1.121 +    *bcp = code;
   1.122 +  }
   1.123 +
   1.124 +  // Check bytecode and profile data collected are compatible
   1.125 +  void assert_virtual_call_type_ok(int bci);
   1.126 +  void assert_call_type_ok(int bci);
   1.127 +
   1.128 + public:
   1.129 +  // Basic method information.
   1.130 +  ciFlags flags() const                          { check_is_loaded(); return _flags; }
   1.131 +  ciSymbol* name() const                         { return _name; }
   1.132 +  ciInstanceKlass* holder() const                { return _holder; }
   1.133 +  ciMethodData* method_data();
   1.134 +  ciMethodData* method_data_or_null();
   1.135 +
   1.136 +  // Signature information.
   1.137 +  ciSignature* signature() const                 { return _signature; }
   1.138 +  ciType*      return_type() const               { return _signature->return_type(); }
   1.139 +  int          arg_size_no_receiver() const      { return _signature->size(); }
   1.140 +  // Can only be used on loaded ciMethods
   1.141 +  int          arg_size() const                  {
   1.142 +    check_is_loaded();
   1.143 +    return _signature->size() + (_flags.is_static() ? 0 : 1);
   1.144 +  }
   1.145 +  // Report the number of elements on stack when invoking this method.
   1.146 +  // This is different than the regular arg_size because invokedynamic
   1.147 +  // has an implicit receiver.
   1.148 +  int invoke_arg_size(Bytecodes::Code code) const {
   1.149 +    if (is_loaded()) {
   1.150 +      return arg_size();
   1.151 +    } else {
   1.152 +      int arg_size = _signature->size();
   1.153 +      // Add a receiver argument, maybe:
   1.154 +      if (code != Bytecodes::_invokestatic &&
   1.155 +          code != Bytecodes::_invokedynamic) {
   1.156 +        arg_size++;
   1.157 +      }
   1.158 +      return arg_size;
   1.159 +    }
   1.160 +  }
   1.161 +
   1.162 +
   1.163 +  // Method code and related information.
   1.164 +  address code()                                 { if (_code == NULL) load_code(); return _code; }
   1.165 +  int code_size() const                          { check_is_loaded(); return _code_size; }
   1.166 +  int max_stack() const                          { check_is_loaded(); return _max_stack; }
   1.167 +  int max_locals() const                         { check_is_loaded(); return _max_locals; }
   1.168 +  vmIntrinsics::ID intrinsic_id() const          { check_is_loaded(); return _intrinsic_id; }
   1.169 +  bool has_exception_handlers() const            { check_is_loaded(); return _handler_count > 0; }
   1.170 +  int exception_table_length() const             { check_is_loaded(); return _handler_count; }
   1.171 +  int interpreter_invocation_count() const       { check_is_loaded(); return _interpreter_invocation_count; }
   1.172 +  int interpreter_throwout_count() const         { check_is_loaded(); return _interpreter_throwout_count; }
   1.173 +  int size_of_parameters() const                 { check_is_loaded(); return _size_of_parameters; }
   1.174 +
   1.175 +  // Code size for inlining decisions.
   1.176 +  int code_size_for_inlining();
   1.177 +
   1.178 +  bool caller_sensitive() { return get_Method()->caller_sensitive(); }
   1.179 +  bool force_inline()     { return get_Method()->force_inline();     }
   1.180 +  bool dont_inline()      { return get_Method()->dont_inline();      }
   1.181 +
   1.182 +  int comp_level();
   1.183 +  int highest_osr_comp_level();
   1.184 +
   1.185 +  Bytecodes::Code java_code_at_bci(int bci) {
   1.186 +    address bcp = code() + bci;
   1.187 +    return Bytecodes::java_code_at(NULL, bcp);
   1.188 +  }
   1.189 +  Bytecodes::Code raw_code_at_bci(int bci) {
   1.190 +    address bcp = code() + bci;
   1.191 +    return Bytecodes::code_at(NULL, bcp);
   1.192 +  }
   1.193 +  BCEscapeAnalyzer  *get_bcea();
   1.194 +  ciMethodBlocks    *get_method_blocks();
   1.195 +
   1.196 +  bool    has_linenumber_table() const;          // length unknown until decompression
   1.197 +  u_char* compressed_linenumber_table() const;   // not preserved by gc
   1.198 +
   1.199 +  int line_number_from_bci(int bci) const;
   1.200 +
   1.201 +  // Runtime information.
   1.202 +  int           vtable_index();
   1.203 +#ifdef SHARK
   1.204 +  int           itable_index();
   1.205 +#endif // SHARK
   1.206 +  address       native_entry();
   1.207 +  address       interpreter_entry();
   1.208 +
   1.209 +  // Analysis and profiling.
   1.210 +  //
   1.211 +  // Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks.
   1.212 +  bool          has_monitor_bytecodes() const    { return _uses_monitors; }
   1.213 +  bool          has_balanced_monitors();
   1.214 +
   1.215 +  // Returns a bitmap indicating which locals are required to be
   1.216 +  // maintained as live for deopt.  raw_liveness_at_bci is always the
   1.217 +  // direct output of the liveness computation while liveness_at_bci
   1.218 +  // may mark all locals as live to improve support for debugging Java
   1.219 +  // code by maintaining the state of as many locals as possible.
   1.220 +  MethodLivenessResult raw_liveness_at_bci(int bci);
   1.221 +  MethodLivenessResult liveness_at_bci(int bci);
   1.222 +
   1.223 +  // Get the interpreters viewpoint on oop liveness.  MethodLiveness is
   1.224 +  // conservative in the sense that it may consider locals to be live which
   1.225 +  // cannot be live, like in the case where a local could contain an oop or
   1.226 +  // a primitive along different paths.  In that case the local must be
   1.227 +  // dead when those paths merge. Since the interpreter's viewpoint is
   1.228 +  // used when gc'ing an interpreter frame we need to use its viewpoint
   1.229 +  // during OSR when loading the locals.
   1.230 +
   1.231 +  BitMap  live_local_oops_at_bci(int bci);
   1.232 +
   1.233 +#ifdef COMPILER1
   1.234 +  const BitMap  bci_block_start();
   1.235 +#endif
   1.236 +
   1.237 +  ciTypeFlow*   get_flow_analysis();
   1.238 +  ciTypeFlow*   get_osr_flow_analysis(int osr_bci);  // alternate entry point
   1.239 +  ciCallProfile call_profile_at_bci(int bci);
   1.240 +  int           interpreter_call_site_count(int bci);
   1.241 +
   1.242 +  // Does type profiling provide a useful type at this point?
   1.243 +  ciKlass*      argument_profiled_type(int bci, int i);
   1.244 +  ciKlass*      parameter_profiled_type(int i);
   1.245 +  ciKlass*      return_profiled_type(int bci);
   1.246 +
   1.247 +  ciField*      get_field_at_bci( int bci, bool &will_link);
   1.248 +  ciMethod*     get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
   1.249 +  // Given a certain calling environment, find the monomorphic target
   1.250 +  // for the call.  Return NULL if the call is not monomorphic in
   1.251 +  // its calling environment.
   1.252 +  ciMethod* find_monomorphic_target(ciInstanceKlass* caller,
   1.253 +                                    ciInstanceKlass* callee_holder,
   1.254 +                                    ciInstanceKlass* actual_receiver);
   1.255 +
   1.256 +  // Given a known receiver klass, find the target for the call.
   1.257 +  // Return NULL if the call has no target or is abstract.
   1.258 +  ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver);
   1.259 +
   1.260 +  // Find the proper vtable index to invoke this method.
   1.261 +  int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
   1.262 +
   1.263 +  // Compilation directives
   1.264 +  bool should_exclude();
   1.265 +  bool should_inline();
   1.266 +  bool should_not_inline();
   1.267 +  bool should_print_assembly();
   1.268 +  bool break_at_execute();
   1.269 +  bool has_option(const char *option);
   1.270 +  bool can_be_compiled();
   1.271 +  bool can_be_osr_compiled(int entry_bci);
   1.272 +  void set_not_compilable(const char* reason = NULL);
   1.273 +  bool has_compiled_code();
   1.274 +  void log_nmethod_identity(xmlStream* log);
   1.275 +  bool is_not_reached(int bci);
   1.276 +  bool was_executed_more_than(int times);
   1.277 +  bool has_unloaded_classes_in_signature();
   1.278 +  bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
   1.279 +  bool check_call(int refinfo_index, bool is_static) const;
   1.280 +  bool ensure_method_data();  // make sure it exists in the VM also
   1.281 +  MethodCounters* ensure_method_counters();
   1.282 +  int instructions_size();
   1.283 +  int scale_count(int count, float prof_factor = 1.);  // make MDO count commensurate with IIC
   1.284 +
   1.285 +  // Stack walking support
   1.286 +  bool is_ignored_by_security_stack_walk() const;
   1.287 +
   1.288 +  // JSR 292 support
   1.289 +  bool is_method_handle_intrinsic()  const;
   1.290 +  bool is_compiled_lambda_form() const;
   1.291 +  bool has_member_arg() const;
   1.292 +
   1.293 +  // What kind of ciObject is this?
   1.294 +  bool is_method() const                         { return true; }
   1.295 +
   1.296 +  // Java access flags
   1.297 +  bool is_public      () const                   { return flags().is_public(); }
   1.298 +  bool is_private     () const                   { return flags().is_private(); }
   1.299 +  bool is_protected   () const                   { return flags().is_protected(); }
   1.300 +  bool is_static      () const                   { return flags().is_static(); }
   1.301 +  bool is_final       () const                   { return flags().is_final(); }
   1.302 +  bool is_synchronized() const                   { return flags().is_synchronized(); }
   1.303 +  bool is_native      () const                   { return flags().is_native(); }
   1.304 +  bool is_interface   () const                   { return flags().is_interface(); }
   1.305 +  bool is_abstract    () const                   { return flags().is_abstract(); }
   1.306 +  bool is_strict      () const                   { return flags().is_strict(); }
   1.307 +
   1.308 +  // Other flags
   1.309 +  bool is_empty_method() const;
   1.310 +  bool is_vanilla_constructor() const;
   1.311 +  bool is_final_method() const                   { return is_final() || holder()->is_final(); }
   1.312 +  bool has_loops      () const;
   1.313 +  bool has_jsrs       () const;
   1.314 +  bool is_accessor    () const;
   1.315 +  bool is_initializer () const;
   1.316 +  bool can_be_statically_bound() const           { return _can_be_statically_bound; }
   1.317 +  bool is_boxing_method() const;
   1.318 +  bool is_unboxing_method() const;
   1.319 +
   1.320 +  // Replay data methods
   1.321 +  void dump_name_as_ascii(outputStream* st);
   1.322 +  void dump_replay_data(outputStream* st);
   1.323 +
   1.324 +  // Print the bytecodes of this method.
   1.325 +  void print_codes_on(outputStream* st);
   1.326 +  void print_codes() {
   1.327 +    print_codes_on(tty);
   1.328 +  }
   1.329 +  void print_codes_on(int from, int to, outputStream* st);
   1.330 +
   1.331 +  // Print the name of this method in various incarnations.
   1.332 +  void print_name(outputStream* st = tty);
   1.333 +  void print_short_name(outputStream* st = tty);
   1.334 +};
   1.335 +
   1.336 +#endif // SHARE_VM_CI_CIMETHOD_HPP

mercurial