1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/ci/ciMethod.hpp Sat Dec 01 00:00:00 2007 +0000 1.3 @@ -0,0 +1,246 @@ 1.4 +/* 1.5 + * Copyright 1999-2007 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +class ciMethodBlocks; 1.29 +class MethodLiveness; 1.30 +class BitMap; 1.31 +class Arena; 1.32 +class BCEscapeAnalyzer; 1.33 + 1.34 + 1.35 +// ciMethod 1.36 +// 1.37 +// This class represents a methodOop in the HotSpot virtual 1.38 +// machine. 1.39 +class ciMethod : public ciObject { 1.40 + friend class CompileBroker; 1.41 + CI_PACKAGE_ACCESS 1.42 + friend class ciEnv; 1.43 + friend class ciExceptionHandlerStream; 1.44 + 1.45 + private: 1.46 + // General method information. 1.47 + ciFlags _flags; 1.48 + ciSymbol* _name; 1.49 + ciInstanceKlass* _holder; 1.50 + ciSignature* _signature; 1.51 + ciMethodData* _method_data; 1.52 + BCEscapeAnalyzer* _bcea; 1.53 + ciMethodBlocks* _method_blocks; 1.54 + 1.55 + // Code attributes. 1.56 + int _code_size; 1.57 + int _max_stack; 1.58 + int _max_locals; 1.59 + vmIntrinsics::ID _intrinsic_id; 1.60 + int _handler_count; 1.61 + int _interpreter_invocation_count; 1.62 + int _interpreter_throwout_count; 1.63 + 1.64 + bool _uses_monitors; 1.65 + bool _balanced_monitors; 1.66 + bool _is_compilable; 1.67 + bool _can_be_statically_bound; 1.68 + 1.69 + // Lazy fields, filled in on demand 1.70 + address _code; 1.71 + ciExceptionHandler** _exception_handlers; 1.72 + 1.73 + // Optional liveness analyzer. 1.74 + MethodLiveness* _liveness; 1.75 +#ifdef COMPILER2 1.76 + ciTypeFlow* _flow; 1.77 +#endif 1.78 + 1.79 + ciMethod(methodHandle h_m); 1.80 + ciMethod(ciInstanceKlass* holder, ciSymbol* name, ciSymbol* signature); 1.81 + 1.82 + methodOop get_methodOop() const { 1.83 + methodOop m = (methodOop)get_oop(); 1.84 + assert(m != NULL, "illegal use of unloaded method"); 1.85 + return m; 1.86 + } 1.87 + 1.88 + oop loader() const { return _holder->loader(); } 1.89 + 1.90 + const char* type_string() { return "ciMethod"; } 1.91 + 1.92 + void print_impl(outputStream* st); 1.93 + 1.94 + void load_code(); 1.95 + 1.96 + void check_is_loaded() const { assert(is_loaded(), "not loaded"); } 1.97 + 1.98 + void build_method_data(methodHandle h_m); 1.99 + 1.100 + void code_at_put(int bci, Bytecodes::Code code) { 1.101 + Bytecodes::check(code); 1.102 + assert(0 <= bci && bci < code_size(), "valid bci"); 1.103 + address bcp = _code + bci; 1.104 + *bcp = code; 1.105 + } 1.106 + 1.107 + public: 1.108 + // Basic method information. 1.109 + ciFlags flags() const { check_is_loaded(); return _flags; } 1.110 + ciSymbol* name() const { return _name; } 1.111 + ciInstanceKlass* holder() const { return _holder; } 1.112 + ciMethodData* method_data(); 1.113 + 1.114 + // Signature information. 1.115 + ciSignature* signature() const { return _signature; } 1.116 + ciType* return_type() const { return _signature->return_type(); } 1.117 + int arg_size_no_receiver() const { return _signature->size(); } 1.118 + int arg_size() const { return _signature->size() + (_flags.is_static() ? 0 : 1); } 1.119 + 1.120 + // Method code and related information. 1.121 + address code() { if (_code == NULL) load_code(); return _code; } 1.122 + int code_size() const { check_is_loaded(); return _code_size; } 1.123 + int max_stack() const { check_is_loaded(); return _max_stack; } 1.124 + int max_locals() const { check_is_loaded(); return _max_locals; } 1.125 + vmIntrinsics::ID intrinsic_id() const { check_is_loaded(); return _intrinsic_id; } 1.126 + bool has_exception_handlers() const { check_is_loaded(); return _handler_count > 0; } 1.127 + int exception_table_length() const { check_is_loaded(); return _handler_count; } 1.128 + int interpreter_invocation_count() const { check_is_loaded(); return _interpreter_invocation_count; } 1.129 + int interpreter_throwout_count() const { check_is_loaded(); return _interpreter_throwout_count; } 1.130 + 1.131 + Bytecodes::Code java_code_at_bci(int bci) { 1.132 + address bcp = code() + bci; 1.133 + return Bytecodes::java_code_at(bcp); 1.134 + } 1.135 + BCEscapeAnalyzer *get_bcea(); 1.136 + ciMethodBlocks *get_method_blocks(); 1.137 + 1.138 + bool has_linenumber_table() const; // length unknown until decompression 1.139 + u_char* compressed_linenumber_table() const; // not preserved by gc 1.140 + 1.141 + int line_number_from_bci(int bci) const; 1.142 + 1.143 + // Runtime information. 1.144 + int vtable_index(); 1.145 + address native_entry(); 1.146 + address interpreter_entry(); 1.147 + 1.148 + // Analysis and profiling. 1.149 + // 1.150 + // Usage note: liveness_at_bci and init_vars should be wrapped in ResourceMarks. 1.151 + bool uses_monitors() const { return _uses_monitors; } // this one should go away, it has a misleading name 1.152 + bool has_monitor_bytecodes() const { return _uses_monitors; } 1.153 + bool has_balanced_monitors(); 1.154 + 1.155 + MethodLivenessResult liveness_at_bci(int bci); 1.156 + 1.157 + // Get the interpreters viewpoint on oop liveness. MethodLiveness is 1.158 + // conservative in the sense that it may consider locals to be live which 1.159 + // cannot be live, like in the case where a local could contain an oop or 1.160 + // a primitive along different paths. In that case the local must be 1.161 + // dead when those paths merge. Since the interpreter's viewpoint is 1.162 + // used when gc'ing an interpreter frame we need to use its viewpoint 1.163 + // during OSR when loading the locals. 1.164 + 1.165 + BitMap live_local_oops_at_bci(int bci); 1.166 + 1.167 +#ifdef COMPILER1 1.168 + const BitMap bci_block_start(); 1.169 +#endif 1.170 + 1.171 + ciTypeFlow* get_flow_analysis(); 1.172 + ciTypeFlow* get_osr_flow_analysis(int osr_bci); // alternate entry point 1.173 + ciCallProfile call_profile_at_bci(int bci); 1.174 + int interpreter_call_site_count(int bci); 1.175 + 1.176 + // Given a certain calling environment, find the monomorphic target 1.177 + // for the call. Return NULL if the call is not monomorphic in 1.178 + // its calling environment. 1.179 + ciMethod* find_monomorphic_target(ciInstanceKlass* caller, 1.180 + ciInstanceKlass* callee_holder, 1.181 + ciInstanceKlass* actual_receiver); 1.182 + 1.183 + // Given a known receiver klass, find the target for the call. 1.184 + // Return NULL if the call has no target or is abstract. 1.185 + ciMethod* resolve_invoke(ciKlass* caller, ciKlass* exact_receiver); 1.186 + 1.187 + // Find the proper vtable index to invoke this method. 1.188 + int resolve_vtable_index(ciKlass* caller, ciKlass* receiver); 1.189 + 1.190 + // Compilation directives 1.191 + bool will_link(ciKlass* accessing_klass, 1.192 + ciKlass* declared_method_holder, 1.193 + Bytecodes::Code bc); 1.194 + bool should_exclude(); 1.195 + bool should_inline(); 1.196 + bool should_not_inline(); 1.197 + bool should_print_assembly(); 1.198 + bool break_at_execute(); 1.199 + bool has_option(const char *option); 1.200 + bool can_be_compiled(); 1.201 + bool can_be_osr_compiled(int entry_bci); 1.202 + void set_not_compilable(); 1.203 + bool has_compiled_code(); 1.204 + int instructions_size(); 1.205 + void log_nmethod_identity(xmlStream* log); 1.206 + bool is_not_reached(int bci); 1.207 + bool was_executed_more_than(int times); 1.208 + bool has_unloaded_classes_in_signature(); 1.209 + bool is_klass_loaded(int refinfo_index, bool must_be_resolved) const; 1.210 + bool check_call(int refinfo_index, bool is_static) const; 1.211 + void build_method_data(); // make sure it exists in the VM also 1.212 + int scale_count(int count, float prof_factor = 1.); // make MDO count commensurate with IIC 1.213 + 1.214 + // What kind of ciObject is this? 1.215 + bool is_method() { return true; } 1.216 + 1.217 + // Java access flags 1.218 + bool is_public () const { return flags().is_public(); } 1.219 + bool is_private () const { return flags().is_private(); } 1.220 + bool is_protected () const { return flags().is_protected(); } 1.221 + bool is_static () const { return flags().is_static(); } 1.222 + bool is_final () const { return flags().is_final(); } 1.223 + bool is_synchronized() const { return flags().is_synchronized(); } 1.224 + bool is_native () const { return flags().is_native(); } 1.225 + bool is_interface () const { return flags().is_interface(); } 1.226 + bool is_abstract () const { return flags().is_abstract(); } 1.227 + bool is_strict () const { return flags().is_strict(); } 1.228 + 1.229 + // Other flags 1.230 + bool is_empty_method() const; 1.231 + bool is_vanilla_constructor() const; 1.232 + bool is_final_method() const { return is_final() || holder()->is_final(); } 1.233 + bool has_loops () const; 1.234 + bool has_jsrs () const; 1.235 + bool is_accessor () const; 1.236 + bool is_initializer () const; 1.237 + bool can_be_statically_bound() const { return _can_be_statically_bound; } 1.238 + 1.239 + // Print the bytecodes of this method. 1.240 + void print_codes_on(outputStream* st); 1.241 + void print_codes() { 1.242 + print_codes_on(tty); 1.243 + } 1.244 + void print_codes_on(int from, int to, outputStream* st); 1.245 + 1.246 + // Print the name of this method in various incarnations. 1.247 + void print_name(outputStream* st = tty); 1.248 + void print_short_name(outputStream* st = tty); 1.249 +};