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