Tue, 18 Jun 2013 12:31:07 -0700
8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti
duke@435 | 1 | /* |
jiangli@4936 | 2 | * Copyright (c) 1999, 2013, 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 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "ci/ciCallProfile.hpp" |
stefank@2314 | 27 | #include "ci/ciExceptionHandler.hpp" |
stefank@2314 | 28 | #include "ci/ciInstanceKlass.hpp" |
stefank@2314 | 29 | #include "ci/ciMethod.hpp" |
stefank@2314 | 30 | #include "ci/ciMethodBlocks.hpp" |
stefank@2314 | 31 | #include "ci/ciMethodData.hpp" |
stefank@2314 | 32 | #include "ci/ciStreams.hpp" |
stefank@2314 | 33 | #include "ci/ciSymbol.hpp" |
minqi@4267 | 34 | #include "ci/ciReplay.hpp" |
stefank@2314 | 35 | #include "ci/ciUtilities.hpp" |
stefank@2314 | 36 | #include "classfile/systemDictionary.hpp" |
stefank@2314 | 37 | #include "compiler/abstractCompiler.hpp" |
stefank@2314 | 38 | #include "compiler/compilerOracle.hpp" |
stefank@2314 | 39 | #include "compiler/methodLiveness.hpp" |
stefank@2314 | 40 | #include "interpreter/interpreter.hpp" |
stefank@2314 | 41 | #include "interpreter/linkResolver.hpp" |
stefank@2314 | 42 | #include "interpreter/oopMapCache.hpp" |
stefank@2314 | 43 | #include "memory/allocation.inline.hpp" |
stefank@2314 | 44 | #include "memory/resourceArea.hpp" |
stefank@2314 | 45 | #include "oops/generateOopMap.hpp" |
stefank@2314 | 46 | #include "oops/oop.inline.hpp" |
stefank@2314 | 47 | #include "prims/nativeLookup.hpp" |
stefank@2314 | 48 | #include "runtime/deoptimization.hpp" |
stefank@2314 | 49 | #include "utilities/bitMap.inline.hpp" |
stefank@2314 | 50 | #include "utilities/xmlstream.hpp" |
stefank@2314 | 51 | #ifdef COMPILER2 |
stefank@2314 | 52 | #include "ci/bcEscapeAnalyzer.hpp" |
stefank@2314 | 53 | #include "ci/ciTypeFlow.hpp" |
coleenp@4037 | 54 | #include "oops/method.hpp" |
stefank@2314 | 55 | #endif |
stefank@2314 | 56 | #ifdef SHARK |
stefank@2314 | 57 | #include "ci/ciTypeFlow.hpp" |
coleenp@4037 | 58 | #include "oops/method.hpp" |
stefank@2314 | 59 | #endif |
duke@435 | 60 | |
duke@435 | 61 | // ciMethod |
duke@435 | 62 | // |
coleenp@4037 | 63 | // This class represents a Method* in the HotSpot virtual |
duke@435 | 64 | // machine. |
duke@435 | 65 | |
duke@435 | 66 | |
duke@435 | 67 | // ------------------------------------------------------------------ |
duke@435 | 68 | // ciMethod::ciMethod |
duke@435 | 69 | // |
duke@435 | 70 | // Loaded method. |
coleenp@4037 | 71 | ciMethod::ciMethod(methodHandle h_m) : ciMetadata(h_m()) { |
duke@435 | 72 | assert(h_m() != NULL, "no null method"); |
duke@435 | 73 | |
duke@435 | 74 | // These fields are always filled in in loaded methods. |
duke@435 | 75 | _flags = ciFlags(h_m()->access_flags()); |
duke@435 | 76 | |
duke@435 | 77 | // Easy to compute, so fill them in now. |
duke@435 | 78 | _max_stack = h_m()->max_stack(); |
duke@435 | 79 | _max_locals = h_m()->max_locals(); |
duke@435 | 80 | _code_size = h_m()->code_size(); |
duke@435 | 81 | _intrinsic_id = h_m()->intrinsic_id(); |
jiangli@3917 | 82 | _handler_count = h_m()->exception_table_length(); |
duke@435 | 83 | _uses_monitors = h_m()->access_flags().has_monitor_bytecodes(); |
duke@435 | 84 | _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching(); |
iveresov@2138 | 85 | _is_c1_compilable = !h_m()->is_not_c1_compilable(); |
iveresov@2138 | 86 | _is_c2_compilable = !h_m()->is_not_c2_compilable(); |
duke@435 | 87 | // Lazy fields, filled in on demand. Require allocation. |
duke@435 | 88 | _code = NULL; |
duke@435 | 89 | _exception_handlers = NULL; |
duke@435 | 90 | _liveness = NULL; |
duke@435 | 91 | _method_blocks = NULL; |
twisti@2047 | 92 | #if defined(COMPILER2) || defined(SHARK) |
duke@435 | 93 | _flow = NULL; |
kvn@2003 | 94 | _bcea = NULL; |
twisti@2047 | 95 | #endif // COMPILER2 || SHARK |
duke@435 | 96 | |
kvn@1215 | 97 | ciEnv *env = CURRENT_ENV; |
iveresov@2138 | 98 | if (env->jvmti_can_hotswap_or_post_breakpoint() && can_be_compiled()) { |
duke@435 | 99 | // 6328518 check hotswap conditions under the right lock. |
duke@435 | 100 | MutexLocker locker(Compile_lock); |
duke@435 | 101 | if (Dependencies::check_evol_method(h_m()) != NULL) { |
iveresov@2138 | 102 | _is_c1_compilable = false; |
iveresov@2138 | 103 | _is_c2_compilable = false; |
duke@435 | 104 | } |
duke@435 | 105 | } else { |
duke@435 | 106 | CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops()); |
duke@435 | 107 | } |
duke@435 | 108 | |
coleenp@4251 | 109 | if (h_m()->method_holder()->is_linked()) { |
duke@435 | 110 | _can_be_statically_bound = h_m()->can_be_statically_bound(); |
duke@435 | 111 | } else { |
duke@435 | 112 | // Have to use a conservative value in this case. |
duke@435 | 113 | _can_be_statically_bound = false; |
duke@435 | 114 | } |
duke@435 | 115 | |
duke@435 | 116 | // Adjust the definition of this condition to be more useful: |
duke@435 | 117 | // %%% take these conditions into account in vtable generation |
duke@435 | 118 | if (!_can_be_statically_bound && h_m()->is_private()) |
duke@435 | 119 | _can_be_statically_bound = true; |
duke@435 | 120 | if (_can_be_statically_bound && h_m()->is_abstract()) |
duke@435 | 121 | _can_be_statically_bound = false; |
duke@435 | 122 | |
duke@435 | 123 | // generating _signature may allow GC and therefore move m. |
duke@435 | 124 | // These fields are always filled in. |
coleenp@2497 | 125 | _name = env->get_symbol(h_m()->name()); |
coleenp@4037 | 126 | _holder = env->get_instance_klass(h_m()->method_holder()); |
coleenp@2497 | 127 | ciSymbol* sig_symbol = env->get_symbol(h_m()->signature()); |
jrose@2982 | 128 | constantPoolHandle cpool = h_m()->constants(); |
jrose@2982 | 129 | _signature = new (env->arena()) ciSignature(_holder, cpool, sig_symbol); |
duke@435 | 130 | _method_data = NULL; |
duke@435 | 131 | // Take a snapshot of these values, so they will be commensurate with the MDO. |
iveresov@2138 | 132 | if (ProfileInterpreter || TieredCompilation) { |
duke@435 | 133 | int invcnt = h_m()->interpreter_invocation_count(); |
duke@435 | 134 | // if the value overflowed report it as max int |
duke@435 | 135 | _interpreter_invocation_count = invcnt < 0 ? max_jint : invcnt ; |
duke@435 | 136 | _interpreter_throwout_count = h_m()->interpreter_throwout_count(); |
duke@435 | 137 | } else { |
duke@435 | 138 | _interpreter_invocation_count = 0; |
duke@435 | 139 | _interpreter_throwout_count = 0; |
duke@435 | 140 | } |
duke@435 | 141 | if (_interpreter_invocation_count == 0) |
duke@435 | 142 | _interpreter_invocation_count = 1; |
minqi@4267 | 143 | _instructions_size = -1; |
minqi@4267 | 144 | #ifdef ASSERT |
minqi@4267 | 145 | if (ReplayCompiles) { |
minqi@4267 | 146 | ciReplay::initialize(this); |
minqi@4267 | 147 | } |
minqi@4267 | 148 | #endif |
duke@435 | 149 | } |
duke@435 | 150 | |
duke@435 | 151 | |
duke@435 | 152 | // ------------------------------------------------------------------ |
duke@435 | 153 | // ciMethod::ciMethod |
duke@435 | 154 | // |
duke@435 | 155 | // Unloaded method. |
duke@435 | 156 | ciMethod::ciMethod(ciInstanceKlass* holder, |
twisti@3197 | 157 | ciSymbol* name, |
twisti@3197 | 158 | ciSymbol* signature, |
twisti@3197 | 159 | ciInstanceKlass* accessor) : |
coleenp@4037 | 160 | ciMetadata((Metadata*)NULL), |
twisti@3197 | 161 | _name( name), |
twisti@3197 | 162 | _holder( holder), |
twisti@3197 | 163 | _intrinsic_id( vmIntrinsics::_none), |
twisti@3197 | 164 | _liveness( NULL), |
twisti@3197 | 165 | _can_be_statically_bound(false), |
twisti@3197 | 166 | _method_blocks( NULL), |
twisti@3197 | 167 | _method_data( NULL) |
twisti@2047 | 168 | #if defined(COMPILER2) || defined(SHARK) |
twisti@3197 | 169 | , |
twisti@3197 | 170 | _flow( NULL), |
minqi@4267 | 171 | _bcea( NULL), |
minqi@4267 | 172 | _instructions_size(-1) |
twisti@2047 | 173 | #endif // COMPILER2 || SHARK |
twisti@3197 | 174 | { |
twisti@3197 | 175 | // Usually holder and accessor are the same type but in some cases |
twisti@3197 | 176 | // the holder has the wrong class loader (e.g. invokedynamic call |
twisti@3197 | 177 | // sites) so we pass the accessor. |
twisti@3197 | 178 | _signature = new (CURRENT_ENV->arena()) ciSignature(accessor, constantPoolHandle(), signature); |
duke@435 | 179 | } |
duke@435 | 180 | |
duke@435 | 181 | |
duke@435 | 182 | // ------------------------------------------------------------------ |
duke@435 | 183 | // ciMethod::load_code |
duke@435 | 184 | // |
duke@435 | 185 | // Load the bytecodes and exception handler table for this method. |
duke@435 | 186 | void ciMethod::load_code() { |
duke@435 | 187 | VM_ENTRY_MARK; |
duke@435 | 188 | assert(is_loaded(), "only loaded methods have code"); |
duke@435 | 189 | |
coleenp@4037 | 190 | Method* me = get_Method(); |
duke@435 | 191 | Arena* arena = CURRENT_THREAD_ENV->arena(); |
duke@435 | 192 | |
duke@435 | 193 | // Load the bytecodes. |
duke@435 | 194 | _code = (address)arena->Amalloc(code_size()); |
duke@435 | 195 | memcpy(_code, me->code_base(), code_size()); |
duke@435 | 196 | |
duke@435 | 197 | // Revert any breakpoint bytecodes in ci's copy |
kvn@462 | 198 | if (me->number_of_breakpoints() > 0) { |
coleenp@4251 | 199 | BreakpointInfo* bp = me->method_holder()->breakpoints(); |
duke@435 | 200 | for (; bp != NULL; bp = bp->next()) { |
duke@435 | 201 | if (bp->match(me)) { |
duke@435 | 202 | code_at_put(bp->bci(), bp->orig_bytecode()); |
duke@435 | 203 | } |
duke@435 | 204 | } |
duke@435 | 205 | } |
duke@435 | 206 | |
duke@435 | 207 | // And load the exception table. |
jiangli@3917 | 208 | ExceptionTable exc_table(me); |
duke@435 | 209 | |
duke@435 | 210 | // Allocate one extra spot in our list of exceptions. This |
duke@435 | 211 | // last entry will be used to represent the possibility that |
duke@435 | 212 | // an exception escapes the method. See ciExceptionHandlerStream |
duke@435 | 213 | // for details. |
duke@435 | 214 | _exception_handlers = |
duke@435 | 215 | (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*) |
duke@435 | 216 | * (_handler_count + 1)); |
duke@435 | 217 | if (_handler_count > 0) { |
duke@435 | 218 | for (int i=0; i<_handler_count; i++) { |
duke@435 | 219 | _exception_handlers[i] = new (arena) ciExceptionHandler( |
duke@435 | 220 | holder(), |
jiangli@3917 | 221 | /* start */ exc_table.start_pc(i), |
jiangli@3917 | 222 | /* limit */ exc_table.end_pc(i), |
jiangli@3917 | 223 | /* goto pc */ exc_table.handler_pc(i), |
jiangli@3917 | 224 | /* cp index */ exc_table.catch_type_index(i)); |
duke@435 | 225 | } |
duke@435 | 226 | } |
duke@435 | 227 | |
duke@435 | 228 | // Put an entry at the end of our list to represent the possibility |
duke@435 | 229 | // of exceptional exit. |
duke@435 | 230 | _exception_handlers[_handler_count] = |
duke@435 | 231 | new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0); |
duke@435 | 232 | |
duke@435 | 233 | if (CIPrintMethodCodes) { |
duke@435 | 234 | print_codes(); |
duke@435 | 235 | } |
duke@435 | 236 | } |
duke@435 | 237 | |
duke@435 | 238 | |
duke@435 | 239 | // ------------------------------------------------------------------ |
duke@435 | 240 | // ciMethod::has_linenumber_table |
duke@435 | 241 | // |
duke@435 | 242 | // length unknown until decompression |
duke@435 | 243 | bool ciMethod::has_linenumber_table() const { |
duke@435 | 244 | check_is_loaded(); |
duke@435 | 245 | VM_ENTRY_MARK; |
coleenp@4037 | 246 | return get_Method()->has_linenumber_table(); |
duke@435 | 247 | } |
duke@435 | 248 | |
duke@435 | 249 | |
duke@435 | 250 | // ------------------------------------------------------------------ |
duke@435 | 251 | // ciMethod::compressed_linenumber_table |
duke@435 | 252 | u_char* ciMethod::compressed_linenumber_table() const { |
duke@435 | 253 | check_is_loaded(); |
duke@435 | 254 | VM_ENTRY_MARK; |
coleenp@4037 | 255 | return get_Method()->compressed_linenumber_table(); |
duke@435 | 256 | } |
duke@435 | 257 | |
duke@435 | 258 | |
duke@435 | 259 | // ------------------------------------------------------------------ |
duke@435 | 260 | // ciMethod::line_number_from_bci |
duke@435 | 261 | int ciMethod::line_number_from_bci(int bci) const { |
duke@435 | 262 | check_is_loaded(); |
duke@435 | 263 | VM_ENTRY_MARK; |
coleenp@4037 | 264 | return get_Method()->line_number_from_bci(bci); |
duke@435 | 265 | } |
duke@435 | 266 | |
duke@435 | 267 | |
duke@435 | 268 | // ------------------------------------------------------------------ |
duke@435 | 269 | // ciMethod::vtable_index |
duke@435 | 270 | // |
duke@435 | 271 | // Get the position of this method's entry in the vtable, if any. |
duke@435 | 272 | int ciMethod::vtable_index() { |
duke@435 | 273 | check_is_loaded(); |
duke@435 | 274 | assert(holder()->is_linked(), "must be linked"); |
duke@435 | 275 | VM_ENTRY_MARK; |
coleenp@4037 | 276 | return get_Method()->vtable_index(); |
duke@435 | 277 | } |
duke@435 | 278 | |
duke@435 | 279 | |
twisti@2047 | 280 | #ifdef SHARK |
twisti@2047 | 281 | // ------------------------------------------------------------------ |
twisti@2047 | 282 | // ciMethod::itable_index |
twisti@2047 | 283 | // |
twisti@2047 | 284 | // Get the position of this method's entry in the itable, if any. |
twisti@2047 | 285 | int ciMethod::itable_index() { |
twisti@2047 | 286 | check_is_loaded(); |
twisti@2047 | 287 | assert(holder()->is_linked(), "must be linked"); |
twisti@2047 | 288 | VM_ENTRY_MARK; |
coleenp@4037 | 289 | return klassItable::compute_itable_index(get_Method()); |
twisti@2047 | 290 | } |
twisti@2047 | 291 | #endif // SHARK |
twisti@2047 | 292 | |
twisti@2047 | 293 | |
duke@435 | 294 | // ------------------------------------------------------------------ |
duke@435 | 295 | // ciMethod::native_entry |
duke@435 | 296 | // |
duke@435 | 297 | // Get the address of this method's native code, if any. |
duke@435 | 298 | address ciMethod::native_entry() { |
duke@435 | 299 | check_is_loaded(); |
duke@435 | 300 | assert(flags().is_native(), "must be native method"); |
duke@435 | 301 | VM_ENTRY_MARK; |
coleenp@4037 | 302 | Method* method = get_Method(); |
duke@435 | 303 | address entry = method->native_function(); |
duke@435 | 304 | assert(entry != NULL, "must be valid entry point"); |
duke@435 | 305 | return entry; |
duke@435 | 306 | } |
duke@435 | 307 | |
duke@435 | 308 | |
duke@435 | 309 | // ------------------------------------------------------------------ |
duke@435 | 310 | // ciMethod::interpreter_entry |
duke@435 | 311 | // |
duke@435 | 312 | // Get the entry point for running this method in the interpreter. |
duke@435 | 313 | address ciMethod::interpreter_entry() { |
duke@435 | 314 | check_is_loaded(); |
duke@435 | 315 | VM_ENTRY_MARK; |
coleenp@4037 | 316 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 317 | return Interpreter::entry_for_method(mh); |
duke@435 | 318 | } |
duke@435 | 319 | |
duke@435 | 320 | |
duke@435 | 321 | // ------------------------------------------------------------------ |
duke@435 | 322 | // ciMethod::uses_balanced_monitors |
duke@435 | 323 | // |
duke@435 | 324 | // Does this method use monitors in a strict stack-disciplined manner? |
duke@435 | 325 | bool ciMethod::has_balanced_monitors() { |
duke@435 | 326 | check_is_loaded(); |
duke@435 | 327 | if (_balanced_monitors) return true; |
duke@435 | 328 | |
duke@435 | 329 | // Analyze the method to see if monitors are used properly. |
duke@435 | 330 | VM_ENTRY_MARK; |
coleenp@4037 | 331 | methodHandle method(THREAD, get_Method()); |
duke@435 | 332 | assert(method->has_monitor_bytecodes(), "should have checked this"); |
duke@435 | 333 | |
duke@435 | 334 | // Check to see if a previous compilation computed the |
duke@435 | 335 | // monitor-matching analysis. |
duke@435 | 336 | if (method->guaranteed_monitor_matching()) { |
duke@435 | 337 | _balanced_monitors = true; |
duke@435 | 338 | return true; |
duke@435 | 339 | } |
duke@435 | 340 | |
duke@435 | 341 | { |
duke@435 | 342 | EXCEPTION_MARK; |
duke@435 | 343 | ResourceMark rm(THREAD); |
duke@435 | 344 | GeneratePairingInfo gpi(method); |
duke@435 | 345 | gpi.compute_map(CATCH); |
duke@435 | 346 | if (!gpi.monitor_safe()) { |
duke@435 | 347 | return false; |
duke@435 | 348 | } |
duke@435 | 349 | method->set_guaranteed_monitor_matching(); |
duke@435 | 350 | _balanced_monitors = true; |
duke@435 | 351 | } |
duke@435 | 352 | return true; |
duke@435 | 353 | } |
duke@435 | 354 | |
duke@435 | 355 | |
duke@435 | 356 | // ------------------------------------------------------------------ |
duke@435 | 357 | // ciMethod::get_flow_analysis |
duke@435 | 358 | ciTypeFlow* ciMethod::get_flow_analysis() { |
twisti@2047 | 359 | #if defined(COMPILER2) || defined(SHARK) |
duke@435 | 360 | if (_flow == NULL) { |
duke@435 | 361 | ciEnv* env = CURRENT_ENV; |
duke@435 | 362 | _flow = new (env->arena()) ciTypeFlow(env, this); |
duke@435 | 363 | _flow->do_flow(); |
duke@435 | 364 | } |
duke@435 | 365 | return _flow; |
twisti@2047 | 366 | #else // COMPILER2 || SHARK |
duke@435 | 367 | ShouldNotReachHere(); |
duke@435 | 368 | return NULL; |
twisti@2047 | 369 | #endif // COMPILER2 || SHARK |
duke@435 | 370 | } |
duke@435 | 371 | |
duke@435 | 372 | |
duke@435 | 373 | // ------------------------------------------------------------------ |
duke@435 | 374 | // ciMethod::get_osr_flow_analysis |
duke@435 | 375 | ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) { |
twisti@2047 | 376 | #if defined(COMPILER2) || defined(SHARK) |
duke@435 | 377 | // OSR entry points are always place after a call bytecode of some sort |
duke@435 | 378 | assert(osr_bci >= 0, "must supply valid OSR entry point"); |
duke@435 | 379 | ciEnv* env = CURRENT_ENV; |
duke@435 | 380 | ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci); |
duke@435 | 381 | flow->do_flow(); |
duke@435 | 382 | return flow; |
twisti@2047 | 383 | #else // COMPILER2 || SHARK |
duke@435 | 384 | ShouldNotReachHere(); |
duke@435 | 385 | return NULL; |
twisti@2047 | 386 | #endif // COMPILER2 || SHARK |
duke@435 | 387 | } |
duke@435 | 388 | |
duke@435 | 389 | // ------------------------------------------------------------------ |
never@1426 | 390 | // ciMethod::raw_liveness_at_bci |
duke@435 | 391 | // |
duke@435 | 392 | // Which local variables are live at a specific bci? |
never@1426 | 393 | MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) { |
duke@435 | 394 | check_is_loaded(); |
duke@435 | 395 | if (_liveness == NULL) { |
duke@435 | 396 | // Create the liveness analyzer. |
duke@435 | 397 | Arena* arena = CURRENT_ENV->arena(); |
duke@435 | 398 | _liveness = new (arena) MethodLiveness(arena, this); |
duke@435 | 399 | _liveness->compute_liveness(); |
duke@435 | 400 | } |
never@1426 | 401 | return _liveness->get_liveness_at(bci); |
never@1426 | 402 | } |
never@1426 | 403 | |
never@1426 | 404 | // ------------------------------------------------------------------ |
never@1426 | 405 | // ciMethod::liveness_at_bci |
never@1426 | 406 | // |
never@1426 | 407 | // Which local variables are live at a specific bci? When debugging |
never@1426 | 408 | // will return true for all locals in some cases to improve debug |
never@1426 | 409 | // information. |
never@1426 | 410 | MethodLivenessResult ciMethod::liveness_at_bci(int bci) { |
never@1426 | 411 | MethodLivenessResult result = raw_liveness_at_bci(bci); |
kvn@1215 | 412 | if (CURRENT_ENV->jvmti_can_access_local_variables() || DeoptimizeALot || CompileTheWorld) { |
duke@435 | 413 | // Keep all locals live for the user's edification and amusement. |
duke@435 | 414 | result.at_put_range(0, result.size(), true); |
duke@435 | 415 | } |
duke@435 | 416 | return result; |
duke@435 | 417 | } |
duke@435 | 418 | |
duke@435 | 419 | // ciMethod::live_local_oops_at_bci |
duke@435 | 420 | // |
duke@435 | 421 | // find all the live oops in the locals array for a particular bci |
duke@435 | 422 | // Compute what the interpreter believes by using the interpreter |
duke@435 | 423 | // oopmap generator. This is used as a double check during osr to |
duke@435 | 424 | // guard against conservative result from MethodLiveness making us |
duke@435 | 425 | // think a dead oop is live. MethodLiveness is conservative in the |
duke@435 | 426 | // sense that it may consider locals to be live which cannot be live, |
duke@435 | 427 | // like in the case where a local could contain an oop or a primitive |
duke@435 | 428 | // along different paths. In that case the local must be dead when |
duke@435 | 429 | // those paths merge. Since the interpreter's viewpoint is used when |
duke@435 | 430 | // gc'ing an interpreter frame we need to use its viewpoint during |
duke@435 | 431 | // OSR when loading the locals. |
duke@435 | 432 | |
duke@435 | 433 | BitMap ciMethod::live_local_oops_at_bci(int bci) { |
duke@435 | 434 | VM_ENTRY_MARK; |
duke@435 | 435 | InterpreterOopMap mask; |
coleenp@4037 | 436 | OopMapCache::compute_one_oop_map(get_Method(), bci, &mask); |
duke@435 | 437 | int mask_size = max_locals(); |
duke@435 | 438 | BitMap result(mask_size); |
duke@435 | 439 | result.clear(); |
duke@435 | 440 | int i; |
duke@435 | 441 | for (i = 0; i < mask_size ; i++ ) { |
duke@435 | 442 | if (mask.is_oop(i)) result.set_bit(i); |
duke@435 | 443 | } |
duke@435 | 444 | return result; |
duke@435 | 445 | } |
duke@435 | 446 | |
duke@435 | 447 | |
duke@435 | 448 | #ifdef COMPILER1 |
duke@435 | 449 | // ------------------------------------------------------------------ |
duke@435 | 450 | // ciMethod::bci_block_start |
duke@435 | 451 | // |
duke@435 | 452 | // Marks all bcis where a new basic block starts |
duke@435 | 453 | const BitMap ciMethod::bci_block_start() { |
duke@435 | 454 | check_is_loaded(); |
duke@435 | 455 | if (_liveness == NULL) { |
duke@435 | 456 | // Create the liveness analyzer. |
duke@435 | 457 | Arena* arena = CURRENT_ENV->arena(); |
duke@435 | 458 | _liveness = new (arena) MethodLiveness(arena, this); |
duke@435 | 459 | _liveness->compute_liveness(); |
duke@435 | 460 | } |
duke@435 | 461 | |
duke@435 | 462 | return _liveness->get_bci_block_start(); |
duke@435 | 463 | } |
duke@435 | 464 | #endif // COMPILER1 |
duke@435 | 465 | |
duke@435 | 466 | |
duke@435 | 467 | // ------------------------------------------------------------------ |
duke@435 | 468 | // ciMethod::call_profile_at_bci |
duke@435 | 469 | // |
duke@435 | 470 | // Get the ciCallProfile for the invocation of this method. |
duke@435 | 471 | // Also reports receiver types for non-call type checks (if TypeProfileCasts). |
duke@435 | 472 | ciCallProfile ciMethod::call_profile_at_bci(int bci) { |
duke@435 | 473 | ResourceMark rm; |
duke@435 | 474 | ciCallProfile result; |
duke@435 | 475 | if (method_data() != NULL && method_data()->is_mature()) { |
duke@435 | 476 | ciProfileData* data = method_data()->bci_to_data(bci); |
duke@435 | 477 | if (data != NULL && data->is_CounterData()) { |
duke@435 | 478 | // Every profiled call site has a counter. |
duke@435 | 479 | int count = data->as_CounterData()->count(); |
duke@435 | 480 | |
duke@435 | 481 | if (!data->is_ReceiverTypeData()) { |
duke@435 | 482 | result._receiver_count[0] = 0; // that's a definite zero |
duke@435 | 483 | } else { // ReceiverTypeData is a subclass of CounterData |
duke@435 | 484 | ciReceiverTypeData* call = (ciReceiverTypeData*)data->as_ReceiverTypeData(); |
duke@435 | 485 | // In addition, virtual call sites have receiver type information |
duke@435 | 486 | int receivers_count_total = 0; |
duke@435 | 487 | int morphism = 0; |
iveresov@2138 | 488 | // Precompute morphism for the possible fixup |
duke@435 | 489 | for (uint i = 0; i < call->row_limit(); i++) { |
duke@435 | 490 | ciKlass* receiver = call->receiver(i); |
duke@435 | 491 | if (receiver == NULL) continue; |
iveresov@2138 | 492 | morphism++; |
iveresov@2138 | 493 | } |
iveresov@2138 | 494 | int epsilon = 0; |
iveresov@2138 | 495 | if (TieredCompilation && ProfileInterpreter) { |
iveresov@2138 | 496 | // Interpreter and C1 treat final and special invokes differently. |
iveresov@2138 | 497 | // C1 will record a type, whereas the interpreter will just |
iveresov@2138 | 498 | // increment the count. Detect this case. |
iveresov@2138 | 499 | if (morphism == 1 && count > 0) { |
iveresov@2138 | 500 | epsilon = count; |
iveresov@2138 | 501 | count = 0; |
iveresov@2138 | 502 | } |
iveresov@2138 | 503 | } |
iveresov@2138 | 504 | for (uint i = 0; i < call->row_limit(); i++) { |
iveresov@2138 | 505 | ciKlass* receiver = call->receiver(i); |
iveresov@2138 | 506 | if (receiver == NULL) continue; |
iveresov@2138 | 507 | int rcount = call->receiver_count(i) + epsilon; |
duke@435 | 508 | if (rcount == 0) rcount = 1; // Should be valid value |
duke@435 | 509 | receivers_count_total += rcount; |
duke@435 | 510 | // Add the receiver to result data. |
duke@435 | 511 | result.add_receiver(receiver, rcount); |
duke@435 | 512 | // If we extend profiling to record methods, |
duke@435 | 513 | // we will set result._method also. |
duke@435 | 514 | } |
duke@435 | 515 | // Determine call site's morphism. |
kvn@1641 | 516 | // The call site count is 0 with known morphism (onlt 1 or 2 receivers) |
kvn@1641 | 517 | // or < 0 in the case of a type check failured for checkcast, aastore, instanceof. |
kvn@1641 | 518 | // The call site count is > 0 in the case of a polymorphic virtual call. |
kvn@1641 | 519 | if (morphism > 0 && morphism == result._limit) { |
kvn@1641 | 520 | // The morphism <= MorphismLimit. |
kvn@1641 | 521 | if ((morphism < ciCallProfile::MorphismLimit) || |
kvn@1641 | 522 | (morphism == ciCallProfile::MorphismLimit && count == 0)) { |
kvn@1641 | 523 | #ifdef ASSERT |
kvn@1641 | 524 | if (count > 0) { |
kvn@1686 | 525 | this->print_short_name(tty); |
kvn@1686 | 526 | tty->print_cr(" @ bci:%d", bci); |
kvn@1641 | 527 | this->print_codes(); |
kvn@1641 | 528 | assert(false, "this call site should not be polymorphic"); |
kvn@1641 | 529 | } |
kvn@1641 | 530 | #endif |
duke@435 | 531 | result._morphism = morphism; |
duke@435 | 532 | } |
duke@435 | 533 | } |
duke@435 | 534 | // Make the count consistent if this is a call profile. If count is |
duke@435 | 535 | // zero or less, presume that this is a typecheck profile and |
duke@435 | 536 | // do nothing. Otherwise, increase count to be the sum of all |
duke@435 | 537 | // receiver's counts. |
kvn@1641 | 538 | if (count >= 0) { |
kvn@1641 | 539 | count += receivers_count_total; |
duke@435 | 540 | } |
duke@435 | 541 | } |
duke@435 | 542 | result._count = count; |
duke@435 | 543 | } |
duke@435 | 544 | } |
duke@435 | 545 | return result; |
duke@435 | 546 | } |
duke@435 | 547 | |
duke@435 | 548 | // ------------------------------------------------------------------ |
duke@435 | 549 | // Add new receiver and sort data by receiver's profile count. |
duke@435 | 550 | void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) { |
duke@435 | 551 | // Add new receiver and sort data by receiver's counts when we have space |
duke@435 | 552 | // for it otherwise replace the less called receiver (less called receiver |
duke@435 | 553 | // is placed to the last array element which is not used). |
duke@435 | 554 | // First array's element contains most called receiver. |
duke@435 | 555 | int i = _limit; |
duke@435 | 556 | for (; i > 0 && receiver_count > _receiver_count[i-1]; i--) { |
duke@435 | 557 | _receiver[i] = _receiver[i-1]; |
duke@435 | 558 | _receiver_count[i] = _receiver_count[i-1]; |
duke@435 | 559 | } |
duke@435 | 560 | _receiver[i] = receiver; |
duke@435 | 561 | _receiver_count[i] = receiver_count; |
duke@435 | 562 | if (_limit < MorphismLimit) _limit++; |
duke@435 | 563 | } |
duke@435 | 564 | |
duke@435 | 565 | // ------------------------------------------------------------------ |
duke@435 | 566 | // ciMethod::find_monomorphic_target |
duke@435 | 567 | // |
duke@435 | 568 | // Given a certain calling environment, find the monomorphic target |
duke@435 | 569 | // for the call. Return NULL if the call is not monomorphic in |
duke@435 | 570 | // its calling environment, or if there are only abstract methods. |
duke@435 | 571 | // The returned method is never abstract. |
duke@435 | 572 | // Note: If caller uses a non-null result, it must inform dependencies |
duke@435 | 573 | // via assert_unique_concrete_method or assert_leaf_type. |
duke@435 | 574 | ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, |
duke@435 | 575 | ciInstanceKlass* callee_holder, |
duke@435 | 576 | ciInstanceKlass* actual_recv) { |
duke@435 | 577 | check_is_loaded(); |
duke@435 | 578 | |
duke@435 | 579 | if (actual_recv->is_interface()) { |
duke@435 | 580 | // %%% We cannot trust interface types, yet. See bug 6312651. |
duke@435 | 581 | return NULL; |
duke@435 | 582 | } |
duke@435 | 583 | |
duke@435 | 584 | ciMethod* root_m = resolve_invoke(caller, actual_recv); |
duke@435 | 585 | if (root_m == NULL) { |
duke@435 | 586 | // Something went wrong looking up the actual receiver method. |
duke@435 | 587 | return NULL; |
duke@435 | 588 | } |
duke@435 | 589 | assert(!root_m->is_abstract(), "resolve_invoke promise"); |
duke@435 | 590 | |
duke@435 | 591 | // Make certain quick checks even if UseCHA is false. |
duke@435 | 592 | |
duke@435 | 593 | // Is it private or final? |
duke@435 | 594 | if (root_m->can_be_statically_bound()) { |
duke@435 | 595 | return root_m; |
duke@435 | 596 | } |
duke@435 | 597 | |
duke@435 | 598 | if (actual_recv->is_leaf_type() && actual_recv == root_m->holder()) { |
duke@435 | 599 | // Easy case. There is no other place to put a method, so don't bother |
duke@435 | 600 | // to go through the VM_ENTRY_MARK and all the rest. |
duke@435 | 601 | return root_m; |
duke@435 | 602 | } |
duke@435 | 603 | |
duke@435 | 604 | // Array methods (clone, hashCode, etc.) are always statically bound. |
duke@435 | 605 | // If we were to see an array type here, we'd return root_m. |
duke@435 | 606 | // However, this method processes only ciInstanceKlasses. (See 4962591.) |
duke@435 | 607 | // The inline_native_clone intrinsic narrows Object to T[] properly, |
duke@435 | 608 | // so there is no need to do the same job here. |
duke@435 | 609 | |
duke@435 | 610 | if (!UseCHA) return NULL; |
duke@435 | 611 | |
duke@435 | 612 | VM_ENTRY_MARK; |
duke@435 | 613 | |
duke@435 | 614 | methodHandle target; |
duke@435 | 615 | { |
duke@435 | 616 | MutexLocker locker(Compile_lock); |
coleenp@4037 | 617 | Klass* context = actual_recv->get_Klass(); |
duke@435 | 618 | target = Dependencies::find_unique_concrete_method(context, |
coleenp@4037 | 619 | root_m->get_Method()); |
duke@435 | 620 | // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods. |
duke@435 | 621 | } |
duke@435 | 622 | |
duke@435 | 623 | #ifndef PRODUCT |
coleenp@4037 | 624 | if (TraceDependencies && target() != NULL && target() != root_m->get_Method()) { |
duke@435 | 625 | tty->print("found a non-root unique target method"); |
coleenp@4037 | 626 | tty->print_cr(" context = %s", InstanceKlass::cast(actual_recv->get_Klass())->external_name()); |
duke@435 | 627 | tty->print(" method = "); |
duke@435 | 628 | target->print_short_name(tty); |
duke@435 | 629 | tty->cr(); |
duke@435 | 630 | } |
duke@435 | 631 | #endif //PRODUCT |
duke@435 | 632 | |
duke@435 | 633 | if (target() == NULL) { |
duke@435 | 634 | return NULL; |
duke@435 | 635 | } |
coleenp@4037 | 636 | if (target() == root_m->get_Method()) { |
duke@435 | 637 | return root_m; |
duke@435 | 638 | } |
duke@435 | 639 | if (!root_m->is_public() && |
duke@435 | 640 | !root_m->is_protected()) { |
duke@435 | 641 | // If we are going to reason about inheritance, it's easiest |
duke@435 | 642 | // if the method in question is public, protected, or private. |
duke@435 | 643 | // If the answer is not root_m, it is conservatively correct |
duke@435 | 644 | // to return NULL, even if the CHA encountered irrelevant |
duke@435 | 645 | // methods in other packages. |
duke@435 | 646 | // %%% TO DO: Work out logic for package-private methods |
duke@435 | 647 | // with the same name but different vtable indexes. |
duke@435 | 648 | return NULL; |
duke@435 | 649 | } |
coleenp@4037 | 650 | return CURRENT_THREAD_ENV->get_method(target()); |
duke@435 | 651 | } |
duke@435 | 652 | |
duke@435 | 653 | // ------------------------------------------------------------------ |
duke@435 | 654 | // ciMethod::resolve_invoke |
duke@435 | 655 | // |
duke@435 | 656 | // Given a known receiver klass, find the target for the call. |
duke@435 | 657 | // Return NULL if the call has no target or the target is abstract. |
duke@435 | 658 | ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver) { |
duke@435 | 659 | check_is_loaded(); |
duke@435 | 660 | VM_ENTRY_MARK; |
duke@435 | 661 | |
coleenp@4037 | 662 | KlassHandle caller_klass (THREAD, caller->get_Klass()); |
coleenp@4037 | 663 | KlassHandle h_recv (THREAD, exact_receiver->get_Klass()); |
coleenp@4037 | 664 | KlassHandle h_resolved (THREAD, holder()->get_Klass()); |
coleenp@2497 | 665 | Symbol* h_name = name()->get_symbol(); |
coleenp@2497 | 666 | Symbol* h_signature = signature()->get_symbol(); |
duke@435 | 667 | |
duke@435 | 668 | methodHandle m; |
duke@435 | 669 | // Only do exact lookup if receiver klass has been linked. Otherwise, |
duke@435 | 670 | // the vtable has not been setup, and the LinkResolver will fail. |
coleenp@4037 | 671 | if (h_recv->oop_is_array() |
duke@435 | 672 | || |
coleenp@4037 | 673 | InstanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) { |
duke@435 | 674 | if (holder()->is_interface()) { |
duke@435 | 675 | m = LinkResolver::resolve_interface_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass); |
duke@435 | 676 | } else { |
duke@435 | 677 | m = LinkResolver::resolve_virtual_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass); |
duke@435 | 678 | } |
duke@435 | 679 | } |
duke@435 | 680 | |
duke@435 | 681 | if (m.is_null()) { |
duke@435 | 682 | // Return NULL only if there was a problem with lookup (uninitialized class, etc.) |
duke@435 | 683 | return NULL; |
duke@435 | 684 | } |
duke@435 | 685 | |
duke@435 | 686 | ciMethod* result = this; |
coleenp@4037 | 687 | if (m() != get_Method()) { |
coleenp@4037 | 688 | result = CURRENT_THREAD_ENV->get_method(m()); |
duke@435 | 689 | } |
duke@435 | 690 | |
duke@435 | 691 | // Don't return abstract methods because they aren't |
duke@435 | 692 | // optimizable or interesting. |
duke@435 | 693 | if (result->is_abstract()) { |
duke@435 | 694 | return NULL; |
duke@435 | 695 | } else { |
duke@435 | 696 | return result; |
duke@435 | 697 | } |
duke@435 | 698 | } |
duke@435 | 699 | |
duke@435 | 700 | // ------------------------------------------------------------------ |
duke@435 | 701 | // ciMethod::resolve_vtable_index |
duke@435 | 702 | // |
duke@435 | 703 | // Given a known receiver klass, find the vtable index for the call. |
coleenp@4037 | 704 | // Return Method::invalid_vtable_index if the vtable_index is unknown. |
duke@435 | 705 | int ciMethod::resolve_vtable_index(ciKlass* caller, ciKlass* receiver) { |
duke@435 | 706 | check_is_loaded(); |
duke@435 | 707 | |
coleenp@4037 | 708 | int vtable_index = Method::invalid_vtable_index; |
duke@435 | 709 | // Only do lookup if receiver klass has been linked. Otherwise, |
duke@435 | 710 | // the vtable has not been setup, and the LinkResolver will fail. |
duke@435 | 711 | if (!receiver->is_interface() |
duke@435 | 712 | && (!receiver->is_instance_klass() || |
duke@435 | 713 | receiver->as_instance_klass()->is_linked())) { |
duke@435 | 714 | VM_ENTRY_MARK; |
duke@435 | 715 | |
coleenp@4037 | 716 | KlassHandle caller_klass (THREAD, caller->get_Klass()); |
coleenp@4037 | 717 | KlassHandle h_recv (THREAD, receiver->get_Klass()); |
coleenp@2497 | 718 | Symbol* h_name = name()->get_symbol(); |
coleenp@2497 | 719 | Symbol* h_signature = signature()->get_symbol(); |
duke@435 | 720 | |
duke@435 | 721 | vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, h_recv, h_name, h_signature, caller_klass); |
coleenp@4037 | 722 | if (vtable_index == Method::nonvirtual_vtable_index) { |
duke@435 | 723 | // A statically bound method. Return "no such index". |
coleenp@4037 | 724 | vtable_index = Method::invalid_vtable_index; |
duke@435 | 725 | } |
duke@435 | 726 | } |
duke@435 | 727 | |
duke@435 | 728 | return vtable_index; |
duke@435 | 729 | } |
duke@435 | 730 | |
duke@435 | 731 | // ------------------------------------------------------------------ |
duke@435 | 732 | // ciMethod::interpreter_call_site_count |
duke@435 | 733 | int ciMethod::interpreter_call_site_count(int bci) { |
duke@435 | 734 | if (method_data() != NULL) { |
duke@435 | 735 | ResourceMark rm; |
duke@435 | 736 | ciProfileData* data = method_data()->bci_to_data(bci); |
duke@435 | 737 | if (data != NULL && data->is_CounterData()) { |
duke@435 | 738 | return scale_count(data->as_CounterData()->count()); |
duke@435 | 739 | } |
duke@435 | 740 | } |
duke@435 | 741 | return -1; // unknown |
duke@435 | 742 | } |
duke@435 | 743 | |
duke@435 | 744 | // ------------------------------------------------------------------ |
twisti@4313 | 745 | // ciMethod::get_field_at_bci |
twisti@4313 | 746 | ciField* ciMethod::get_field_at_bci(int bci, bool &will_link) { |
twisti@4313 | 747 | ciBytecodeStream iter(this); |
twisti@4313 | 748 | iter.reset_to_bci(bci); |
twisti@4313 | 749 | iter.next(); |
twisti@4313 | 750 | return iter.get_field(will_link); |
twisti@4313 | 751 | } |
twisti@4313 | 752 | |
twisti@4313 | 753 | // ------------------------------------------------------------------ |
twisti@4313 | 754 | // ciMethod::get_method_at_bci |
twisti@4313 | 755 | ciMethod* ciMethod::get_method_at_bci(int bci, bool &will_link, ciSignature* *declared_signature) { |
twisti@4313 | 756 | ciBytecodeStream iter(this); |
twisti@4313 | 757 | iter.reset_to_bci(bci); |
twisti@4313 | 758 | iter.next(); |
twisti@4313 | 759 | return iter.get_method(will_link, declared_signature); |
twisti@4313 | 760 | } |
twisti@4313 | 761 | |
twisti@4313 | 762 | // ------------------------------------------------------------------ |
duke@435 | 763 | // Adjust a CounterData count to be commensurate with |
duke@435 | 764 | // interpreter_invocation_count. If the MDO exists for |
duke@435 | 765 | // only 25% of the time the method exists, then the |
duke@435 | 766 | // counts in the MDO should be scaled by 4X, so that |
duke@435 | 767 | // they can be usefully and stably compared against the |
duke@435 | 768 | // invocation counts in methods. |
duke@435 | 769 | int ciMethod::scale_count(int count, float prof_factor) { |
duke@435 | 770 | if (count > 0 && method_data() != NULL) { |
iveresov@2138 | 771 | int counter_life; |
duke@435 | 772 | int method_life = interpreter_invocation_count(); |
iveresov@2138 | 773 | if (TieredCompilation) { |
iveresov@2138 | 774 | // In tiered the MDO's life is measured directly, so just use the snapshotted counters |
iveresov@2138 | 775 | counter_life = MAX2(method_data()->invocation_count(), method_data()->backedge_count()); |
iveresov@2138 | 776 | } else { |
iveresov@2138 | 777 | int current_mileage = method_data()->current_mileage(); |
iveresov@2138 | 778 | int creation_mileage = method_data()->creation_mileage(); |
iveresov@2138 | 779 | counter_life = current_mileage - creation_mileage; |
iveresov@2138 | 780 | } |
iveresov@2138 | 781 | |
duke@435 | 782 | // counter_life due to backedge_counter could be > method_life |
duke@435 | 783 | if (counter_life > method_life) |
duke@435 | 784 | counter_life = method_life; |
duke@435 | 785 | if (0 < counter_life && counter_life <= method_life) { |
duke@435 | 786 | count = (int)((double)count * prof_factor * method_life / counter_life + 0.5); |
duke@435 | 787 | count = (count > 0) ? count : 1; |
duke@435 | 788 | } |
duke@435 | 789 | } |
duke@435 | 790 | return count; |
duke@435 | 791 | } |
duke@435 | 792 | |
twisti@4866 | 793 | |
twisti@4866 | 794 | // ------------------------------------------------------------------ |
twisti@4866 | 795 | // ciMethod::is_special_get_caller_class_method |
twisti@4866 | 796 | // |
twisti@4866 | 797 | bool ciMethod::is_ignored_by_security_stack_walk() const { |
twisti@4866 | 798 | check_is_loaded(); |
twisti@4866 | 799 | VM_ENTRY_MARK; |
twisti@4866 | 800 | return get_Method()->is_ignored_by_security_stack_walk(); |
twisti@4866 | 801 | } |
twisti@4866 | 802 | |
twisti@4866 | 803 | |
duke@435 | 804 | // ------------------------------------------------------------------ |
jrose@1145 | 805 | // invokedynamic support |
twisti@1919 | 806 | |
twisti@1919 | 807 | // ------------------------------------------------------------------ |
twisti@3969 | 808 | // ciMethod::is_method_handle_intrinsic |
jrose@1145 | 809 | // |
twisti@3969 | 810 | // Return true if the method is an instance of the JVM-generated |
twisti@3969 | 811 | // signature-polymorphic MethodHandle methods, _invokeBasic, _linkToVirtual, etc. |
twisti@3969 | 812 | bool ciMethod::is_method_handle_intrinsic() const { |
twisti@3969 | 813 | vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded |
twisti@3969 | 814 | return (MethodHandles::is_signature_polymorphic(iid) && |
twisti@3969 | 815 | MethodHandles::is_signature_polymorphic_intrinsic(iid)); |
jrose@1145 | 816 | } |
jrose@1145 | 817 | |
twisti@1919 | 818 | // ------------------------------------------------------------------ |
twisti@3969 | 819 | // ciMethod::is_compiled_lambda_form |
twisti@1919 | 820 | // |
twisti@1919 | 821 | // Return true if the method is a generated MethodHandle adapter. |
twisti@3969 | 822 | // These are built by Java code. |
twisti@3969 | 823 | bool ciMethod::is_compiled_lambda_form() const { |
twisti@3969 | 824 | vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded |
twisti@3969 | 825 | return iid == vmIntrinsics::_compiledLambdaForm; |
twisti@1587 | 826 | } |
twisti@1587 | 827 | |
twisti@3969 | 828 | // ------------------------------------------------------------------ |
twisti@3969 | 829 | // ciMethod::has_member_arg |
twisti@3969 | 830 | // |
twisti@3969 | 831 | // Return true if the method is a linker intrinsic like _linkToVirtual. |
twisti@3969 | 832 | // These are built by the JVM. |
twisti@3969 | 833 | bool ciMethod::has_member_arg() const { |
twisti@3969 | 834 | vmIntrinsics::ID iid = _intrinsic_id; // do not check if loaded |
twisti@3969 | 835 | return (MethodHandles::is_signature_polymorphic(iid) && |
twisti@3969 | 836 | MethodHandles::has_member_arg(iid)); |
jrose@1145 | 837 | } |
jrose@1145 | 838 | |
jrose@1145 | 839 | // ------------------------------------------------------------------ |
iveresov@2349 | 840 | // ciMethod::ensure_method_data |
duke@435 | 841 | // |
coleenp@4037 | 842 | // Generate new MethodData* objects at compile time. |
iveresov@2349 | 843 | // Return true if allocation was successful or no MDO is required. |
iveresov@2349 | 844 | bool ciMethod::ensure_method_data(methodHandle h_m) { |
duke@435 | 845 | EXCEPTION_CONTEXT; |
iveresov@2349 | 846 | if (is_native() || is_abstract() || h_m()->is_accessor()) return true; |
duke@435 | 847 | if (h_m()->method_data() == NULL) { |
coleenp@4037 | 848 | Method::build_interpreter_method_data(h_m, THREAD); |
duke@435 | 849 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 850 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 851 | } |
duke@435 | 852 | } |
duke@435 | 853 | if (h_m()->method_data() != NULL) { |
coleenp@4037 | 854 | _method_data = CURRENT_ENV->get_method_data(h_m()->method_data()); |
duke@435 | 855 | _method_data->load_data(); |
iveresov@2349 | 856 | return true; |
duke@435 | 857 | } else { |
duke@435 | 858 | _method_data = CURRENT_ENV->get_empty_methodData(); |
iveresov@2349 | 859 | return false; |
duke@435 | 860 | } |
duke@435 | 861 | } |
duke@435 | 862 | |
duke@435 | 863 | // public, retroactive version |
iveresov@2349 | 864 | bool ciMethod::ensure_method_data() { |
iveresov@2349 | 865 | bool result = true; |
duke@435 | 866 | if (_method_data == NULL || _method_data->is_empty()) { |
duke@435 | 867 | GUARDED_VM_ENTRY({ |
coleenp@4037 | 868 | result = ensure_method_data(get_Method()); |
duke@435 | 869 | }); |
duke@435 | 870 | } |
iveresov@2349 | 871 | return result; |
duke@435 | 872 | } |
duke@435 | 873 | |
duke@435 | 874 | |
duke@435 | 875 | // ------------------------------------------------------------------ |
duke@435 | 876 | // ciMethod::method_data |
duke@435 | 877 | // |
duke@435 | 878 | ciMethodData* ciMethod::method_data() { |
duke@435 | 879 | if (_method_data != NULL) { |
duke@435 | 880 | return _method_data; |
duke@435 | 881 | } |
duke@435 | 882 | VM_ENTRY_MARK; |
duke@435 | 883 | ciEnv* env = CURRENT_ENV; |
duke@435 | 884 | Thread* my_thread = JavaThread::current(); |
coleenp@4037 | 885 | methodHandle h_m(my_thread, get_Method()); |
duke@435 | 886 | |
duke@435 | 887 | if (h_m()->method_data() != NULL) { |
coleenp@4037 | 888 | _method_data = CURRENT_ENV->get_method_data(h_m()->method_data()); |
duke@435 | 889 | _method_data->load_data(); |
duke@435 | 890 | } else { |
duke@435 | 891 | _method_data = CURRENT_ENV->get_empty_methodData(); |
duke@435 | 892 | } |
duke@435 | 893 | return _method_data; |
duke@435 | 894 | |
duke@435 | 895 | } |
duke@435 | 896 | |
iveresov@2349 | 897 | // ------------------------------------------------------------------ |
iveresov@2349 | 898 | // ciMethod::method_data_or_null |
iveresov@2349 | 899 | // Returns a pointer to ciMethodData if MDO exists on the VM side, |
iveresov@2349 | 900 | // NULL otherwise. |
iveresov@2349 | 901 | ciMethodData* ciMethod::method_data_or_null() { |
iveresov@2349 | 902 | ciMethodData *md = method_data(); |
iveresov@2349 | 903 | if (md->is_empty()) return NULL; |
iveresov@2349 | 904 | return md; |
iveresov@2349 | 905 | } |
duke@435 | 906 | |
duke@435 | 907 | // ------------------------------------------------------------------ |
jiangli@4936 | 908 | // ciMethod::ensure_method_counters |
jiangli@4936 | 909 | // |
jiangli@4936 | 910 | address ciMethod::ensure_method_counters() { |
jiangli@4936 | 911 | check_is_loaded(); |
jiangli@4936 | 912 | VM_ENTRY_MARK; |
jiangli@4936 | 913 | methodHandle mh(THREAD, get_Method()); |
jiangli@4936 | 914 | MethodCounters *counter = mh->method_counters(); |
jiangli@4936 | 915 | if (counter == NULL) { |
jiangli@4936 | 916 | counter = Method::build_method_counters(mh(), CHECK_AND_CLEAR_NULL); |
jiangli@4936 | 917 | } |
jiangli@4936 | 918 | return (address)counter; |
jiangli@4936 | 919 | } |
jiangli@4936 | 920 | |
jiangli@4936 | 921 | // ------------------------------------------------------------------ |
duke@435 | 922 | // ciMethod::should_exclude |
duke@435 | 923 | // |
duke@435 | 924 | // Should this method be excluded from compilation? |
duke@435 | 925 | bool ciMethod::should_exclude() { |
duke@435 | 926 | check_is_loaded(); |
duke@435 | 927 | VM_ENTRY_MARK; |
coleenp@4037 | 928 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 929 | bool ignore; |
duke@435 | 930 | return CompilerOracle::should_exclude(mh, ignore); |
duke@435 | 931 | } |
duke@435 | 932 | |
duke@435 | 933 | // ------------------------------------------------------------------ |
duke@435 | 934 | // ciMethod::should_inline |
duke@435 | 935 | // |
duke@435 | 936 | // Should this method be inlined during compilation? |
duke@435 | 937 | bool ciMethod::should_inline() { |
duke@435 | 938 | check_is_loaded(); |
duke@435 | 939 | VM_ENTRY_MARK; |
coleenp@4037 | 940 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 941 | return CompilerOracle::should_inline(mh); |
duke@435 | 942 | } |
duke@435 | 943 | |
duke@435 | 944 | // ------------------------------------------------------------------ |
duke@435 | 945 | // ciMethod::should_not_inline |
duke@435 | 946 | // |
duke@435 | 947 | // Should this method be disallowed from inlining during compilation? |
duke@435 | 948 | bool ciMethod::should_not_inline() { |
duke@435 | 949 | check_is_loaded(); |
duke@435 | 950 | VM_ENTRY_MARK; |
coleenp@4037 | 951 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 952 | return CompilerOracle::should_not_inline(mh); |
duke@435 | 953 | } |
duke@435 | 954 | |
duke@435 | 955 | // ------------------------------------------------------------------ |
duke@435 | 956 | // ciMethod::should_print_assembly |
duke@435 | 957 | // |
duke@435 | 958 | // Should the compiler print the generated code for this method? |
duke@435 | 959 | bool ciMethod::should_print_assembly() { |
duke@435 | 960 | check_is_loaded(); |
duke@435 | 961 | VM_ENTRY_MARK; |
coleenp@4037 | 962 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 963 | return CompilerOracle::should_print(mh); |
duke@435 | 964 | } |
duke@435 | 965 | |
duke@435 | 966 | // ------------------------------------------------------------------ |
duke@435 | 967 | // ciMethod::break_at_execute |
duke@435 | 968 | // |
duke@435 | 969 | // Should the compiler insert a breakpoint into the generated code |
duke@435 | 970 | // method? |
duke@435 | 971 | bool ciMethod::break_at_execute() { |
duke@435 | 972 | check_is_loaded(); |
duke@435 | 973 | VM_ENTRY_MARK; |
coleenp@4037 | 974 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 975 | return CompilerOracle::should_break_at(mh); |
duke@435 | 976 | } |
duke@435 | 977 | |
duke@435 | 978 | // ------------------------------------------------------------------ |
duke@435 | 979 | // ciMethod::has_option |
duke@435 | 980 | // |
duke@435 | 981 | bool ciMethod::has_option(const char* option) { |
duke@435 | 982 | check_is_loaded(); |
duke@435 | 983 | VM_ENTRY_MARK; |
coleenp@4037 | 984 | methodHandle mh(THREAD, get_Method()); |
duke@435 | 985 | return CompilerOracle::has_option_string(mh, option); |
duke@435 | 986 | } |
duke@435 | 987 | |
duke@435 | 988 | // ------------------------------------------------------------------ |
duke@435 | 989 | // ciMethod::can_be_compiled |
duke@435 | 990 | // |
duke@435 | 991 | // Have previous compilations of this method succeeded? |
duke@435 | 992 | bool ciMethod::can_be_compiled() { |
duke@435 | 993 | check_is_loaded(); |
iveresov@2138 | 994 | ciEnv* env = CURRENT_ENV; |
iveresov@2138 | 995 | if (is_c1_compile(env->comp_level())) { |
iveresov@2138 | 996 | return _is_c1_compilable; |
iveresov@2138 | 997 | } |
iveresov@2138 | 998 | return _is_c2_compilable; |
duke@435 | 999 | } |
duke@435 | 1000 | |
duke@435 | 1001 | // ------------------------------------------------------------------ |
duke@435 | 1002 | // ciMethod::set_not_compilable |
duke@435 | 1003 | // |
duke@435 | 1004 | // Tell the VM that this method cannot be compiled at all. |
vlivanov@4539 | 1005 | void ciMethod::set_not_compilable(const char* reason) { |
duke@435 | 1006 | check_is_loaded(); |
duke@435 | 1007 | VM_ENTRY_MARK; |
iveresov@2138 | 1008 | ciEnv* env = CURRENT_ENV; |
iveresov@2138 | 1009 | if (is_c1_compile(env->comp_level())) { |
iveresov@2138 | 1010 | _is_c1_compilable = false; |
iveresov@2138 | 1011 | } else { |
iveresov@2138 | 1012 | _is_c2_compilable = false; |
iveresov@2138 | 1013 | } |
vlivanov@4539 | 1014 | get_Method()->set_not_compilable(env->comp_level(), true, reason); |
duke@435 | 1015 | } |
duke@435 | 1016 | |
duke@435 | 1017 | // ------------------------------------------------------------------ |
duke@435 | 1018 | // ciMethod::can_be_osr_compiled |
duke@435 | 1019 | // |
duke@435 | 1020 | // Have previous compilations of this method succeeded? |
duke@435 | 1021 | // |
duke@435 | 1022 | // Implementation note: the VM does not currently keep track |
duke@435 | 1023 | // of failed OSR compilations per bci. The entry_bci parameter |
duke@435 | 1024 | // is currently unused. |
duke@435 | 1025 | bool ciMethod::can_be_osr_compiled(int entry_bci) { |
duke@435 | 1026 | check_is_loaded(); |
duke@435 | 1027 | VM_ENTRY_MARK; |
iveresov@2138 | 1028 | ciEnv* env = CURRENT_ENV; |
coleenp@4037 | 1029 | return !get_Method()->is_not_osr_compilable(env->comp_level()); |
duke@435 | 1030 | } |
duke@435 | 1031 | |
duke@435 | 1032 | // ------------------------------------------------------------------ |
duke@435 | 1033 | // ciMethod::has_compiled_code |
duke@435 | 1034 | bool ciMethod::has_compiled_code() { |
minqi@4267 | 1035 | return instructions_size() > 0; |
duke@435 | 1036 | } |
duke@435 | 1037 | |
iveresov@2138 | 1038 | int ciMethod::comp_level() { |
iveresov@2138 | 1039 | check_is_loaded(); |
iveresov@2138 | 1040 | VM_ENTRY_MARK; |
coleenp@4037 | 1041 | nmethod* nm = get_Method()->code(); |
iveresov@2138 | 1042 | if (nm != NULL) return nm->comp_level(); |
iveresov@2138 | 1043 | return 0; |
iveresov@2138 | 1044 | } |
iveresov@2138 | 1045 | |
iveresov@2988 | 1046 | int ciMethod::highest_osr_comp_level() { |
iveresov@2988 | 1047 | check_is_loaded(); |
iveresov@2988 | 1048 | VM_ENTRY_MARK; |
coleenp@4037 | 1049 | return get_Method()->highest_osr_comp_level(); |
iveresov@2988 | 1050 | } |
iveresov@2988 | 1051 | |
duke@435 | 1052 | // ------------------------------------------------------------------ |
twisti@3097 | 1053 | // ciMethod::code_size_for_inlining |
twisti@3097 | 1054 | // |
twisti@3969 | 1055 | // Code size for inlining decisions. This method returns a code |
twisti@3969 | 1056 | // size of 1 for methods which has the ForceInline annotation. |
twisti@3097 | 1057 | int ciMethod::code_size_for_inlining() { |
twisti@3097 | 1058 | check_is_loaded(); |
coleenp@4037 | 1059 | if (get_Method()->force_inline()) { |
twisti@3969 | 1060 | return 1; |
twisti@3097 | 1061 | } |
twisti@3097 | 1062 | return code_size(); |
twisti@3097 | 1063 | } |
twisti@3097 | 1064 | |
twisti@3097 | 1065 | // ------------------------------------------------------------------ |
duke@435 | 1066 | // ciMethod::instructions_size |
twisti@2103 | 1067 | // |
twisti@2103 | 1068 | // This is a rough metric for "fat" methods, compared before inlining |
twisti@2103 | 1069 | // with InlineSmallCode. The CodeBlob::code_size accessor includes |
twisti@2103 | 1070 | // junk like exception handler, stubs, and constant table, which are |
twisti@2103 | 1071 | // not highly relevant to an inlined method. So we use the more |
twisti@2103 | 1072 | // specific accessor nmethod::insts_size. |
minqi@4267 | 1073 | int ciMethod::instructions_size() { |
minqi@4267 | 1074 | if (_instructions_size == -1) { |
minqi@4267 | 1075 | GUARDED_VM_ENTRY( |
minqi@4267 | 1076 | nmethod* code = get_Method()->code(); |
minqi@4267 | 1077 | if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) { |
minqi@4267 | 1078 | _instructions_size = code->insts_end() - code->verified_entry_point(); |
minqi@4267 | 1079 | } else { |
minqi@4267 | 1080 | _instructions_size = 0; |
minqi@4267 | 1081 | } |
minqi@4267 | 1082 | ); |
minqi@4267 | 1083 | } |
minqi@4267 | 1084 | return _instructions_size; |
duke@435 | 1085 | } |
duke@435 | 1086 | |
duke@435 | 1087 | // ------------------------------------------------------------------ |
duke@435 | 1088 | // ciMethod::log_nmethod_identity |
duke@435 | 1089 | void ciMethod::log_nmethod_identity(xmlStream* log) { |
duke@435 | 1090 | GUARDED_VM_ENTRY( |
coleenp@4037 | 1091 | nmethod* code = get_Method()->code(); |
duke@435 | 1092 | if (code != NULL) { |
duke@435 | 1093 | code->log_identity(log); |
duke@435 | 1094 | } |
duke@435 | 1095 | ) |
duke@435 | 1096 | } |
duke@435 | 1097 | |
duke@435 | 1098 | // ------------------------------------------------------------------ |
duke@435 | 1099 | // ciMethod::is_not_reached |
duke@435 | 1100 | bool ciMethod::is_not_reached(int bci) { |
duke@435 | 1101 | check_is_loaded(); |
duke@435 | 1102 | VM_ENTRY_MARK; |
duke@435 | 1103 | return Interpreter::is_not_reached( |
coleenp@4037 | 1104 | methodHandle(THREAD, get_Method()), bci); |
duke@435 | 1105 | } |
duke@435 | 1106 | |
duke@435 | 1107 | // ------------------------------------------------------------------ |
duke@435 | 1108 | // ciMethod::was_never_executed |
duke@435 | 1109 | bool ciMethod::was_executed_more_than(int times) { |
duke@435 | 1110 | VM_ENTRY_MARK; |
coleenp@4037 | 1111 | return get_Method()->was_executed_more_than(times); |
duke@435 | 1112 | } |
duke@435 | 1113 | |
duke@435 | 1114 | // ------------------------------------------------------------------ |
duke@435 | 1115 | // ciMethod::has_unloaded_classes_in_signature |
duke@435 | 1116 | bool ciMethod::has_unloaded_classes_in_signature() { |
duke@435 | 1117 | VM_ENTRY_MARK; |
duke@435 | 1118 | { |
duke@435 | 1119 | EXCEPTION_MARK; |
coleenp@4037 | 1120 | methodHandle m(THREAD, get_Method()); |
coleenp@4037 | 1121 | bool has_unloaded = Method::has_unloaded_classes_in_signature(m, (JavaThread *)THREAD); |
duke@435 | 1122 | if( HAS_PENDING_EXCEPTION ) { |
duke@435 | 1123 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 1124 | return true; // Declare that we may have unloaded classes |
duke@435 | 1125 | } |
duke@435 | 1126 | return has_unloaded; |
duke@435 | 1127 | } |
duke@435 | 1128 | } |
duke@435 | 1129 | |
duke@435 | 1130 | // ------------------------------------------------------------------ |
duke@435 | 1131 | // ciMethod::is_klass_loaded |
duke@435 | 1132 | bool ciMethod::is_klass_loaded(int refinfo_index, bool must_be_resolved) const { |
duke@435 | 1133 | VM_ENTRY_MARK; |
coleenp@4037 | 1134 | return get_Method()->is_klass_loaded(refinfo_index, must_be_resolved); |
duke@435 | 1135 | } |
duke@435 | 1136 | |
duke@435 | 1137 | // ------------------------------------------------------------------ |
duke@435 | 1138 | // ciMethod::check_call |
duke@435 | 1139 | bool ciMethod::check_call(int refinfo_index, bool is_static) const { |
duke@435 | 1140 | VM_ENTRY_MARK; |
duke@435 | 1141 | { |
duke@435 | 1142 | EXCEPTION_MARK; |
duke@435 | 1143 | HandleMark hm(THREAD); |
coleenp@4037 | 1144 | constantPoolHandle pool (THREAD, get_Method()->constants()); |
duke@435 | 1145 | methodHandle spec_method; |
duke@435 | 1146 | KlassHandle spec_klass; |
twisti@3969 | 1147 | Bytecodes::Code code = (is_static ? Bytecodes::_invokestatic : Bytecodes::_invokevirtual); |
twisti@3969 | 1148 | LinkResolver::resolve_method_statically(spec_method, spec_klass, code, pool, refinfo_index, THREAD); |
duke@435 | 1149 | if (HAS_PENDING_EXCEPTION) { |
duke@435 | 1150 | CLEAR_PENDING_EXCEPTION; |
duke@435 | 1151 | return false; |
duke@435 | 1152 | } else { |
duke@435 | 1153 | return (spec_method->is_static() == is_static); |
duke@435 | 1154 | } |
duke@435 | 1155 | } |
duke@435 | 1156 | return false; |
duke@435 | 1157 | } |
duke@435 | 1158 | |
duke@435 | 1159 | // ------------------------------------------------------------------ |
duke@435 | 1160 | // ciMethod::print_codes |
duke@435 | 1161 | // |
duke@435 | 1162 | // Print the bytecodes for this method. |
duke@435 | 1163 | void ciMethod::print_codes_on(outputStream* st) { |
duke@435 | 1164 | check_is_loaded(); |
coleenp@4037 | 1165 | GUARDED_VM_ENTRY(get_Method()->print_codes_on(st);) |
duke@435 | 1166 | } |
duke@435 | 1167 | |
duke@435 | 1168 | |
duke@435 | 1169 | #define FETCH_FLAG_FROM_VM(flag_accessor) { \ |
duke@435 | 1170 | check_is_loaded(); \ |
duke@435 | 1171 | VM_ENTRY_MARK; \ |
coleenp@4037 | 1172 | return get_Method()->flag_accessor(); \ |
duke@435 | 1173 | } |
duke@435 | 1174 | |
duke@435 | 1175 | bool ciMethod::is_empty_method() const { FETCH_FLAG_FROM_VM(is_empty_method); } |
duke@435 | 1176 | bool ciMethod::is_vanilla_constructor() const { FETCH_FLAG_FROM_VM(is_vanilla_constructor); } |
duke@435 | 1177 | bool ciMethod::has_loops () const { FETCH_FLAG_FROM_VM(has_loops); } |
duke@435 | 1178 | bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs); } |
duke@435 | 1179 | bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); } |
duke@435 | 1180 | bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); } |
duke@435 | 1181 | |
kvn@5110 | 1182 | bool ciMethod::is_boxing_method() const { |
kvn@5110 | 1183 | if (holder()->is_box_klass()) { |
kvn@5110 | 1184 | switch (intrinsic_id()) { |
kvn@5110 | 1185 | case vmIntrinsics::_Boolean_valueOf: |
kvn@5110 | 1186 | case vmIntrinsics::_Byte_valueOf: |
kvn@5110 | 1187 | case vmIntrinsics::_Character_valueOf: |
kvn@5110 | 1188 | case vmIntrinsics::_Short_valueOf: |
kvn@5110 | 1189 | case vmIntrinsics::_Integer_valueOf: |
kvn@5110 | 1190 | case vmIntrinsics::_Long_valueOf: |
kvn@5110 | 1191 | case vmIntrinsics::_Float_valueOf: |
kvn@5110 | 1192 | case vmIntrinsics::_Double_valueOf: |
kvn@5110 | 1193 | return true; |
kvn@5110 | 1194 | default: |
kvn@5110 | 1195 | return false; |
kvn@5110 | 1196 | } |
kvn@5110 | 1197 | } |
kvn@5110 | 1198 | return false; |
kvn@5110 | 1199 | } |
kvn@5110 | 1200 | |
kvn@5110 | 1201 | bool ciMethod::is_unboxing_method() const { |
kvn@5110 | 1202 | if (holder()->is_box_klass()) { |
kvn@5110 | 1203 | switch (intrinsic_id()) { |
kvn@5110 | 1204 | case vmIntrinsics::_booleanValue: |
kvn@5110 | 1205 | case vmIntrinsics::_byteValue: |
kvn@5110 | 1206 | case vmIntrinsics::_charValue: |
kvn@5110 | 1207 | case vmIntrinsics::_shortValue: |
kvn@5110 | 1208 | case vmIntrinsics::_intValue: |
kvn@5110 | 1209 | case vmIntrinsics::_longValue: |
kvn@5110 | 1210 | case vmIntrinsics::_floatValue: |
kvn@5110 | 1211 | case vmIntrinsics::_doubleValue: |
kvn@5110 | 1212 | return true; |
kvn@5110 | 1213 | default: |
kvn@5110 | 1214 | return false; |
kvn@5110 | 1215 | } |
kvn@5110 | 1216 | } |
kvn@5110 | 1217 | return false; |
kvn@5110 | 1218 | } |
kvn@5110 | 1219 | |
duke@435 | 1220 | BCEscapeAnalyzer *ciMethod::get_bcea() { |
kvn@2003 | 1221 | #ifdef COMPILER2 |
duke@435 | 1222 | if (_bcea == NULL) { |
duke@435 | 1223 | _bcea = new (CURRENT_ENV->arena()) BCEscapeAnalyzer(this, NULL); |
duke@435 | 1224 | } |
duke@435 | 1225 | return _bcea; |
kvn@2003 | 1226 | #else // COMPILER2 |
kvn@2003 | 1227 | ShouldNotReachHere(); |
kvn@2003 | 1228 | return NULL; |
kvn@2003 | 1229 | #endif // COMPILER2 |
duke@435 | 1230 | } |
duke@435 | 1231 | |
duke@435 | 1232 | ciMethodBlocks *ciMethod::get_method_blocks() { |
duke@435 | 1233 | Arena *arena = CURRENT_ENV->arena(); |
duke@435 | 1234 | if (_method_blocks == NULL) { |
duke@435 | 1235 | _method_blocks = new (arena) ciMethodBlocks(arena, this); |
duke@435 | 1236 | } |
duke@435 | 1237 | return _method_blocks; |
duke@435 | 1238 | } |
duke@435 | 1239 | |
duke@435 | 1240 | #undef FETCH_FLAG_FROM_VM |
duke@435 | 1241 | |
minqi@4267 | 1242 | void ciMethod::dump_replay_data(outputStream* st) { |
minqi@4267 | 1243 | ASSERT_IN_VM; |
vlivanov@4531 | 1244 | ResourceMark rm; |
minqi@4267 | 1245 | Method* method = get_Method(); |
jiangli@4936 | 1246 | MethodCounters* mcs = method->method_counters(); |
minqi@4267 | 1247 | Klass* holder = method->method_holder(); |
minqi@4267 | 1248 | st->print_cr("ciMethod %s %s %s %d %d %d %d %d", |
minqi@4267 | 1249 | holder->name()->as_quoted_ascii(), |
minqi@4267 | 1250 | method->name()->as_quoted_ascii(), |
minqi@4267 | 1251 | method->signature()->as_quoted_ascii(), |
jiangli@4936 | 1252 | mcs == NULL ? 0 : mcs->invocation_counter()->raw_counter(), |
jiangli@4936 | 1253 | mcs == NULL ? 0 : mcs->backedge_counter()->raw_counter(), |
minqi@4267 | 1254 | interpreter_invocation_count(), |
minqi@4267 | 1255 | interpreter_throwout_count(), |
minqi@4267 | 1256 | _instructions_size); |
minqi@4267 | 1257 | } |
duke@435 | 1258 | |
duke@435 | 1259 | // ------------------------------------------------------------------ |
duke@435 | 1260 | // ciMethod::print_codes |
duke@435 | 1261 | // |
duke@435 | 1262 | // Print a range of the bytecodes for this method. |
duke@435 | 1263 | void ciMethod::print_codes_on(int from, int to, outputStream* st) { |
duke@435 | 1264 | check_is_loaded(); |
coleenp@4037 | 1265 | GUARDED_VM_ENTRY(get_Method()->print_codes_on(from, to, st);) |
duke@435 | 1266 | } |
duke@435 | 1267 | |
duke@435 | 1268 | // ------------------------------------------------------------------ |
duke@435 | 1269 | // ciMethod::print_name |
duke@435 | 1270 | // |
duke@435 | 1271 | // Print the name of this method, including signature and some flags. |
duke@435 | 1272 | void ciMethod::print_name(outputStream* st) { |
duke@435 | 1273 | check_is_loaded(); |
coleenp@4037 | 1274 | GUARDED_VM_ENTRY(get_Method()->print_name(st);) |
duke@435 | 1275 | } |
duke@435 | 1276 | |
duke@435 | 1277 | // ------------------------------------------------------------------ |
duke@435 | 1278 | // ciMethod::print_short_name |
duke@435 | 1279 | // |
duke@435 | 1280 | // Print the name of this method, without signature. |
duke@435 | 1281 | void ciMethod::print_short_name(outputStream* st) { |
twisti@3969 | 1282 | if (is_loaded()) { |
coleenp@4037 | 1283 | GUARDED_VM_ENTRY(get_Method()->print_short_name(st);); |
twisti@3969 | 1284 | } else { |
twisti@3969 | 1285 | // Fall back if method is not loaded. |
twisti@3969 | 1286 | holder()->print_name_on(st); |
twisti@3969 | 1287 | st->print("::"); |
twisti@3969 | 1288 | name()->print_symbol_on(st); |
twisti@3969 | 1289 | if (WizardMode) |
twisti@3969 | 1290 | signature()->as_symbol()->print_symbol_on(st); |
twisti@3969 | 1291 | } |
duke@435 | 1292 | } |
duke@435 | 1293 | |
duke@435 | 1294 | // ------------------------------------------------------------------ |
duke@435 | 1295 | // ciMethod::print_impl |
duke@435 | 1296 | // |
duke@435 | 1297 | // Implementation of the print method. |
duke@435 | 1298 | void ciMethod::print_impl(outputStream* st) { |
coleenp@4037 | 1299 | ciMetadata::print_impl(st); |
duke@435 | 1300 | st->print(" name="); |
duke@435 | 1301 | name()->print_symbol_on(st); |
duke@435 | 1302 | st->print(" holder="); |
duke@435 | 1303 | holder()->print_name_on(st); |
duke@435 | 1304 | st->print(" signature="); |
duke@435 | 1305 | signature()->as_symbol()->print_symbol_on(st); |
duke@435 | 1306 | if (is_loaded()) { |
twisti@4021 | 1307 | st->print(" loaded=true"); |
twisti@4021 | 1308 | st->print(" arg_size=%d", arg_size()); |
twisti@4021 | 1309 | st->print(" flags="); |
duke@435 | 1310 | flags().print_member_flags(st); |
duke@435 | 1311 | } else { |
duke@435 | 1312 | st->print(" loaded=false"); |
duke@435 | 1313 | } |
duke@435 | 1314 | } |