1 /*
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
949 }
950 if (PrintExceptionHandlers) {
951 print_handler_table();
952 print_nul_chk_table();
953 }
954 if (xtty != NULL) {
955 xtty->tail("print_nmethod");
956 }
957 }
958
959
960 void nmethod::set_version(int v) {
961 flags.version = v;
962 }
963
964
965 ScopeDesc* nmethod::scope_desc_at(address pc) {
966 PcDesc* pd = pc_desc_at(pc);
967 guarantee(pd != NULL, "scope must be present");
968 return new ScopeDesc(this, pd->scope_decode_offset(),
969 pd->obj_decode_offset());
970 }
971
972
973 void nmethod::clear_inline_caches() {
974 assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
975 if (is_zombie()) {
976 return;
977 }
978
979 RelocIterator iter(this);
980 while (iter.next()) {
981 iter.reloc()->clear_inline_cache();
982 }
983 }
984
985
986 void nmethod::cleanup_inline_caches() {
987
988 assert(SafepointSynchronize::is_at_safepoint() &&
989 !CompiledIC_lock->is_locked() &&
1915 }
1916
1917
1918 void nmethod::verify_interrupt_point(address call_site) {
1919 // This code does not work in release mode since
1920 // owns_lock only is available in debug mode.
1921 CompiledIC* ic = NULL;
1922 Thread *cur = Thread::current();
1923 if (CompiledIC_lock->owner() == cur ||
1924 ((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) &&
1925 SafepointSynchronize::is_at_safepoint())) {
1926 ic = CompiledIC_at(call_site);
1927 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
1928 } else {
1929 MutexLocker ml_verify (CompiledIC_lock);
1930 ic = CompiledIC_at(call_site);
1931 }
1932 PcDesc* pd = pc_desc_at(ic->end_of_call());
1933 assert(pd != NULL, "PcDesc must exist");
1934 for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
1935 pd->obj_decode_offset());
1936 !sd->is_top(); sd = sd->sender()) {
1937 sd->verify();
1938 }
1939 }
1940
1941 void nmethod::verify_scopes() {
1942 if( !method() ) return; // Runtime stubs have no scope
1943 if (method()->is_native()) return; // Ignore stub methods.
1944 // iterate through all interrupt point
1945 // and verify the debug information is valid.
1946 RelocIterator iter((nmethod*)this);
1947 while (iter.next()) {
1948 address stub = NULL;
1949 switch (iter.type()) {
1950 case relocInfo::virtual_call_type:
1951 verify_interrupt_point(iter.addr());
1952 break;
1953 case relocInfo::opt_virtual_call_type:
1954 stub = iter.opt_virtual_call_reloc()->static_stub();
1955 verify_interrupt_point(iter.addr());
2164 case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
2165 case relocInfo::static_call_type: return "static_call";
2166 case relocInfo::static_stub_type: return "static_stub";
2167 case relocInfo::runtime_call_type: return "runtime_call";
2168 case relocInfo::external_word_type: return "external_word";
2169 case relocInfo::internal_word_type: return "internal_word";
2170 case relocInfo::section_word_type: return "section_word";
2171 case relocInfo::poll_type: return "poll";
2172 case relocInfo::poll_return_type: return "poll_return";
2173 case relocInfo::type_mask: return "type_bit_mask";
2174 }
2175 }
2176 return have_one ? "other" : NULL;
2177 }
2178
2179 // Return a the last scope in (begin..end]
2180 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
2181 PcDesc* p = pc_desc_near(begin+1);
2182 if (p != NULL && p->real_pc(this) <= end) {
2183 return new ScopeDesc(this, p->scope_decode_offset(),
2184 p->obj_decode_offset());
2185 }
2186 return NULL;
2187 }
2188
2189 void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, u_char* end) {
2190 // First, find an oopmap in (begin, end].
2191 // We use the odd half-closed interval so that oop maps and scope descs
2192 // which are tied to the byte after a call are printed with the call itself.
2193 address base = instructions_begin();
2194 OopMapSet* oms = oop_maps();
2195 if (oms != NULL) {
2196 for (int i = 0, imax = oms->size(); i < imax; i++) {
2197 OopMap* om = oms->at(i);
2198 address pc = base + om->offset();
2199 if (pc > begin) {
2200 if (pc <= end) {
2201 st->move_to(column);
2202 st->print("; ");
2203 om->print_on(st);
2204 }
|
1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
949 }
950 if (PrintExceptionHandlers) {
951 print_handler_table();
952 print_nul_chk_table();
953 }
954 if (xtty != NULL) {
955 xtty->tail("print_nmethod");
956 }
957 }
958
959
960 void nmethod::set_version(int v) {
961 flags.version = v;
962 }
963
964
965 ScopeDesc* nmethod::scope_desc_at(address pc) {
966 PcDesc* pd = pc_desc_at(pc);
967 guarantee(pd != NULL, "scope must be present");
968 return new ScopeDesc(this, pd->scope_decode_offset(),
969 pd->obj_decode_offset(), pd->should_reexecute());
970 }
971
972
973 void nmethod::clear_inline_caches() {
974 assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
975 if (is_zombie()) {
976 return;
977 }
978
979 RelocIterator iter(this);
980 while (iter.next()) {
981 iter.reloc()->clear_inline_cache();
982 }
983 }
984
985
986 void nmethod::cleanup_inline_caches() {
987
988 assert(SafepointSynchronize::is_at_safepoint() &&
989 !CompiledIC_lock->is_locked() &&
1915 }
1916
1917
1918 void nmethod::verify_interrupt_point(address call_site) {
1919 // This code does not work in release mode since
1920 // owns_lock only is available in debug mode.
1921 CompiledIC* ic = NULL;
1922 Thread *cur = Thread::current();
1923 if (CompiledIC_lock->owner() == cur ||
1924 ((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) &&
1925 SafepointSynchronize::is_at_safepoint())) {
1926 ic = CompiledIC_at(call_site);
1927 CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
1928 } else {
1929 MutexLocker ml_verify (CompiledIC_lock);
1930 ic = CompiledIC_at(call_site);
1931 }
1932 PcDesc* pd = pc_desc_at(ic->end_of_call());
1933 assert(pd != NULL, "PcDesc must exist");
1934 for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
1935 pd->obj_decode_offset(), pd->should_reexecute());
1936 !sd->is_top(); sd = sd->sender()) {
1937 sd->verify();
1938 }
1939 }
1940
1941 void nmethod::verify_scopes() {
1942 if( !method() ) return; // Runtime stubs have no scope
1943 if (method()->is_native()) return; // Ignore stub methods.
1944 // iterate through all interrupt point
1945 // and verify the debug information is valid.
1946 RelocIterator iter((nmethod*)this);
1947 while (iter.next()) {
1948 address stub = NULL;
1949 switch (iter.type()) {
1950 case relocInfo::virtual_call_type:
1951 verify_interrupt_point(iter.addr());
1952 break;
1953 case relocInfo::opt_virtual_call_type:
1954 stub = iter.opt_virtual_call_reloc()->static_stub();
1955 verify_interrupt_point(iter.addr());
2164 case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
2165 case relocInfo::static_call_type: return "static_call";
2166 case relocInfo::static_stub_type: return "static_stub";
2167 case relocInfo::runtime_call_type: return "runtime_call";
2168 case relocInfo::external_word_type: return "external_word";
2169 case relocInfo::internal_word_type: return "internal_word";
2170 case relocInfo::section_word_type: return "section_word";
2171 case relocInfo::poll_type: return "poll";
2172 case relocInfo::poll_return_type: return "poll_return";
2173 case relocInfo::type_mask: return "type_bit_mask";
2174 }
2175 }
2176 return have_one ? "other" : NULL;
2177 }
2178
2179 // Return a the last scope in (begin..end]
2180 ScopeDesc* nmethod::scope_desc_in(address begin, address end) {
2181 PcDesc* p = pc_desc_near(begin+1);
2182 if (p != NULL && p->real_pc(this) <= end) {
2183 return new ScopeDesc(this, p->scope_decode_offset(),
2184 p->obj_decode_offset(), p->should_reexecute());
2185 }
2186 return NULL;
2187 }
2188
2189 void nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, u_char* end) {
2190 // First, find an oopmap in (begin, end].
2191 // We use the odd half-closed interval so that oop maps and scope descs
2192 // which are tied to the byte after a call are printed with the call itself.
2193 address base = instructions_begin();
2194 OopMapSet* oms = oop_maps();
2195 if (oms != NULL) {
2196 for (int i = 0, imax = oms->size(); i < imax; i++) {
2197 OopMap* om = oms->at(i);
2198 address pc = base + om->offset();
2199 if (pc > begin) {
2200 if (pc <= end) {
2201 st->move_to(column);
2202 st->print("; ");
2203 om->print_on(st);
2204 }
|