Mercurial > hg > graal-compiler
comparison src/share/vm/code/nmethod.cpp @ 100:c7c777385a15
6667042: PrintAssembly option does not work without special plugin
Summary: remove old private plugin interface, simplify, rework old plugin to use unchanged Gnu sources
Reviewed-by: kvn, rasbold
author | jrose |
---|---|
date | Wed, 02 Apr 2008 12:09:59 -0700 |
parents | 65a06b4a51b8 |
children | 018d5b58dd4f |
comparison
equal
deleted
inserted
replaced
99:8a4ef4e001d3 | 100:c7c777385a15 |
---|---|
705 assert(compiler->is_c2() || | 705 assert(compiler->is_c2() || |
706 _method->is_static() == (entry_point() == _verified_entry_point), | 706 _method->is_static() == (entry_point() == _verified_entry_point), |
707 " entry points must be same for static methods and vice versa"); | 707 " entry points must be same for static methods and vice versa"); |
708 } | 708 } |
709 | 709 |
710 bool printnmethods = PrintNMethods || CompilerOracle::has_option_string(_method, "PrintNMethods"); | 710 bool printnmethods = PrintNMethods |
711 || CompilerOracle::should_print(_method) | |
712 || CompilerOracle::has_option_string(_method, "PrintNMethods"); | |
711 if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) { | 713 if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) { |
712 print_nmethod(printnmethods); | 714 print_nmethod(printnmethods); |
713 } | 715 } |
714 | 716 |
715 // Note: Do not verify in here as the CodeCache_lock is | 717 // Note: Do not verify in here as the CodeCache_lock is |
796 } | 798 } |
797 } | 799 } |
798 } | 800 } |
799 | 801 |
800 | 802 |
801 #ifndef PRODUCT | |
802 void nmethod::print_nmethod(bool printmethod) { | 803 void nmethod::print_nmethod(bool printmethod) { |
803 ttyLocker ttyl; // keep the following output all in one block | 804 ttyLocker ttyl; // keep the following output all in one block |
804 if (xtty != NULL) { | 805 if (xtty != NULL) { |
805 xtty->begin_head("print_nmethod"); | 806 xtty->begin_head("print_nmethod"); |
806 xtty->stamp(); | 807 xtty->stamp(); |
829 } | 830 } |
830 if (xtty != NULL) { | 831 if (xtty != NULL) { |
831 xtty->tail("print_nmethod"); | 832 xtty->tail("print_nmethod"); |
832 } | 833 } |
833 } | 834 } |
834 #endif | |
835 | 835 |
836 | 836 |
837 void nmethod::set_version(int v) { | 837 void nmethod::set_version(int v) { |
838 flags.version = v; | 838 flags.version = v; |
839 } | 839 } |
1868 } | 1868 } |
1869 } | 1869 } |
1870 } | 1870 } |
1871 } | 1871 } |
1872 | 1872 |
1873 #endif // PRODUCT | |
1873 | 1874 |
1874 // Printing operations | 1875 // Printing operations |
1875 | 1876 |
1876 void nmethod::print() const { | 1877 void nmethod::print() const { |
1877 ResourceMark rm; | 1878 ResourceMark rm; |
1946 oops_begin(), | 1947 oops_begin(), |
1947 oops_end(), | 1948 oops_end(), |
1948 oops_size()); | 1949 oops_size()); |
1949 } | 1950 } |
1950 | 1951 |
1952 void nmethod::print_code() { | |
1953 HandleMark hm; | |
1954 ResourceMark m; | |
1955 Disassembler::decode(this); | |
1956 } | |
1957 | |
1958 | |
1959 #ifndef PRODUCT | |
1951 | 1960 |
1952 void nmethod::print_scopes() { | 1961 void nmethod::print_scopes() { |
1953 // Find the first pc desc for all scopes in the code and print it. | 1962 // Find the first pc desc for all scopes in the code and print it. |
1954 ResourceMark rm; | 1963 ResourceMark rm; |
1955 for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) { | 1964 for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) { |
1974 tty->print_cr(" [nmethod<=klass]%s", k->external_name()); | 1983 tty->print_cr(" [nmethod<=klass]%s", k->external_name()); |
1975 } | 1984 } |
1976 } | 1985 } |
1977 deps.log_dependency(); // put it into the xml log also | 1986 deps.log_dependency(); // put it into the xml log also |
1978 } | 1987 } |
1979 } | |
1980 | |
1981 | |
1982 void nmethod::print_code() { | |
1983 HandleMark hm; | |
1984 ResourceMark m; | |
1985 Disassembler().decode(this); | |
1986 } | 1988 } |
1987 | 1989 |
1988 | 1990 |
1989 void nmethod::print_relocations() { | 1991 void nmethod::print_relocations() { |
1990 ResourceMark m; // in case methods get printed via the debugger | 1992 ResourceMark m; // in case methods get printed via the debugger |
2019 for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) { | 2021 for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) { |
2020 p->print(this); | 2022 p->print(this); |
2021 } | 2023 } |
2022 } | 2024 } |
2023 | 2025 |
2026 #endif // PRODUCT | |
2024 | 2027 |
2025 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { | 2028 const char* nmethod::reloc_string_for(u_char* begin, u_char* end) { |
2026 RelocIterator iter(this, begin, end); | 2029 RelocIterator iter(this, begin, end); |
2027 bool have_one = false; | 2030 bool have_one = false; |
2028 while (iter.next()) { | 2031 while (iter.next()) { |
2053 } | 2056 } |
2054 } | 2057 } |
2055 return have_one ? "other" : NULL; | 2058 return have_one ? "other" : NULL; |
2056 } | 2059 } |
2057 | 2060 |
2058 | |
2059 // Return a the last scope in (begin..end] | 2061 // Return a the last scope in (begin..end] |
2060 ScopeDesc* nmethod::scope_desc_in(address begin, address end) { | 2062 ScopeDesc* nmethod::scope_desc_in(address begin, address end) { |
2061 PcDesc* p = pc_desc_near(begin+1); | 2063 PcDesc* p = pc_desc_near(begin+1); |
2062 if (p != NULL && p->real_pc(this) <= end) { | 2064 if (p != NULL && p->real_pc(this) <= end) { |
2063 return new ScopeDesc(this, p->scope_decode_offset(), | 2065 return new ScopeDesc(this, p->scope_decode_offset(), |
2076 for (int i = 0, imax = oms->size(); i < imax; i++) { | 2078 for (int i = 0, imax = oms->size(); i < imax; i++) { |
2077 OopMap* om = oms->at(i); | 2079 OopMap* om = oms->at(i); |
2078 address pc = base + om->offset(); | 2080 address pc = base + om->offset(); |
2079 if (pc > begin) { | 2081 if (pc > begin) { |
2080 if (pc <= end) { | 2082 if (pc <= end) { |
2081 st->fill_to(column); | 2083 st->move_to(column); |
2082 if (st == tty) { | 2084 st->print("; "); |
2083 st->print("; OopMap "); | 2085 om->print_on(st); |
2084 om->print(); | |
2085 tty->cr(); | |
2086 } else { | |
2087 st->print_cr("; OopMap #%d offset:%d", i, om->offset()); | |
2088 } | |
2089 } | 2086 } |
2090 break; | 2087 break; |
2091 } | 2088 } |
2092 } | 2089 } |
2093 } | 2090 } |
2091 | |
2092 // Print any debug info present at this pc. | |
2094 ScopeDesc* sd = scope_desc_in(begin, end); | 2093 ScopeDesc* sd = scope_desc_in(begin, end); |
2095 if (sd != NULL) { | 2094 if (sd != NULL) { |
2096 st->fill_to(column); | 2095 st->move_to(column); |
2097 if (sd->bci() == SynchronizationEntryBCI) { | 2096 if (sd->bci() == SynchronizationEntryBCI) { |
2098 st->print(";*synchronization entry"); | 2097 st->print(";*synchronization entry"); |
2099 } else { | 2098 } else { |
2100 if (sd->method().is_null()) { | 2099 if (sd->method().is_null()) { |
2101 tty->print("method is NULL"); | 2100 st->print("method is NULL"); |
2102 } else if (sd->method()->is_native()) { | 2101 } else if (sd->method()->is_native()) { |
2103 tty->print("method is native"); | 2102 st->print("method is native"); |
2104 } else { | 2103 } else { |
2105 address bcp = sd->method()->bcp_from(sd->bci()); | 2104 address bcp = sd->method()->bcp_from(sd->bci()); |
2106 Bytecodes::Code bc = Bytecodes::java_code_at(bcp); | 2105 Bytecodes::Code bc = Bytecodes::java_code_at(bcp); |
2107 st->print(";*%s", Bytecodes::name(bc)); | 2106 st->print(";*%s", Bytecodes::name(bc)); |
2108 switch (bc) { | 2107 switch (bc) { |
2135 st->print("<UNKNOWN>"); | 2134 st->print("<UNKNOWN>"); |
2136 } | 2135 } |
2137 } | 2136 } |
2138 } | 2137 } |
2139 } | 2138 } |
2140 st->cr(); | 2139 |
2141 // Print all scopes | 2140 // Print all scopes |
2142 for (;sd != NULL; sd = sd->sender()) { | 2141 for (;sd != NULL; sd = sd->sender()) { |
2143 st->fill_to(column); | 2142 st->move_to(column); |
2144 st->print("; -"); | 2143 st->print("; -"); |
2145 if (sd->method().is_null()) { | 2144 if (sd->method().is_null()) { |
2146 tty->print("method is NULL"); | 2145 st->print("method is NULL"); |
2147 } else { | 2146 } else { |
2148 sd->method()->print_short_name(st); | 2147 sd->method()->print_short_name(st); |
2149 } | 2148 } |
2150 int lineno = sd->method()->line_number_from_bci(sd->bci()); | 2149 int lineno = sd->method()->line_number_from_bci(sd->bci()); |
2151 if (lineno != -1) { | 2150 if (lineno != -1) { |
2159 | 2158 |
2160 // Print relocation information | 2159 // Print relocation information |
2161 const char* str = reloc_string_for(begin, end); | 2160 const char* str = reloc_string_for(begin, end); |
2162 if (str != NULL) { | 2161 if (str != NULL) { |
2163 if (sd != NULL) st->cr(); | 2162 if (sd != NULL) st->cr(); |
2164 st->fill_to(column); | 2163 st->move_to(column); |
2165 st->print("; {%s}", str); | 2164 st->print("; {%s}", str); |
2166 } | 2165 } |
2167 int cont_offset = ImplicitExceptionTable(this).at(begin - instructions_begin()); | 2166 int cont_offset = ImplicitExceptionTable(this).at(begin - instructions_begin()); |
2168 if (cont_offset != 0) { | 2167 if (cont_offset != 0) { |
2169 st->fill_to(column); | 2168 st->move_to(column); |
2170 st->print("; implicit exception: dispatches to " INTPTR_FORMAT, instructions_begin() + cont_offset); | 2169 st->print("; implicit exception: dispatches to " INTPTR_FORMAT, instructions_begin() + cont_offset); |
2171 } | 2170 } |
2172 | 2171 |
2173 } | 2172 } |
2173 | |
2174 #ifndef PRODUCT | |
2174 | 2175 |
2175 void nmethod::print_value_on(outputStream* st) const { | 2176 void nmethod::print_value_on(outputStream* st) const { |
2176 print_on(st, "nmethod"); | 2177 print_on(st, "nmethod"); |
2177 } | 2178 } |
2178 | 2179 |