src/share/vm/ci/ciMethod.hpp

Mon, 26 Apr 2010 23:59:45 -0700

author
never
date
Mon, 26 Apr 2010 23:59:45 -0700
changeset 1832
b4776199210f
parent 1587
cd37471eaecc
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6943485: JVMTI always on capabilities change code generation too much
Reviewed-by: twisti, dcubed

duke@435 1 /*
twisti@1587 2 * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
duke@435 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@435 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@435 21 * have any questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 class ciMethodBlocks;
duke@435 26 class MethodLiveness;
duke@435 27 class BitMap;
duke@435 28 class Arena;
duke@435 29 class BCEscapeAnalyzer;
duke@435 30
duke@435 31
duke@435 32 // ciMethod
duke@435 33 //
duke@435 34 // This class represents a methodOop in the HotSpot virtual
duke@435 35 // machine.
duke@435 36 class ciMethod : public ciObject {
duke@435 37 friend class CompileBroker;
duke@435 38 CI_PACKAGE_ACCESS
duke@435 39 friend class ciEnv;
duke@435 40 friend class ciExceptionHandlerStream;
twisti@1573 41 friend class ciBytecodeStream;
twisti@1573 42 friend class ciMethodHandle;
duke@435 43
duke@435 44 private:
duke@435 45 // General method information.
duke@435 46 ciFlags _flags;
duke@435 47 ciSymbol* _name;
duke@435 48 ciInstanceKlass* _holder;
duke@435 49 ciSignature* _signature;
duke@435 50 ciMethodData* _method_data;
duke@435 51 BCEscapeAnalyzer* _bcea;
duke@435 52 ciMethodBlocks* _method_blocks;
duke@435 53
duke@435 54 // Code attributes.
duke@435 55 int _code_size;
duke@435 56 int _max_stack;
duke@435 57 int _max_locals;
duke@435 58 vmIntrinsics::ID _intrinsic_id;
duke@435 59 int _handler_count;
duke@435 60 int _interpreter_invocation_count;
duke@435 61 int _interpreter_throwout_count;
duke@435 62
duke@435 63 bool _uses_monitors;
duke@435 64 bool _balanced_monitors;
duke@435 65 bool _is_compilable;
duke@435 66 bool _can_be_statically_bound;
duke@435 67
duke@435 68 // Lazy fields, filled in on demand
duke@435 69 address _code;
duke@435 70 ciExceptionHandler** _exception_handlers;
duke@435 71
duke@435 72 // Optional liveness analyzer.
duke@435 73 MethodLiveness* _liveness;
duke@435 74 #ifdef COMPILER2
duke@435 75 ciTypeFlow* _flow;
duke@435 76 #endif
duke@435 77
duke@435 78 ciMethod(methodHandle h_m);
duke@435 79 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature);
duke@435 80
duke@435 81 methodOop get_methodOop() const {
duke@435 82 methodOop m = (methodOop)get_oop();
duke@435 83 assert(m != NULL, "illegal use of unloaded method");
duke@435 84 return m;
duke@435 85 }
duke@435 86
duke@435 87 oop loader() const { return _holder->loader(); }
duke@435 88
duke@435 89 const char* type_string() { return "ciMethod"; }
duke@435 90
duke@435 91 void print_impl(outputStream* st);
duke@435 92
duke@435 93 void load_code();
duke@435 94
duke@435 95 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
duke@435 96
duke@435 97 void build_method_data(methodHandle h_m);
duke@435 98
duke@435 99 void code_at_put(int bci, Bytecodes::Code code) {
duke@435 100 Bytecodes::check(code);
duke@435 101 assert(0 <= bci && bci < code_size(), "valid bci");
duke@435 102 address bcp = _code + bci;
duke@435 103 *bcp = code;
duke@435 104 }
duke@435 105
duke@435 106 public:
duke@435 107 // Basic method information.
duke@435 108 ciFlags flags() const { check_is_loaded(); return _flags; }
duke@435 109 ciSymbol* name() const { return _name; }
duke@435 110 ciInstanceKlass* holder() const { return _holder; }
duke@435 111 ciMethodData* method_data();
duke@435 112
duke@435 113 // Signature information.
duke@435 114 ciSignature* signature() const { return _signature; }
duke@435 115 ciType* return_type() const { return _signature->return_type(); }
duke@435 116 int arg_size_no_receiver() const { return _signature->size(); }
duke@435 117 int arg_size() const { return _signature->size() + (_flags.is_static() ? 0 : 1); }
duke@435 118
duke@435 119 // Method code and related information.
duke@435 120 address code() { if (_code == NULL) load_code(); return _code; }
duke@435 121 int code_size() const { check_is_loaded(); return _code_size; }
duke@435 122 int max_stack() const { check_is_loaded(); return _max_stack; }
duke@435 123 int max_locals() const { check_is_loaded(); return _max_locals; }
duke@435 124 vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
duke@435 125 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
duke@435 126 int exception_table_length() const { check_is_loaded(); return _handler_count; }
duke@435 127 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
duke@435 128 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
duke@435 129
duke@435 130 Bytecodes::Code java_code_at_bci(int bci) {
duke@435 131 address bcp = code() + bci;
duke@435 132 return Bytecodes::java_code_at(bcp);
duke@435 133 }
duke@435 134 BCEscapeAnalyzer *get_bcea();
duke@435 135 ciMethodBlocks *get_method_blocks();
duke@435 136
duke@435 137 bool has_linenumber_table() const; // length unknown until decompression
duke@435 138 u_char* compressed_linenumber_table() const; // not preserved by gc
duke@435 139
duke@435 140 int line_number_from_bci(int bci) const;
duke@435 141
duke@435 142 // Runtime information.
duke@435 143 int vtable_index();
duke@435 144 address native_entry();
duke@435 145 address interpreter_entry();
duke@435 146
duke@435 147 // Analysis and profiling.
duke@435 148 //
duke@435 149 // Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks.
duke@435 150 bool uses_monitors() const { return _uses_monitors; } // this one should go away, it has a misleading name
duke@435 151 bool has_monitor_bytecodes() const { return _uses_monitors; }
duke@435 152 bool has_balanced_monitors();
duke@435 153
never@1426 154 // Returns a bitmap indicating which locals are required to be
never@1426 155 // maintained as live for deopt. raw_liveness_at_bci is always the
never@1426 156 // direct output of the liveness computation while liveness_at_bci
never@1426 157 // may mark all locals as live to improve support for debugging Java
never@1426 158 // code by maintaining the state of as many locals as possible.
never@1426 159 MethodLivenessResult raw_liveness_at_bci(int bci);
duke@435 160 MethodLivenessResult liveness_at_bci(int bci);
duke@435 161
duke@435 162 // Get the interpreters viewpoint on oop liveness. MethodLiveness is
duke@435 163 // conservative in the sense that it may consider locals to be live which
duke@435 164 // cannot be live, like in the case where a local could contain an oop or
duke@435 165 // a primitive along different paths. In that case the local must be
duke@435 166 // dead when those paths merge. Since the interpreter's viewpoint is
duke@435 167 // used when gc'ing an interpreter frame we need to use its viewpoint
duke@435 168 // during OSR when loading the locals.
duke@435 169
duke@435 170 BitMap live_local_oops_at_bci(int bci);
duke@435 171
duke@435 172 #ifdef COMPILER1
duke@435 173 const BitMap bci_block_start();
duke@435 174 #endif
duke@435 175
duke@435 176 ciTypeFlow* get_flow_analysis();
duke@435 177 ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point
duke@435 178 ciCallProfile call_profile_at_bci(int bci);
duke@435 179 int interpreter_call_site_count(int bci);
duke@435 180
duke@435 181 // Given a certain calling environment, find the monomorphic target
duke@435 182 // for the call. Return NULL if the call is not monomorphic in
duke@435 183 // its calling environment.
duke@435 184 ciMethod* find_monomorphic_target(ciInstanceKlass* caller,
duke@435 185 ciInstanceKlass* callee_holder,
duke@435 186 ciInstanceKlass* actual_receiver);
duke@435 187
duke@435 188 // Given a known receiver klass, find the target for the call.
duke@435 189 // Return NULL if the call has no target or is abstract.
duke@435 190 ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver);
duke@435 191
duke@435 192 // Find the proper vtable index to invoke this method.
duke@435 193 int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
duke@435 194
duke@435 195 // Compilation directives
duke@435 196 bool will_link(ciKlass* accessing_klass,
duke@435 197 ciKlass* declared_method_holder,
duke@435 198 Bytecodes::Code bc);
duke@435 199 bool should_exclude();
duke@435 200 bool should_inline();
duke@435 201 bool should_not_inline();
duke@435 202 bool should_print_assembly();
duke@435 203 bool break_at_execute();
duke@435 204 bool has_option(const char *option);
duke@435 205 bool can_be_compiled();
duke@435 206 bool can_be_osr_compiled(int entry_bci);
duke@435 207 void set_not_compilable();
duke@435 208 bool has_compiled_code();
duke@435 209 int instructions_size();
duke@435 210 void log_nmethod_identity(xmlStream* log);
duke@435 211 bool is_not_reached(int bci);
duke@435 212 bool was_executed_more_than(int times);
duke@435 213 bool has_unloaded_classes_in_signature();
duke@435 214 bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
duke@435 215 bool check_call(int refinfo_index, bool is_static) const;
duke@435 216 void build_method_data(); // make sure it exists in the VM also
duke@435 217 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC
twisti@1587 218
twisti@1587 219 // JSR 292 support
twisti@1587 220 bool is_method_handle_invoke() const;
twisti@1587 221 bool is_method_handle_adapter() const;
jrose@1145 222 ciInstance* method_handle_type();
duke@435 223
duke@435 224 // What kind of ciObject is this?
duke@435 225 bool is_method() { return true; }
duke@435 226
duke@435 227 // Java access flags
duke@435 228 bool is_public () const { return flags().is_public(); }
duke@435 229 bool is_private () const { return flags().is_private(); }
duke@435 230 bool is_protected () const { return flags().is_protected(); }
duke@435 231 bool is_static () const { return flags().is_static(); }
duke@435 232 bool is_final () const { return flags().is_final(); }
duke@435 233 bool is_synchronized() const { return flags().is_synchronized(); }
duke@435 234 bool is_native () const { return flags().is_native(); }
duke@435 235 bool is_interface () const { return flags().is_interface(); }
duke@435 236 bool is_abstract () const { return flags().is_abstract(); }
duke@435 237 bool is_strict () const { return flags().is_strict(); }
duke@435 238
duke@435 239 // Other flags
duke@435 240 bool is_empty_method() const;
duke@435 241 bool is_vanilla_constructor() const;
duke@435 242 bool is_final_method() const { return is_final() || holder()->is_final(); }
duke@435 243 bool has_loops () const;
duke@435 244 bool has_jsrs () const;
duke@435 245 bool is_accessor () const;
duke@435 246 bool is_initializer () const;
duke@435 247 bool can_be_statically_bound() const { return _can_be_statically_bound; }
duke@435 248
duke@435 249 // Print the bytecodes of this method.
duke@435 250 void print_codes_on(outputStream* st);
duke@435 251 void print_codes() {
duke@435 252 print_codes_on(tty);
duke@435 253 }
duke@435 254 void print_codes_on(int from, int to, outputStream* st);
duke@435 255
duke@435 256 // Print the name of this method in various incarnations.
duke@435 257 void print_name(outputStream* st = tty);
duke@435 258 void print_short_name(outputStream* st = tty);
twisti@1573 259
twisti@1573 260 methodOop get_method_handle_target() {
twisti@1573 261 klassOop receiver_limit_oop = NULL;
twisti@1573 262 int flags = 0;
twisti@1573 263 return MethodHandles::decode_method(get_oop(), receiver_limit_oop, flags);
twisti@1573 264 }
duke@435 265 };

mercurial