src/share/vm/ci/ciMethod.hpp

Mon, 27 Mar 2017 11:31:27 -0700

author
asaha
date
Mon, 27 Mar 2017 11:31:27 -0700
changeset 8758
e7db67a9ddfd
parent 8652
057571442f86
parent 8739
0b85ccd62409
child 8856
ac27a9c85bea
child 9007
91894ffc746c
permissions
-rw-r--r--

Merge

duke@435 1 /*
coleenp@8739 2 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. 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 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CI_CIMETHOD_HPP
stefank@2314 26 #define SHARE_VM_CI_CIMETHOD_HPP
stefank@2314 27
stefank@2314 28 #include "ci/ciFlags.hpp"
stefank@2314 29 #include "ci/ciInstanceKlass.hpp"
stefank@2314 30 #include "ci/ciObject.hpp"
stefank@2314 31 #include "ci/ciSignature.hpp"
stefank@2314 32 #include "compiler/methodLiveness.hpp"
stefank@2314 33 #include "prims/methodHandles.hpp"
stefank@2314 34 #include "utilities/bitMap.hpp"
stefank@2314 35
duke@435 36 class ciMethodBlocks;
duke@435 37 class MethodLiveness;
duke@435 38 class BitMap;
duke@435 39 class Arena;
duke@435 40 class BCEscapeAnalyzer;
duke@435 41
duke@435 42
duke@435 43 // ciMethod
duke@435 44 //
coleenp@4037 45 // This class represents a Method* in the HotSpot virtual
duke@435 46 // machine.
coleenp@4037 47 class ciMethod : public ciMetadata {
duke@435 48 friend class CompileBroker;
duke@435 49 CI_PACKAGE_ACCESS
duke@435 50 friend class ciEnv;
duke@435 51 friend class ciExceptionHandlerStream;
twisti@1573 52 friend class ciBytecodeStream;
twisti@1573 53 friend class ciMethodHandle;
minqi@4267 54 friend class ciReplay;
duke@435 55
duke@435 56 private:
duke@435 57 // General method information.
duke@435 58 ciFlags _flags;
duke@435 59 ciSymbol* _name;
duke@435 60 ciInstanceKlass* _holder;
duke@435 61 ciSignature* _signature;
duke@435 62 ciMethodData* _method_data;
duke@435 63 ciMethodBlocks* _method_blocks;
duke@435 64
duke@435 65 // Code attributes.
duke@435 66 int _code_size;
duke@435 67 int _max_stack;
duke@435 68 int _max_locals;
duke@435 69 vmIntrinsics::ID _intrinsic_id;
duke@435 70 int _handler_count;
duke@435 71 int _interpreter_invocation_count;
duke@435 72 int _interpreter_throwout_count;
minqi@4267 73 int _instructions_size;
roland@6723 74 int _size_of_parameters;
duke@435 75
duke@435 76 bool _uses_monitors;
duke@435 77 bool _balanced_monitors;
iveresov@2138 78 bool _is_c1_compilable;
iveresov@2138 79 bool _is_c2_compilable;
duke@435 80 bool _can_be_statically_bound;
duke@435 81
duke@435 82 // Lazy fields, filled in on demand
duke@435 83 address _code;
duke@435 84 ciExceptionHandler** _exception_handlers;
duke@435 85
duke@435 86 // Optional liveness analyzer.
duke@435 87 MethodLiveness* _liveness;
twisti@2047 88 #if defined(COMPILER2) || defined(SHARK)
kvn@2003 89 ciTypeFlow* _flow;
kvn@2003 90 BCEscapeAnalyzer* _bcea;
duke@435 91 #endif
duke@435 92
vlivanov@7384 93 ciMethod(methodHandle h_m, ciInstanceKlass* holder);
twisti@3197 94 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
duke@435 95
coleenp@4037 96 Method* get_Method() const {
coleenp@4037 97 Method* m = (Method*)_metadata;
duke@435 98 assert(m != NULL, "illegal use of unloaded method");
duke@435 99 return m;
duke@435 100 }
duke@435 101
duke@435 102 oop loader() const { return _holder->loader(); }
duke@435 103
duke@435 104 const char* type_string() { return "ciMethod"; }
duke@435 105
duke@435 106 void print_impl(outputStream* st);
duke@435 107
duke@435 108 void load_code();
duke@435 109
duke@435 110 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
duke@435 111
iveresov@2349 112 bool ensure_method_data(methodHandle h_m);
duke@435 113
duke@435 114 void code_at_put(int bci, Bytecodes::Code code) {
duke@435 115 Bytecodes::check(code);
duke@435 116 assert(0 <= bci && bci < code_size(), "valid bci");
duke@435 117 address bcp = _code + bci;
duke@435 118 *bcp = code;
duke@435 119 }
duke@435 120
roland@5991 121 // Check bytecode and profile data collected are compatible
roland@5991 122 void assert_virtual_call_type_ok(int bci);
roland@5991 123 void assert_call_type_ok(int bci);
roland@5991 124
duke@435 125 public:
duke@435 126 // Basic method information.
duke@435 127 ciFlags flags() const { check_is_loaded(); return _flags; }
duke@435 128 ciSymbol* name() const { return _name; }
duke@435 129 ciInstanceKlass* holder() const { return _holder; }
duke@435 130 ciMethodData* method_data();
iveresov@2349 131 ciMethodData* method_data_or_null();
duke@435 132
duke@435 133 // Signature information.
duke@435 134 ciSignature* signature() const { return _signature; }
duke@435 135 ciType* return_type() const { return _signature->return_type(); }
duke@435 136 int arg_size_no_receiver() const { return _signature->size(); }
never@2812 137 // Can only be used on loaded ciMethods
never@2812 138 int arg_size() const {
never@2812 139 check_is_loaded();
never@2812 140 return _signature->size() + (_flags.is_static() ? 0 : 1);
never@2812 141 }
never@2812 142 // Report the number of elements on stack when invoking this method.
twisti@3969 143 // This is different than the regular arg_size because invokedynamic
never@2812 144 // has an implicit receiver.
never@2812 145 int invoke_arg_size(Bytecodes::Code code) const {
twisti@3969 146 if (is_loaded()) {
twisti@3969 147 return arg_size();
twisti@3969 148 } else {
twisti@3969 149 int arg_size = _signature->size();
twisti@3969 150 // Add a receiver argument, maybe:
twisti@3969 151 if (code != Bytecodes::_invokestatic &&
twisti@3969 152 code != Bytecodes::_invokedynamic) {
twisti@3969 153 arg_size++;
twisti@3969 154 }
twisti@3969 155 return arg_size;
never@2812 156 }
never@2812 157 }
never@2812 158
duke@435 159
duke@435 160 // Method code and related information.
duke@435 161 address code() { if (_code == NULL) load_code(); return _code; }
duke@435 162 int code_size() const { check_is_loaded(); return _code_size; }
duke@435 163 int max_stack() const { check_is_loaded(); return _max_stack; }
duke@435 164 int max_locals() const { check_is_loaded(); return _max_locals; }
duke@435 165 vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
duke@435 166 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
duke@435 167 int exception_table_length() const { check_is_loaded(); return _handler_count; }
duke@435 168 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
duke@435 169 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
roland@6723 170 int size_of_parameters() const { check_is_loaded(); return _size_of_parameters; }
duke@435 171
twisti@3097 172 // Code size for inlining decisions.
twisti@3097 173 int code_size_for_inlining();
twisti@3097 174
vlivanov@7890 175 bool caller_sensitive() const { return get_Method()->caller_sensitive(); }
vlivanov@7890 176 bool force_inline() const { return get_Method()->force_inline(); }
vlivanov@7890 177 bool dont_inline() const { return get_Method()->dont_inline(); }
jrose@3926 178
iveresov@2138 179 int comp_level();
iveresov@2988 180 int highest_osr_comp_level();
iveresov@2138 181
duke@435 182 Bytecodes::Code java_code_at_bci(int bci) {
duke@435 183 address bcp = code() + bci;
never@2462 184 return Bytecodes::java_code_at(NULL, bcp);
duke@435 185 }
roland@5628 186 Bytecodes::Code raw_code_at_bci(int bci) {
roland@5628 187 address bcp = code() + bci;
roland@5628 188 return Bytecodes::code_at(NULL, bcp);
roland@5628 189 }
duke@435 190 BCEscapeAnalyzer *get_bcea();
duke@435 191 ciMethodBlocks *get_method_blocks();
duke@435 192
duke@435 193 bool has_linenumber_table() const; // length unknown until decompression
duke@435 194 u_char* compressed_linenumber_table() const; // not preserved by gc
duke@435 195
duke@435 196 int line_number_from_bci(int bci) const;
duke@435 197
duke@435 198 // Runtime information.
duke@435 199 int vtable_index();
twisti@2047 200 #ifdef SHARK
twisti@2047 201 int itable_index();
twisti@2047 202 #endif // SHARK
duke@435 203 address native_entry();
duke@435 204 address interpreter_entry();
duke@435 205
duke@435 206 // Analysis and profiling.
duke@435 207 //
duke@435 208 // Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks.
duke@435 209 bool has_monitor_bytecodes() const { return _uses_monitors; }
duke@435 210 bool has_balanced_monitors();
duke@435 211
never@1426 212 // Returns a bitmap indicating which locals are required to be
never@1426 213 // maintained as live for deopt. raw_liveness_at_bci is always the
never@1426 214 // direct output of the liveness computation while liveness_at_bci
never@1426 215 // may mark all locals as live to improve support for debugging Java
never@1426 216 // code by maintaining the state of as many locals as possible.
never@1426 217 MethodLivenessResult raw_liveness_at_bci(int bci);
duke@435 218 MethodLivenessResult liveness_at_bci(int bci);
duke@435 219
duke@435 220 // Get the interpreters viewpoint on oop liveness. MethodLiveness is
duke@435 221 // conservative in the sense that it may consider locals to be live which
duke@435 222 // cannot be live, like in the case where a local could contain an oop or
duke@435 223 // a primitive along different paths. In that case the local must be
duke@435 224 // dead when those paths merge. Since the interpreter's viewpoint is
duke@435 225 // used when gc'ing an interpreter frame we need to use its viewpoint
duke@435 226 // during OSR when loading the locals.
duke@435 227
duke@435 228 BitMap live_local_oops_at_bci(int bci);
duke@435 229
duke@435 230 #ifdef COMPILER1
duke@435 231 const BitMap bci_block_start();
duke@435 232 #endif
duke@435 233
duke@435 234 ciTypeFlow* get_flow_analysis();
duke@435 235 ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point
duke@435 236 ciCallProfile call_profile_at_bci(int bci);
duke@435 237 int interpreter_call_site_count(int bci);
duke@435 238
roland@5991 239 // Does type profiling provide a useful type at this point?
roland@5991 240 ciKlass* argument_profiled_type(int bci, int i);
roland@5991 241 ciKlass* parameter_profiled_type(int i);
roland@5991 242 ciKlass* return_profiled_type(int bci);
roland@5991 243
twisti@4313 244 ciField* get_field_at_bci( int bci, bool &will_link);
twisti@4313 245 ciMethod* get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature);
shshahma@8652 246
shshahma@8652 247 ciSignature* get_declared_signature_at_bci(int bci) {
shshahma@8652 248 bool ignored_will_link;
shshahma@8652 249 ciSignature* declared_signature;
shshahma@8652 250 get_method_at_bci(bci, ignored_will_link, &declared_signature);
shshahma@8652 251 assert(declared_signature != NULL, "cannot be null");
shshahma@8652 252 return declared_signature;
shshahma@8652 253 }
shshahma@8652 254
dbuck@8651 255 ciMethod* get_method_at_bci(int bci) {
dbuck@8651 256 bool ignored_will_link;
dbuck@8651 257 ciSignature* ignored_declared_signature;
dbuck@8651 258 return get_method_at_bci(bci, ignored_will_link, &ignored_declared_signature);
dbuck@8651 259 }
shshahma@8652 260
duke@435 261 // Given a certain calling environment, find the monomorphic target
duke@435 262 // for the call. Return NULL if the call is not monomorphic in
duke@435 263 // its calling environment.
duke@435 264 ciMethod* find_monomorphic_target(ciInstanceKlass* caller,
duke@435 265 ciInstanceKlass* callee_holder,
vlivanov@7792 266 ciInstanceKlass* actual_receiver,
vlivanov@7792 267 bool check_access = true);
duke@435 268
duke@435 269 // Given a known receiver klass, find the target for the call.
duke@435 270 // Return NULL if the call has no target or is abstract.
vlivanov@7792 271 ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, bool check_access = true);
duke@435 272
duke@435 273 // Find the proper vtable index to invoke this method.
duke@435 274 int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
duke@435 275
duke@435 276 // Compilation directives
duke@435 277 bool should_exclude();
duke@435 278 bool should_inline();
duke@435 279 bool should_not_inline();
duke@435 280 bool should_print_assembly();
duke@435 281 bool break_at_execute();
duke@435 282 bool has_option(const char *option);
kvn@7144 283 template<typename T>
kvn@7144 284 bool has_option_value(const char* option, T& value);
duke@435 285 bool can_be_compiled();
duke@435 286 bool can_be_osr_compiled(int entry_bci);
vlivanov@4539 287 void set_not_compilable(const char* reason = NULL);
duke@435 288 bool has_compiled_code();
duke@435 289 void log_nmethod_identity(xmlStream* log);
duke@435 290 bool is_not_reached(int bci);
duke@435 291 bool was_executed_more_than(int times);
duke@435 292 bool has_unloaded_classes_in_signature();
duke@435 293 bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
duke@435 294 bool check_call(int refinfo_index, bool is_static) const;
iveresov@2349 295 bool ensure_method_data(); // make sure it exists in the VM also
twisti@5907 296 MethodCounters* ensure_method_counters();
minqi@4267 297 int instructions_size();
duke@435 298 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC
twisti@1587 299
twisti@4866 300 // Stack walking support
twisti@4866 301 bool is_ignored_by_security_stack_walk() const;
twisti@4866 302
twisti@1587 303 // JSR 292 support
twisti@3969 304 bool is_method_handle_intrinsic() const;
twisti@3969 305 bool is_compiled_lambda_form() const;
twisti@3969 306 bool has_member_arg() const;
duke@435 307
duke@435 308 // What kind of ciObject is this?
coleenp@4037 309 bool is_method() const { return true; }
duke@435 310
duke@435 311 // Java access flags
duke@435 312 bool is_public () const { return flags().is_public(); }
duke@435 313 bool is_private () const { return flags().is_private(); }
duke@435 314 bool is_protected () const { return flags().is_protected(); }
duke@435 315 bool is_static () const { return flags().is_static(); }
duke@435 316 bool is_final () const { return flags().is_final(); }
duke@435 317 bool is_synchronized() const { return flags().is_synchronized(); }
duke@435 318 bool is_native () const { return flags().is_native(); }
duke@435 319 bool is_interface () const { return flags().is_interface(); }
duke@435 320 bool is_abstract () const { return flags().is_abstract(); }
duke@435 321 bool is_strict () const { return flags().is_strict(); }
duke@435 322
duke@435 323 // Other flags
duke@435 324 bool is_empty_method() const;
duke@435 325 bool is_vanilla_constructor() const;
duke@435 326 bool is_final_method() const { return is_final() || holder()->is_final(); }
duke@435 327 bool has_loops () const;
duke@435 328 bool has_jsrs () const;
duke@435 329 bool is_accessor () const;
duke@435 330 bool is_initializer () const;
duke@435 331 bool can_be_statically_bound() const { return _can_be_statically_bound; }
kvn@5110 332 bool is_boxing_method() const;
kvn@5110 333 bool is_unboxing_method() const;
coleenp@8739 334 bool is_object_initializer() const;
duke@435 335
kvn@6217 336 // Replay data methods
kvn@6217 337 void dump_name_as_ascii(outputStream* st);
kvn@6217 338 void dump_replay_data(outputStream* st);
kvn@6217 339
duke@435 340 // Print the bytecodes of this method.
duke@435 341 void print_codes_on(outputStream* st);
duke@435 342 void print_codes() {
duke@435 343 print_codes_on(tty);
duke@435 344 }
duke@435 345 void print_codes_on(int from, int to, outputStream* st);
duke@435 346
duke@435 347 // Print the name of this method in various incarnations.
duke@435 348 void print_name(outputStream* st = tty);
duke@435 349 void print_short_name(outputStream* st = tty);
duke@435 350 };
stefank@2314 351
stefank@2314 352 #endif // SHARE_VM_CI_CIMETHOD_HPP

mercurial