src/share/vm/code/nmethod.cpp

Print this page




2045   address low_boundary = verified_entry_point();
2046   if (is_not_entrant()) {
2047     low_boundary += NativeJump::instruction_size;
2048     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
2049     // (See comment above.)
2050   }
2051   {
2052     // Visit all immediate references that are embedded in the instruction stream.
2053     RelocIterator iter(this, low_boundary);
2054     while (iter.next()) {
2055       if (iter.type() == relocInfo::metadata_type ) {
2056         metadata_Relocation* r = iter.metadata_reloc();
2057         // In this lmetadata, we must only follow those metadatas directly embedded in
2058         // the code.  Other metadatas (oop_index>0) are seen as part of
2059         // the metadata section below.
2060         assert(1 == (r->metadata_is_immediate()) +
2061                (r->metadata_addr() >= metadata_begin() && r->metadata_addr() < metadata_end()),
2062                "metadata must be found in exactly one place");
2063         if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
2064           Metadata* md = r->metadata_value();
2065           f(md);
2066         }
2067       } else if (iter.type() == relocInfo::virtual_call_type) {
2068         // Check compiledIC holders associated with this nmethod
2069         CompiledIC *ic = CompiledIC_at(&iter);
2070         if (ic->is_icholder_call()) {
2071           CompiledICHolder* cichk = ic->cached_icholder();
2072           f(cichk->holder_method());
2073           f(cichk->holder_klass());
2074         } else {
2075           Metadata* ic_oop = ic->cached_metadata();
2076           if (ic_oop != NULL) {
2077             f(ic_oop);
2078           }
2079         }
2080       }
2081     }
2082   }
2083 
2084   // Visit the metadata section
2085   for (Metadata** p = metadata_begin(); p < metadata_end(); p++) {
2086     if (*p == Universe::non_oop_word() || *p == NULL)  continue;  // skip non-oops
2087     Metadata* md = *p;
2088     f(md);
2089   }
2090 
2091   // Call function Method*, not embedded in these other places.
2092   if (_method != NULL) f(_method);
2093 }
2094 
2095 void nmethod::oops_do(OopClosure* f, bool allow_zombie) {
2096   // make sure the oops ready to receive visitors
2097   assert(allow_zombie || !is_zombie(), "should not call follow on zombie nmethod");
2098   assert(!is_unloaded(), "should not call follow on unloaded nmethod");
2099 
2100   // If the method is not entrant or zombie then a JMP is plastered over the
2101   // first few bytes.  If an oop in the old code was there, that oop
2102   // should not get GC'd.  Skip the first few bytes of oops on
2103   // not-entrant methods.
2104   address low_boundary = verified_entry_point();
2105   if (is_not_entrant()) {
2106     low_boundary += NativeJump::instruction_size;
2107     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
2108     // (See comment above.)
2109   }
2110 
2111   RelocIterator iter(this, low_boundary);
2112 




2045   address low_boundary = verified_entry_point();
2046   if (is_not_entrant()) {
2047     low_boundary += NativeJump::instruction_size;
2048     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
2049     // (See comment above.)
2050   }
2051   {
2052     // Visit all immediate references that are embedded in the instruction stream.
2053     RelocIterator iter(this, low_boundary);
2054     while (iter.next()) {
2055       if (iter.type() == relocInfo::metadata_type ) {
2056         metadata_Relocation* r = iter.metadata_reloc();
2057         // In this lmetadata, we must only follow those metadatas directly embedded in
2058         // the code.  Other metadatas (oop_index>0) are seen as part of
2059         // the metadata section below.
2060         assert(1 == (r->metadata_is_immediate()) +
2061                (r->metadata_addr() >= metadata_begin() && r->metadata_addr() < metadata_end()),
2062                "metadata must be found in exactly one place");
2063         if (r->metadata_is_immediate() && r->metadata_value() != NULL) {
2064           Metadata* md = r->metadata_value();
2065           if (md != _method) f(md);
2066         }
2067       } else if (iter.type() == relocInfo::virtual_call_type) {
2068         // Check compiledIC holders associated with this nmethod
2069         CompiledIC *ic = CompiledIC_at(&iter);
2070         if (ic->is_icholder_call()) {
2071           CompiledICHolder* cichk = ic->cached_icholder();
2072           f(cichk->holder_method());
2073           f(cichk->holder_klass());
2074         } else {
2075           Metadata* ic_oop = ic->cached_metadata();
2076           if (ic_oop != NULL) {
2077             f(ic_oop);
2078           }
2079         }
2080       }
2081     }
2082   }
2083 
2084   // Visit the metadata section
2085   for (Metadata** p = metadata_begin(); p < metadata_end(); p++) {
2086     if (*p == Universe::non_oop_word() || *p == NULL)  continue;  // skip non-oops
2087     Metadata* md = *p;
2088     f(md);
2089   }



2090 }
2091 
2092 void nmethod::oops_do(OopClosure* f, bool allow_zombie) {
2093   // make sure the oops ready to receive visitors
2094   assert(allow_zombie || !is_zombie(), "should not call follow on zombie nmethod");
2095   assert(!is_unloaded(), "should not call follow on unloaded nmethod");
2096 
2097   // If the method is not entrant or zombie then a JMP is plastered over the
2098   // first few bytes.  If an oop in the old code was there, that oop
2099   // should not get GC'd.  Skip the first few bytes of oops on
2100   // not-entrant methods.
2101   address low_boundary = verified_entry_point();
2102   if (is_not_entrant()) {
2103     low_boundary += NativeJump::instruction_size;
2104     // %%% Note:  On SPARC we patch only a 4-byte trap, not a full NativeJump.
2105     // (See comment above.)
2106   }
2107 
2108   RelocIterator iter(this, low_boundary);
2109