< prev index next >

src/share/vm/code/nmethod.cpp

Print this page




2073 
2074 void nmethodLocker::unlock_nmethod(CompiledMethod* cm) {
2075   if (cm == NULL)  return;
2076   if (cm->is_aot()) return;  // FIXME: Revisit once _lock_count is added to aot_method
2077   nmethod* nm = cm->as_nmethod();
2078   Atomic::dec(&nm->_lock_count);
2079   assert(nm->_lock_count >= 0, "unmatched nmethod lock/unlock");
2080 }
2081 
2082 
2083 // -----------------------------------------------------------------------------
2084 // Verification
2085 
2086 class VerifyOopsClosure: public OopClosure {
2087   nmethod* _nm;
2088   bool     _ok;
2089 public:
2090   VerifyOopsClosure(nmethod* nm) : _nm(nm), _ok(true) { }
2091   bool ok() { return _ok; }
2092   virtual void do_oop(oop* p) {
2093     if ((*p) == NULL || (*p)->is_oop())  return;
2094     if (_ok) {
2095       _nm->print_nmethod(true);
2096       _ok = false;
2097     }
2098     tty->print_cr("*** non-oop " PTR_FORMAT " found at " PTR_FORMAT " (offset %d)",
2099                   p2i(*p), p2i(p), (int)((intptr_t)p - (intptr_t)_nm));
2100   }
2101   virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2102 };
2103 
2104 void nmethod::verify() {
2105 
2106   // Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
2107   // seems odd.
2108 
2109   if (is_zombie() || is_not_entrant() || is_unloaded())
2110     return;
2111 
2112   // Make sure all the entry points are correctly aligned for patching.
2113   NativeJump::check_verified_entry_alignment(entry_point(), verified_entry_point());
2114 
2115   // assert(method()->is_oop(), "must be valid");
2116 
2117   ResourceMark rm;
2118 
2119   if (!CodeCache::contains(this)) {
2120     fatal("nmethod at " INTPTR_FORMAT " not in zone", p2i(this));
2121   }
2122 
2123   if(is_native_method() )
2124     return;
2125 
2126   nmethod* nm = CodeCache::find_nmethod(verified_entry_point());
2127   if (nm != this) {
2128     fatal("findNMethod did not find this nmethod (" INTPTR_FORMAT ")", p2i(this));
2129   }
2130 
2131   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
2132     if (! p->verify(this)) {
2133       tty->print_cr("\t\tin nmethod at " INTPTR_FORMAT " (pcs)", p2i(this));
2134     }
2135   }




2073 
2074 void nmethodLocker::unlock_nmethod(CompiledMethod* cm) {
2075   if (cm == NULL)  return;
2076   if (cm->is_aot()) return;  // FIXME: Revisit once _lock_count is added to aot_method
2077   nmethod* nm = cm->as_nmethod();
2078   Atomic::dec(&nm->_lock_count);
2079   assert(nm->_lock_count >= 0, "unmatched nmethod lock/unlock");
2080 }
2081 
2082 
2083 // -----------------------------------------------------------------------------
2084 // Verification
2085 
2086 class VerifyOopsClosure: public OopClosure {
2087   nmethod* _nm;
2088   bool     _ok;
2089 public:
2090   VerifyOopsClosure(nmethod* nm) : _nm(nm), _ok(true) { }
2091   bool ok() { return _ok; }
2092   virtual void do_oop(oop* p) {
2093     if ((*p) == NULL || oopDesc::is_oop(*p))  return;
2094     if (_ok) {
2095       _nm->print_nmethod(true);
2096       _ok = false;
2097     }
2098     tty->print_cr("*** non-oop " PTR_FORMAT " found at " PTR_FORMAT " (offset %d)",
2099                   p2i(*p), p2i(p), (int)((intptr_t)p - (intptr_t)_nm));
2100   }
2101   virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2102 };
2103 
2104 void nmethod::verify() {
2105 
2106   // Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
2107   // seems odd.
2108 
2109   if (is_zombie() || is_not_entrant() || is_unloaded())
2110     return;
2111 
2112   // Make sure all the entry points are correctly aligned for patching.
2113   NativeJump::check_verified_entry_alignment(entry_point(), verified_entry_point());
2114 
2115   // assert(oopDesc::is_oop(method()), "must be valid");
2116 
2117   ResourceMark rm;
2118 
2119   if (!CodeCache::contains(this)) {
2120     fatal("nmethod at " INTPTR_FORMAT " not in zone", p2i(this));
2121   }
2122 
2123   if(is_native_method() )
2124     return;
2125 
2126   nmethod* nm = CodeCache::find_nmethod(verified_entry_point());
2127   if (nm != this) {
2128     fatal("findNMethod did not find this nmethod (" INTPTR_FORMAT ")", p2i(this));
2129   }
2130 
2131   for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
2132     if (! p->verify(this)) {
2133       tty->print_cr("\t\tin nmethod at " INTPTR_FORMAT " (pcs)", p2i(this));
2134     }
2135   }


< prev index next >