/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "code/codeCache.hpp"
#include "code/compiledIC.hpp"
#include "code/dependencies.hpp"
#include "code/nmethod.hpp"
#include "code/scopeDesc.hpp"
#include "compiler/abstractCompiler.hpp"
#include "compiler/compileBroker.hpp"
#include "compiler/compileLog.hpp"
#include "compiler/compilerOracle.hpp"
#include "compiler/disassembler.hpp"
#include "interpreter/bytecode.hpp"
#include "oops/methodDataOop.hpp"
#include "prims/jvmtiRedefineClassesTrace.hpp"
#include "prims/jvmtiImpl.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/sweeper.hpp"
#include "utilities/dtrace.hpp"
#include "utilities/events.hpp"
#include "utilities/xmlstream.hpp"
#ifdef SHARK
#include "shark/sharkCompiler.hpp"
#endif
#ifdef DTRACE_ENABLED
// Only bother with this argument setup if dtrace is available
#ifndef USDT2
const char*, int, const char*, int, const char*, int, void*, size_t);
char*, int, char*, int, char*, int);
{ \
if (m != NULL) { \
} \
}
#else /* USDT2 */
{ \
if (m != NULL) { \
} \
}
#endif /* USDT2 */
#else // ndef DTRACE_ENABLED
#endif
if (is_native_method()) return false;
}
if (is_native_method()) return false;
}
if (is_native_method()) return false;
}
//---------------------------------------------------------------------------------
// NMethod statistics
// They are printed under various flags, including:
// PrintC1Statistics, PrintOptoStatistics, LogVMOutput, and LogCompilation.
// (In the latter two cases, they like other stats are printed to the log only.)
#ifndef PRODUCT
// These variables are put into one block to reduce relocations
// and make it simpler to print from the debugger.
static
struct nmethod_stats_struct {
int nmethod_count;
int total_size;
int relocation_size;
int consts_size;
int insts_size;
int stub_size;
int scopes_data_size;
int scopes_pcs_size;
int dependencies_size;
int handler_table_size;
int nul_chk_table_size;
int oops_size;
nmethod_count += 1;
}
void print_nmethod_stats() {
if (nmethod_count == 0) return;
}
int native_nmethod_count;
int native_total_size;
int native_insts_size;
int native_oops_size;
native_nmethod_count += 1;
}
void print_native_nmethod_stats() {
if (native_nmethod_count == 0) return;
}
void print_pc_stats() {
(double)(pc_desc_tests + pc_desc_searches)
/ pc_desc_queries);
}
#endif //PRODUCT
//---------------------------------------------------------------------------------
_count = 0;
}
return (test_address(pc));
}
return NULL;
}
return true;
}
return false;
}
for (int i=0; i<count(); i++) {
return handler_at(i);
}
}
return NULL;
}
if (count() < cache_size) {
return true;
}
return false;
}
// private method for handling exception cache
// These methods are private, and used to manipulate the exception cache
// directly.
return ec;
}
}
return NULL;
}
//-----------------------------------------------------------------------------
// Helper used by both find_pc_desc methods.
if (!approximate)
else
}
if (initial_pc_desc == NULL) {
return;
}
// reset the cache by filling it with benign (non-null) values
for (int i = 0; i < cache_size; i++)
_pc_descs[i] = initial_pc_desc;
}
// Note: one might think that caching the most recently
// read value separately would be a win, but one would be
// wrong. When many threads are updating it, the cache
// line it's in would bounce between caches, negating
// any benefit.
// In order to prevent race conditions do not load cache elements
// repeatedly, but use a local copy:
// Step one: Check the most recently added value.
return res;
}
// Step two: Check the rest of the LRU cache.
for (int i = 1; i < cache_size; ++i) {
return res;
}
}
// Report failure.
return NULL;
}
// Update the LRU cache by shifting pc_desc forward.
for (int i = 0; i < cache_size; i++) {
}
}
// adjust pcs_size so that it is a multiple of both oopSize and
// sizeof(PcDesc) (assumes that if sizeof(PcDesc) is not a multiple
// of oopSize, then 2*sizeof(PcDesc) is)
}
return nsize;
}
//-----------------------------------------------------------------------------
if (exception_cache() != NULL) {
}
}
// find the previous and next entry of ec
}
// now: curr == ec
} else {
}
delete curr;
}
// public method for accessing the exception cache
// These are the public access methods.
// We never grab a lock to read the exception cache, so we may
// have false negatives. This is okay, as it can only happen during
// the first few exception lookups for a given nmethod.
return ret_val;
}
}
return NULL;
}
// There are potential race conditions during exception cache updates, so we
// must own the ExceptionCache_lock before doing ANY modifications. Because
// we don't lock during reads, it is possible to have several threads attempt
// to update the cache with the same data. We need to check for already inserted
// copies of the current data before adding it.
}
}
//-------------end of code for ExceptionCache--------------
return
consts_size() +
insts_size() +
stub_size() +
scopes_data_size() +
scopes_pcs_size() +
}
if (is_osr_method()) return "osr";
return NULL;
}
// Fill in default values for various flag fields
_has_unsafe_access = 0;
_has_wide_vectors = 0;
_lock_count = 0;
_unload_reported = false; // jvmti state
#ifdef ASSERT
_oops_are_stale = false;
#endif
_jmethod_id = NULL;
_scavenge_root_state = 0;
#ifdef HAVE_DTRACE_H
_trap_offset = 0;
#endif // def HAVE_DTRACE_H
}
int compile_id,
int vep_offset,
int frame_complete,
int frame_size,
// create nmethod
{
nm = new (native_nmethod_size)
oop_maps);
}
// verify nmethod
nm->log_new_nmethod();
}
return nm;
}
#ifdef HAVE_DTRACE_H
int vep_offset,
int trap_offset,
int frame_complete,
int frame_size) {
// create nmethod
{
}
// verify nmethod
nm->log_new_nmethod();
}
return nm;
}
#endif // def HAVE_DTRACE_H
int compile_id,
int entry_bci,
int orig_pc_offset,
int comp_level
)
{
// create nmethod
int nmethod_size =
nm = new (nmethod_size)
// To make dependency checking during class loading fast, record
// the nmethod dependencies in the classes it is dependent on.
// This allows the dependency checking code to simply walk the
// class hierarchy above the loaded class, checking only nmethods
// which are dependent on those classes. The slow way is to
// check every nmethod for dependencies which makes it linear in
// the number of methods compiled. For applications with a lot
// classes the slow way is too slow.
// record this nmethod as dependent on this klass
}
}
}
// verify nmethod
nm->log_new_nmethod();
}
// done
return nm;
}
// For native wrappers
int nmethod_size,
int compile_id,
int frame_size,
{
{
// We have no exception handler or deopt handler make the
// values something that will never match a pc like the nmethod vtable entry
_exception_offset = 0;
_deoptimize_offset = 0;
_orig_pc_offset = 0;
_stub_offset = data_offset();
_oops_offset = data_offset();
code_buffer->copy_oops_to(this);
if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
CodeCache::add_scavenge_root_nmethod(this);
}
}
// This output goes directly to the tty, not the compiler log.
// To enable tools to match it up with the compilation activity,
// be sure to tag this tty output with the compile ID.
}
// print the header part first
print();
// then print the requested information
if (PrintNativeNMethods) {
print_code();
}
}
if (PrintRelocations) {
}
}
}
}
// For dtrace wrappers
#ifdef HAVE_DTRACE_H
int nmethod_size,
int frame_size)
{
{
// We have no exception handler or deopt handler make the
// values something that will never match a pc like the nmethod vtable entry
_exception_offset = 0;
_deoptimize_offset = 0;
_unwind_handler_offset = -1;
_orig_pc_offset = 0;
_stub_offset = data_offset();
_oops_offset = data_offset();
_compile_id = 0; // default
code_buffer->copy_oops_to(this);
}
// This output goes directly to the tty, not the compiler log.
// To enable tools to match it up with the compilation activity,
// be sure to tag this tty output with the compile ID.
}
// print the header part first
print();
// then print the requested information
if (PrintNMethods) {
print_code();
}
if (PrintRelocations) {
}
}
}
}
#endif // def HAVE_DTRACE_H
}
int nmethod_size,
int compile_id,
int entry_bci,
int orig_pc_offset,
int frame_size,
int comp_level
)
{
{
// Section offsets
// Exception handler and deopt handler are in the stub section
} else {
_deoptimize_mh_offset = -1;
}
} else {
_unwind_handler_offset = -1;
}
_oops_offset = data_offset();
// Copy contents of ScopeDescRecorder to nmethod
code_buffer->copy_oops_to(this);
debug_info->copy_to(this);
dependencies->copy_to(this);
if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
CodeCache::add_scavenge_root_nmethod(this);
}
// Copy contents of ExceptionHandlerTable to nmethod
handler_table->copy_to(this);
nul_chk_table->copy_to(this);
// we use the information of entry points to find out if a method is
// static or non static
" entry points must be same for static methods and vice versa");
}
if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
}
}
// Print a short set of xml attributes to identify this nmethod. The
// output should be embedded in some other element.
}
if (TieredCompilation) {
}
}
}
}
// Print out more verbose output usually for a newly created nmethod.
if (WizardMode) {
} else {
}
}
}
}
// print the header part first
print();
// then print the requested information
if (printmethod) {
print_code();
print_pcs();
if (oop_maps()) {
}
}
if (PrintDebugInfo) {
print_scopes();
}
if (PrintRelocations) {
}
if (PrintDependencies) {
}
if (PrintExceptionHandlers) {
}
}
}
// Promote one word from an assembly-time handle to a live embedded oop.
// As a special case, IC oops are initialized to 1 or -1.
} else {
}
}
//assert(oops_size() == 0, "do this handshake just once, please");
}
// Now we can fix up all the oops in the code. We need to do this
// in the code because the assembler uses jobjects as placeholders.
// The code and relocations have already been initialized by the
// CodeBlob constructor, so it is valid even at this early point to
// iterate over relocations and patch the code.
}
return true;
}
return false;
}
return true;
}
return false;
}
// re-patch all oop-bearing instructions, just in case some oops moved
}
// Refresh the oop-related bits of this instruction.
}
// There must not be any interfering patches or breakpoints.
"no active breakpoint");
}
}
// Ensure sure that the code matches the current oop values
if (!reloc->oop_is_immediate()) {
}
}
}
}
pd->return_oop());
}
if (is_zombie()) {
return;
}
RelocIterator iter(this);
}
}
// If the method is not entrant or zombie then a JMP is plastered over the
// first few bytes. If an oop in the old code was there, that oop
// should not get GC'd. Skip the first few bytes of oops on
// not-entrant methods.
if (!is_in_use()) {
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
// This means that the low_boundary is going to be a little too high.
// This shouldn't matter, since oops of non-entrant methods are never used.
// In fact, why are we bothering to look at oops in a non-entrant method??
}
// Find all calls in an nmethod, and clear the ones that points to zombie methods
case relocInfo::virtual_call_type:
case relocInfo::opt_virtual_call_type: {
// Ok, to lookup references to zombies here
// Clean inline caches pointing to both zombie and not_entrant methods
}
break;
}
case relocInfo::static_call_type: {
// Clean inline caches pointing to both zombie and not_entrant methods
}
break;
}
}
}
}
// This is a private interface with the sweeper.
// Set the traversal mark to ensure that the sweeper does 2
// cleaning passes before moving to zombie.
}
// Tell if a non-entrant method can be converted to a zombie (i.e.,
// there are no activations on the stack, not in use by the VM,
// and not in use by the ServiceThread)
// Since the nmethod sweeper only does partial sweep the sweeper's traversal
// count can be greater than the stack traversal count before it hits the
// nmethod for the second time.
!is_locked_by_vm();
}
if (!is_compiled_by_c2()) return;
// Could be gated by ProfileTraps, but do not bother...
if (m == NULL) return;
// There is a benign race here. See comments in methodDataOop.hpp.
}
// Since this nmethod is being unloaded, make sure that dependencies
// recorded in instanceKlasses get flushed and pass non-NULL closure to
// indicate that this work is being done during a GC.
// A non-NULL is_alive closure indicates that this is being called during GC.
// Break cycle between nmethod & method
if (TraceClassUnloading && WizardMode) {
" unloadable], methodOop(" INTPTR_FORMAT
}
// Unlink the osr method, so we do not look this up again
if (is_osr_method()) {
}
// If _method is already NULL the methodOop is about to be unloaded,
// so we don't have to break the cycle. Note that it is possible to
// have the methodOop live here, in case we unload the nmethod because
// it is pointing to some oop (other than the methodOop) being unloaded.
// OSR methods point to the methodOop, but the methodOop does not
// point back!
}
}
// Make the class unloaded - i.e., change state and notify sweeper
if (is_in_use()) {
// Transitioning directly from live to unloaded -- so
// we need to force a cache clean-up; remember this
// for later on.
CodeCache::set_needs_cache_clean(true);
}
// Log the unloading.
// The methodOop is gone at this point
//set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods
NMethodSweeper::notify(this);
}
// Remove from list of active nmethods
// Set entry as invalid
}
if (LogCompilation) {
os::current_thread_id());
} else {
os::current_thread_id(),
}
}
}
}
}
// Common functionality for both make_not_entrant and make_zombie
// Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
nmethodLocker nml(this);
{
// invalidate osr nmethod before acquiring the patching lock since
// they both acquire leaf locks and we don't want a deadlock.
// This logic is equivalent to the logic below for patching the
// verified entry point of regular methods.
if (is_osr_method()) {
// this effectively makes the osr nmethod not entrant
}
// Enter critical section. Does not block for safepoint.
// another thread already performed this transition so nothing
// to do, but return false to indicate this.
return false;
}
// The caller can be calling the method statically or through an inline
// cache call.
if (!is_osr_method() && !is_not_entrant()) {
}
if (is_in_use()) {
// It's a true state change, so mark the method as decompiled.
// Do it only for transition from alive.
}
// Change state
// Log the transition once
// Remove nmethod from method.
// We need to check if both the _code and _from_compiled_code_entry_point
// refer to this nmethod because there is a race in setting these two fields
// in methodOop as seen in bugid 4947125.
// If the vep() points to the zombie nmethod, the memory for the nmethod
// could be flushed and the compiler and vtable stubs could still call
// through it.
method()->clear_code();
}
if (state == not_entrant) {
}
} // leave critical region under Patching_lock
// When the nmethod becomes zombie it is no longer alive so the
// dependencies must be flushed. nmethods in the not_entrant
// state will be flushed later when the transition to zombie
// happens or they get unloaded.
{
// Flushing dependecies must be done before any possible
// safepoint can sneak in, otherwise the oops used by the
// dependency logic could have become stale.
}
// zombie only - if a JVMTI agent has enabled the CompiledMethodUnload
// event and it hasn't already been reported for this nmethod then
// report it now. The event may have been reported earilier if the GC
// marked it for unloading). JvmtiDeferredEventQueue support means
// we no longer go to a safepoint here.
#ifdef ASSERT
// It's no longer safe to access the oops section since zombie
// nmethods aren't scanned for GC.
_oops_are_stale = true;
#endif
} else {
}
if (TraceCreateZombies) {
tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie");
}
// Make sweeper aware that there is a zombie method that needs to be removed
NMethodSweeper::notify(this);
return true;
}
// Note that there are no valid oops in the nmethod anymore.
assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation");
// completely deallocate this method
if (PrintMethodFlushing) {
tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb",
}
// We need to deallocate any ExceptionCache data.
// Note that we do not need to grab the nmethod lock for this, it
// better be thread safe if we're disposing of it!
delete ec;
}
if (on_scavenge_root_list()) {
CodeCache::drop_scavenge_root_nmethod(this);
}
if (is_speculatively_disconnected()) {
CodeCache::remove_saved_code(this);
}
#ifdef SHARK
#endif // SHARK
}
//
// Notify all classes this nmethod is dependent on that it is no
// longer dependent. This should only be called in two situations.
// First, when a nmethod transitions to a zombie all dependents need
// to be clear. Since zombification happens at a safepoint there's no
// synchronization issues. The second place is a little more tricky.
// During phase 1 of mark sweep class unloading may happen and as a
// result some nmethods may get unloaded. In this case the flushing
// of dependencies must happen during phase 1 since after GC any
// dependencies in the unloaded nmethod won't be updated, so
// traversing the dependency information in unsafe. In that case this
// function is called with a non-NULL argument and this function only
// notifies instanceKlasses that are reachable
"is_alive is non-NULL if and only if we are called during GC");
if (!has_flushed_dependencies()) {
// During GC the is_alive closure is non-NULL, and is used to
// determine liveness of dependees that need to be updated.
}
}
}
}
// If this oop is not live, the nmethod can be unloaded.
return false;
}
if (obj->is_compiledICHolder()) {
if (is_alive->do_object_b(
// The oop should be kept alive
return false;
}
}
// If ScavengeRootsInCode is true, an nmethod might be unloaded
// simply because one of its constant oops has gone dead.
// No actual classes need to be unloaded in order for this to occur.
return true;
}
// ------------------------------------------------------------------
// post_compiled_method_load_event
// new method for install_code() path
// Transfer information from compilation to jvmti
#ifndef USDT2
insts_begin(), insts_size());
#else /* USDT2 */
insts_begin(), insts_size());
#endif /* USDT2 */
if (JvmtiExport::should_post_compiled_method_load() ||
}
if (JvmtiExport::should_post_compiled_method_load()) {
// Let the Service thread (which is a real Java thread) post the event
}
}
if (_jmethod_id == NULL) {
// Cache the jmethod_id since it can no longer be looked up once the
// method itself has been marked for unloading.
}
return _jmethod_id;
}
if (unload_reported()) {
// During unloading we transition to unloaded and then to zombie
// and the unloading is reported during the first transition.
return;
}
// If a JVMTI agent has enabled the CompiledMethodUnload event then
// post the event. Sometime later this nmethod will be made a zombie
// by the sweeper but the methodOop will not be valid at that point.
// If the _jmethod_id is null then no load event was ever requested
// so don't bother posting the unload. The main reason for this is
// that the jmethodID is a weak reference to the methodOop so if
// it's being unloaded there's no way to look it up since the weak
// ref will have been cleared.
_jmethod_id, insts_begin());
if (SafepointSynchronize::is_at_safepoint()) {
// Don't want to take the queueing lock. Add it as pending and
// it will get enqueued later.
} else {
}
}
// The JVMTI CompiledMethodUnload event can be enabled or disabled at
// any time. As the nmethod is being unloaded now we mark it has
// having the unload event reported - this will ensure that we don't
// attempt to report the event in the unlikely scenario where the
// event is enabled at the time the nmethod is made a zombie.
}
// GC to unload an nmethod if it contains otherwise unreachable
// oops.
// Make sure the oop's ready to receive visitors
"should not call follow on zombie or unloaded nmethod");
// If the method is not entrant then a JMP is plastered over the
// first few bytes. If an oop in the old code was there, that oop
// should not get GC'd. Skip the first few bytes of oops on
// not-entrant methods.
if (is_not_entrant()) {
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
// (See comment above.)
}
// The RedefineClasses() API can cause the class unloading invariant
// to no longer be true. See jvmtiExport.hpp for details.
// Also, leave a debugging breadcrumb in local flag.
if (a_class_was_redefined) {
// This set of the unloading_occurred flag is done before the
// call to post_compiled_method_unload() so that the unloading
// of this nmethod is reported.
unloading_occurred = true;
}
// Follow methodOop
return;
}
// Exception cache
}
}
// If class unloading occurred we first iterate over all inline caches and
// clear ICs where the cached oop is referring to an unloaded klass or method.
// The remaining live cached oops will be traversed in the relocInfo::oop_type
// iteration below.
if (unloading_occurred) {
// The only exception is compiledICHolder oops which may
// yet be marked below. (We check this further below).
if (ic_oop->is_compiledICHolder()) {
if (is_alive->do_object_b(
continue;
}
}
ic->set_to_clean();
"cached oop in IC should be cleared");
}
}
}
}
// Compiled code
// In this loop, we must only traverse those oops directly embedded in
// the code. Other oops (oop_index>0) are seen as part of scopes_oops.
"oop must be found in exactly one place");
return;
}
}
}
}
// Scopes
return;
}
}
#ifndef PRODUCT
// This nmethod was not unloaded; check below that all CompiledICs
// refer to marked oops.
{
"Found unmarked ic_oop in reachable nmethod");
}
}
}
#endif // !PRODUCT
}
// This method is called twice during GC -- once while
// tracing the "active" nmethods on thread stacks during
// the (strong) marking phase, and then again when walking
// the code cache contents during the weak roots processing
// phase. The two uses are distinguished by means of the
// 'do_strong_roots_only' flag, which is true in the first
// case. We want to walk the weak roots in the nmethod
// only in the second case. The weak roots in the nmethod
// are the oops in the ExceptionCache and the InlineCache
// oops.
// make sure the oops ready to receive visitors
"should not call follow on zombie or unloaded nmethod");
// If the method is not entrant or zombie then a JMP is plastered over the
// first few bytes. If an oop in the old code was there, that oop
// should not get GC'd. Skip the first few bytes of oops on
// not-entrant methods.
if (is_not_entrant()) {
// %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
// (See comment above.)
}
// Compiled code
if (!do_strong_roots_only) {
// weak roots processing phase -- update ExceptionCache oops
}
} // Else strong roots phase -- skip oops in ExceptionCache
// In this loop, we must only follow those oops directly embedded in
// the code. Other oops (oop_index>0) are seen as part of scopes_oops.
"oop must be found in exactly one place");
}
}
}
// Scopes
// This includes oop constants not inlined in the code stream.
f->do_oop(p);
}
}
// An nmethod is "marked" if its _mark_link is set non-null.
// Even if it is the end of the linked list, it will have a non-null link value,
// as long as it is on the list.
// This code must be MP safe, because it is used from parallel GC passes.
if (observed_mark_link == NULL) {
// Claim this nmethod for this thread to mark.
if (observed_mark_link == NULL) {
// Atomically append this nmethod (now claimed) to the head of the list:
for (;;) {
break;
}
// Mark was clear when we first saw this guy.
return false;
}
}
// On fall through, another racing thread marked this nmethod before we did.
return true;
}
// We use cmpxchg_ptr instead of regular assignment here because the user
// may fork a bunch of threads, and we need them all to see the same state.
}
while (cur != NMETHOD_SENTINEL) {
}
}
bool _detected_scavenge_root;
public:
if ((*p) != NULL && (*p)->is_scavengable()) {
NOT_PRODUCT(maybe_print(p));
_detected_scavenge_root = true;
}
}
#ifndef PRODUCT
tty->print_cr(""PTR_FORMAT"[offset=%d] detected scavengable oop "PTR_FORMAT" (found at "PTR_FORMAT")",
(*p)->print();
}
#endif //PRODUCT
};
return detect_scavenge_root.detected_scavenge_root();
}
// Method that knows how to preserve outgoing arguments at call. This method must be
// called with a frame corresponding to a Java invoke
#ifndef SHARK
// compiled invokedynamic call sites have an implicit receiver at
// resolution time, so make sure it gets GC'ed.
}
#endif // !SHARK
}
}
return NULL;
}
}
#ifdef ASSERT
// must be sorted and unique; we do a binary search in find_pc_desc()
"must start with a sentinel");
for (int i = 1; i < count; i++) {
}
"must end with a sentinel");
#endif //ASSERT
// Search for MethodHandle invokes and tag the nmethod.
for (int i = 0; i < count; i++) {
if (pcs[i].is_method_handle_invoke()) {
break;
}
}
// Adjust the final sentinel downward.
// Fill any rounding gaps with copies of the last record.
}
// The following assert could fail if sizeof(PcDesc) is not
// an integral multiple of oopSize (the rounding term).
// If it fails, change the logic to always allocate a multiple
// of sizeof(PcDesc), and fill unused words with copies of *last_pc.
}
}
#ifdef ASSERT
res = p;
else
}
}
return res;
}
#endif
// Finds a PcDesc with real-pc equal to "pc"
if ((pc < base_address) ||
return NULL; // PC is wildly out of range
}
// Check the PcDesc cache if it contains the desired PcDesc
// (This as an almost 100% hit rate.)
return res;
}
// Fallback algorithm: quasi-linear search for the PcDesc
// Find the last pc_offset less than the given offset.
// The successor must be the required match, if there is a match at all.
// (Use a fixed radix to avoid expensive affine pointer arithmetic.)
#define assert_LU_OK \
/* invariant on lower..upper during the following search: */ \
// Use the last successful return as a split point.
} else {
}
// Take giant steps at first (4096, then 256, then 16, then 1)
} else {
break;
}
}
}
// Sneak up on the value with a linear search of length ~16.
while (true) {
} else {
break;
}
}
return upper;
} else {
return NULL;
}
}
bool found_check = false;
// wholesale check of all dependencies
found_check = true;
NOT_DEBUG(break);
}
}
return found_check; // tell caller if we found anything
}
// What has happened:
// 1) a new class dependee has been added
// 2) dependee and all its super classes have been marked
// Evaluate only relevant dependencies.
found_check = true;
NOT_DEBUG(break);
}
}
return found_check;
}
for (int j = 0; j < dependee_methods->length(); j++) {
// RC_TRACE macro has an embedded ResourceMark
RC_TRACE(0x01000000,
("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)",
if (TraceDependencies || LogCompilation)
return true;
}
}
}
}
return false;
}
// Called from mark_for_deoptimization, when dependee is invalidated.
continue;
}
return false;
}
if (is_zombie()) {
// a zombie may never be patched
return false;
}
return true;
}
// Exception happened outside inline-cache check code => we are inside
// an active nmethod => use cpc to determine a return address
#ifdef ASSERT
if (cont_offset == 0) {
print();
method()->print_codes();
print_code();
print_pcs();
}
#endif
if (cont_offset == 0) {
// Let the normal error handling report the exception
return NULL;
}
return code_begin() + cont_offset;
}
void nmethod_init() {
// make sure you didn't forget to adjust the filler fields
}
//-------------------------------------------------------------------------------------------
// QQQ might we make this work from a frame??
}
// Only JvmtiDeferredEvent::compiled_method_unload_event()
// should pass zombie_ok == true.
}
}
// -----------------------------------------------------------------------------
// nmethod::get_deopt_original_pc
//
// Return the original PC for the given PC if:
// (a) the given PC belongs to a nmethod and
// (b) it is a deopt PC
return NULL;
}
// -----------------------------------------------------------------------------
// MethodHandle
if (!has_method_handle_invokes()) return false;
return false;
return pd->is_method_handle_invoke();
}
// -----------------------------------------------------------------------------
// Verification
bool _ok;
public:
if (_ok) {
_nm->print_nmethod(true);
_ok = false;
}
}
};
// Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
// seems odd.
if( is_zombie() || is_not_entrant() )
return;
// Make sure all the entry points are correctly aligned for patching.
}
if(is_native_method() )
return;
if (nm != this) {
this));
}
if (! p->verify(this)) {
}
}
VerifyOopsClosure voc(this);
}
// This code does not work in release mode since
// owns_lock only is available in debug mode.
} else {
}
pd->return_oop());
}
}
if( !method() ) return; // Runtime stubs have no scope
// iterate through all interrupt point
// and verify the debug information is valid.
case relocInfo::virtual_call_type:
break;
case relocInfo::opt_virtual_call_type:
break;
case relocInfo::static_call_type:
//verify_interrupt_point(iter.addr());
break;
case relocInfo::runtime_call_type:
// Right now there is no way to find out which entries support
// an interrupt point. It would be nice if we had this
// information in a table.
break;
}
}
}
// -----------------------------------------------------------------------------
// Non-product code
#ifndef PRODUCT
bool _ok;
public:
if ((*p) == NULL || !(*p)->is_scavengable()) return;
if (_ok) {
_nm->print_nmethod(true);
_ok = false;
}
(*p)->print();
}
};
if (!on_scavenge_root_list()) {
// Actually look inside, to verify the claim that it's clean.
if (!debug_scavenge_root.ok())
fatal("found an unadvertised bad scavengable oop in the code cache");
}
}
#endif // PRODUCT
// Printing operations
if (is_compiled_by_c1()) {
} else if (is_compiled_by_c2()) {
} else if (is_compiled_by_shark()) {
} else {
}
if (WizardMode) {
}
(address)this,
size());
relocation_size());
consts_begin(),
consts_end(),
consts_size());
insts_begin(),
insts_end(),
insts_size());
stub_begin(),
stub_end(),
stub_size());
oops_begin(),
oops_end(),
oops_size());
if (scopes_data_size () > 0) tty->print_cr(" scopes data [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
scopes_data_size());
scopes_pcs_size());
if (dependencies_size () > 0) tty->print_cr(" dependencies [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
if (handler_table_size() > 0) tty->print_cr(" handler table [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
if (nul_chk_table_size() > 0) tty->print_cr(" nul chk table [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
}
ResourceMark m;
Disassembler::decode(this);
}
#ifndef PRODUCT
// Find the first pc desc for all scopes in the code and print it.
continue;
}
}
}
}
}
}
ResourceMark m; // in case methods get printed via the debugger
RelocIterator iter(this);
if (UseRelocIndex) {
if (index_size > 0) {
ip[0],
ip[1],
header_end()+ip[0],
}
}
}
ResourceMark m; // in case methods get printed via debugger
p->print(this);
}
}
#endif // PRODUCT
bool have_one = false;
have_one = true;
}
}
}
}
// Return a the last scope in (begin..end]
return new ScopeDesc(this, p->scope_decode_offset(),
p->obj_decode_offset(), p->should_reexecute(),
p->return_oop());
}
return NULL;
}
if (has_method_handle_invokes())
if (block_begin == entry_point()) {
methodHandle m = method();
if (m.not_null()) {
m->print_value_on(stream);
}
if (m.not_null() && !is_osr_method()) {
{
int sig_index = 0;
if (!m->is_static())
if (type2size[t] == 2) {
} else {
}
}
}
int sig_index = 0;
bool did_old_sp = false;
bool at_old_sp = false;
if (at_this)
else
}
} else {
}
if (at_this) {
} else {
bool did_name = false;
did_name = true;
}
}
if (!did_name)
}
if (at_old_sp) {
did_old_sp = true;
}
arg_index += 1;
}
if (!did_old_sp) {
}
}
}
}
// First, find an oopmap in (begin, end].
// We use the odd half-closed interval so that oop maps and scope descs
// which are tied to the byte after a call are printed with the call itself.
}
break;
}
}
}
// Print any debug info present at this pc.
} else {
} else {
switch (bc) {
case Bytecodes::_invokevirtual:
case Bytecodes::_invokespecial:
case Bytecodes::_invokestatic:
case Bytecodes::_invokeinterface:
{
else
break;
}
case Bytecodes::_getstatic:
case Bytecodes::_putstatic:
{
else
}
}
}
}
// Print all scopes
} else {
}
if (lineno != -1) {
} else {
}
}
}
// Print relocation information
}
if (cont_offset != 0) {
}
}
#ifndef PRODUCT
}
RelocIterator iter(this);
case relocInfo::virtual_call_type:
case relocInfo::opt_virtual_call_type: {
break;
}
case relocInfo::static_call_type:
break;
}
}
}
ExceptionHandlerTable(this).print();
}
}
}
#endif // PRODUCT