src/share/vm/ci/ciMethod.hpp

Tue, 24 Jul 2012 10:51:00 -0700

author
twisti
date
Tue, 24 Jul 2012 10:51:00 -0700
changeset 3969
1d7922586cf6
parent 3926
6d8f36bcef55
child 4037
da91efe96a93
permissions
-rw-r--r--

7023639: JSR 292 method handle invocation needs a fast path for compiled code
6984705: JSR 292 method handle creation should not go through JNI
Summary: remove assembly code for JDK 7 chained method handles
Reviewed-by: jrose, twisti, kvn, mhaupt
Contributed-by: John Rose <john.r.rose@oracle.com>, Christian Thalinger <christian.thalinger@oracle.com>, Michael Haupt <michael.haupt@oracle.com>

duke@435 1 /*
never@2462 2 * Copyright (c) 1999, 2011, 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 //
duke@435 45 // This class represents a methodOop in the HotSpot virtual
duke@435 46 // machine.
duke@435 47 class ciMethod : public ciObject {
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;
duke@435 54
duke@435 55 private:
duke@435 56 // General method information.
duke@435 57 ciFlags _flags;
duke@435 58 ciSymbol* _name;
duke@435 59 ciInstanceKlass* _holder;
duke@435 60 ciSignature* _signature;
duke@435 61 ciMethodData* _method_data;
duke@435 62 ciMethodBlocks* _method_blocks;
duke@435 63
duke@435 64 // Code attributes.
duke@435 65 int _code_size;
duke@435 66 int _max_stack;
duke@435 67 int _max_locals;
duke@435 68 vmIntrinsics::ID _intrinsic_id;
duke@435 69 int _handler_count;
duke@435 70 int _interpreter_invocation_count;
duke@435 71 int _interpreter_throwout_count;
duke@435 72
duke@435 73 bool _uses_monitors;
duke@435 74 bool _balanced_monitors;
iveresov@2138 75 bool _is_c1_compilable;
iveresov@2138 76 bool _is_c2_compilable;
duke@435 77 bool _can_be_statically_bound;
duke@435 78
duke@435 79 // Lazy fields, filled in on demand
duke@435 80 address _code;
duke@435 81 ciExceptionHandler** _exception_handlers;
duke@435 82
duke@435 83 // Optional liveness analyzer.
duke@435 84 MethodLiveness* _liveness;
twisti@2047 85 #if defined(COMPILER2) || defined(SHARK)
kvn@2003 86 ciTypeFlow* _flow;
kvn@2003 87 BCEscapeAnalyzer* _bcea;
duke@435 88 #endif
duke@435 89
duke@435 90 ciMethod(methodHandle h_m);
twisti@3197 91 ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature, ciInstanceKlass* accessor);
duke@435 92
duke@435 93 methodOop get_methodOop() const {
duke@435 94 methodOop m = (methodOop)get_oop();
duke@435 95 assert(m != NULL, "illegal use of unloaded method");
duke@435 96 return m;
duke@435 97 }
duke@435 98
duke@435 99 oop loader() const { return _holder->loader(); }
duke@435 100
duke@435 101 const char* type_string() { return "ciMethod"; }
duke@435 102
duke@435 103 void print_impl(outputStream* st);
duke@435 104
duke@435 105 void load_code();
duke@435 106
duke@435 107 void check_is_loaded() const { assert(is_loaded(), "not loaded"); }
duke@435 108
iveresov@2349 109 bool ensure_method_data(methodHandle h_m);
duke@435 110
duke@435 111 void code_at_put(int bci, Bytecodes::Code code) {
duke@435 112 Bytecodes::check(code);
duke@435 113 assert(0 <= bci && bci < code_size(), "valid bci");
duke@435 114 address bcp = _code + bci;
duke@435 115 *bcp = code;
duke@435 116 }
duke@435 117
duke@435 118 public:
duke@435 119 // Basic method information.
duke@435 120 ciFlags flags() const { check_is_loaded(); return _flags; }
duke@435 121 ciSymbol* name() const { return _name; }
duke@435 122 ciInstanceKlass* holder() const { return _holder; }
duke@435 123 ciMethodData* method_data();
iveresov@2349 124 ciMethodData* method_data_or_null();
duke@435 125
duke@435 126 // Signature information.
duke@435 127 ciSignature* signature() const { return _signature; }
duke@435 128 ciType* return_type() const { return _signature->return_type(); }
duke@435 129 int arg_size_no_receiver() const { return _signature->size(); }
never@2812 130 // Can only be used on loaded ciMethods
never@2812 131 int arg_size() const {
never@2812 132 check_is_loaded();
never@2812 133 return _signature->size() + (_flags.is_static() ? 0 : 1);
never@2812 134 }
never@2812 135 // Report the number of elements on stack when invoking this method.
twisti@3969 136 // This is different than the regular arg_size because invokedynamic
never@2812 137 // has an implicit receiver.
never@2812 138 int invoke_arg_size(Bytecodes::Code code) const {
twisti@3969 139 if (is_loaded()) {
twisti@3969 140 return arg_size();
twisti@3969 141 } else {
twisti@3969 142 int arg_size = _signature->size();
twisti@3969 143 // Add a receiver argument, maybe:
twisti@3969 144 if (code != Bytecodes::_invokestatic &&
twisti@3969 145 code != Bytecodes::_invokedynamic) {
twisti@3969 146 arg_size++;
twisti@3969 147 }
twisti@3969 148 return arg_size;
never@2812 149 }
never@2812 150 }
never@2812 151
duke@435 152
duke@435 153 // Method code and related information.
duke@435 154 address code() { if (_code == NULL) load_code(); return _code; }
duke@435 155 int code_size() const { check_is_loaded(); return _code_size; }
duke@435 156 int max_stack() const { check_is_loaded(); return _max_stack; }
duke@435 157 int max_locals() const { check_is_loaded(); return _max_locals; }
duke@435 158 vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; }
duke@435 159 bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; }
duke@435 160 int exception_table_length() const { check_is_loaded(); return _handler_count; }
duke@435 161 int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; }
duke@435 162 int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; }
duke@435 163
twisti@3097 164 // Code size for inlining decisions.
twisti@3097 165 int code_size_for_inlining();
twisti@3097 166
jrose@3926 167 bool force_inline() { return get_methodOop()->force_inline(); }
twisti@3969 168 bool dont_inline() { return get_methodOop()->dont_inline(); }
jrose@3926 169
iveresov@2138 170 int comp_level();
iveresov@2988 171 int highest_osr_comp_level();
iveresov@2138 172
duke@435 173 Bytecodes::Code java_code_at_bci(int bci) {
duke@435 174 address bcp = code() + bci;
never@2462 175 return Bytecodes::java_code_at(NULL, bcp);
duke@435 176 }
duke@435 177 BCEscapeAnalyzer *get_bcea();
duke@435 178 ciMethodBlocks *get_method_blocks();
duke@435 179
duke@435 180 bool has_linenumber_table() const; // length unknown until decompression
duke@435 181 u_char* compressed_linenumber_table() const; // not preserved by gc
duke@435 182
duke@435 183 int line_number_from_bci(int bci) const;
duke@435 184
duke@435 185 // Runtime information.
duke@435 186 int vtable_index();
twisti@2047 187 #ifdef SHARK
twisti@2047 188 int itable_index();
twisti@2047 189 #endif // SHARK
duke@435 190 address native_entry();
duke@435 191 address interpreter_entry();
duke@435 192
duke@435 193 // Analysis and profiling.
duke@435 194 //
duke@435 195 // Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks.
duke@435 196 bool uses_monitors() const { return _uses_monitors; } // this one should go away, it has a misleading name
duke@435 197 bool has_monitor_bytecodes() const { return _uses_monitors; }
duke@435 198 bool has_balanced_monitors();
duke@435 199
never@1426 200 // Returns a bitmap indicating which locals are required to be
never@1426 201 // maintained as live for deopt. raw_liveness_at_bci is always the
never@1426 202 // direct output of the liveness computation while liveness_at_bci
never@1426 203 // may mark all locals as live to improve support for debugging Java
never@1426 204 // code by maintaining the state of as many locals as possible.
never@1426 205 MethodLivenessResult raw_liveness_at_bci(int bci);
duke@435 206 MethodLivenessResult liveness_at_bci(int bci);
duke@435 207
duke@435 208 // Get the interpreters viewpoint on oop liveness. MethodLiveness is
duke@435 209 // conservative in the sense that it may consider locals to be live which
duke@435 210 // cannot be live, like in the case where a local could contain an oop or
duke@435 211 // a primitive along different paths. In that case the local must be
duke@435 212 // dead when those paths merge. Since the interpreter's viewpoint is
duke@435 213 // used when gc'ing an interpreter frame we need to use its viewpoint
duke@435 214 // during OSR when loading the locals.
duke@435 215
duke@435 216 BitMap live_local_oops_at_bci(int bci);
duke@435 217
duke@435 218 #ifdef COMPILER1
duke@435 219 const BitMap bci_block_start();
duke@435 220 #endif
duke@435 221
duke@435 222 ciTypeFlow* get_flow_analysis();
duke@435 223 ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point
duke@435 224 ciCallProfile call_profile_at_bci(int bci);
duke@435 225 int interpreter_call_site_count(int bci);
duke@435 226
duke@435 227 // Given a certain calling environment, find the monomorphic target
duke@435 228 // for the call. Return NULL if the call is not monomorphic in
duke@435 229 // its calling environment.
duke@435 230 ciMethod* find_monomorphic_target(ciInstanceKlass* caller,
duke@435 231 ciInstanceKlass* callee_holder,
duke@435 232 ciInstanceKlass* actual_receiver);
duke@435 233
duke@435 234 // Given a known receiver klass, find the target for the call.
duke@435 235 // Return NULL if the call has no target or is abstract.
duke@435 236 ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver);
duke@435 237
duke@435 238 // Find the proper vtable index to invoke this method.
duke@435 239 int resolve_vtable_index(ciKlass* caller, ciKlass* receiver);
duke@435 240
duke@435 241 // Compilation directives
duke@435 242 bool will_link(ciKlass* accessing_klass,
duke@435 243 ciKlass* declared_method_holder,
duke@435 244 Bytecodes::Code bc);
duke@435 245 bool should_exclude();
duke@435 246 bool should_inline();
duke@435 247 bool should_not_inline();
duke@435 248 bool should_print_assembly();
duke@435 249 bool break_at_execute();
duke@435 250 bool has_option(const char *option);
duke@435 251 bool can_be_compiled();
duke@435 252 bool can_be_osr_compiled(int entry_bci);
duke@435 253 void set_not_compilable();
duke@435 254 bool has_compiled_code();
iveresov@2138 255 int instructions_size(int comp_level = CompLevel_any);
duke@435 256 void log_nmethod_identity(xmlStream* log);
duke@435 257 bool is_not_reached(int bci);
duke@435 258 bool was_executed_more_than(int times);
duke@435 259 bool has_unloaded_classes_in_signature();
duke@435 260 bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const;
duke@435 261 bool check_call(int refinfo_index, bool is_static) const;
iveresov@2349 262 bool ensure_method_data(); // make sure it exists in the VM also
duke@435 263 int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC
twisti@1587 264
twisti@1587 265 // JSR 292 support
twisti@3969 266 bool is_method_handle_intrinsic() const;
twisti@3969 267 bool is_compiled_lambda_form() const;
twisti@3969 268 bool has_member_arg() const;
duke@435 269
duke@435 270 // What kind of ciObject is this?
duke@435 271 bool is_method() { return true; }
duke@435 272
duke@435 273 // Java access flags
duke@435 274 bool is_public () const { return flags().is_public(); }
duke@435 275 bool is_private () const { return flags().is_private(); }
duke@435 276 bool is_protected () const { return flags().is_protected(); }
duke@435 277 bool is_static () const { return flags().is_static(); }
duke@435 278 bool is_final () const { return flags().is_final(); }
duke@435 279 bool is_synchronized() const { return flags().is_synchronized(); }
duke@435 280 bool is_native () const { return flags().is_native(); }
duke@435 281 bool is_interface () const { return flags().is_interface(); }
duke@435 282 bool is_abstract () const { return flags().is_abstract(); }
duke@435 283 bool is_strict () const { return flags().is_strict(); }
duke@435 284
duke@435 285 // Other flags
duke@435 286 bool is_empty_method() const;
duke@435 287 bool is_vanilla_constructor() const;
duke@435 288 bool is_final_method() const { return is_final() || holder()->is_final(); }
duke@435 289 bool has_loops () const;
duke@435 290 bool has_jsrs () const;
duke@435 291 bool is_accessor () const;
duke@435 292 bool is_initializer () const;
duke@435 293 bool can_be_statically_bound() const { return _can_be_statically_bound; }
duke@435 294
duke@435 295 // Print the bytecodes of this method.
duke@435 296 void print_codes_on(outputStream* st);
duke@435 297 void print_codes() {
duke@435 298 print_codes_on(tty);
duke@435 299 }
duke@435 300 void print_codes_on(int from, int to, outputStream* st);
duke@435 301
duke@435 302 // Print the name of this method in various incarnations.
duke@435 303 void print_name(outputStream* st = tty);
duke@435 304 void print_short_name(outputStream* st = tty);
duke@435 305 };
stefank@2314 306
stefank@2314 307 #endif // SHARE_VM_CI_CIMETHOD_HPP

mercurial