492 case Bytecodes::_if_icmpgt:
493 case Bytecodes::_if_icmple:
494 case Bytecodes::_if_icmpge:
495 case Bytecodes::_if_acmpeq:
496 case Bytecodes::_if_acmpne:
497 case Bytecodes::_goto:
498 case Bytecodes::_jsr:
499 if( bcs.dest() < bcs.next_bci() ) _access_flags.set_has_loops();
500 break;
501
502 case Bytecodes::_goto_w:
503 case Bytecodes::_jsr_w:
504 if( bcs.dest_w() < bcs.next_bci() ) _access_flags.set_has_loops();
505 break;
506 }
507 }
508 _access_flags.set_loops_flag_init();
509 return _access_flags.has_loops();
510 }
511
512
513 bool Method::is_final_method() const {
514 // %%% Should return true for private methods also,
515 // since there is no way to override them.
516 return is_final() || method_holder()->is_final();
517 }
518
519
520 bool Method::is_strict_method() const {
521 return is_strict();
522 }
523
524
525 bool Method::can_be_statically_bound() const {
526 if (is_final_method()) return true;
527 return vtable_index() == nonvirtual_vtable_index;
528 }
529
530
531 bool Method::is_accessor() const {
532 if (code_size() != 5) return false;
533 if (size_of_parameters() != 1) return false;
534 if (java_code_at(0) != Bytecodes::_aload_0 ) return false;
535 if (java_code_at(1) != Bytecodes::_getfield) return false;
536 if (java_code_at(4) != Bytecodes::_areturn &&
537 java_code_at(4) != Bytecodes::_ireturn ) return false;
538 return true;
539 }
540
541
542 bool Method::is_initializer() const {
543 return name() == vmSymbols::object_initializer_name() || is_static_initializer();
544 }
545
546 bool Method::has_valid_initializer_flags() const {
547 return (is_static() ||
548 method_holder()->major_version() < 51);
549 }
550
950
951
952 bool Method::is_overridden_in(Klass* k) const {
953 InstanceKlass* ik = InstanceKlass::cast(k);
954
955 if (ik->is_interface()) return false;
956
957 // If method is an interface, we skip it - except if it
958 // is a miranda method
959 if (method_holder()->is_interface()) {
960 // Check that method is not a miranda method
961 if (ik->lookup_method(name(), signature()) == NULL) {
962 // No implementation exist - so miranda method
963 return false;
964 }
965 return true;
966 }
967
968 assert(ik->is_subclass_of(method_holder()), "should be subklass");
969 assert(ik->vtable() != NULL, "vtable should exist");
970 if (vtable_index() == nonvirtual_vtable_index) {
971 return false;
972 } else {
973 Method* vt_m = ik->method_at_vtable(vtable_index());
974 return vt_m != this;
975 }
976 }
977
978
979 // give advice about whether this Method* should be cached or not
980 bool Method::should_not_be_cached() const {
981 if (is_old()) {
982 // This method has been redefined. It is either EMCP or obsolete
983 // and we don't want to cache it because that would pin the method
984 // down and prevent it from being collectible if and when it
985 // finishes executing.
986 return true;
987 }
988
989 // caching this method should be just fine
990 return false;
1942 const char* desc = constants()->printable_name_at(table[i].descriptor_cp_index);
1943 int slot = table[i].slot;
1944 st->print_cr(" - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot);
1945 }
1946 }
1947 }
1948 if (code() != NULL) {
1949 st->print (" - compiled code: ");
1950 code()->print_value_on(st);
1951 }
1952 if (is_native()) {
1953 st->print_cr(" - native function: " INTPTR_FORMAT, native_function());
1954 st->print_cr(" - signature handler: " INTPTR_FORMAT, signature_handler());
1955 }
1956 }
1957
1958 #endif //PRODUCT
1959
1960 void Method::print_value_on(outputStream* st) const {
1961 assert(is_method(), "must be method");
1962 st->print_cr(internal_name());
1963 print_address_on(st);
1964 st->print(" ");
1965 name()->print_value_on(st);
1966 st->print(" ");
1967 signature()->print_value_on(st);
1968 st->print(" in ");
1969 method_holder()->print_value_on(st);
1970 if (WizardMode) st->print("[%d,%d]", size_of_parameters(), max_locals());
1971 if (WizardMode && code() != NULL) st->print(" ((nmethod*)%p)", code());
1972 }
1973
1974 #if INCLUDE_SERVICES
1975 // Size Statistics
1976 void Method::collect_statistics(KlassSizeStats *sz) const {
1977 int mysize = sz->count(this);
1978 sz->_method_bytes += mysize;
1979 sz->_method_all_bytes += mysize;
1980 sz->_rw_bytes += mysize;
1981
1982 if (constMethod()) {
1983 constMethod()->collect_statistics(sz);
1984 }
1985 if (method_data()) {
1986 method_data()->collect_statistics(sz);
1987 }
1988 }
1989 #endif // INCLUDE_SERVICES
|
492 case Bytecodes::_if_icmpgt:
493 case Bytecodes::_if_icmple:
494 case Bytecodes::_if_icmpge:
495 case Bytecodes::_if_acmpeq:
496 case Bytecodes::_if_acmpne:
497 case Bytecodes::_goto:
498 case Bytecodes::_jsr:
499 if( bcs.dest() < bcs.next_bci() ) _access_flags.set_has_loops();
500 break;
501
502 case Bytecodes::_goto_w:
503 case Bytecodes::_jsr_w:
504 if( bcs.dest_w() < bcs.next_bci() ) _access_flags.set_has_loops();
505 break;
506 }
507 }
508 _access_flags.set_loops_flag_init();
509 return _access_flags.has_loops();
510 }
511
512 bool Method::is_final_method(AccessFlags class_access_flags) const {
513 // or "does_not_require_vtable_entry"
514 // overpass can occur, is not final (reuses vtable entry)
515 // private methods get vtable entries for backward class compatibility.
516 if (is_overpass()) return false;
517 return is_final() || class_access_flags.is_final();
518 }
519
520 bool Method::is_final_method() const {
521 return is_final_method(method_holder()->access_flags());
522 }
523
524 bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
525 if (is_final_method(class_access_flags)) return true;
526 #ifdef ASSERT
527 bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
528 if (class_access_flags.is_interface()) assert(is_nonv == is_static(), err_msg("is_nonv=%s", is_nonv));
529 #endif
530 assert(valid_vtable_index() || valid_itable_index(), "method must be linked before we ask this question");
531 return vtable_index() == nonvirtual_vtable_index;
532 }
533
534 bool Method::can_be_statically_bound() const {
535 return can_be_statically_bound(method_holder()->access_flags());
536 }
537
538 bool Method::is_accessor() const {
539 if (code_size() != 5) return false;
540 if (size_of_parameters() != 1) return false;
541 if (java_code_at(0) != Bytecodes::_aload_0 ) return false;
542 if (java_code_at(1) != Bytecodes::_getfield) return false;
543 if (java_code_at(4) != Bytecodes::_areturn &&
544 java_code_at(4) != Bytecodes::_ireturn ) return false;
545 return true;
546 }
547
548
549 bool Method::is_initializer() const {
550 return name() == vmSymbols::object_initializer_name() || is_static_initializer();
551 }
552
553 bool Method::has_valid_initializer_flags() const {
554 return (is_static() ||
555 method_holder()->major_version() < 51);
556 }
557
957
958
959 bool Method::is_overridden_in(Klass* k) const {
960 InstanceKlass* ik = InstanceKlass::cast(k);
961
962 if (ik->is_interface()) return false;
963
964 // If method is an interface, we skip it - except if it
965 // is a miranda method
966 if (method_holder()->is_interface()) {
967 // Check that method is not a miranda method
968 if (ik->lookup_method(name(), signature()) == NULL) {
969 // No implementation exist - so miranda method
970 return false;
971 }
972 return true;
973 }
974
975 assert(ik->is_subclass_of(method_holder()), "should be subklass");
976 assert(ik->vtable() != NULL, "vtable should exist");
977 if (!has_vtable_index()) {
978 return false;
979 } else {
980 Method* vt_m = ik->method_at_vtable(vtable_index());
981 return vt_m != this;
982 }
983 }
984
985
986 // give advice about whether this Method* should be cached or not
987 bool Method::should_not_be_cached() const {
988 if (is_old()) {
989 // This method has been redefined. It is either EMCP or obsolete
990 // and we don't want to cache it because that would pin the method
991 // down and prevent it from being collectible if and when it
992 // finishes executing.
993 return true;
994 }
995
996 // caching this method should be just fine
997 return false;
1949 const char* desc = constants()->printable_name_at(table[i].descriptor_cp_index);
1950 int slot = table[i].slot;
1951 st->print_cr(" - %s %s bci=%d len=%d slot=%d", desc, name, bci, len, slot);
1952 }
1953 }
1954 }
1955 if (code() != NULL) {
1956 st->print (" - compiled code: ");
1957 code()->print_value_on(st);
1958 }
1959 if (is_native()) {
1960 st->print_cr(" - native function: " INTPTR_FORMAT, native_function());
1961 st->print_cr(" - signature handler: " INTPTR_FORMAT, signature_handler());
1962 }
1963 }
1964
1965 #endif //PRODUCT
1966
1967 void Method::print_value_on(outputStream* st) const {
1968 assert(is_method(), "must be method");
1969 st->print(internal_name());
1970 print_address_on(st);
1971 st->print(" ");
1972 name()->print_value_on(st);
1973 st->print(" ");
1974 signature()->print_value_on(st);
1975 st->print(" in ");
1976 method_holder()->print_value_on(st);
1977 if (WizardMode) st->print("#%d", _vtable_index);
1978 if (WizardMode) st->print("[%d,%d]", size_of_parameters(), max_locals());
1979 if (WizardMode && code() != NULL) st->print(" ((nmethod*)%p)", code());
1980 }
1981
1982 #if INCLUDE_SERVICES
1983 // Size Statistics
1984 void Method::collect_statistics(KlassSizeStats *sz) const {
1985 int mysize = sz->count(this);
1986 sz->_method_bytes += mysize;
1987 sz->_method_all_bytes += mysize;
1988 sz->_rw_bytes += mysize;
1989
1990 if (constMethod()) {
1991 constMethod()->collect_statistics(sz);
1992 }
1993 if (method_data()) {
1994 method_data()->collect_statistics(sz);
1995 }
1996 }
1997 #endif // INCLUDE_SERVICES
|