annotate src/share/vm/ci/ciMethod.cpp @ 1485:61b2245abf36

6930772: JSR 292 needs to support SPARC C1 Summary: C1 for SPARC needs to support JSR 292. Reviewed-by: never, jrose
author twisti
date Fri, 21 May 2010 02:59:24 -0700
parents 576e77447e3c
children e9ff18c4ace7
rev   line source
duke@0 1 /*
twisti@1152 2 * Copyright 1999-2010 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_ciMethod.cpp.incl"
duke@0 27
duke@0 28 // ciMethod
duke@0 29 //
duke@0 30 // This class represents a methodOop in the HotSpot virtual
duke@0 31 // machine.
duke@0 32
duke@0 33
duke@0 34 // ------------------------------------------------------------------
duke@0 35 // ciMethod::ciMethod
duke@0 36 //
duke@0 37 // Loaded method.
duke@0 38 ciMethod::ciMethod(methodHandle h_m) : ciObject(h_m) {
duke@0 39 assert(h_m() != NULL, "no null method");
duke@0 40
duke@0 41 // These fields are always filled in in loaded methods.
duke@0 42 _flags = ciFlags(h_m()->access_flags());
duke@0 43
duke@0 44 // Easy to compute, so fill them in now.
duke@0 45 _max_stack = h_m()->max_stack();
duke@0 46 _max_locals = h_m()->max_locals();
duke@0 47 _code_size = h_m()->code_size();
duke@0 48 _intrinsic_id = h_m()->intrinsic_id();
duke@0 49 _handler_count = h_m()->exception_table()->length() / 4;
duke@0 50 _uses_monitors = h_m()->access_flags().has_monitor_bytecodes();
duke@0 51 _balanced_monitors = !_uses_monitors || h_m()->access_flags().is_monitor_matching();
duke@0 52 _is_compilable = !h_m()->is_not_compilable();
duke@0 53 // Lazy fields, filled in on demand. Require allocation.
duke@0 54 _code = NULL;
duke@0 55 _exception_handlers = NULL;
duke@0 56 _liveness = NULL;
duke@0 57 _bcea = NULL;
duke@0 58 _method_blocks = NULL;
duke@0 59 #ifdef COMPILER2
duke@0 60 _flow = NULL;
duke@0 61 #endif // COMPILER2
duke@0 62
kvn@780 63 ciEnv *env = CURRENT_ENV;
kvn@780 64 if (env->jvmti_can_hotswap_or_post_breakpoint() && _is_compilable) {
duke@0 65 // 6328518 check hotswap conditions under the right lock.
duke@0 66 MutexLocker locker(Compile_lock);
duke@0 67 if (Dependencies::check_evol_method(h_m()) != NULL) {
duke@0 68 _is_compilable = false;
duke@0 69 }
duke@0 70 } else {
duke@0 71 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
duke@0 72 }
duke@0 73
duke@0 74 if (instanceKlass::cast(h_m()->method_holder())->is_linked()) {
duke@0 75 _can_be_statically_bound = h_m()->can_be_statically_bound();
duke@0 76 } else {
duke@0 77 // Have to use a conservative value in this case.
duke@0 78 _can_be_statically_bound = false;
duke@0 79 }
duke@0 80
duke@0 81 // Adjust the definition of this condition to be more useful:
duke@0 82 // %%% take these conditions into account in vtable generation
duke@0 83 if (!_can_be_statically_bound && h_m()->is_private())
duke@0 84 _can_be_statically_bound = true;
duke@0 85 if (_can_be_statically_bound && h_m()->is_abstract())
duke@0 86 _can_be_statically_bound = false;
duke@0 87
duke@0 88 // generating _signature may allow GC and therefore move m.
duke@0 89 // These fields are always filled in.
duke@0 90 _name = env->get_object(h_m()->name())->as_symbol();
duke@0 91 _holder = env->get_object(h_m()->method_holder())->as_instance_klass();
duke@0 92 ciSymbol* sig_symbol = env->get_object(h_m()->signature())->as_symbol();
duke@0 93 _signature = new (env->arena()) ciSignature(_holder, sig_symbol);
duke@0 94 _method_data = NULL;
duke@0 95 // Take a snapshot of these values, so they will be commensurate with the MDO.
duke@0 96 if (ProfileInterpreter) {
duke@0 97 int invcnt = h_m()->interpreter_invocation_count();
duke@0 98 // if the value overflowed report it as max int
duke@0 99 _interpreter_invocation_count = invcnt < 0 ? max_jint : invcnt ;
duke@0 100 _interpreter_throwout_count = h_m()->interpreter_throwout_count();
duke@0 101 } else {
duke@0 102 _interpreter_invocation_count = 0;
duke@0 103 _interpreter_throwout_count = 0;
duke@0 104 }
duke@0 105 if (_interpreter_invocation_count == 0)
duke@0 106 _interpreter_invocation_count = 1;
duke@0 107 }
duke@0 108
duke@0 109
duke@0 110 // ------------------------------------------------------------------
duke@0 111 // ciMethod::ciMethod
duke@0 112 //
duke@0 113 // Unloaded method.
duke@0 114 ciMethod::ciMethod(ciInstanceKlass* holder,
duke@0 115 ciSymbol* name,
duke@0 116 ciSymbol* signature) : ciObject(ciMethodKlass::make()) {
duke@0 117 // These fields are always filled in.
duke@0 118 _name = name;
duke@0 119 _holder = holder;
duke@0 120 _signature = new (CURRENT_ENV->arena()) ciSignature(_holder, signature);
duke@0 121 _intrinsic_id = vmIntrinsics::_none;
duke@0 122 _liveness = NULL;
duke@0 123 _can_be_statically_bound = false;
duke@0 124 _bcea = NULL;
duke@0 125 _method_blocks = NULL;
duke@0 126 _method_data = NULL;
duke@0 127 #ifdef COMPILER2
duke@0 128 _flow = NULL;
duke@0 129 #endif // COMPILER2
duke@0 130 }
duke@0 131
duke@0 132
duke@0 133 // ------------------------------------------------------------------
duke@0 134 // ciMethod::load_code
duke@0 135 //
duke@0 136 // Load the bytecodes and exception handler table for this method.
duke@0 137 void ciMethod::load_code() {
duke@0 138 VM_ENTRY_MARK;
duke@0 139 assert(is_loaded(), "only loaded methods have code");
duke@0 140
duke@0 141 methodOop me = get_methodOop();
duke@0 142 Arena* arena = CURRENT_THREAD_ENV->arena();
duke@0 143
duke@0 144 // Load the bytecodes.
duke@0 145 _code = (address)arena->Amalloc(code_size());
duke@0 146 memcpy(_code, me->code_base(), code_size());
duke@0 147
duke@0 148 // Revert any breakpoint bytecodes in ci's copy
kvn@27 149 if (me->number_of_breakpoints() > 0) {
duke@0 150 BreakpointInfo* bp = instanceKlass::cast(me->method_holder())->breakpoints();
duke@0 151 for (; bp != NULL; bp = bp->next()) {
duke@0 152 if (bp->match(me)) {
duke@0 153 code_at_put(bp->bci(), bp->orig_bytecode());
duke@0 154 }
duke@0 155 }
duke@0 156 }
duke@0 157
duke@0 158 // And load the exception table.
duke@0 159 typeArrayOop exc_table = me->exception_table();
duke@0 160
duke@0 161 // Allocate one extra spot in our list of exceptions. This
duke@0 162 // last entry will be used to represent the possibility that
duke@0 163 // an exception escapes the method. See ciExceptionHandlerStream
duke@0 164 // for details.
duke@0 165 _exception_handlers =
duke@0 166 (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
duke@0 167 * (_handler_count + 1));
duke@0 168 if (_handler_count > 0) {
duke@0 169 for (int i=0; i<_handler_count; i++) {
duke@0 170 int base = i*4;
duke@0 171 _exception_handlers[i] = new (arena) ciExceptionHandler(
duke@0 172 holder(),
duke@0 173 /* start */ exc_table->int_at(base),
duke@0 174 /* limit */ exc_table->int_at(base+1),
duke@0 175 /* goto pc */ exc_table->int_at(base+2),
duke@0 176 /* cp index */ exc_table->int_at(base+3));
duke@0 177 }
duke@0 178 }
duke@0 179
duke@0 180 // Put an entry at the end of our list to represent the possibility
duke@0 181 // of exceptional exit.
duke@0 182 _exception_handlers[_handler_count] =
duke@0 183 new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);
duke@0 184
duke@0 185 if (CIPrintMethodCodes) {
duke@0 186 print_codes();
duke@0 187 }
duke@0 188 }
duke@0 189
duke@0 190
duke@0 191 // ------------------------------------------------------------------
duke@0 192 // ciMethod::has_linenumber_table
duke@0 193 //
duke@0 194 // length unknown until decompression
duke@0 195 bool ciMethod::has_linenumber_table() const {
duke@0 196 check_is_loaded();
duke@0 197 VM_ENTRY_MARK;
duke@0 198 return get_methodOop()->has_linenumber_table();
duke@0 199 }
duke@0 200
duke@0 201
duke@0 202 // ------------------------------------------------------------------
duke@0 203 // ciMethod::compressed_linenumber_table
duke@0 204 u_char* ciMethod::compressed_linenumber_table() const {
duke@0 205 check_is_loaded();
duke@0 206 VM_ENTRY_MARK;
duke@0 207 return get_methodOop()->compressed_linenumber_table();
duke@0 208 }
duke@0 209
duke@0 210
duke@0 211 // ------------------------------------------------------------------
duke@0 212 // ciMethod::line_number_from_bci
duke@0 213 int ciMethod::line_number_from_bci(int bci) const {
duke@0 214 check_is_loaded();
duke@0 215 VM_ENTRY_MARK;
duke@0 216 return get_methodOop()->line_number_from_bci(bci);
duke@0 217 }
duke@0 218
duke@0 219
duke@0 220 // ------------------------------------------------------------------
duke@0 221 // ciMethod::vtable_index
duke@0 222 //
duke@0 223 // Get the position of this method's entry in the vtable, if any.
duke@0 224 int ciMethod::vtable_index() {
duke@0 225 check_is_loaded();
duke@0 226 assert(holder()->is_linked(), "must be linked");
duke@0 227 VM_ENTRY_MARK;
duke@0 228 return get_methodOop()->vtable_index();
duke@0 229 }
duke@0 230
duke@0 231
duke@0 232 // ------------------------------------------------------------------
duke@0 233 // ciMethod::native_entry
duke@0 234 //
duke@0 235 // Get the address of this method's native code, if any.
duke@0 236 address ciMethod::native_entry() {
duke@0 237 check_is_loaded();
duke@0 238 assert(flags().is_native(), "must be native method");
duke@0 239 VM_ENTRY_MARK;
duke@0 240 methodOop method = get_methodOop();
duke@0 241 address entry = method->native_function();
duke@0 242 assert(entry != NULL, "must be valid entry point");
duke@0 243 return entry;
duke@0 244 }
duke@0 245
duke@0 246
duke@0 247 // ------------------------------------------------------------------
duke@0 248 // ciMethod::interpreter_entry
duke@0 249 //
duke@0 250 // Get the entry point for running this method in the interpreter.
duke@0 251 address ciMethod::interpreter_entry() {
duke@0 252 check_is_loaded();
duke@0 253 VM_ENTRY_MARK;
duke@0 254 methodHandle mh(THREAD, get_methodOop());
duke@0 255 return Interpreter::entry_for_method(mh);
duke@0 256 }
duke@0 257
duke@0 258
duke@0 259 // ------------------------------------------------------------------
duke@0 260 // ciMethod::uses_balanced_monitors
duke@0 261 //
duke@0 262 // Does this method use monitors in a strict stack-disciplined manner?
duke@0 263 bool ciMethod::has_balanced_monitors() {
duke@0 264 check_is_loaded();
duke@0 265 if (_balanced_monitors) return true;
duke@0 266
duke@0 267 // Analyze the method to see if monitors are used properly.
duke@0 268 VM_ENTRY_MARK;
duke@0 269 methodHandle method(THREAD, get_methodOop());
duke@0 270 assert(method->has_monitor_bytecodes(), "should have checked this");
duke@0 271
duke@0 272 // Check to see if a previous compilation computed the
duke@0 273 // monitor-matching analysis.
duke@0 274 if (method->guaranteed_monitor_matching()) {
duke@0 275 _balanced_monitors = true;
duke@0 276 return true;
duke@0 277 }
duke@0 278
duke@0 279 {
duke@0 280 EXCEPTION_MARK;
duke@0 281 ResourceMark rm(THREAD);
duke@0 282 GeneratePairingInfo gpi(method);
duke@0 283 gpi.compute_map(CATCH);
duke@0 284 if (!gpi.monitor_safe()) {
duke@0 285 return false;
duke@0 286 }
duke@0 287 method->set_guaranteed_monitor_matching();
duke@0 288 _balanced_monitors = true;
duke@0 289 }
duke@0 290 return true;
duke@0 291 }
duke@0 292
duke@0 293
duke@0 294 // ------------------------------------------------------------------
duke@0 295 // ciMethod::get_flow_analysis
duke@0 296 ciTypeFlow* ciMethod::get_flow_analysis() {
duke@0 297 #ifdef COMPILER2
duke@0 298 if (_flow == NULL) {
duke@0 299 ciEnv* env = CURRENT_ENV;
duke@0 300 _flow = new (env->arena()) ciTypeFlow(env, this);
duke@0 301 _flow->do_flow();
duke@0 302 }
duke@0 303 return _flow;
duke@0 304 #else // COMPILER2
duke@0 305 ShouldNotReachHere();
duke@0 306 return NULL;
duke@0 307 #endif // COMPILER2
duke@0 308 }
duke@0 309
duke@0 310
duke@0 311 // ------------------------------------------------------------------
duke@0 312 // ciMethod::get_osr_flow_analysis
duke@0 313 ciTypeFlow* ciMethod::get_osr_flow_analysis(int osr_bci) {
duke@0 314 #ifdef COMPILER2
duke@0 315 // OSR entry points are always place after a call bytecode of some sort
duke@0 316 assert(osr_bci >= 0, "must supply valid OSR entry point");
duke@0 317 ciEnv* env = CURRENT_ENV;
duke@0 318 ciTypeFlow* flow = new (env->arena()) ciTypeFlow(env, this, osr_bci);
duke@0 319 flow->do_flow();
duke@0 320 return flow;
duke@0 321 #else // COMPILER2
duke@0 322 ShouldNotReachHere();
duke@0 323 return NULL;
duke@0 324 #endif // COMPILER2
duke@0 325 }
duke@0 326
duke@0 327 // ------------------------------------------------------------------
never@991 328 // ciMethod::raw_liveness_at_bci
duke@0 329 //
duke@0 330 // Which local variables are live at a specific bci?
never@991 331 MethodLivenessResult ciMethod::raw_liveness_at_bci(int bci) {
duke@0 332 check_is_loaded();
duke@0 333 if (_liveness == NULL) {
duke@0 334 // Create the liveness analyzer.
duke@0 335 Arena* arena = CURRENT_ENV->arena();
duke@0 336 _liveness = new (arena) MethodLiveness(arena, this);
duke@0 337 _liveness->compute_liveness();
duke@0 338 }
never@991 339 return _liveness->get_liveness_at(bci);
never@991 340 }
never@991 341
never@991 342 // ------------------------------------------------------------------
never@991 343 // ciMethod::liveness_at_bci
never@991 344 //
never@991 345 // Which local variables are live at a specific bci? When debugging
never@991 346 // will return true for all locals in some cases to improve debug
never@991 347 // information.
never@991 348 MethodLivenessResult ciMethod::liveness_at_bci(int bci) {
never@991 349 MethodLivenessResult result = raw_liveness_at_bci(bci);
kvn@780 350 if (CURRENT_ENV->jvmti_can_access_local_variables() || DeoptimizeALot || CompileTheWorld) {
duke@0 351 // Keep all locals live for the user's edification and amusement.
duke@0 352 result.at_put_range(0, result.size(), true);
duke@0 353 }
duke@0 354 return result;
duke@0 355 }
duke@0 356
duke@0 357 // ciMethod::live_local_oops_at_bci
duke@0 358 //
duke@0 359 // find all the live oops in the locals array for a particular bci
duke@0 360 // Compute what the interpreter believes by using the interpreter
duke@0 361 // oopmap generator. This is used as a double check during osr to
duke@0 362 // guard against conservative result from MethodLiveness making us
duke@0 363 // think a dead oop is live. MethodLiveness is conservative in the
duke@0 364 // sense that it may consider locals to be live which cannot be live,
duke@0 365 // like in the case where a local could contain an oop or a primitive
duke@0 366 // along different paths. In that case the local must be dead when
duke@0 367 // those paths merge. Since the interpreter's viewpoint is used when
duke@0 368 // gc'ing an interpreter frame we need to use its viewpoint during
duke@0 369 // OSR when loading the locals.
duke@0 370
duke@0 371 BitMap ciMethod::live_local_oops_at_bci(int bci) {
duke@0 372 VM_ENTRY_MARK;
duke@0 373 InterpreterOopMap mask;
duke@0 374 OopMapCache::compute_one_oop_map(get_methodOop(), bci, &mask);
duke@0 375 int mask_size = max_locals();
duke@0 376 BitMap result(mask_size);
duke@0 377 result.clear();
duke@0 378 int i;
duke@0 379 for (i = 0; i < mask_size ; i++ ) {
duke@0 380 if (mask.is_oop(i)) result.set_bit(i);
duke@0 381 }
duke@0 382 return result;
duke@0 383 }
duke@0 384
duke@0 385
duke@0 386 #ifdef COMPILER1
duke@0 387 // ------------------------------------------------------------------
duke@0 388 // ciMethod::bci_block_start
duke@0 389 //
duke@0 390 // Marks all bcis where a new basic block starts
duke@0 391 const BitMap ciMethod::bci_block_start() {
duke@0 392 check_is_loaded();
duke@0 393 if (_liveness == NULL) {
duke@0 394 // Create the liveness analyzer.
duke@0 395 Arena* arena = CURRENT_ENV->arena();
duke@0 396 _liveness = new (arena) MethodLiveness(arena, this);
duke@0 397 _liveness->compute_liveness();
duke@0 398 }
duke@0 399
duke@0 400 return _liveness->get_bci_block_start();
duke@0 401 }
duke@0 402 #endif // COMPILER1
duke@0 403
duke@0 404
duke@0 405 // ------------------------------------------------------------------
duke@0 406 // ciMethod::call_profile_at_bci
duke@0 407 //
duke@0 408 // Get the ciCallProfile for the invocation of this method.
duke@0 409 // Also reports receiver types for non-call type checks (if TypeProfileCasts).
duke@0 410 ciCallProfile ciMethod::call_profile_at_bci(int bci) {
duke@0 411 ResourceMark rm;
duke@0 412 ciCallProfile result;
duke@0 413 if (method_data() != NULL && method_data()->is_mature()) {
duke@0 414 ciProfileData* data = method_data()->bci_to_data(bci);
duke@0 415 if (data != NULL && data->is_CounterData()) {
duke@0 416 // Every profiled call site has a counter.
duke@0 417 int count = data->as_CounterData()->count();
duke@0 418
duke@0 419 if (!data->is_ReceiverTypeData()) {
duke@0 420 result._receiver_count[0] = 0; // that's a definite zero
duke@0 421 } else { // ReceiverTypeData is a subclass of CounterData
duke@0 422 ciReceiverTypeData* call = (ciReceiverTypeData*)data->as_ReceiverTypeData();
duke@0 423 // In addition, virtual call sites have receiver type information
duke@0 424 int receivers_count_total = 0;
duke@0 425 int morphism = 0;
duke@0 426 for (uint i = 0; i < call->row_limit(); i++) {
duke@0 427 ciKlass* receiver = call->receiver(i);
duke@0 428 if (receiver == NULL) continue;
duke@0 429 morphism += 1;
duke@0 430 int rcount = call->receiver_count(i);
duke@0 431 if (rcount == 0) rcount = 1; // Should be valid value
duke@0 432 receivers_count_total += rcount;
duke@0 433 // Add the receiver to result data.
duke@0 434 result.add_receiver(receiver, rcount);
duke@0 435 // If we extend profiling to record methods,
duke@0 436 // we will set result._method also.
duke@0 437 }
duke@0 438 // Determine call site's morphism.
kvn@1206 439 // The call site count is 0 with known morphism (onlt 1 or 2 receivers)
kvn@1206 440 // or < 0 in the case of a type check failured for checkcast, aastore, instanceof.
kvn@1206 441 // The call site count is > 0 in the case of a polymorphic virtual call.
kvn@1206 442 if (morphism > 0 && morphism == result._limit) {
kvn@1206 443 // The morphism <= MorphismLimit.
kvn@1206 444 if ((morphism < ciCallProfile::MorphismLimit) ||
kvn@1206 445 (morphism == ciCallProfile::MorphismLimit && count == 0)) {
kvn@1206 446 #ifdef ASSERT
kvn@1206 447 if (count > 0) {
kvn@1251 448 this->print_short_name(tty);
kvn@1251 449 tty->print_cr(" @ bci:%d", bci);
kvn@1206 450 this->print_codes();
kvn@1206 451 assert(false, "this call site should not be polymorphic");
kvn@1206 452 }
kvn@1206 453 #endif
duke@0 454 result._morphism = morphism;
duke@0 455 }
duke@0 456 }
duke@0 457 // Make the count consistent if this is a call profile. If count is
duke@0 458 // zero or less, presume that this is a typecheck profile and
duke@0 459 // do nothing. Otherwise, increase count to be the sum of all
duke@0 460 // receiver's counts.
kvn@1206 461 if (count >= 0) {
kvn@1206 462 count += receivers_count_total;
duke@0 463 }
duke@0 464 }
duke@0 465 result._count = count;
duke@0 466 }
duke@0 467 }
duke@0 468 return result;
duke@0 469 }
duke@0 470
duke@0 471 // ------------------------------------------------------------------
duke@0 472 // Add new receiver and sort data by receiver's profile count.
duke@0 473 void ciCallProfile::add_receiver(ciKlass* receiver, int receiver_count) {
duke@0 474 // Add new receiver and sort data by receiver's counts when we have space
duke@0 475 // for it otherwise replace the less called receiver (less called receiver
duke@0 476 // is placed to the last array element which is not used).
duke@0 477 // First array's element contains most called receiver.
duke@0 478 int i = _limit;
duke@0 479 for (; i > 0 && receiver_count > _receiver_count[i-1]; i--) {
duke@0 480 _receiver[i] = _receiver[i-1];
duke@0 481 _receiver_count[i] = _receiver_count[i-1];
duke@0 482 }
duke@0 483 _receiver[i] = receiver;
duke@0 484 _receiver_count[i] = receiver_count;
duke@0 485 if (_limit < MorphismLimit) _limit++;
duke@0 486 }
duke@0 487
duke@0 488 // ------------------------------------------------------------------
duke@0 489 // ciMethod::find_monomorphic_target
duke@0 490 //
duke@0 491 // Given a certain calling environment, find the monomorphic target
duke@0 492 // for the call. Return NULL if the call is not monomorphic in
duke@0 493 // its calling environment, or if there are only abstract methods.
duke@0 494 // The returned method is never abstract.
duke@0 495 // Note: If caller uses a non-null result, it must inform dependencies
duke@0 496 // via assert_unique_concrete_method or assert_leaf_type.
duke@0 497 ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller,
duke@0 498 ciInstanceKlass* callee_holder,
duke@0 499 ciInstanceKlass* actual_recv) {
duke@0 500 check_is_loaded();
duke@0 501
duke@0 502 if (actual_recv->is_interface()) {
duke@0 503 // %%% We cannot trust interface types, yet. See bug 6312651.
duke@0 504 return NULL;
duke@0 505 }
duke@0 506
duke@0 507 ciMethod* root_m = resolve_invoke(caller, actual_recv);
duke@0 508 if (root_m == NULL) {
duke@0 509 // Something went wrong looking up the actual receiver method.
duke@0 510 return NULL;
duke@0 511 }
duke@0 512 assert(!root_m->is_abstract(), "resolve_invoke promise");
duke@0 513
duke@0 514 // Make certain quick checks even if UseCHA is false.
duke@0 515
duke@0 516 // Is it private or final?
duke@0 517 if (root_m->can_be_statically_bound()) {
duke@0 518 return root_m;
duke@0 519 }
duke@0 520
duke@0 521 if (actual_recv->is_leaf_type() && actual_recv == root_m->holder()) {
duke@0 522 // Easy case. There is no other place to put a method, so don't bother
duke@0 523 // to go through the VM_ENTRY_MARK and all the rest.
duke@0 524 return root_m;
duke@0 525 }
duke@0 526
duke@0 527 // Array methods (clone, hashCode, etc.) are always statically bound.
duke@0 528 // If we were to see an array type here, we'd return root_m.
duke@0 529 // However, this method processes only ciInstanceKlasses. (See 4962591.)
duke@0 530 // The inline_native_clone intrinsic narrows Object to T[] properly,
duke@0 531 // so there is no need to do the same job here.
duke@0 532
duke@0 533 if (!UseCHA) return NULL;
duke@0 534
duke@0 535 VM_ENTRY_MARK;
duke@0 536
duke@0 537 methodHandle target;
duke@0 538 {
duke@0 539 MutexLocker locker(Compile_lock);
duke@0 540 klassOop context = actual_recv->get_klassOop();
duke@0 541 target = Dependencies::find_unique_concrete_method(context,
duke@0 542 root_m->get_methodOop());
duke@0 543 // %%% Should upgrade this ciMethod API to look for 1 or 2 concrete methods.
duke@0 544 }
duke@0 545
duke@0 546 #ifndef PRODUCT
duke@0 547 if (TraceDependencies && target() != NULL && target() != root_m->get_methodOop()) {
duke@0 548 tty->print("found a non-root unique target method");
duke@0 549 tty->print_cr(" context = %s", instanceKlass::cast(actual_recv->get_klassOop())->external_name());
duke@0 550 tty->print(" method = ");
duke@0 551 target->print_short_name(tty);
duke@0 552 tty->cr();
duke@0 553 }
duke@0 554 #endif //PRODUCT
duke@0 555
duke@0 556 if (target() == NULL) {
duke@0 557 return NULL;
duke@0 558 }
duke@0 559 if (target() == root_m->get_methodOop()) {
duke@0 560 return root_m;
duke@0 561 }
duke@0 562 if (!root_m->is_public() &&
duke@0 563 !root_m->is_protected()) {
duke@0 564 // If we are going to reason about inheritance, it's easiest
duke@0 565 // if the method in question is public, protected, or private.
duke@0 566 // If the answer is not root_m, it is conservatively correct
duke@0 567 // to return NULL, even if the CHA encountered irrelevant
duke@0 568 // methods in other packages.
duke@0 569 // %%% TO DO: Work out logic for package-private methods
duke@0 570 // with the same name but different vtable indexes.
duke@0 571 return NULL;
duke@0 572 }
duke@0 573 return CURRENT_THREAD_ENV->get_object(target())->as_method();
duke@0 574 }
duke@0 575
duke@0 576 // ------------------------------------------------------------------
duke@0 577 // ciMethod::resolve_invoke
duke@0 578 //
duke@0 579 // Given a known receiver klass, find the target for the call.
duke@0 580 // Return NULL if the call has no target or the target is abstract.
duke@0 581 ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver) {
duke@0 582 check_is_loaded();
duke@0 583 VM_ENTRY_MARK;
duke@0 584
duke@0 585 KlassHandle caller_klass (THREAD, caller->get_klassOop());
duke@0 586 KlassHandle h_recv (THREAD, exact_receiver->get_klassOop());
duke@0 587 KlassHandle h_resolved (THREAD, holder()->get_klassOop());
duke@0 588 symbolHandle h_name (THREAD, name()->get_symbolOop());
duke@0 589 symbolHandle h_signature (THREAD, signature()->get_symbolOop());
duke@0 590
duke@0 591 methodHandle m;
duke@0 592 // Only do exact lookup if receiver klass has been linked. Otherwise,
duke@0 593 // the vtable has not been setup, and the LinkResolver will fail.
duke@0 594 if (h_recv->oop_is_javaArray()
duke@0 595 ||
duke@0 596 instanceKlass::cast(h_recv())->is_linked() && !exact_receiver->is_interface()) {
duke@0 597 if (holder()->is_interface()) {
duke@0 598 m = LinkResolver::resolve_interface_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass);
duke@0 599 } else {
duke@0 600 m = LinkResolver::resolve_virtual_call_or_null(h_recv, h_resolved, h_name, h_signature, caller_klass);
duke@0 601 }
duke@0 602 }
duke@0 603
duke@0 604 if (m.is_null()) {
duke@0 605 // Return NULL only if there was a problem with lookup (uninitialized class, etc.)
duke@0 606 return NULL;
duke@0 607 }
duke@0 608
duke@0 609 ciMethod* result = this;
duke@0 610 if (m() != get_methodOop()) {
duke@0 611 result = CURRENT_THREAD_ENV->get_object(m())->as_method();
duke@0 612 }
duke@0 613
duke@0 614 // Don't return abstract methods because they aren't
duke@0 615 // optimizable or interesting.
duke@0 616 if (result->is_abstract()) {
duke@0 617 return NULL;
duke@0 618 } else {
duke@0 619 return result;
duke@0 620 }
duke@0 621 }
duke@0 622
duke@0 623 // ------------------------------------------------------------------
duke@0 624 // ciMethod::resolve_vtable_index
duke@0 625 //
duke@0 626 // Given a known receiver klass, find the vtable index for the call.
duke@0 627 // Return methodOopDesc::invalid_vtable_index if the vtable_index is unknown.
duke@0 628 int ciMethod::resolve_vtable_index(ciKlass* caller, ciKlass* receiver) {
duke@0 629 check_is_loaded();
duke@0 630
duke@0 631 int vtable_index = methodOopDesc::invalid_vtable_index;
duke@0 632 // Only do lookup if receiver klass has been linked. Otherwise,
duke@0 633 // the vtable has not been setup, and the LinkResolver will fail.
duke@0 634 if (!receiver->is_interface()
duke@0 635 && (!receiver->is_instance_klass() ||
duke@0 636 receiver->as_instance_klass()->is_linked())) {
duke@0 637 VM_ENTRY_MARK;
duke@0 638
duke@0 639 KlassHandle caller_klass (THREAD, caller->get_klassOop());
duke@0 640 KlassHandle h_recv (THREAD, receiver->get_klassOop());
duke@0 641 symbolHandle h_name (THREAD, name()->get_symbolOop());
duke@0 642 symbolHandle h_signature (THREAD, signature()->get_symbolOop());
duke@0 643
duke@0 644 vtable_index = LinkResolver::resolve_virtual_vtable_index(h_recv, h_recv, h_name, h_signature, caller_klass);
duke@0 645 if (vtable_index == methodOopDesc::nonvirtual_vtable_index) {
duke@0 646 // A statically bound method. Return "no such index".
duke@0 647 vtable_index = methodOopDesc::invalid_vtable_index;
duke@0 648 }
duke@0 649 }
duke@0 650
duke@0 651 return vtable_index;
duke@0 652 }
duke@0 653
duke@0 654 // ------------------------------------------------------------------
duke@0 655 // ciMethod::interpreter_call_site_count
duke@0 656 int ciMethod::interpreter_call_site_count(int bci) {
duke@0 657 if (method_data() != NULL) {
duke@0 658 ResourceMark rm;
duke@0 659 ciProfileData* data = method_data()->bci_to_data(bci);
duke@0 660 if (data != NULL && data->is_CounterData()) {
duke@0 661 return scale_count(data->as_CounterData()->count());
duke@0 662 }
duke@0 663 }
duke@0 664 return -1; // unknown
duke@0 665 }
duke@0 666
duke@0 667 // ------------------------------------------------------------------
duke@0 668 // Adjust a CounterData count to be commensurate with
duke@0 669 // interpreter_invocation_count. If the MDO exists for
duke@0 670 // only 25% of the time the method exists, then the
duke@0 671 // counts in the MDO should be scaled by 4X, so that
duke@0 672 // they can be usefully and stably compared against the
duke@0 673 // invocation counts in methods.
duke@0 674 int ciMethod::scale_count(int count, float prof_factor) {
duke@0 675 if (count > 0 && method_data() != NULL) {
duke@0 676 int current_mileage = method_data()->current_mileage();
duke@0 677 int creation_mileage = method_data()->creation_mileage();
duke@0 678 int counter_life = current_mileage - creation_mileage;
duke@0 679 int method_life = interpreter_invocation_count();
duke@0 680 // counter_life due to backedge_counter could be > method_life
duke@0 681 if (counter_life > method_life)
duke@0 682 counter_life = method_life;
duke@0 683 if (0 < counter_life && counter_life <= method_life) {
duke@0 684 count = (int)((double)count * prof_factor * method_life / counter_life + 0.5);
duke@0 685 count = (count > 0) ? count : 1;
duke@0 686 }
duke@0 687 }
duke@0 688 return count;
duke@0 689 }
duke@0 690
duke@0 691 // ------------------------------------------------------------------
jrose@710 692 // invokedynamic support
twisti@1485 693
twisti@1485 694 // ------------------------------------------------------------------
twisti@1485 695 // ciMethod::is_method_handle_invoke
jrose@710 696 //
twisti@1485 697 // Return true if the method is a MethodHandle target.
twisti@1137 698 bool ciMethod::is_method_handle_invoke() const {
twisti@1485 699 bool flag = (holder()->name() == ciSymbol::java_dyn_MethodHandle() &&
twisti@1485 700 methodOopDesc::is_method_handle_invoke_name(name()->sid()));
jrose@710 701 #ifdef ASSERT
twisti@1485 702 if (is_loaded()) {
twisti@1485 703 bool flag2 = ((flags().as_int() & JVM_MH_INVOKE_BITS) == JVM_MH_INVOKE_BITS);
twisti@1485 704 {
twisti@1485 705 VM_ENTRY_MARK;
twisti@1485 706 bool flag3 = get_methodOop()->is_method_handle_invoke();
twisti@1485 707 assert(flag2 == flag3, "consistent");
twisti@1485 708 assert(flag == flag3, "consistent");
twisti@1485 709 }
jrose@710 710 }
jrose@710 711 #endif //ASSERT
jrose@710 712 return flag;
jrose@710 713 }
jrose@710 714
twisti@1485 715 // ------------------------------------------------------------------
twisti@1485 716 // ciMethod::is_method_handle_adapter
twisti@1485 717 //
twisti@1485 718 // Return true if the method is a generated MethodHandle adapter.
twisti@1152 719 bool ciMethod::is_method_handle_adapter() const {
twisti@1152 720 check_is_loaded();
twisti@1152 721 VM_ENTRY_MARK;
twisti@1152 722 return get_methodOop()->is_method_handle_adapter();
twisti@1152 723 }
twisti@1152 724
jrose@710 725 ciInstance* ciMethod::method_handle_type() {
jrose@710 726 check_is_loaded();
jrose@710 727 VM_ENTRY_MARK;
jrose@710 728 oop mtype = get_methodOop()->method_handle_type();
jrose@710 729 return CURRENT_THREAD_ENV->get_object(mtype)->as_instance();
jrose@710 730 }
jrose@710 731
jrose@710 732
jrose@710 733 // ------------------------------------------------------------------
duke@0 734 // ciMethod::build_method_data
duke@0 735 //
duke@0 736 // Generate new methodDataOop objects at compile time.
duke@0 737 void ciMethod::build_method_data(methodHandle h_m) {
duke@0 738 EXCEPTION_CONTEXT;
duke@0 739 if (is_native() || is_abstract() || h_m()->is_accessor()) return;
duke@0 740 if (h_m()->method_data() == NULL) {
duke@0 741 methodOopDesc::build_interpreter_method_data(h_m, THREAD);
duke@0 742 if (HAS_PENDING_EXCEPTION) {
duke@0 743 CLEAR_PENDING_EXCEPTION;
duke@0 744 }
duke@0 745 }
duke@0 746 if (h_m()->method_data() != NULL) {
duke@0 747 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data();
duke@0 748 _method_data->load_data();
duke@0 749 } else {
duke@0 750 _method_data = CURRENT_ENV->get_empty_methodData();
duke@0 751 }
duke@0 752 }
duke@0 753
duke@0 754 // public, retroactive version
duke@0 755 void ciMethod::build_method_data() {
duke@0 756 if (_method_data == NULL || _method_data->is_empty()) {
duke@0 757 GUARDED_VM_ENTRY({
duke@0 758 build_method_data(get_methodOop());
duke@0 759 });
duke@0 760 }
duke@0 761 }
duke@0 762
duke@0 763
duke@0 764 // ------------------------------------------------------------------
duke@0 765 // ciMethod::method_data
duke@0 766 //
duke@0 767 ciMethodData* ciMethod::method_data() {
duke@0 768 if (_method_data != NULL) {
duke@0 769 return _method_data;
duke@0 770 }
duke@0 771 VM_ENTRY_MARK;
duke@0 772 ciEnv* env = CURRENT_ENV;
duke@0 773 Thread* my_thread = JavaThread::current();
duke@0 774 methodHandle h_m(my_thread, get_methodOop());
duke@0 775
duke@0 776 if (Tier1UpdateMethodData && is_tier1_compile(env->comp_level())) {
duke@0 777 build_method_data(h_m);
duke@0 778 }
duke@0 779
duke@0 780 if (h_m()->method_data() != NULL) {
duke@0 781 _method_data = CURRENT_ENV->get_object(h_m()->method_data())->as_method_data();
duke@0 782 _method_data->load_data();
duke@0 783 } else {
duke@0 784 _method_data = CURRENT_ENV->get_empty_methodData();
duke@0 785 }
duke@0 786 return _method_data;
duke@0 787
duke@0 788 }
duke@0 789
duke@0 790
duke@0 791 // ------------------------------------------------------------------
duke@0 792 // ciMethod::will_link
duke@0 793 //
duke@0 794 // Will this method link in a specific calling context?
duke@0 795 bool ciMethod::will_link(ciKlass* accessing_klass,
duke@0 796 ciKlass* declared_method_holder,
duke@0 797 Bytecodes::Code bc) {
duke@0 798 if (!is_loaded()) {
duke@0 799 // Method lookup failed.
duke@0 800 return false;
duke@0 801 }
duke@0 802
duke@0 803 // The link checks have been front-loaded into the get_method
duke@0 804 // call. This method (ciMethod::will_link()) will be removed
duke@0 805 // in the future.
duke@0 806
duke@0 807 return true;
duke@0 808 }
duke@0 809
duke@0 810 // ------------------------------------------------------------------
duke@0 811 // ciMethod::should_exclude
duke@0 812 //
duke@0 813 // Should this method be excluded from compilation?
duke@0 814 bool ciMethod::should_exclude() {
duke@0 815 check_is_loaded();
duke@0 816 VM_ENTRY_MARK;
duke@0 817 methodHandle mh(THREAD, get_methodOop());
duke@0 818 bool ignore;
duke@0 819 return CompilerOracle::should_exclude(mh, ignore);
duke@0 820 }
duke@0 821
duke@0 822 // ------------------------------------------------------------------
duke@0 823 // ciMethod::should_inline
duke@0 824 //
duke@0 825 // Should this method be inlined during compilation?
duke@0 826 bool ciMethod::should_inline() {
duke@0 827 check_is_loaded();
duke@0 828 VM_ENTRY_MARK;
duke@0 829 methodHandle mh(THREAD, get_methodOop());
duke@0 830 return CompilerOracle::should_inline(mh);
duke@0 831 }
duke@0 832
duke@0 833 // ------------------------------------------------------------------
duke@0 834 // ciMethod::should_not_inline
duke@0 835 //
duke@0 836 // Should this method be disallowed from inlining during compilation?
duke@0 837 bool ciMethod::should_not_inline() {
duke@0 838 check_is_loaded();
duke@0 839 VM_ENTRY_MARK;
duke@0 840 methodHandle mh(THREAD, get_methodOop());
duke@0 841 return CompilerOracle::should_not_inline(mh);
duke@0 842 }
duke@0 843
duke@0 844 // ------------------------------------------------------------------
duke@0 845 // ciMethod::should_print_assembly
duke@0 846 //
duke@0 847 // Should the compiler print the generated code for this method?
duke@0 848 bool ciMethod::should_print_assembly() {
duke@0 849 check_is_loaded();
duke@0 850 VM_ENTRY_MARK;
duke@0 851 methodHandle mh(THREAD, get_methodOop());
duke@0 852 return CompilerOracle::should_print(mh);
duke@0 853 }
duke@0 854
duke@0 855 // ------------------------------------------------------------------
duke@0 856 // ciMethod::break_at_execute
duke@0 857 //
duke@0 858 // Should the compiler insert a breakpoint into the generated code
duke@0 859 // method?
duke@0 860 bool ciMethod::break_at_execute() {
duke@0 861 check_is_loaded();
duke@0 862 VM_ENTRY_MARK;
duke@0 863 methodHandle mh(THREAD, get_methodOop());
duke@0 864 return CompilerOracle::should_break_at(mh);
duke@0 865 }
duke@0 866
duke@0 867 // ------------------------------------------------------------------
duke@0 868 // ciMethod::has_option
duke@0 869 //
duke@0 870 bool ciMethod::has_option(const char* option) {
duke@0 871 check_is_loaded();
duke@0 872 VM_ENTRY_MARK;
duke@0 873 methodHandle mh(THREAD, get_methodOop());
duke@0 874 return CompilerOracle::has_option_string(mh, option);
duke@0 875 }
duke@0 876
duke@0 877 // ------------------------------------------------------------------
duke@0 878 // ciMethod::can_be_compiled
duke@0 879 //
duke@0 880 // Have previous compilations of this method succeeded?
duke@0 881 bool ciMethod::can_be_compiled() {
duke@0 882 check_is_loaded();
duke@0 883 return _is_compilable;
duke@0 884 }
duke@0 885
duke@0 886 // ------------------------------------------------------------------
duke@0 887 // ciMethod::set_not_compilable
duke@0 888 //
duke@0 889 // Tell the VM that this method cannot be compiled at all.
duke@0 890 void ciMethod::set_not_compilable() {
duke@0 891 check_is_loaded();
duke@0 892 VM_ENTRY_MARK;
duke@0 893 _is_compilable = false;
duke@0 894 get_methodOop()->set_not_compilable();
duke@0 895 }
duke@0 896
duke@0 897 // ------------------------------------------------------------------
duke@0 898 // ciMethod::can_be_osr_compiled
duke@0 899 //
duke@0 900 // Have previous compilations of this method succeeded?
duke@0 901 //
duke@0 902 // Implementation note: the VM does not currently keep track
duke@0 903 // of failed OSR compilations per bci. The entry_bci parameter
duke@0 904 // is currently unused.
duke@0 905 bool ciMethod::can_be_osr_compiled(int entry_bci) {
duke@0 906 check_is_loaded();
duke@0 907 VM_ENTRY_MARK;
duke@0 908 return !get_methodOop()->access_flags().is_not_osr_compilable();
duke@0 909 }
duke@0 910
duke@0 911 // ------------------------------------------------------------------
duke@0 912 // ciMethod::has_compiled_code
duke@0 913 bool ciMethod::has_compiled_code() {
duke@0 914 VM_ENTRY_MARK;
duke@0 915 return get_methodOop()->code() != NULL;
duke@0 916 }
duke@0 917
duke@0 918 // ------------------------------------------------------------------
duke@0 919 // ciMethod::instructions_size
duke@0 920 // This is a rough metric for "fat" methods, compared
duke@0 921 // before inlining with InlineSmallCode.
duke@0 922 // The CodeBlob::instructions_size accessor includes
duke@0 923 // junk like exception handler, stubs, and constant table,
duke@0 924 // which are not highly relevant to an inlined method.
duke@0 925 // So we use the more specific accessor nmethod::code_size.
duke@0 926 int ciMethod::instructions_size() {
duke@0 927 GUARDED_VM_ENTRY(
duke@0 928 nmethod* code = get_methodOop()->code();
duke@0 929 // if there's no compiled code or the code was produced by the
duke@0 930 // tier1 profiler return 0 for the code size. This should
duke@0 931 // probably be based on the compilation level of the nmethod but
duke@0 932 // that currently isn't properly recorded.
duke@0 933 if (code == NULL ||
duke@0 934 (TieredCompilation && code->compiler() != NULL && code->compiler()->is_c1())) {
duke@0 935 return 0;
duke@0 936 }
kvn@182 937 return code->code_end() - code->verified_entry_point();
duke@0 938 )
duke@0 939 }
duke@0 940
duke@0 941 // ------------------------------------------------------------------
duke@0 942 // ciMethod::log_nmethod_identity
duke@0 943 void ciMethod::log_nmethod_identity(xmlStream* log) {
duke@0 944 GUARDED_VM_ENTRY(
duke@0 945 nmethod* code = get_methodOop()->code();
duke@0 946 if (code != NULL) {
duke@0 947 code->log_identity(log);
duke@0 948 }
duke@0 949 )
duke@0 950 }
duke@0 951
duke@0 952 // ------------------------------------------------------------------
duke@0 953 // ciMethod::is_not_reached
duke@0 954 bool ciMethod::is_not_reached(int bci) {
duke@0 955 check_is_loaded();
duke@0 956 VM_ENTRY_MARK;
duke@0 957 return Interpreter::is_not_reached(
duke@0 958 methodHandle(THREAD, get_methodOop()), bci);
duke@0 959 }
duke@0 960
duke@0 961 // ------------------------------------------------------------------
duke@0 962 // ciMethod::was_never_executed
duke@0 963 bool ciMethod::was_executed_more_than(int times) {
duke@0 964 VM_ENTRY_MARK;
duke@0 965 return get_methodOop()->was_executed_more_than(times);
duke@0 966 }
duke@0 967
duke@0 968 // ------------------------------------------------------------------
duke@0 969 // ciMethod::has_unloaded_classes_in_signature
duke@0 970 bool ciMethod::has_unloaded_classes_in_signature() {
duke@0 971 VM_ENTRY_MARK;
duke@0 972 {
duke@0 973 EXCEPTION_MARK;
duke@0 974 methodHandle m(THREAD, get_methodOop());
duke@0 975 bool has_unloaded = methodOopDesc::has_unloaded_classes_in_signature(m, (JavaThread *)THREAD);
duke@0 976 if( HAS_PENDING_EXCEPTION ) {
duke@0 977 CLEAR_PENDING_EXCEPTION;
duke@0 978 return true; // Declare that we may have unloaded classes
duke@0 979 }
duke@0 980 return has_unloaded;
duke@0 981 }
duke@0 982 }
duke@0 983
duke@0 984 // ------------------------------------------------------------------
duke@0 985 // ciMethod::is_klass_loaded
duke@0 986 bool ciMethod::is_klass_loaded(int refinfo_index, bool must_be_resolved) const {
duke@0 987 VM_ENTRY_MARK;
duke@0 988 return get_methodOop()->is_klass_loaded(refinfo_index, must_be_resolved);
duke@0 989 }
duke@0 990
duke@0 991 // ------------------------------------------------------------------
duke@0 992 // ciMethod::check_call
duke@0 993 bool ciMethod::check_call(int refinfo_index, bool is_static) const {
duke@0 994 VM_ENTRY_MARK;
duke@0 995 {
duke@0 996 EXCEPTION_MARK;
duke@0 997 HandleMark hm(THREAD);
duke@0 998 constantPoolHandle pool (THREAD, get_methodOop()->constants());
duke@0 999 methodHandle spec_method;
duke@0 1000 KlassHandle spec_klass;
duke@0 1001 LinkResolver::resolve_method(spec_method, spec_klass, pool, refinfo_index, THREAD);
duke@0 1002 if (HAS_PENDING_EXCEPTION) {
duke@0 1003 CLEAR_PENDING_EXCEPTION;
duke@0 1004 return false;
duke@0 1005 } else {
duke@0 1006 return (spec_method->is_static() == is_static);
duke@0 1007 }
duke@0 1008 }
duke@0 1009 return false;
duke@0 1010 }
duke@0 1011
duke@0 1012 // ------------------------------------------------------------------
duke@0 1013 // ciMethod::print_codes
duke@0 1014 //
duke@0 1015 // Print the bytecodes for this method.
duke@0 1016 void ciMethod::print_codes_on(outputStream* st) {
duke@0 1017 check_is_loaded();
duke@0 1018 GUARDED_VM_ENTRY(get_methodOop()->print_codes_on(st);)
duke@0 1019 }
duke@0 1020
duke@0 1021
duke@0 1022 #define FETCH_FLAG_FROM_VM(flag_accessor) { \
duke@0 1023 check_is_loaded(); \
duke@0 1024 VM_ENTRY_MARK; \
duke@0 1025 return get_methodOop()->flag_accessor(); \
duke@0 1026 }
duke@0 1027
duke@0 1028 bool ciMethod::is_empty_method() const { FETCH_FLAG_FROM_VM(is_empty_method); }
duke@0 1029 bool ciMethod::is_vanilla_constructor() const { FETCH_FLAG_FROM_VM(is_vanilla_constructor); }
duke@0 1030 bool ciMethod::has_loops () const { FETCH_FLAG_FROM_VM(has_loops); }
duke@0 1031 bool ciMethod::has_jsrs () const { FETCH_FLAG_FROM_VM(has_jsrs); }
duke@0 1032 bool ciMethod::is_accessor () const { FETCH_FLAG_FROM_VM(is_accessor); }
duke@0 1033 bool ciMethod::is_initializer () const { FETCH_FLAG_FROM_VM(is_initializer); }
duke@0 1034
duke@0 1035 BCEscapeAnalyzer *ciMethod::get_bcea() {
duke@0 1036 if (_bcea == NULL) {
duke@0 1037 _bcea = new (CURRENT_ENV->arena()) BCEscapeAnalyzer(this, NULL);
duke@0 1038 }
duke@0 1039 return _bcea;
duke@0 1040 }
duke@0 1041
duke@0 1042 ciMethodBlocks *ciMethod::get_method_blocks() {
duke@0 1043 Arena *arena = CURRENT_ENV->arena();
duke@0 1044 if (_method_blocks == NULL) {
duke@0 1045 _method_blocks = new (arena) ciMethodBlocks(arena, this);
duke@0 1046 }
duke@0 1047 return _method_blocks;
duke@0 1048 }
duke@0 1049
duke@0 1050 #undef FETCH_FLAG_FROM_VM
duke@0 1051
duke@0 1052
duke@0 1053 // ------------------------------------------------------------------
duke@0 1054 // ciMethod::print_codes
duke@0 1055 //
duke@0 1056 // Print a range of the bytecodes for this method.
duke@0 1057 void ciMethod::print_codes_on(int from, int to, outputStream* st) {
duke@0 1058 check_is_loaded();
duke@0 1059 GUARDED_VM_ENTRY(get_methodOop()->print_codes_on(from, to, st);)
duke@0 1060 }
duke@0 1061
duke@0 1062 // ------------------------------------------------------------------
duke@0 1063 // ciMethod::print_name
duke@0 1064 //
duke@0 1065 // Print the name of this method, including signature and some flags.
duke@0 1066 void ciMethod::print_name(outputStream* st) {
duke@0 1067 check_is_loaded();
duke@0 1068 GUARDED_VM_ENTRY(get_methodOop()->print_name(st);)
duke@0 1069 }
duke@0 1070
duke@0 1071 // ------------------------------------------------------------------
duke@0 1072 // ciMethod::print_short_name
duke@0 1073 //
duke@0 1074 // Print the name of this method, without signature.
duke@0 1075 void ciMethod::print_short_name(outputStream* st) {
duke@0 1076 check_is_loaded();
duke@0 1077 GUARDED_VM_ENTRY(get_methodOop()->print_short_name(st);)
duke@0 1078 }
duke@0 1079
duke@0 1080 // ------------------------------------------------------------------
duke@0 1081 // ciMethod::print_impl
duke@0 1082 //
duke@0 1083 // Implementation of the print method.
duke@0 1084 void ciMethod::print_impl(outputStream* st) {
duke@0 1085 ciObject::print_impl(st);
duke@0 1086 st->print(" name=");
duke@0 1087 name()->print_symbol_on(st);
duke@0 1088 st->print(" holder=");
duke@0 1089 holder()->print_name_on(st);
duke@0 1090 st->print(" signature=");
duke@0 1091 signature()->as_symbol()->print_symbol_on(st);
duke@0 1092 if (is_loaded()) {
duke@0 1093 st->print(" loaded=true flags=");
duke@0 1094 flags().print_member_flags(st);
duke@0 1095 } else {
duke@0 1096 st->print(" loaded=false");
duke@0 1097 }
duke@0 1098 }