Mercurial > hg > graal-compiler
comparison src/share/vm/oops/methodOop.cpp @ 1783:d5d065957597
6953144: Tiered compilation
Summary: Infrastructure for tiered compilation support (interpreter + c1 + c2) for 32 and 64 bit. Simple tiered policy implementation.
Reviewed-by: kvn, never, phh, twisti
author | iveresov |
---|---|
date | Fri, 03 Sep 2010 17:51:07 -0700 |
parents | d2ede61b7a12 |
children | d257356e35f0 |
comparison
equal
deleted
inserted
replaced
1782:f353275af40e | 1783:d5d065957597 |
---|---|
231 unlink_method(); | 231 unlink_method(); |
232 set_interpreter_kind(); | 232 set_interpreter_kind(); |
233 } | 233 } |
234 | 234 |
235 | 235 |
236 bool methodOopDesc::was_executed_more_than(int n) const { | 236 bool methodOopDesc::was_executed_more_than(int n) { |
237 // Invocation counter is reset when the methodOop is compiled. | 237 // Invocation counter is reset when the methodOop is compiled. |
238 // If the method has compiled code we therefore assume it has | 238 // If the method has compiled code we therefore assume it has |
239 // be excuted more than n times. | 239 // be excuted more than n times. |
240 if (is_accessor() || is_empty_method() || (code() != NULL)) { | 240 if (is_accessor() || is_empty_method() || (code() != NULL)) { |
241 // interpreter doesn't bump invocation counter of trivial methods | 241 // interpreter doesn't bump invocation counter of trivial methods |
242 // compiler does not bump invocation counter of compiled methods | 242 // compiler does not bump invocation counter of compiled methods |
243 return true; | 243 return true; |
244 } else if (_invocation_counter.carry()) { | 244 } |
245 else if (_invocation_counter.carry() || (method_data() != NULL && method_data()->invocation_counter()->carry())) { | |
245 // The carry bit is set when the counter overflows and causes | 246 // The carry bit is set when the counter overflows and causes |
246 // a compilation to occur. We don't know how many times | 247 // a compilation to occur. We don't know how many times |
247 // the counter has been reset, so we simply assume it has | 248 // the counter has been reset, so we simply assume it has |
248 // been executed more than n times. | 249 // been executed more than n times. |
249 return true; | 250 return true; |
251 return invocation_count() > n; | 252 return invocation_count() > n; |
252 } | 253 } |
253 } | 254 } |
254 | 255 |
255 #ifndef PRODUCT | 256 #ifndef PRODUCT |
256 void methodOopDesc::print_invocation_count() const { | 257 void methodOopDesc::print_invocation_count() { |
257 if (is_static()) tty->print("static "); | 258 if (is_static()) tty->print("static "); |
258 if (is_final()) tty->print("final "); | 259 if (is_final()) tty->print("final "); |
259 if (is_synchronized()) tty->print("synchronized "); | 260 if (is_synchronized()) tty->print("synchronized "); |
260 if (is_native()) tty->print("native "); | 261 if (is_native()) tty->print("native "); |
261 method_holder()->klass_part()->name()->print_symbol_on(tty); | 262 method_holder()->klass_part()->name()->print_symbol_on(tty); |
572 bool methodOopDesc::is_not_compilable(int comp_level) const { | 573 bool methodOopDesc::is_not_compilable(int comp_level) const { |
573 if (is_method_handle_invoke()) { | 574 if (is_method_handle_invoke()) { |
574 // compilers must recognize this method specially, or not at all | 575 // compilers must recognize this method specially, or not at all |
575 return true; | 576 return true; |
576 } | 577 } |
577 | 578 if (number_of_breakpoints() > 0) { |
578 #ifdef COMPILER2 | 579 return true; |
579 if (is_tier1_compile(comp_level)) { | 580 } |
580 if (is_not_tier1_compilable()) { | 581 if (comp_level == CompLevel_any) { |
581 return true; | 582 return is_not_c1_compilable() || is_not_c2_compilable(); |
582 } | 583 } |
583 } | 584 if (is_c1_compile(comp_level)) { |
584 #endif // COMPILER2 | 585 return is_not_c1_compilable(); |
585 return (_invocation_counter.state() == InvocationCounter::wait_for_nothing) | 586 } |
586 || (number_of_breakpoints() > 0); | 587 if (is_c2_compile(comp_level)) { |
588 return is_not_c2_compilable(); | |
589 } | |
590 return false; | |
587 } | 591 } |
588 | 592 |
589 // call this when compiler finds that this method is not compilable | 593 // call this when compiler finds that this method is not compilable |
590 void methodOopDesc::set_not_compilable(int comp_level, bool report) { | 594 void methodOopDesc::set_not_compilable(int comp_level, bool report) { |
591 if (PrintCompilation && report) { | 595 if (PrintCompilation && report) { |
602 xtty->begin_elem("make_not_compilable thread='%d'", (int) os::current_thread_id()); | 606 xtty->begin_elem("make_not_compilable thread='%d'", (int) os::current_thread_id()); |
603 xtty->method(methodOop(this)); | 607 xtty->method(methodOop(this)); |
604 xtty->stamp(); | 608 xtty->stamp(); |
605 xtty->end_elem(); | 609 xtty->end_elem(); |
606 } | 610 } |
607 #ifdef COMPILER2 | 611 if (comp_level == CompLevel_all) { |
608 if (is_tier1_compile(comp_level)) { | 612 set_not_c1_compilable(); |
609 set_not_tier1_compilable(); | 613 set_not_c2_compilable(); |
610 return; | 614 } else { |
611 } | 615 if (is_c1_compile(comp_level)) { |
612 #endif /* COMPILER2 */ | 616 set_not_c1_compilable(); |
613 assert(comp_level == CompLevel_highest_tier, "unexpected compilation level"); | 617 } else |
614 invocation_counter()->set_state(InvocationCounter::wait_for_nothing); | 618 if (is_c2_compile(comp_level)) { |
615 backedge_counter()->set_state(InvocationCounter::wait_for_nothing); | 619 set_not_c2_compilable(); |
620 } | |
621 } | |
622 CompilationPolicy::policy()->disable_compilation(this); | |
616 } | 623 } |
617 | 624 |
618 // Revert to using the interpreter and clear out the nmethod | 625 // Revert to using the interpreter and clear out the nmethod |
619 void methodOopDesc::clear_code() { | 626 void methodOopDesc::clear_code() { |
620 | 627 |
647 _from_compiled_entry = NULL; | 654 _from_compiled_entry = NULL; |
648 assert(_method_data == NULL, "unexpected method data?"); | 655 assert(_method_data == NULL, "unexpected method data?"); |
649 set_method_data(NULL); | 656 set_method_data(NULL); |
650 set_interpreter_throwout_count(0); | 657 set_interpreter_throwout_count(0); |
651 set_interpreter_invocation_count(0); | 658 set_interpreter_invocation_count(0); |
652 _highest_tier_compile = CompLevel_none; | |
653 } | 659 } |
654 | 660 |
655 // Called when the method_holder is getting linked. Setup entrypoints so the method | 661 // Called when the method_holder is getting linked. Setup entrypoints so the method |
656 // is ready to be called from interpreter, compiler, and vtables. | 662 // is ready to be called from interpreter, compiler, and vtables. |
657 void methodOopDesc::link_method(methodHandle h_method, TRAPS) { | 663 void methodOopDesc::link_method(methodHandle h_method, TRAPS) { |
744 mh->_code = code; // Assign before allowing compiled code to exec | 750 mh->_code = code; // Assign before allowing compiled code to exec |
745 | 751 |
746 int comp_level = code->comp_level(); | 752 int comp_level = code->comp_level(); |
747 // In theory there could be a race here. In practice it is unlikely | 753 // In theory there could be a race here. In practice it is unlikely |
748 // and not worth worrying about. | 754 // and not worth worrying about. |
749 if (comp_level > mh->highest_tier_compile()) { | 755 if (comp_level > mh->highest_comp_level()) { |
750 mh->set_highest_tier_compile(comp_level); | 756 mh->set_highest_comp_level(comp_level); |
751 } | 757 } |
752 | 758 |
753 OrderAccess::storestore(); | 759 OrderAccess::storestore(); |
754 #ifdef SHARK | 760 #ifdef SHARK |
755 mh->_from_interpreted_entry = code->instructions_begin(); | 761 mh->_from_interpreted_entry = code->instructions_begin(); |
1440 void methodOopDesc::clear_all_breakpoints() { | 1446 void methodOopDesc::clear_all_breakpoints() { |
1441 clear_matches(this, -1); | 1447 clear_matches(this, -1); |
1442 } | 1448 } |
1443 | 1449 |
1444 | 1450 |
1451 int methodOopDesc::invocation_count() { | |
1452 if (TieredCompilation) { | |
1453 const methodDataOop mdo = method_data(); | |
1454 if (invocation_counter()->carry() || ((mdo != NULL) ? mdo->invocation_counter()->carry() : false)) { | |
1455 return InvocationCounter::count_limit; | |
1456 } else { | |
1457 return invocation_counter()->count() + ((mdo != NULL) ? mdo->invocation_counter()->count() : 0); | |
1458 } | |
1459 } else { | |
1460 return invocation_counter()->count(); | |
1461 } | |
1462 } | |
1463 | |
1464 int methodOopDesc::backedge_count() { | |
1465 if (TieredCompilation) { | |
1466 const methodDataOop mdo = method_data(); | |
1467 if (backedge_counter()->carry() || ((mdo != NULL) ? mdo->backedge_counter()->carry() : false)) { | |
1468 return InvocationCounter::count_limit; | |
1469 } else { | |
1470 return backedge_counter()->count() + ((mdo != NULL) ? mdo->backedge_counter()->count() : 0); | |
1471 } | |
1472 } else { | |
1473 return backedge_counter()->count(); | |
1474 } | |
1475 } | |
1476 | |
1477 int methodOopDesc::highest_comp_level() const { | |
1478 methodDataOop mdo = method_data(); | |
1479 if (mdo != NULL) { | |
1480 return mdo->highest_comp_level(); | |
1481 } else { | |
1482 return CompLevel_none; | |
1483 } | |
1484 } | |
1485 | |
1486 int methodOopDesc::highest_osr_comp_level() const { | |
1487 methodDataOop mdo = method_data(); | |
1488 if (mdo != NULL) { | |
1489 return mdo->highest_osr_comp_level(); | |
1490 } else { | |
1491 return CompLevel_none; | |
1492 } | |
1493 } | |
1494 | |
1495 void methodOopDesc::set_highest_comp_level(int level) { | |
1496 methodDataOop mdo = method_data(); | |
1497 if (mdo != NULL) { | |
1498 mdo->set_highest_comp_level(level); | |
1499 } | |
1500 } | |
1501 | |
1502 void methodOopDesc::set_highest_osr_comp_level(int level) { | |
1503 methodDataOop mdo = method_data(); | |
1504 if (mdo != NULL) { | |
1505 mdo->set_highest_osr_comp_level(level); | |
1506 } | |
1507 } | |
1508 | |
1445 BreakpointInfo::BreakpointInfo(methodOop m, int bci) { | 1509 BreakpointInfo::BreakpointInfo(methodOop m, int bci) { |
1446 _bci = bci; | 1510 _bci = bci; |
1447 _name_index = m->name_index(); | 1511 _name_index = m->name_index(); |
1448 _signature_index = m->signature_index(); | 1512 _signature_index = m->signature_index(); |
1449 _orig_bytecode = (Bytecodes::Code) *m->bcp_from(_bci); | 1513 _orig_bytecode = (Bytecodes::Code) *m->bcp_from(_bci); |