src/share/vm/ci/ciMethod.cpp

Wed, 31 Jan 2018 19:24:57 -0500

author
dbuck
date
Wed, 31 Jan 2018 19:24:57 -0500
changeset 9289
427b2fb1944f
parent 8739
0b85ccd62409
child 8856
ac27a9c85bea
child 9942
eddd586d1a4c
permissions
-rw-r--r--

8189170: Add option to disable stack overflow checking in primordial thread for use with JNI_CreateJavaJVM
Reviewed-by: dcubed

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

mercurial