nmethod.cpp revision 1879
0N/A/*
1472N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "code/codeCache.hpp"
1879N/A#include "code/compiledIC.hpp"
1879N/A#include "code/nmethod.hpp"
1879N/A#include "code/scopeDesc.hpp"
1879N/A#include "compiler/abstractCompiler.hpp"
1879N/A#include "compiler/compileLog.hpp"
1879N/A#include "compiler/compilerOracle.hpp"
1879N/A#include "compiler/disassembler.hpp"
1879N/A#include "interpreter/bytecode.hpp"
1879N/A#include "oops/methodDataOop.hpp"
1879N/A#include "prims/jvmtiRedefineClassesTrace.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/sweeper.hpp"
1879N/A#include "utilities/dtrace.hpp"
1879N/A#include "utilities/events.hpp"
1879N/A#include "utilities/xmlstream.hpp"
1879N/A#ifdef SHARK
1879N/A#include "shark/sharkCompiler.hpp"
1879N/A#endif
0N/A
0N/A#ifdef DTRACE_ENABLED
0N/A
0N/A// Only bother with this argument setup if dtrace is available
0N/A
0N/AHS_DTRACE_PROBE_DECL8(hotspot, compiled__method__load,
0N/A const char*, int, const char*, int, const char*, int, void*, size_t);
0N/A
0N/AHS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload,
0N/A char*, int, char*, int, char*, int);
0N/A
0N/A#define DTRACE_METHOD_UNLOAD_PROBE(method) \
0N/A { \
0N/A methodOop m = (method); \
0N/A if (m != NULL) { \
0N/A symbolOop klass_name = m->klass_name(); \
0N/A symbolOop name = m->name(); \
0N/A symbolOop signature = m->signature(); \
0N/A HS_DTRACE_PROBE6(hotspot, compiled__method__unload, \
0N/A klass_name->bytes(), klass_name->utf8_length(), \
0N/A name->bytes(), name->utf8_length(), \
0N/A signature->bytes(), signature->utf8_length()); \
0N/A } \
0N/A }
0N/A
0N/A#else // ndef DTRACE_ENABLED
0N/A
0N/A#define DTRACE_METHOD_UNLOAD_PROBE(method)
0N/A
0N/A#endif
0N/A
0N/Abool nmethod::is_compiled_by_c1() const {
1155N/A if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing
0N/A if (is_native_method()) return false;
0N/A return compiler()->is_c1();
0N/A}
0N/Abool nmethod::is_compiled_by_c2() const {
1155N/A if (compiler() == NULL || method() == NULL) return false; // can happen during debug printing
0N/A if (is_native_method()) return false;
0N/A return compiler()->is_c2();
0N/A}
1612N/Abool nmethod::is_compiled_by_shark() const {
1612N/A if (is_native_method()) return false;
1612N/A assert(compiler() != NULL, "must be");
1612N/A return compiler()->is_shark();
1612N/A}
0N/A
0N/A
0N/A
0N/A//---------------------------------------------------------------------------------
0N/A// NMethod statistics
0N/A// They are printed under various flags, including:
0N/A// PrintC1Statistics, PrintOptoStatistics, LogVMOutput, and LogCompilation.
0N/A// (In the latter two cases, they like other stats are printed to the log only.)
0N/A
0N/A#ifndef PRODUCT
0N/A// These variables are put into one block to reduce relocations
0N/A// and make it simpler to print from the debugger.
0N/Astatic
0N/Astruct nmethod_stats_struct {
0N/A int nmethod_count;
0N/A int total_size;
0N/A int relocation_size;
1682N/A int consts_size;
1668N/A int insts_size;
0N/A int stub_size;
0N/A int scopes_data_size;
0N/A int scopes_pcs_size;
0N/A int dependencies_size;
0N/A int handler_table_size;
0N/A int nul_chk_table_size;
0N/A int oops_size;
0N/A
0N/A void note_nmethod(nmethod* nm) {
0N/A nmethod_count += 1;
0N/A total_size += nm->size();
0N/A relocation_size += nm->relocation_size();
1682N/A consts_size += nm->consts_size();
1668N/A insts_size += nm->insts_size();
0N/A stub_size += nm->stub_size();
1483N/A oops_size += nm->oops_size();
0N/A scopes_data_size += nm->scopes_data_size();
0N/A scopes_pcs_size += nm->scopes_pcs_size();
0N/A dependencies_size += nm->dependencies_size();
0N/A handler_table_size += nm->handler_table_size();
0N/A nul_chk_table_size += nm->nul_chk_table_size();
0N/A }
0N/A void print_nmethod_stats() {
0N/A if (nmethod_count == 0) return;
0N/A tty->print_cr("Statistics for %d bytecoded nmethods:", nmethod_count);
0N/A if (total_size != 0) tty->print_cr(" total in heap = %d", total_size);
0N/A if (relocation_size != 0) tty->print_cr(" relocation = %d", relocation_size);
1682N/A if (consts_size != 0) tty->print_cr(" constants = %d", consts_size);
1668N/A if (insts_size != 0) tty->print_cr(" main code = %d", insts_size);
0N/A if (stub_size != 0) tty->print_cr(" stub code = %d", stub_size);
1483N/A if (oops_size != 0) tty->print_cr(" oops = %d", oops_size);
0N/A if (scopes_data_size != 0) tty->print_cr(" scopes data = %d", scopes_data_size);
0N/A if (scopes_pcs_size != 0) tty->print_cr(" scopes pcs = %d", scopes_pcs_size);
0N/A if (dependencies_size != 0) tty->print_cr(" dependencies = %d", dependencies_size);
0N/A if (handler_table_size != 0) tty->print_cr(" handler table = %d", handler_table_size);
0N/A if (nul_chk_table_size != 0) tty->print_cr(" nul chk table = %d", nul_chk_table_size);
0N/A }
0N/A
0N/A int native_nmethod_count;
0N/A int native_total_size;
0N/A int native_relocation_size;
1668N/A int native_insts_size;
0N/A int native_oops_size;
0N/A void note_native_nmethod(nmethod* nm) {
0N/A native_nmethod_count += 1;
0N/A native_total_size += nm->size();
0N/A native_relocation_size += nm->relocation_size();
1668N/A native_insts_size += nm->insts_size();
0N/A native_oops_size += nm->oops_size();
0N/A }
0N/A void print_native_nmethod_stats() {
0N/A if (native_nmethod_count == 0) return;
0N/A tty->print_cr("Statistics for %d native nmethods:", native_nmethod_count);
0N/A if (native_total_size != 0) tty->print_cr(" N. total size = %d", native_total_size);
0N/A if (native_relocation_size != 0) tty->print_cr(" N. relocation = %d", native_relocation_size);
1668N/A if (native_insts_size != 0) tty->print_cr(" N. main code = %d", native_insts_size);
0N/A if (native_oops_size != 0) tty->print_cr(" N. oops = %d", native_oops_size);
0N/A }
0N/A
0N/A int pc_desc_resets; // number of resets (= number of caches)
0N/A int pc_desc_queries; // queries to nmethod::find_pc_desc
0N/A int pc_desc_approx; // number of those which have approximate true
0N/A int pc_desc_repeats; // number of _last_pc_desc hits
0N/A int pc_desc_hits; // number of LRU cache hits
0N/A int pc_desc_tests; // total number of PcDesc examinations
0N/A int pc_desc_searches; // total number of quasi-binary search steps
0N/A int pc_desc_adds; // number of LUR cache insertions
0N/A
0N/A void print_pc_stats() {
0N/A tty->print_cr("PcDesc Statistics: %d queries, %.2f comparisons per query",
0N/A pc_desc_queries,
0N/A (double)(pc_desc_tests + pc_desc_searches)
0N/A / pc_desc_queries);
0N/A tty->print_cr(" caches=%d queries=%d/%d, hits=%d+%d, tests=%d+%d, adds=%d",
0N/A pc_desc_resets,
0N/A pc_desc_queries, pc_desc_approx,
0N/A pc_desc_repeats, pc_desc_hits,
0N/A pc_desc_tests, pc_desc_searches, pc_desc_adds);
0N/A }
0N/A} nmethod_stats;
0N/A#endif //PRODUCT
0N/A
0N/A//---------------------------------------------------------------------------------
0N/A
0N/A
0N/A// The _unwind_handler is a special marker address, which says that
0N/A// for given exception oop and address, the frame should be removed
0N/A// as the tuple cannot be caught in the nmethod
0N/Aaddress ExceptionCache::_unwind_handler = (address) -1;
0N/A
0N/A
0N/AExceptionCache::ExceptionCache(Handle exception, address pc, address handler) {
0N/A assert(pc != NULL, "Must be non null");
0N/A assert(exception.not_null(), "Must be non null");
0N/A assert(handler != NULL, "Must be non null");
0N/A
0N/A _count = 0;
0N/A _exception_type = exception->klass();
0N/A _next = NULL;
0N/A
0N/A add_address_and_handler(pc,handler);
0N/A}
0N/A
0N/A
0N/Aaddress ExceptionCache::match(Handle exception, address pc) {
0N/A assert(pc != NULL,"Must be non null");
0N/A assert(exception.not_null(),"Must be non null");
0N/A if (exception->klass() == exception_type()) {
0N/A return (test_address(pc));
0N/A }
0N/A
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/Abool ExceptionCache::match_exception_with_space(Handle exception) {
0N/A assert(exception.not_null(),"Must be non null");
0N/A if (exception->klass() == exception_type() && count() < cache_size) {
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/Aaddress ExceptionCache::test_address(address addr) {
0N/A for (int i=0; i<count(); i++) {
0N/A if (pc_at(i) == addr) {
0N/A return handler_at(i);
0N/A }
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/Abool ExceptionCache::add_address_and_handler(address addr, address handler) {
0N/A if (test_address(addr) == handler) return true;
0N/A if (count() < cache_size) {
0N/A set_pc_at(count(),addr);
0N/A set_handler_at(count(), handler);
0N/A increment_count();
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/A// private method for handling exception cache
0N/A// These methods are private, and used to manipulate the exception cache
0N/A// directly.
0N/AExceptionCache* nmethod::exception_cache_entry_for_exception(Handle exception) {
0N/A ExceptionCache* ec = exception_cache();
0N/A while (ec != NULL) {
0N/A if (ec->match_exception_with_space(exception)) {
0N/A return ec;
0N/A }
0N/A ec = ec->next();
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/A//-----------------------------------------------------------------------------
0N/A
0N/A
0N/A// Helper used by both find_pc_desc methods.
0N/Astatic inline bool match_desc(PcDesc* pc, int pc_offset, bool approximate) {
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_tests);
0N/A if (!approximate)
0N/A return pc->pc_offset() == pc_offset;
0N/A else
0N/A return (pc-1)->pc_offset() < pc_offset && pc_offset <= pc->pc_offset();
0N/A}
0N/A
0N/Avoid PcDescCache::reset_to(PcDesc* initial_pc_desc) {
0N/A if (initial_pc_desc == NULL) {
0N/A _last_pc_desc = NULL; // native method
0N/A return;
0N/A }
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_resets);
0N/A // reset the cache by filling it with benign (non-null) values
0N/A assert(initial_pc_desc->pc_offset() < 0, "must be sentinel");
0N/A _last_pc_desc = initial_pc_desc + 1; // first valid one is after sentinel
0N/A for (int i = 0; i < cache_size; i++)
0N/A _pc_descs[i] = initial_pc_desc;
0N/A}
0N/A
0N/APcDesc* PcDescCache::find_pc_desc(int pc_offset, bool approximate) {
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_queries);
0N/A NOT_PRODUCT(if (approximate) ++nmethod_stats.pc_desc_approx);
0N/A
0N/A // In order to prevent race conditions do not load cache elements
0N/A // repeatedly, but use a local copy:
0N/A PcDesc* res;
0N/A
0N/A // Step one: Check the most recently returned value.
0N/A res = _last_pc_desc;
0N/A if (res == NULL) return NULL; // native method; no PcDescs at all
0N/A if (match_desc(res, pc_offset, approximate)) {
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_repeats);
0N/A return res;
0N/A }
0N/A
0N/A // Step two: Check the LRU cache.
0N/A for (int i = 0; i < cache_size; i++) {
0N/A res = _pc_descs[i];
0N/A if (res->pc_offset() < 0) break; // optimization: skip empty cache
0N/A if (match_desc(res, pc_offset, approximate)) {
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_hits);
0N/A _last_pc_desc = res; // record this cache hit in case of repeat
0N/A return res;
0N/A }
0N/A }
0N/A
0N/A // Report failure.
0N/A return NULL;
0N/A}
0N/A
0N/Avoid PcDescCache::add_pc_desc(PcDesc* pc_desc) {
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_adds);
0N/A // Update the LRU cache by shifting pc_desc forward:
0N/A for (int i = 0; i < cache_size; i++) {
0N/A PcDesc* next = _pc_descs[i];
0N/A _pc_descs[i] = pc_desc;
0N/A pc_desc = next;
0N/A }
0N/A // Note: Do not update _last_pc_desc. It fronts for the LRU cache.
0N/A}
0N/A
0N/A// adjust pcs_size so that it is a multiple of both oopSize and
0N/A// sizeof(PcDesc) (assumes that if sizeof(PcDesc) is not a multiple
0N/A// of oopSize, then 2*sizeof(PcDesc) is)
0N/Astatic int adjust_pcs_size(int pcs_size) {
0N/A int nsize = round_to(pcs_size, oopSize);
0N/A if ((nsize % sizeof(PcDesc)) != 0) {
0N/A nsize = pcs_size + sizeof(PcDesc);
0N/A }
0N/A assert((nsize % oopSize) == 0, "correct alignment");
0N/A return nsize;
0N/A}
0N/A
0N/A//-----------------------------------------------------------------------------
0N/A
0N/A
0N/Avoid nmethod::add_exception_cache_entry(ExceptionCache* new_entry) {
0N/A assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock");
0N/A assert(new_entry != NULL,"Must be non null");
0N/A assert(new_entry->next() == NULL, "Must be null");
0N/A
0N/A if (exception_cache() != NULL) {
0N/A new_entry->set_next(exception_cache());
0N/A }
0N/A set_exception_cache(new_entry);
0N/A}
0N/A
0N/Avoid nmethod::remove_from_exception_cache(ExceptionCache* ec) {
0N/A ExceptionCache* prev = NULL;
0N/A ExceptionCache* curr = exception_cache();
0N/A assert(curr != NULL, "nothing to remove");
0N/A // find the previous and next entry of ec
0N/A while (curr != ec) {
0N/A prev = curr;
0N/A curr = curr->next();
0N/A assert(curr != NULL, "ExceptionCache not found");
0N/A }
0N/A // now: curr == ec
0N/A ExceptionCache* next = curr->next();
0N/A if (prev == NULL) {
0N/A set_exception_cache(next);
0N/A } else {
0N/A prev->set_next(next);
0N/A }
0N/A delete curr;
0N/A}
0N/A
0N/A
0N/A// public method for accessing the exception cache
0N/A// These are the public access methods.
0N/Aaddress nmethod::handler_for_exception_and_pc(Handle exception, address pc) {
0N/A // We never grab a lock to read the exception cache, so we may
0N/A // have false negatives. This is okay, as it can only happen during
0N/A // the first few exception lookups for a given nmethod.
0N/A ExceptionCache* ec = exception_cache();
0N/A while (ec != NULL) {
0N/A address ret_val;
0N/A if ((ret_val = ec->match(exception,pc)) != NULL) {
0N/A return ret_val;
0N/A }
0N/A ec = ec->next();
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/Avoid nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) {
0N/A // There are potential race conditions during exception cache updates, so we
0N/A // must own the ExceptionCache_lock before doing ANY modifications. Because
605N/A // we don't lock during reads, it is possible to have several threads attempt
0N/A // to update the cache with the same data. We need to check for already inserted
0N/A // copies of the current data before adding it.
0N/A
0N/A MutexLocker ml(ExceptionCache_lock);
0N/A ExceptionCache* target_entry = exception_cache_entry_for_exception(exception);
0N/A
0N/A if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) {
0N/A target_entry = new ExceptionCache(exception,pc,handler);
0N/A add_exception_cache_entry(target_entry);
0N/A }
0N/A}
0N/A
0N/A
0N/A//-------------end of code for ExceptionCache--------------
0N/A
0N/A
0N/Aint nmethod::total_size() const {
0N/A return
1682N/A consts_size() +
1668N/A insts_size() +
0N/A stub_size() +
0N/A scopes_data_size() +
0N/A scopes_pcs_size() +
0N/A handler_table_size() +
0N/A nul_chk_table_size();
0N/A}
0N/A
0N/Aconst char* nmethod::compile_kind() const {
0N/A if (is_osr_method()) return "osr";
1109N/A if (method() != NULL && is_native_method()) return "c2n";
0N/A return NULL;
0N/A}
0N/A
1564N/A// Fill in default values for various flag fields
1564N/Avoid nmethod::init_defaults() {
1564N/A _state = alive;
1564N/A _marked_for_reclamation = 0;
1564N/A _has_flushed_dependencies = 0;
1564N/A _speculatively_disconnected = 0;
1564N/A _has_unsafe_access = 0;
1564N/A _has_method_handle_invokes = 0;
1564N/A _marked_for_deoptimization = 0;
1564N/A _lock_count = 0;
1564N/A _stack_traversal_mark = 0;
1564N/A _unload_reported = false; // jvmti state
1564N/A
1564N/A NOT_PRODUCT(_has_debug_info = false);
1646N/A#ifdef ASSERT
1646N/A _oops_are_stale = false;
1646N/A#endif
1646N/A
1564N/A _oops_do_mark_link = NULL;
1564N/A _jmethod_id = NULL;
1564N/A _osr_link = NULL;
1564N/A _scavenge_root_link = NULL;
1564N/A _scavenge_root_state = 0;
1564N/A _saved_nmethod_link = NULL;
1564N/A _compiler = NULL;
1564N/A
1564N/A#ifdef HAVE_DTRACE_H
1564N/A _trap_offset = 0;
1564N/A#endif // def HAVE_DTRACE_H
1564N/A}
0N/A
0N/A
0N/Anmethod* nmethod::new_native_nmethod(methodHandle method,
0N/A CodeBuffer *code_buffer,
0N/A int vep_offset,
0N/A int frame_complete,
0N/A int frame_size,
0N/A ByteSize basic_lock_owner_sp_offset,
0N/A ByteSize basic_lock_sp_offset,
0N/A OopMapSet* oop_maps) {
0N/A // create nmethod
0N/A nmethod* nm = NULL;
0N/A {
0N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod));
0N/A CodeOffsets offsets;
0N/A offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
0N/A offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
0N/A nm = new (native_nmethod_size)
0N/A nmethod(method(), native_nmethod_size, &offsets,
0N/A code_buffer, frame_size,
0N/A basic_lock_owner_sp_offset, basic_lock_sp_offset,
0N/A oop_maps);
0N/A NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_native_nmethod(nm));
0N/A if (PrintAssembly && nm != NULL)
0N/A Disassembler::decode(nm);
0N/A }
0N/A // verify nmethod
0N/A debug_only(if (nm) nm->verify();) // might block
0N/A
0N/A if (nm != NULL) {
0N/A nm->log_new_nmethod();
0N/A }
0N/A
0N/A return nm;
0N/A}
0N/A
116N/A#ifdef HAVE_DTRACE_H
116N/Anmethod* nmethod::new_dtrace_nmethod(methodHandle method,
116N/A CodeBuffer *code_buffer,
116N/A int vep_offset,
116N/A int trap_offset,
116N/A int frame_complete,
116N/A int frame_size) {
116N/A // create nmethod
116N/A nmethod* nm = NULL;
116N/A {
116N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
116N/A int nmethod_size = allocation_size(code_buffer, sizeof(nmethod));
116N/A CodeOffsets offsets;
116N/A offsets.set_value(CodeOffsets::Verified_Entry, vep_offset);
116N/A offsets.set_value(CodeOffsets::Dtrace_trap, trap_offset);
116N/A offsets.set_value(CodeOffsets::Frame_Complete, frame_complete);
116N/A
116N/A nm = new (nmethod_size) nmethod(method(), nmethod_size, &offsets, code_buffer, frame_size);
116N/A
116N/A NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm));
116N/A if (PrintAssembly && nm != NULL)
116N/A Disassembler::decode(nm);
116N/A }
116N/A // verify nmethod
116N/A debug_only(if (nm) nm->verify();) // might block
116N/A
116N/A if (nm != NULL) {
116N/A nm->log_new_nmethod();
116N/A }
116N/A
116N/A return nm;
116N/A}
116N/A
116N/A#endif // def HAVE_DTRACE_H
116N/A
0N/Anmethod* nmethod::new_nmethod(methodHandle method,
0N/A int compile_id,
0N/A int entry_bci,
0N/A CodeOffsets* offsets,
0N/A int orig_pc_offset,
0N/A DebugInformationRecorder* debug_info,
0N/A Dependencies* dependencies,
0N/A CodeBuffer* code_buffer, int frame_size,
0N/A OopMapSet* oop_maps,
0N/A ExceptionHandlerTable* handler_table,
0N/A ImplicitExceptionTable* nul_chk_table,
0N/A AbstractCompiler* compiler,
0N/A int comp_level
0N/A)
0N/A{
0N/A assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR");
0N/A // create nmethod
0N/A nmethod* nm = NULL;
0N/A { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
0N/A int nmethod_size =
0N/A allocation_size(code_buffer, sizeof(nmethod))
0N/A + adjust_pcs_size(debug_info->pcs_size())
0N/A + round_to(dependencies->size_in_bytes() , oopSize)
0N/A + round_to(handler_table->size_in_bytes(), oopSize)
0N/A + round_to(nul_chk_table->size_in_bytes(), oopSize)
0N/A + round_to(debug_info->data_size() , oopSize);
0N/A nm = new (nmethod_size)
0N/A nmethod(method(), nmethod_size, compile_id, entry_bci, offsets,
0N/A orig_pc_offset, debug_info, dependencies, code_buffer, frame_size,
0N/A oop_maps,
0N/A handler_table,
0N/A nul_chk_table,
0N/A compiler,
0N/A comp_level);
0N/A if (nm != NULL) {
0N/A // To make dependency checking during class loading fast, record
0N/A // the nmethod dependencies in the classes it is dependent on.
0N/A // This allows the dependency checking code to simply walk the
0N/A // class hierarchy above the loaded class, checking only nmethods
0N/A // which are dependent on those classes. The slow way is to
0N/A // check every nmethod for dependencies which makes it linear in
0N/A // the number of methods compiled. For applications with a lot
0N/A // classes the slow way is too slow.
0N/A for (Dependencies::DepStream deps(nm); deps.next(); ) {
0N/A klassOop klass = deps.context_type();
0N/A if (klass == NULL) continue; // ignore things like evol_method
0N/A
0N/A // record this nmethod as dependent on this klass
0N/A instanceKlass::cast(klass)->add_dependent_nmethod(nm);
0N/A }
0N/A }
0N/A NOT_PRODUCT(if (nm != NULL) nmethod_stats.note_nmethod(nm));
0N/A if (PrintAssembly && nm != NULL)
0N/A Disassembler::decode(nm);
0N/A }
0N/A
0N/A // verify nmethod
0N/A debug_only(if (nm) nm->verify();) // might block
0N/A
0N/A if (nm != NULL) {
0N/A nm->log_new_nmethod();
0N/A }
0N/A
0N/A // done
0N/A return nm;
0N/A}
0N/A
0N/A
0N/A// For native wrappers
0N/Anmethod::nmethod(
0N/A methodOop method,
0N/A int nmethod_size,
0N/A CodeOffsets* offsets,
0N/A CodeBuffer* code_buffer,
0N/A int frame_size,
0N/A ByteSize basic_lock_owner_sp_offset,
0N/A ByteSize basic_lock_sp_offset,
0N/A OopMapSet* oop_maps )
0N/A : CodeBlob("native nmethod", code_buffer, sizeof(nmethod),
0N/A nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps),
0N/A _compiled_synchronized_native_basic_lock_owner_sp_offset(basic_lock_owner_sp_offset),
0N/A _compiled_synchronized_native_basic_lock_sp_offset(basic_lock_sp_offset)
0N/A{
0N/A {
0N/A debug_only(No_Safepoint_Verifier nsv;)
0N/A assert_locked_or_safepoint(CodeCache_lock);
0N/A
1564N/A init_defaults();
0N/A _method = method;
0N/A _entry_bci = InvocationEntryBci;
0N/A // We have no exception handler or deopt handler make the
0N/A // values something that will never match a pc like the nmethod vtable entry
0N/A _exception_offset = 0;
0N/A _deoptimize_offset = 0;
1204N/A _deoptimize_mh_offset = 0;
0N/A _orig_pc_offset = 0;
1564N/A
1668N/A _consts_offset = data_offset();
0N/A _stub_offset = data_offset();
1483N/A _oops_offset = data_offset();
1483N/A _scopes_data_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize);
0N/A _scopes_pcs_offset = _scopes_data_offset;
0N/A _dependencies_offset = _scopes_pcs_offset;
0N/A _handler_table_offset = _dependencies_offset;
0N/A _nul_chk_table_offset = _handler_table_offset;
0N/A _nmethod_end_offset = _nul_chk_table_offset;
0N/A _compile_id = 0; // default
0N/A _comp_level = CompLevel_none;
1668N/A _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
1668N/A _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
0N/A _osr_entry_point = NULL;
0N/A _exception_cache = NULL;
0N/A _pc_desc_cache.reset_to(NULL);
0N/A
0N/A code_buffer->copy_oops_to(this);
989N/A debug_only(verify_scavenge_root_oops());
0N/A CodeCache::commit(this);
0N/A }
0N/A
0N/A if (PrintNativeNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
0N/A ttyLocker ttyl; // keep the following output all in one block
0N/A // This output goes directly to the tty, not the compiler log.
0N/A // To enable tools to match it up with the compilation activity,
0N/A // be sure to tag this tty output with the compile ID.
0N/A if (xtty != NULL) {
0N/A xtty->begin_head("print_native_nmethod");
0N/A xtty->method(_method);
0N/A xtty->stamp();
0N/A xtty->end_head(" address='" INTPTR_FORMAT "'", (intptr_t) this);
0N/A }
0N/A // print the header part first
0N/A print();
0N/A // then print the requested information
0N/A if (PrintNativeNMethods) {
0N/A print_code();
0N/A oop_maps->print();
0N/A }
0N/A if (PrintRelocations) {
0N/A print_relocations();
0N/A }
0N/A if (xtty != NULL) {
0N/A xtty->tail("print_native_nmethod");
0N/A }
0N/A }
0N/A Events::log("Create nmethod " INTPTR_FORMAT, this);
0N/A}
0N/A
116N/A// For dtrace wrappers
116N/A#ifdef HAVE_DTRACE_H
116N/Anmethod::nmethod(
116N/A methodOop method,
116N/A int nmethod_size,
116N/A CodeOffsets* offsets,
116N/A CodeBuffer* code_buffer,
116N/A int frame_size)
116N/A : CodeBlob("dtrace nmethod", code_buffer, sizeof(nmethod),
116N/A nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, NULL),
116N/A _compiled_synchronized_native_basic_lock_owner_sp_offset(in_ByteSize(-1)),
116N/A _compiled_synchronized_native_basic_lock_sp_offset(in_ByteSize(-1))
116N/A{
116N/A {
116N/A debug_only(No_Safepoint_Verifier nsv;)
116N/A assert_locked_or_safepoint(CodeCache_lock);
116N/A
1564N/A init_defaults();
116N/A _method = method;
116N/A _entry_bci = InvocationEntryBci;
116N/A // We have no exception handler or deopt handler make the
116N/A // values something that will never match a pc like the nmethod vtable entry
116N/A _exception_offset = 0;
116N/A _deoptimize_offset = 0;
1204N/A _deoptimize_mh_offset = 0;
1378N/A _unwind_handler_offset = -1;
116N/A _trap_offset = offsets->value(CodeOffsets::Dtrace_trap);
116N/A _orig_pc_offset = 0;
1668N/A _consts_offset = data_offset();
116N/A _stub_offset = data_offset();
1483N/A _oops_offset = data_offset();
1483N/A _scopes_data_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize);
116N/A _scopes_pcs_offset = _scopes_data_offset;
116N/A _dependencies_offset = _scopes_pcs_offset;
116N/A _handler_table_offset = _dependencies_offset;
116N/A _nul_chk_table_offset = _handler_table_offset;
116N/A _nmethod_end_offset = _nul_chk_table_offset;
116N/A _compile_id = 0; // default
116N/A _comp_level = CompLevel_none;
1668N/A _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
1668N/A _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
116N/A _osr_entry_point = NULL;
116N/A _exception_cache = NULL;
116N/A _pc_desc_cache.reset_to(NULL);
116N/A
116N/A code_buffer->copy_oops_to(this);
989N/A debug_only(verify_scavenge_root_oops());
116N/A CodeCache::commit(this);
116N/A }
116N/A
116N/A if (PrintNMethods || PrintDebugInfo || PrintRelocations || PrintDependencies) {
116N/A ttyLocker ttyl; // keep the following output all in one block
116N/A // This output goes directly to the tty, not the compiler log.
116N/A // To enable tools to match it up with the compilation activity,
116N/A // be sure to tag this tty output with the compile ID.
116N/A if (xtty != NULL) {
116N/A xtty->begin_head("print_dtrace_nmethod");
116N/A xtty->method(_method);
116N/A xtty->stamp();
116N/A xtty->end_head(" address='" INTPTR_FORMAT "'", (intptr_t) this);
116N/A }
116N/A // print the header part first
116N/A print();
116N/A // then print the requested information
116N/A if (PrintNMethods) {
116N/A print_code();
116N/A }
116N/A if (PrintRelocations) {
116N/A print_relocations();
116N/A }
116N/A if (xtty != NULL) {
116N/A xtty->tail("print_dtrace_nmethod");
116N/A }
116N/A }
116N/A Events::log("Create nmethod " INTPTR_FORMAT, this);
116N/A}
116N/A#endif // def HAVE_DTRACE_H
0N/A
0N/Avoid* nmethod::operator new(size_t size, int nmethod_size) {
0N/A // Always leave some room in the CodeCache for I2C/C2I adapters
0N/A if (CodeCache::unallocated_capacity() < CodeCacheMinimumFreeSpace) return NULL;
0N/A return CodeCache::allocate(nmethod_size);
0N/A}
0N/A
0N/A
0N/Anmethod::nmethod(
0N/A methodOop method,
0N/A int nmethod_size,
0N/A int compile_id,
0N/A int entry_bci,
0N/A CodeOffsets* offsets,
0N/A int orig_pc_offset,
0N/A DebugInformationRecorder* debug_info,
0N/A Dependencies* dependencies,
0N/A CodeBuffer *code_buffer,
0N/A int frame_size,
0N/A OopMapSet* oop_maps,
0N/A ExceptionHandlerTable* handler_table,
0N/A ImplicitExceptionTable* nul_chk_table,
0N/A AbstractCompiler* compiler,
0N/A int comp_level
0N/A )
0N/A : CodeBlob("nmethod", code_buffer, sizeof(nmethod),
0N/A nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps),
0N/A _compiled_synchronized_native_basic_lock_owner_sp_offset(in_ByteSize(-1)),
0N/A _compiled_synchronized_native_basic_lock_sp_offset(in_ByteSize(-1))
0N/A{
0N/A assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR");
0N/A {
0N/A debug_only(No_Safepoint_Verifier nsv;)
0N/A assert_locked_or_safepoint(CodeCache_lock);
0N/A
1564N/A init_defaults();
0N/A _method = method;
1564N/A _entry_bci = entry_bci;
0N/A _compile_id = compile_id;
0N/A _comp_level = comp_level;
0N/A _compiler = compiler;
0N/A _orig_pc_offset = orig_pc_offset;
1668N/A
1668N/A // Section offsets
1682N/A _consts_offset = content_offset() + code_buffer->total_offset_of(code_buffer->consts());
1682N/A _stub_offset = content_offset() + code_buffer->total_offset_of(code_buffer->stubs());
0N/A
0N/A // Exception handler and deopt handler are in the stub section
1668N/A _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions);
1668N/A _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt);
1682N/A if (has_method_handle_invokes()) {
1682N/A _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH);
1682N/A } else {
1682N/A _deoptimize_mh_offset = -1;
1682N/A }
1378N/A if (offsets->value(CodeOffsets::UnwindHandler) != -1) {
1668N/A _unwind_handler_offset = code_offset() + offsets->value(CodeOffsets::UnwindHandler);
1378N/A } else {
1668N/A _unwind_handler_offset = -1;
1378N/A }
1668N/A
1483N/A _oops_offset = data_offset();
1483N/A _scopes_data_offset = _oops_offset + round_to(code_buffer->total_oop_size (), oopSize);
1483N/A _scopes_pcs_offset = _scopes_data_offset + round_to(debug_info->data_size (), oopSize);
0N/A _dependencies_offset = _scopes_pcs_offset + adjust_pcs_size(debug_info->pcs_size());
0N/A _handler_table_offset = _dependencies_offset + round_to(dependencies->size_in_bytes (), oopSize);
0N/A _nul_chk_table_offset = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize);
0N/A _nmethod_end_offset = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize);
0N/A
1668N/A _entry_point = code_begin() + offsets->value(CodeOffsets::Entry);
1668N/A _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry);
1668N/A _osr_entry_point = code_begin() + offsets->value(CodeOffsets::OSR_Entry);
0N/A _exception_cache = NULL;
0N/A _pc_desc_cache.reset_to(scopes_pcs_begin());
0N/A
0N/A // Copy contents of ScopeDescRecorder to nmethod
0N/A code_buffer->copy_oops_to(this);
0N/A debug_info->copy_to(this);
0N/A dependencies->copy_to(this);
989N/A if (ScavengeRootsInCode && detect_scavenge_root_oops()) {
989N/A CodeCache::add_scavenge_root_nmethod(this);
989N/A }
989N/A debug_only(verify_scavenge_root_oops());
0N/A
0N/A CodeCache::commit(this);
0N/A
0N/A // Copy contents of ExceptionHandlerTable to nmethod
0N/A handler_table->copy_to(this);
0N/A nul_chk_table->copy_to(this);
0N/A
0N/A // we use the information of entry points to find out if a method is
0N/A // static or non static
0N/A assert(compiler->is_c2() ||
0N/A _method->is_static() == (entry_point() == _verified_entry_point),
0N/A " entry points must be same for static methods and vice versa");
0N/A }
0N/A
100N/A bool printnmethods = PrintNMethods
100N/A || CompilerOracle::should_print(_method)
100N/A || CompilerOracle::has_option_string(_method, "PrintNMethods");
0N/A if (printnmethods || PrintDebugInfo || PrintRelocations || PrintDependencies || PrintExceptionHandlers) {
0N/A print_nmethod(printnmethods);
0N/A }
0N/A
0N/A // Note: Do not verify in here as the CodeCache_lock is
0N/A // taken which would conflict with the CompiledIC_lock
0N/A // which taken during the verification of call sites.
0N/A // (was bug - gri 10/25/99)
0N/A
0N/A Events::log("Create nmethod " INTPTR_FORMAT, this);
0N/A}
0N/A
0N/A
0N/A// Print a short set of xml attributes to identify this nmethod. The
0N/A// output should be embedded in some other element.
0N/Avoid nmethod::log_identity(xmlStream* log) const {
0N/A log->print(" compile_id='%d'", compile_id());
0N/A const char* nm_kind = compile_kind();
0N/A if (nm_kind != NULL) log->print(" compile_kind='%s'", nm_kind);
0N/A if (compiler() != NULL) {
0N/A log->print(" compiler='%s'", compiler()->name());
0N/A }
1703N/A if (TieredCompilation) {
1703N/A log->print(" level='%d'", comp_level());
1703N/A }
0N/A}
0N/A
0N/A
0N/A#define LOG_OFFSET(log, name) \
0N/A if ((intptr_t)name##_end() - (intptr_t)name##_begin()) \
0N/A log->print(" " XSTR(name) "_offset='%d'" , \
0N/A (intptr_t)name##_begin() - (intptr_t)this)
0N/A
0N/A
0N/Avoid nmethod::log_new_nmethod() const {
0N/A if (LogCompilation && xtty != NULL) {
0N/A ttyLocker ttyl;
0N/A HandleMark hm;
0N/A xtty->begin_elem("nmethod");
0N/A log_identity(xtty);
1668N/A xtty->print(" entry='" INTPTR_FORMAT "' size='%d'", code_begin(), size());
0N/A xtty->print(" address='" INTPTR_FORMAT "'", (intptr_t) this);
0N/A
0N/A LOG_OFFSET(xtty, relocation);
1682N/A LOG_OFFSET(xtty, consts);
1668N/A LOG_OFFSET(xtty, insts);
0N/A LOG_OFFSET(xtty, stub);
0N/A LOG_OFFSET(xtty, scopes_data);
0N/A LOG_OFFSET(xtty, scopes_pcs);
0N/A LOG_OFFSET(xtty, dependencies);
0N/A LOG_OFFSET(xtty, handler_table);
0N/A LOG_OFFSET(xtty, nul_chk_table);
0N/A LOG_OFFSET(xtty, oops);
0N/A
0N/A xtty->method(method());
0N/A xtty->stamp();
0N/A xtty->end_elem();
0N/A }
0N/A}
0N/A
0N/A#undef LOG_OFFSET
0N/A
0N/A
1703N/Avoid nmethod::print_compilation(outputStream *st, const char *method_name, const char *title,
1703N/A methodOop method, bool is_blocking, int compile_id, int bci, int comp_level) {
1703N/A bool is_synchronized = false, has_xhandler = false, is_native = false;
1703N/A int code_size = -1;
1703N/A if (method != NULL) {
1703N/A is_synchronized = method->is_synchronized();
1703N/A has_xhandler = method->has_exception_handler();
1703N/A is_native = method->is_native();
1703N/A code_size = method->code_size();
1703N/A }
1703N/A // print compilation number
1703N/A st->print("%7d %3d", (int)tty->time_stamp().milliseconds(), compile_id);
1703N/A
1703N/A // print method attributes
1703N/A const bool is_osr = bci != InvocationEntryBci;
1703N/A const char blocking_char = is_blocking ? 'b' : ' ';
1703N/A const char compile_type = is_osr ? '%' : ' ';
1703N/A const char sync_char = is_synchronized ? 's' : ' ';
1703N/A const char exception_char = has_xhandler ? '!' : ' ';
1703N/A const char native_char = is_native ? 'n' : ' ';
1703N/A st->print("%c%c%c%c%c ", compile_type, sync_char, exception_char, blocking_char, native_char);
1703N/A if (TieredCompilation) {
1703N/A st->print("%d ", comp_level);
1703N/A }
1703N/A
1703N/A // print optional title
1703N/A bool do_nl = false;
1703N/A if (title != NULL) {
1703N/A int tlen = (int) strlen(title);
1703N/A bool do_nl = false;
1703N/A if (tlen > 0 && title[tlen-1] == '\n') { tlen--; do_nl = true; }
1703N/A st->print("%.*s", tlen, title);
1703N/A } else {
1703N/A do_nl = true;
1703N/A }
1703N/A
1703N/A // print method name string if given
1703N/A if (method_name != NULL) {
1703N/A st->print(method_name);
1703N/A } else {
1703N/A // otherwise as the method to print itself
1703N/A if (method != NULL && !Universe::heap()->is_gc_active()) {
1703N/A method->print_short_name(st);
1703N/A } else {
1703N/A st->print("(method)");
1703N/A }
1703N/A }
1703N/A
1703N/A if (method != NULL) {
1703N/A // print osr_bci if any
1703N/A if (is_osr) st->print(" @ %d", bci);
1703N/A // print method size
1703N/A st->print(" (%d bytes)", code_size);
1703N/A }
1703N/A if (do_nl) st->cr();
1703N/A}
1703N/A
0N/A// Print out more verbose output usually for a newly created nmethod.
0N/Avoid nmethod::print_on(outputStream* st, const char* title) const {
0N/A if (st != NULL) {
0N/A ttyLocker ttyl;
1703N/A print_compilation(st, /*method_name*/NULL, title,
1703N/A method(), /*is_blocking*/false,
1704N/A compile_id(),
1704N/A is_osr_method() ? osr_entry_bci() : InvocationEntryBci,
1704N/A comp_level());
0N/A if (WizardMode) st->print(" (" INTPTR_FORMAT ")", this);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid nmethod::print_nmethod(bool printmethod) {
0N/A ttyLocker ttyl; // keep the following output all in one block
0N/A if (xtty != NULL) {
0N/A xtty->begin_head("print_nmethod");
0N/A xtty->stamp();
0N/A xtty->end_head();
0N/A }
0N/A // print the header part first
0N/A print();
0N/A // then print the requested information
0N/A if (printmethod) {
0N/A print_code();
0N/A print_pcs();
0N/A oop_maps()->print();
0N/A }
0N/A if (PrintDebugInfo) {
0N/A print_scopes();
0N/A }
0N/A if (PrintRelocations) {
0N/A print_relocations();
0N/A }
0N/A if (PrintDependencies) {
0N/A print_dependencies();
0N/A }
0N/A if (PrintExceptionHandlers) {
0N/A print_handler_table();
0N/A print_nul_chk_table();
0N/A }
0N/A if (xtty != NULL) {
0N/A xtty->tail("print_nmethod");
0N/A }
0N/A}
0N/A
0N/A
1483N/A// Promote one word from an assembly-time handle to a live embedded oop.
1483N/Ainline void nmethod::initialize_immediate_oop(oop* dest, jobject handle) {
1483N/A if (handle == NULL ||
1483N/A // As a special case, IC oops are initialized to 1 or -1.
1483N/A handle == (jobject) Universe::non_oop_word()) {
1483N/A (*dest) = (oop) handle;
1483N/A } else {
1483N/A (*dest) = JNIHandles::resolve_non_null(handle);
1483N/A }
1483N/A}
1483N/A
1483N/A
1483N/Avoid nmethod::copy_oops(GrowableArray<jobject>* array) {
1483N/A //assert(oops_size() == 0, "do this handshake just once, please");
1483N/A int length = array->length();
1483N/A assert((address)(oops_begin() + length) <= data_end(), "oops big enough");
1483N/A oop* dest = oops_begin();
1483N/A for (int index = 0 ; index < length; index++) {
1483N/A initialize_immediate_oop(&dest[index], array->at(index));
1483N/A }
1483N/A
1483N/A // Now we can fix up all the oops in the code. We need to do this
1483N/A // in the code because the assembler uses jobjects as placeholders.
1483N/A // The code and relocations have already been initialized by the
1483N/A // CodeBlob constructor, so it is valid even at this early point to
1483N/A // iterate over relocations and patch the code.
1483N/A fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true);
1483N/A}
1483N/A
1483N/A
1483N/Abool nmethod::is_at_poll_return(address pc) {
1483N/A RelocIterator iter(this, pc, pc+1);
1483N/A while (iter.next()) {
1483N/A if (iter.type() == relocInfo::poll_return_type)
1483N/A return true;
1483N/A }
1483N/A return false;
1483N/A}
1483N/A
1483N/A
1483N/Abool nmethod::is_at_poll_or_poll_return(address pc) {
1483N/A RelocIterator iter(this, pc, pc+1);
1483N/A while (iter.next()) {
1483N/A relocInfo::relocType t = iter.type();
1483N/A if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
1483N/A return true;
1483N/A }
1483N/A return false;
1483N/A}
1483N/A
1483N/A
1483N/Avoid nmethod::fix_oop_relocations(address begin, address end, bool initialize_immediates) {
1483N/A // re-patch all oop-bearing instructions, just in case some oops moved
1483N/A RelocIterator iter(this, begin, end);
1483N/A while (iter.next()) {
1483N/A if (iter.type() == relocInfo::oop_type) {
1483N/A oop_Relocation* reloc = iter.oop_reloc();
1483N/A if (initialize_immediates && reloc->oop_is_immediate()) {
1483N/A oop* dest = reloc->oop_addr();
1483N/A initialize_immediate_oop(dest, (jobject) *dest);
1483N/A }
1483N/A // Refresh the oop-related bits of this instruction.
1483N/A reloc->fix_oop_relocation();
1483N/A }
1483N/A
1483N/A // There must not be any interfering patches or breakpoints.
1483N/A assert(!(iter.type() == relocInfo::breakpoint_type
1483N/A && iter.breakpoint_reloc()->active()),
1483N/A "no active breakpoint");
1483N/A }
1483N/A}
1483N/A
1483N/A
0N/AScopeDesc* nmethod::scope_desc_at(address pc) {
0N/A PcDesc* pd = pc_desc_at(pc);
0N/A guarantee(pd != NULL, "scope must be present");
0N/A return new ScopeDesc(this, pd->scope_decode_offset(),
1253N/A pd->obj_decode_offset(), pd->should_reexecute(),
1253N/A pd->return_oop());
0N/A}
0N/A
0N/A
0N/Avoid nmethod::clear_inline_caches() {
0N/A assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint");
0N/A if (is_zombie()) {
0N/A return;
0N/A }
0N/A
0N/A RelocIterator iter(this);
0N/A while (iter.next()) {
0N/A iter.reloc()->clear_inline_cache();
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid nmethod::cleanup_inline_caches() {
0N/A
1458N/A assert_locked_or_safepoint(CompiledIC_lock);
0N/A
0N/A // If the method is not entrant or zombie then a JMP is plastered over the
0N/A // first few bytes. If an oop in the old code was there, that oop
0N/A // should not get GC'd. Skip the first few bytes of oops on
0N/A // not-entrant methods.
0N/A address low_boundary = verified_entry_point();
0N/A if (!is_in_use()) {
0N/A low_boundary += NativeJump::instruction_size;
0N/A // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
0N/A // This means that the low_boundary is going to be a little too high.
0N/A // This shouldn't matter, since oops of non-entrant methods are never used.
0N/A // In fact, why are we bothering to look at oops in a non-entrant method??
0N/A }
0N/A
0N/A // Find all calls in an nmethod, and clear the ones that points to zombie methods
0N/A ResourceMark rm;
0N/A RelocIterator iter(this, low_boundary);
0N/A while(iter.next()) {
0N/A switch(iter.type()) {
0N/A case relocInfo::virtual_call_type:
0N/A case relocInfo::opt_virtual_call_type: {
0N/A CompiledIC *ic = CompiledIC_at(iter.reloc());
0N/A // Ok, to lookup references to zombies here
0N/A CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination());
0N/A if( cb != NULL && cb->is_nmethod() ) {
0N/A nmethod* nm = (nmethod*)cb;
0N/A // Clean inline caches pointing to both zombie and not_entrant methods
1202N/A if (!nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean();
0N/A }
0N/A break;
0N/A }
0N/A case relocInfo::static_call_type: {
0N/A CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc());
0N/A CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination());
0N/A if( cb != NULL && cb->is_nmethod() ) {
0N/A nmethod* nm = (nmethod*)cb;
0N/A // Clean inline caches pointing to both zombie and not_entrant methods
1202N/A if (!nm->is_in_use() || (nm->method()->code() != nm)) csc->set_to_clean();
0N/A }
0N/A break;
0N/A }
0N/A }
0N/A }
0N/A}
0N/A
989N/A// This is a private interface with the sweeper.
0N/Avoid nmethod::mark_as_seen_on_stack() {
0N/A assert(is_not_entrant(), "must be a non-entrant method");
1564N/A // Set the traversal mark to ensure that the sweeper does 2
1564N/A // cleaning passes before moving to zombie.
0N/A set_stack_traversal_mark(NMethodSweeper::traversal_count());
0N/A}
0N/A
0N/A// Tell if a non-entrant method can be converted to a zombie (i.e., there is no activations on the stack)
0N/Abool nmethod::can_not_entrant_be_converted() {
0N/A assert(is_not_entrant(), "must be a non-entrant method");
0N/A
0N/A // Since the nmethod sweeper only does partial sweep the sweeper's traversal
0N/A // count can be greater than the stack traversal count before it hits the
0N/A // nmethod for the second time.
0N/A return stack_traversal_mark()+1 < NMethodSweeper::traversal_count();
0N/A}
0N/A
0N/Avoid nmethod::inc_decompile_count() {
1703N/A if (!is_compiled_by_c2()) return;
0N/A // Could be gated by ProfileTraps, but do not bother...
0N/A methodOop m = method();
0N/A if (m == NULL) return;
0N/A methodDataOop mdo = m->method_data();
0N/A if (mdo == NULL) return;
0N/A // There is a benign race here. See comments in methodDataOop.hpp.
0N/A mdo->inc_decompile_count();
0N/A}
0N/A
0N/Avoid nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) {
0N/A
0N/A post_compiled_method_unload();
0N/A
0N/A // Since this nmethod is being unloaded, make sure that dependencies
0N/A // recorded in instanceKlasses get flushed and pass non-NULL closure to
0N/A // indicate that this work is being done during a GC.
0N/A assert(Universe::heap()->is_gc_active(), "should only be called during gc");
0N/A assert(is_alive != NULL, "Should be non-NULL");
0N/A // A non-NULL is_alive closure indicates that this is being called during GC.
0N/A flush_dependencies(is_alive);
0N/A
0N/A // Break cycle between nmethod & method
0N/A if (TraceClassUnloading && WizardMode) {
0N/A tty->print_cr("[Class unloading: Making nmethod " INTPTR_FORMAT
0N/A " unloadable], methodOop(" INTPTR_FORMAT
0N/A "), cause(" INTPTR_FORMAT ")",
0N/A this, (address)_method, (address)cause);
989N/A if (!Universe::heap()->is_gc_active())
989N/A cause->klass()->print();
0N/A }
941N/A // Unlink the osr method, so we do not look this up again
941N/A if (is_osr_method()) {
941N/A invalidate_osr_method();
941N/A }
0N/A // If _method is already NULL the methodOop is about to be unloaded,
0N/A // so we don't have to break the cycle. Note that it is possible to
0N/A // have the methodOop live here, in case we unload the nmethod because
0N/A // it is pointing to some oop (other than the methodOop) being unloaded.
0N/A if (_method != NULL) {
0N/A // OSR methods point to the methodOop, but the methodOop does not
0N/A // point back!
0N/A if (_method->code() == this) {
0N/A _method->clear_code(); // Break a cycle
0N/A }
0N/A _method = NULL; // Clear the method of this dead nmethod
0N/A }
0N/A // Make the class unloaded - i.e., change state and notify sweeper
1458N/A assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
0N/A if (is_in_use()) {
0N/A // Transitioning directly from live to unloaded -- so
0N/A // we need to force a cache clean-up; remember this
0N/A // for later on.
0N/A CodeCache::set_needs_cache_clean(true);
0N/A }
1564N/A _state = unloaded;
0N/A
1109N/A // Log the unloading.
1109N/A log_state_change();
1109N/A
0N/A // The methodOop is gone at this point
0N/A assert(_method == NULL, "Tautology");
0N/A
989N/A set_osr_link(NULL);
989N/A //set_scavenge_root_link(NULL); // done by prune_scavenge_root_nmethods
0N/A NMethodSweeper::notify(this);
0N/A}
0N/A
0N/Avoid nmethod::invalidate_osr_method() {
0N/A assert(_entry_bci != InvocationEntryBci, "wrong kind of nmethod");
0N/A // Remove from list of active nmethods
0N/A if (method() != NULL)
0N/A instanceKlass::cast(method()->method_holder())->remove_osr_nmethod(this);
0N/A // Set entry as invalid
0N/A _entry_bci = InvalidOSREntryBci;
0N/A}
0N/A
1109N/Avoid nmethod::log_state_change() const {
0N/A if (LogCompilation) {
0N/A if (xtty != NULL) {
0N/A ttyLocker ttyl; // keep the following output all in one block
1564N/A if (_state == unloaded) {
1109N/A xtty->begin_elem("make_unloaded thread='" UINTX_FORMAT "'",
1109N/A os::current_thread_id());
1109N/A } else {
1109N/A xtty->begin_elem("make_not_entrant thread='" UINTX_FORMAT "'%s",
1109N/A os::current_thread_id(),
1564N/A (_state == zombie ? " zombie='1'" : ""));
1109N/A }
0N/A log_identity(xtty);
0N/A xtty->stamp();
0N/A xtty->end_elem();
0N/A }
0N/A }
1564N/A if (PrintCompilation && _state != unloaded) {
1564N/A print_on(tty, _state == zombie ? "made zombie " : "made not entrant ");
0N/A tty->cr();
0N/A }
0N/A}
0N/A
0N/A// Common functionality for both make_not_entrant and make_zombie
1141N/Abool nmethod::make_not_entrant_or_zombie(unsigned int state) {
0N/A assert(state == zombie || state == not_entrant, "must be zombie or not_entrant");
0N/A
1564N/A // Make sure neither the nmethod nor the method is flushed in case of a safepoint in code below.
0N/A nmethodLocker nml(this);
1564N/A methodHandle the_method(method());
1646N/A No_Safepoint_Verifier nsv;
0N/A
0N/A {
1206N/A // If the method is already zombie there is nothing to do
1206N/A if (is_zombie()) {
1206N/A return false;
1206N/A }
1206N/A
1109N/A // invalidate osr nmethod before acquiring the patching lock since
1109N/A // they both acquire leaf locks and we don't want a deadlock.
1109N/A // This logic is equivalent to the logic below for patching the
1109N/A // verified entry point of regular methods.
1109N/A if (is_osr_method()) {
1109N/A // this effectively makes the osr nmethod not entrant
1109N/A invalidate_osr_method();
1109N/A }
1109N/A
0N/A // Enter critical section. Does not block for safepoint.
0N/A MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
1109N/A
1564N/A if (_state == state) {
1109N/A // another thread already performed this transition so nothing
1109N/A // to do, but return false to indicate this.
1109N/A return false;
1109N/A }
1109N/A
0N/A // The caller can be calling the method statically or through an inline
0N/A // cache call.
1109N/A if (!is_osr_method() && !is_not_entrant()) {
0N/A NativeJump::patch_verified_entry(entry_point(), verified_entry_point(),
0N/A SharedRuntime::get_handle_wrong_method_stub());
0N/A }
0N/A
1564N/A if (is_in_use()) {
1564N/A // It's a true state change, so mark the method as decompiled.
1564N/A // Do it only for transition from alive.
1564N/A inc_decompile_count();
1564N/A }
1206N/A
0N/A // Change state
1564N/A _state = state;
1109N/A
1109N/A // Log the transition once
1109N/A log_state_change();
1109N/A
1564N/A // Remove nmethod from method.
1564N/A // We need to check if both the _code and _from_compiled_code_entry_point
1564N/A // refer to this nmethod because there is a race in setting these two fields
1564N/A // in methodOop as seen in bugid 4947125.
1564N/A // If the vep() points to the zombie nmethod, the memory for the nmethod
1564N/A // could be flushed and the compiler and vtable stubs could still call
1564N/A // through it.
1564N/A if (method() != NULL && (method()->code() == this ||
1564N/A method()->from_compiled_entry() == verified_entry_point())) {
1564N/A HandleMark hm;
1564N/A method()->clear_code();
1564N/A }
1564N/A
1564N/A if (state == not_entrant) {
1564N/A mark_as_seen_on_stack();
1564N/A }
1564N/A
0N/A } // leave critical region under Patching_lock
0N/A
1458N/A // When the nmethod becomes zombie it is no longer alive so the
1458N/A // dependencies must be flushed. nmethods in the not_entrant
1458N/A // state will be flushed later when the transition to zombie
1458N/A // happens or they get unloaded.
1458N/A if (state == zombie) {
1646N/A {
1646N/A // Flushing dependecies must be done before any possible
1646N/A // safepoint can sneak in, otherwise the oops used by the
1646N/A // dependency logic could have become stale.
1646N/A MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
1646N/A flush_dependencies(NULL);
1646N/A }
1564N/A
1646N/A {
1646N/A // zombie only - if a JVMTI agent has enabled the CompiledMethodUnload event
1646N/A // and it hasn't already been reported for this nmethod then report it now.
1646N/A // (the event may have been reported earilier if the GC marked it for unloading).
1646N/A Pause_No_Safepoint_Verifier pnsv(&nsv);
1646N/A post_compiled_method_unload();
1646N/A }
1646N/A
1646N/A#ifdef ASSERT
1646N/A // It's no longer safe to access the oops section since zombie
1646N/A // nmethods aren't scanned for GC.
1646N/A _oops_are_stale = true;
1646N/A#endif
1458N/A } else {
1458N/A assert(state == not_entrant, "other cases may need to be handled differently");
1458N/A }
1458N/A
0N/A if (TraceCreateZombies) {
0N/A tty->print_cr("nmethod <" INTPTR_FORMAT "> code made %s", this, (state == not_entrant) ? "not entrant" : "zombie");
0N/A }
0N/A
0N/A // Make sweeper aware that there is a zombie method that needs to be removed
0N/A NMethodSweeper::notify(this);
0N/A
1109N/A return true;
0N/A}
0N/A
0N/Avoid nmethod::flush() {
0N/A // Note that there are no valid oops in the nmethod anymore.
0N/A assert(is_zombie() || (is_osr_method() && is_unloaded()), "must be a zombie method");
0N/A assert(is_marked_for_reclamation() || (is_osr_method() && is_unloaded()), "must be marked for reclamation");
0N/A
0N/A assert (!is_locked_by_vm(), "locked methods shouldn't be flushed");
1458N/A assert_locked_or_safepoint(CodeCache_lock);
0N/A
0N/A // completely deallocate this method
0N/A EventMark m("flushing nmethod " INTPTR_FORMAT " %s", this, "");
0N/A if (PrintMethodFlushing) {
1202N/A tty->print_cr("*flushing nmethod %3d/" INTPTR_FORMAT ". Live blobs:" UINT32_FORMAT "/Free CodeCache:" SIZE_FORMAT "Kb",
1202N/A _compile_id, this, CodeCache::nof_blobs(), CodeCache::unallocated_capacity()/1024);
0N/A }
0N/A
0N/A // We need to deallocate any ExceptionCache data.
0N/A // Note that we do not need to grab the nmethod lock for this, it
0N/A // better be thread safe if we're disposing of it!
0N/A ExceptionCache* ec = exception_cache();
0N/A set_exception_cache(NULL);
0N/A while(ec != NULL) {
0N/A ExceptionCache* next = ec->next();
0N/A delete ec;
0N/A ec = next;
0N/A }
0N/A
989N/A if (on_scavenge_root_list()) {
989N/A CodeCache::drop_scavenge_root_nmethod(this);
989N/A }
989N/A
1202N/A if (is_speculatively_disconnected()) {
1202N/A CodeCache::remove_saved_code(this);
1202N/A }
1202N/A
1612N/A#ifdef SHARK
1765N/A ((SharkCompiler *) compiler())->free_compiled_method(insts_begin());
1612N/A#endif // SHARK
1612N/A
0N/A ((CodeBlob*)(this))->flush();
0N/A
0N/A CodeCache::free(this);
0N/A}
0N/A
0N/A
0N/A//
0N/A// Notify all classes this nmethod is dependent on that it is no
0N/A// longer dependent. This should only be called in two situations.
0N/A// First, when a nmethod transitions to a zombie all dependents need
0N/A// to be clear. Since zombification happens at a safepoint there's no
0N/A// synchronization issues. The second place is a little more tricky.
0N/A// During phase 1 of mark sweep class unloading may happen and as a
0N/A// result some nmethods may get unloaded. In this case the flushing
0N/A// of dependencies must happen during phase 1 since after GC any
0N/A// dependencies in the unloaded nmethod won't be updated, so
0N/A// traversing the dependency information in unsafe. In that case this
0N/A// function is called with a non-NULL argument and this function only
0N/A// notifies instanceKlasses that are reachable
0N/A
0N/Avoid nmethod::flush_dependencies(BoolObjectClosure* is_alive) {
1458N/A assert_locked_or_safepoint(CodeCache_lock);
0N/A assert(Universe::heap()->is_gc_active() == (is_alive != NULL),
0N/A "is_alive is non-NULL if and only if we are called during GC");
0N/A if (!has_flushed_dependencies()) {
0N/A set_has_flushed_dependencies();
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A klassOop klass = deps.context_type();
0N/A if (klass == NULL) continue; // ignore things like evol_method
0N/A
0N/A // During GC the is_alive closure is non-NULL, and is used to
0N/A // determine liveness of dependees that need to be updated.
0N/A if (is_alive == NULL || is_alive->do_object_b(klass)) {
0N/A instanceKlass::cast(klass)->remove_dependent_nmethod(this);
0N/A }
0N/A }
0N/A }
0N/A}
0N/A
0N/A
0N/A// If this oop is not live, the nmethod can be unloaded.
0N/Abool nmethod::can_unload(BoolObjectClosure* is_alive,
0N/A OopClosure* keep_alive,
0N/A oop* root, bool unloading_occurred) {
0N/A assert(root != NULL, "just checking");
0N/A oop obj = *root;
0N/A if (obj == NULL || is_alive->do_object_b(obj)) {
0N/A return false;
0N/A }
0N/A if (obj->is_compiledICHolder()) {
0N/A compiledICHolderOop cichk_oop = compiledICHolderOop(obj);
0N/A if (is_alive->do_object_b(
0N/A cichk_oop->holder_method()->method_holder()) &&
0N/A is_alive->do_object_b(cichk_oop->holder_klass())) {
0N/A // The oop should be kept alive
0N/A keep_alive->do_oop(root);
0N/A return false;
0N/A }
0N/A }
989N/A // If ScavengeRootsInCode is true, an nmethod might be unloaded
989N/A // simply because one of its constant oops has gone dead.
989N/A // No actual classes need to be unloaded in order for this to occur.
989N/A assert(unloading_occurred || ScavengeRootsInCode, "Inconsistency in unloading");
0N/A make_unloaded(is_alive, obj);
0N/A return true;
0N/A}
0N/A
0N/A// ------------------------------------------------------------------
0N/A// post_compiled_method_load_event
0N/A// new method for install_code() path
0N/A// Transfer information from compilation to jvmti
0N/Avoid nmethod::post_compiled_method_load_event() {
0N/A
0N/A methodOop moop = method();
0N/A HS_DTRACE_PROBE8(hotspot, compiled__method__load,
0N/A moop->klass_name()->bytes(),
0N/A moop->klass_name()->utf8_length(),
0N/A moop->name()->bytes(),
0N/A moop->name()->utf8_length(),
0N/A moop->signature()->bytes(),
0N/A moop->signature()->utf8_length(),
1668N/A insts_begin(), insts_size());
0N/A
1536N/A if (JvmtiExport::should_post_compiled_method_load() ||
1536N/A JvmtiExport::should_post_compiled_method_unload()) {
1536N/A get_and_cache_jmethod_id();
1536N/A }
1536N/A
0N/A if (JvmtiExport::should_post_compiled_method_load()) {
0N/A JvmtiExport::post_compiled_method_load(this);
0N/A }
0N/A}
0N/A
1536N/AjmethodID nmethod::get_and_cache_jmethod_id() {
1536N/A if (_jmethod_id == NULL) {
1536N/A // Cache the jmethod_id since it can no longer be looked up once the
1536N/A // method itself has been marked for unloading.
1536N/A _jmethod_id = method()->jmethod_id();
1536N/A }
1536N/A return _jmethod_id;
1536N/A}
1536N/A
0N/Avoid nmethod::post_compiled_method_unload() {
1497N/A if (unload_reported()) {
1497N/A // During unloading we transition to unloaded and then to zombie
1497N/A // and the unloading is reported during the first transition.
1497N/A return;
1497N/A }
1497N/A
0N/A assert(_method != NULL && !is_unloaded(), "just checking");
0N/A DTRACE_METHOD_UNLOAD_PROBE(method());
0N/A
0N/A // If a JVMTI agent has enabled the CompiledMethodUnload event then
1536N/A // post the event. Sometime later this nmethod will be made a zombie
1536N/A // by the sweeper but the methodOop will not be valid at that point.
1536N/A // If the _jmethod_id is null then no load event was ever requested
1536N/A // so don't bother posting the unload. The main reason for this is
1536N/A // that the jmethodID is a weak reference to the methodOop so if
1536N/A // it's being unloaded there's no way to look it up since the weak
1536N/A // ref will have been cleared.
1536N/A if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) {
0N/A assert(!unload_reported(), "already unloaded");
0N/A HandleMark hm;
1668N/A JvmtiExport::post_compiled_method_unload(_jmethod_id, insts_begin());
0N/A }
0N/A
0N/A // The JVMTI CompiledMethodUnload event can be enabled or disabled at
0N/A // any time. As the nmethod is being unloaded now we mark it has
0N/A // having the unload event reported - this will ensure that we don't
0N/A // attempt to report the event in the unlikely scenario where the
0N/A // event is enabled at the time the nmethod is made a zombie.
0N/A set_unload_reported();
0N/A}
0N/A
0N/A// This is called at the end of the strong tracing/marking phase of a
0N/A// GC to unload an nmethod if it contains otherwise unreachable
0N/A// oops.
0N/A
0N/Avoid nmethod::do_unloading(BoolObjectClosure* is_alive,
0N/A OopClosure* keep_alive, bool unloading_occurred) {
0N/A // Make sure the oop's ready to receive visitors
0N/A assert(!is_zombie() && !is_unloaded(),
0N/A "should not call follow on zombie or unloaded nmethod");
0N/A
0N/A // If the method is not entrant then a JMP is plastered over the
0N/A // first few bytes. If an oop in the old code was there, that oop
0N/A // should not get GC'd. Skip the first few bytes of oops on
0N/A // not-entrant methods.
0N/A address low_boundary = verified_entry_point();
0N/A if (is_not_entrant()) {
0N/A low_boundary += NativeJump::instruction_size;
0N/A // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
0N/A // (See comment above.)
0N/A }
0N/A
0N/A // The RedefineClasses() API can cause the class unloading invariant
0N/A // to no longer be true. See jvmtiExport.hpp for details.
0N/A // Also, leave a debugging breadcrumb in local flag.
0N/A bool a_class_was_redefined = JvmtiExport::has_redefined_a_class();
0N/A if (a_class_was_redefined) {
0N/A // This set of the unloading_occurred flag is done before the
0N/A // call to post_compiled_method_unload() so that the unloading
0N/A // of this nmethod is reported.
0N/A unloading_occurred = true;
0N/A }
0N/A
0N/A // Follow methodOop
0N/A if (can_unload(is_alive, keep_alive, (oop*)&_method, unloading_occurred)) {
0N/A return;
0N/A }
0N/A
0N/A // Exception cache
0N/A ExceptionCache* ec = exception_cache();
0N/A while (ec != NULL) {
0N/A oop* ex_addr = (oop*)ec->exception_type_addr();
0N/A oop ex = *ex_addr;
0N/A ExceptionCache* next_ec = ec->next();
0N/A if (ex != NULL && !is_alive->do_object_b(ex)) {
0N/A assert(!ex->is_compiledICHolder(), "Possible error here");
0N/A remove_from_exception_cache(ec);
0N/A }
0N/A ec = next_ec;
0N/A }
0N/A
0N/A // If class unloading occurred we first iterate over all inline caches and
0N/A // clear ICs where the cached oop is referring to an unloaded klass or method.
0N/A // The remaining live cached oops will be traversed in the relocInfo::oop_type
0N/A // iteration below.
0N/A if (unloading_occurred) {
0N/A RelocIterator iter(this, low_boundary);
0N/A while(iter.next()) {
0N/A if (iter.type() == relocInfo::virtual_call_type) {
0N/A CompiledIC *ic = CompiledIC_at(iter.reloc());
0N/A oop ic_oop = ic->cached_oop();
0N/A if (ic_oop != NULL && !is_alive->do_object_b(ic_oop)) {
0N/A // The only exception is compiledICHolder oops which may
0N/A // yet be marked below. (We check this further below).
0N/A if (ic_oop->is_compiledICHolder()) {
0N/A compiledICHolderOop cichk_oop = compiledICHolderOop(ic_oop);
0N/A if (is_alive->do_object_b(
0N/A cichk_oop->holder_method()->method_holder()) &&
0N/A is_alive->do_object_b(cichk_oop->holder_klass())) {
0N/A continue;
0N/A }
0N/A }
0N/A ic->set_to_clean();
1409N/A assert(ic->cached_oop() == NULL,
1409N/A "cached oop in IC should be cleared");
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Compiled code
0N/A RelocIterator iter(this, low_boundary);
0N/A while (iter.next()) {
0N/A if (iter.type() == relocInfo::oop_type) {
0N/A oop_Relocation* r = iter.oop_reloc();
0N/A // In this loop, we must only traverse those oops directly embedded in
0N/A // the code. Other oops (oop_index>0) are seen as part of scopes_oops.
0N/A assert(1 == (r->oop_is_immediate()) +
0N/A (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
0N/A "oop must be found in exactly one place");
0N/A if (r->oop_is_immediate() && r->oop_value() != NULL) {
0N/A if (can_unload(is_alive, keep_alive, r->oop_addr(), unloading_occurred)) {
0N/A return;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A
0N/A // Scopes
0N/A for (oop* p = oops_begin(); p < oops_end(); p++) {
0N/A if (*p == Universe::non_oop_word()) continue; // skip non-oops
0N/A if (can_unload(is_alive, keep_alive, p, unloading_occurred)) {
0N/A return;
0N/A }
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A // This nmethod was not unloaded; check below that all CompiledICs
0N/A // refer to marked oops.
0N/A {
0N/A RelocIterator iter(this, low_boundary);
0N/A while (iter.next()) {
0N/A if (iter.type() == relocInfo::virtual_call_type) {
0N/A CompiledIC *ic = CompiledIC_at(iter.reloc());
0N/A oop ic_oop = ic->cached_oop();
0N/A assert(ic_oop == NULL || is_alive->do_object_b(ic_oop),
0N/A "Found unmarked ic_oop in reachable nmethod");
0N/A }
0N/A }
0N/A }
0N/A#endif // !PRODUCT
0N/A}
0N/A
941N/A// This method is called twice during GC -- once while
941N/A// tracing the "active" nmethods on thread stacks during
941N/A// the (strong) marking phase, and then again when walking
941N/A// the code cache contents during the weak roots processing
941N/A// phase. The two uses are distinguished by means of the
994N/A// 'do_strong_roots_only' flag, which is true in the first
941N/A// case. We want to walk the weak roots in the nmethod
941N/A// only in the second case. The weak roots in the nmethod
941N/A// are the oops in the ExceptionCache and the InlineCache
941N/A// oops.
994N/Avoid nmethod::oops_do(OopClosure* f, bool do_strong_roots_only) {
0N/A // make sure the oops ready to receive visitors
0N/A assert(!is_zombie() && !is_unloaded(),
0N/A "should not call follow on zombie or unloaded nmethod");
0N/A
0N/A // If the method is not entrant or zombie then a JMP is plastered over the
0N/A // first few bytes. If an oop in the old code was there, that oop
0N/A // should not get GC'd. Skip the first few bytes of oops on
0N/A // not-entrant methods.
0N/A address low_boundary = verified_entry_point();
0N/A if (is_not_entrant()) {
0N/A low_boundary += NativeJump::instruction_size;
0N/A // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump.
0N/A // (See comment above.)
0N/A }
0N/A
0N/A // Compiled code
0N/A f->do_oop((oop*) &_method);
994N/A if (!do_strong_roots_only) {
941N/A // weak roots processing phase -- update ExceptionCache oops
941N/A ExceptionCache* ec = exception_cache();
941N/A while(ec != NULL) {
941N/A f->do_oop((oop*)ec->exception_type_addr());
941N/A ec = ec->next();
941N/A }
941N/A } // Else strong roots phase -- skip oops in ExceptionCache
0N/A
0N/A RelocIterator iter(this, low_boundary);
941N/A
0N/A while (iter.next()) {
0N/A if (iter.type() == relocInfo::oop_type ) {
0N/A oop_Relocation* r = iter.oop_reloc();
0N/A // In this loop, we must only follow those oops directly embedded in
0N/A // the code. Other oops (oop_index>0) are seen as part of scopes_oops.
941N/A assert(1 == (r->oop_is_immediate()) +
941N/A (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
941N/A "oop must be found in exactly one place");
0N/A if (r->oop_is_immediate() && r->oop_value() != NULL) {
0N/A f->do_oop(r->oop_addr());
0N/A }
0N/A }
0N/A }
0N/A
0N/A // Scopes
989N/A // This includes oop constants not inlined in the code stream.
0N/A for (oop* p = oops_begin(); p < oops_end(); p++) {
0N/A if (*p == Universe::non_oop_word()) continue; // skip non-oops
0N/A f->do_oop(p);
0N/A }
0N/A}
0N/A
989N/A#define NMETHOD_SENTINEL ((nmethod*)badAddress)
989N/A
989N/Anmethod* volatile nmethod::_oops_do_mark_nmethods;
989N/A
989N/A// An nmethod is "marked" if its _mark_link is set non-null.
989N/A// Even if it is the end of the linked list, it will have a non-null link value,
989N/A// as long as it is on the list.
989N/A// This code must be MP safe, because it is used from parallel GC passes.
989N/Abool nmethod::test_set_oops_do_mark() {
989N/A assert(nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called");
989N/A nmethod* observed_mark_link = _oops_do_mark_link;
989N/A if (observed_mark_link == NULL) {
989N/A // Claim this nmethod for this thread to mark.
989N/A observed_mark_link = (nmethod*)
989N/A Atomic::cmpxchg_ptr(NMETHOD_SENTINEL, &_oops_do_mark_link, NULL);
989N/A if (observed_mark_link == NULL) {
989N/A
989N/A // Atomically append this nmethod (now claimed) to the head of the list:
989N/A nmethod* observed_mark_nmethods = _oops_do_mark_nmethods;
989N/A for (;;) {
989N/A nmethod* required_mark_nmethods = observed_mark_nmethods;
989N/A _oops_do_mark_link = required_mark_nmethods;
989N/A observed_mark_nmethods = (nmethod*)
989N/A Atomic::cmpxchg_ptr(this, &_oops_do_mark_nmethods, required_mark_nmethods);
989N/A if (observed_mark_nmethods == required_mark_nmethods)
989N/A break;
989N/A }
989N/A // Mark was clear when we first saw this guy.
989N/A NOT_PRODUCT(if (TraceScavenge) print_on(tty, "oops_do, mark\n"));
989N/A return false;
989N/A }
989N/A }
989N/A // On fall through, another racing thread marked this nmethod before we did.
989N/A return true;
989N/A}
989N/A
989N/Avoid nmethod::oops_do_marking_prologue() {
989N/A NOT_PRODUCT(if (TraceScavenge) tty->print_cr("[oops_do_marking_prologue"));
989N/A assert(_oops_do_mark_nmethods == NULL, "must not call oops_do_marking_prologue twice in a row");
989N/A // We use cmpxchg_ptr instead of regular assignment here because the user
989N/A // may fork a bunch of threads, and we need them all to see the same state.
989N/A void* observed = Atomic::cmpxchg_ptr(NMETHOD_SENTINEL, &_oops_do_mark_nmethods, NULL);
989N/A guarantee(observed == NULL, "no races in this sequential code");
989N/A}
989N/A
989N/Avoid nmethod::oops_do_marking_epilogue() {
989N/A assert(_oops_do_mark_nmethods != NULL, "must not call oops_do_marking_epilogue twice in a row");
989N/A nmethod* cur = _oops_do_mark_nmethods;
989N/A while (cur != NMETHOD_SENTINEL) {
989N/A assert(cur != NULL, "not NULL-terminated");
989N/A nmethod* next = cur->_oops_do_mark_link;
989N/A cur->_oops_do_mark_link = NULL;
989N/A NOT_PRODUCT(if (TraceScavenge) cur->print_on(tty, "oops_do, unmark\n"));
989N/A cur = next;
989N/A }
989N/A void* required = _oops_do_mark_nmethods;
989N/A void* observed = Atomic::cmpxchg_ptr(NULL, &_oops_do_mark_nmethods, required);
989N/A guarantee(observed == required, "no races in this sequential code");
989N/A NOT_PRODUCT(if (TraceScavenge) tty->print_cr("oops_do_marking_epilogue]"));
989N/A}
989N/A
989N/Aclass DetectScavengeRoot: public OopClosure {
989N/A bool _detected_scavenge_root;
989N/Apublic:
989N/A DetectScavengeRoot() : _detected_scavenge_root(false)
989N/A { NOT_PRODUCT(_print_nm = NULL); }
989N/A bool detected_scavenge_root() { return _detected_scavenge_root; }
989N/A virtual void do_oop(oop* p) {
989N/A if ((*p) != NULL && (*p)->is_scavengable()) {
989N/A NOT_PRODUCT(maybe_print(p));
989N/A _detected_scavenge_root = true;
989N/A }
989N/A }
989N/A virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
989N/A
989N/A#ifndef PRODUCT
989N/A nmethod* _print_nm;
989N/A void maybe_print(oop* p) {
989N/A if (_print_nm == NULL) return;
989N/A if (!_detected_scavenge_root) _print_nm->print_on(tty, "new scavenge root");
989N/A tty->print_cr(""PTR_FORMAT"[offset=%d] detected non-perm oop "PTR_FORMAT" (found at "PTR_FORMAT")",
989N/A _print_nm, (int)((intptr_t)p - (intptr_t)_print_nm),
989N/A (intptr_t)(*p), (intptr_t)p);
989N/A (*p)->print();
989N/A }
989N/A#endif //PRODUCT
989N/A};
989N/A
989N/Abool nmethod::detect_scavenge_root_oops() {
989N/A DetectScavengeRoot detect_scavenge_root;
989N/A NOT_PRODUCT(if (TraceScavenge) detect_scavenge_root._print_nm = this);
989N/A oops_do(&detect_scavenge_root);
989N/A return detect_scavenge_root.detected_scavenge_root();
989N/A}
989N/A
0N/A// Method that knows how to preserve outgoing arguments at call. This method must be
0N/A// called with a frame corresponding to a Java invoke
0N/Avoid nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
1612N/A#ifndef SHARK
0N/A if (!method()->is_native()) {
0N/A SimpleScopeDesc ssd(this, fr.pc());
0N/A Bytecode_invoke* call = Bytecode_invoke_at(ssd.method(), ssd.bci());
1138N/A bool has_receiver = call->has_receiver();
0N/A symbolOop signature = call->signature();
1138N/A fr.oops_compiled_arguments_do(signature, has_receiver, reg_map, f);
0N/A }
1612N/A#endif // !SHARK
0N/A}
0N/A
0N/A
0N/Aoop nmethod::embeddedOop_at(u_char* p) {
0N/A RelocIterator iter(this, p, p + oopSize);
0N/A while (iter.next())
0N/A if (iter.type() == relocInfo::oop_type) {
0N/A return iter.oop_reloc()->oop_value();
0N/A }
0N/A return NULL;
0N/A}
0N/A
0N/A
0N/Ainline bool includes(void* p, void* from, void* to) {
0N/A return from <= p && p < to;
0N/A}
0N/A
0N/A
0N/Avoid nmethod::copy_scopes_pcs(PcDesc* pcs, int count) {
0N/A assert(count >= 2, "must be sentinel values, at least");
0N/A
0N/A#ifdef ASSERT
0N/A // must be sorted and unique; we do a binary search in find_pc_desc()
0N/A int prev_offset = pcs[0].pc_offset();
0N/A assert(prev_offset == PcDesc::lower_offset_limit,
0N/A "must start with a sentinel");
0N/A for (int i = 1; i < count; i++) {
0N/A int this_offset = pcs[i].pc_offset();
0N/A assert(this_offset > prev_offset, "offsets must be sorted");
0N/A prev_offset = this_offset;
0N/A }
0N/A assert(prev_offset == PcDesc::upper_offset_limit,
0N/A "must end with a sentinel");
0N/A#endif //ASSERT
0N/A
1135N/A // Search for MethodHandle invokes and tag the nmethod.
1135N/A for (int i = 0; i < count; i++) {
1135N/A if (pcs[i].is_method_handle_invoke()) {
1135N/A set_has_method_handle_invokes(true);
1135N/A break;
1135N/A }
1135N/A }
1135N/A
0N/A int size = count * sizeof(PcDesc);
0N/A assert(scopes_pcs_size() >= size, "oob");
0N/A memcpy(scopes_pcs_begin(), pcs, size);
0N/A
0N/A // Adjust the final sentinel downward.
0N/A PcDesc* last_pc = &scopes_pcs_begin()[count-1];
0N/A assert(last_pc->pc_offset() == PcDesc::upper_offset_limit, "sanity");
1668N/A last_pc->set_pc_offset(content_size() + 1);
0N/A for (; last_pc + 1 < scopes_pcs_end(); last_pc += 1) {
0N/A // Fill any rounding gaps with copies of the last record.
0N/A last_pc[1] = last_pc[0];
0N/A }
0N/A // The following assert could fail if sizeof(PcDesc) is not
0N/A // an integral multiple of oopSize (the rounding term).
0N/A // If it fails, change the logic to always allocate a multiple
0N/A // of sizeof(PcDesc), and fill unused words with copies of *last_pc.
0N/A assert(last_pc + 1 == scopes_pcs_end(), "must match exactly");
0N/A}
0N/A
0N/Avoid nmethod::copy_scopes_data(u_char* buffer, int size) {
0N/A assert(scopes_data_size() >= size, "oob");
0N/A memcpy(scopes_data_begin(), buffer, size);
0N/A}
0N/A
0N/A
0N/A#ifdef ASSERT
0N/Astatic PcDesc* linear_search(nmethod* nm, int pc_offset, bool approximate) {
0N/A PcDesc* lower = nm->scopes_pcs_begin();
0N/A PcDesc* upper = nm->scopes_pcs_end();
0N/A lower += 1; // exclude initial sentinel
0N/A PcDesc* res = NULL;
0N/A for (PcDesc* p = lower; p < upper; p++) {
0N/A NOT_PRODUCT(--nmethod_stats.pc_desc_tests); // don't count this call to match_desc
0N/A if (match_desc(p, pc_offset, approximate)) {
0N/A if (res == NULL)
0N/A res = p;
0N/A else
0N/A res = (PcDesc*) badAddress;
0N/A }
0N/A }
0N/A return res;
0N/A}
0N/A#endif
0N/A
0N/A
0N/A// Finds a PcDesc with real-pc equal to "pc"
0N/APcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) {
1668N/A address base_address = code_begin();
0N/A if ((pc < base_address) ||
0N/A (pc - base_address) >= (ptrdiff_t) PcDesc::upper_offset_limit) {
0N/A return NULL; // PC is wildly out of range
0N/A }
0N/A int pc_offset = (int) (pc - base_address);
0N/A
0N/A // Check the PcDesc cache if it contains the desired PcDesc
0N/A // (This as an almost 100% hit rate.)
0N/A PcDesc* res = _pc_desc_cache.find_pc_desc(pc_offset, approximate);
0N/A if (res != NULL) {
0N/A assert(res == linear_search(this, pc_offset, approximate), "cache ok");
0N/A return res;
0N/A }
0N/A
0N/A // Fallback algorithm: quasi-linear search for the PcDesc
0N/A // Find the last pc_offset less than the given offset.
0N/A // The successor must be the required match, if there is a match at all.
0N/A // (Use a fixed radix to avoid expensive affine pointer arithmetic.)
0N/A PcDesc* lower = scopes_pcs_begin();
0N/A PcDesc* upper = scopes_pcs_end();
0N/A upper -= 1; // exclude final sentinel
0N/A if (lower >= upper) return NULL; // native method; no PcDescs at all
0N/A
0N/A#define assert_LU_OK \
0N/A /* invariant on lower..upper during the following search: */ \
0N/A assert(lower->pc_offset() < pc_offset, "sanity"); \
0N/A assert(upper->pc_offset() >= pc_offset, "sanity")
0N/A assert_LU_OK;
0N/A
0N/A // Use the last successful return as a split point.
0N/A PcDesc* mid = _pc_desc_cache.last_pc_desc();
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_searches);
0N/A if (mid->pc_offset() < pc_offset) {
0N/A lower = mid;
0N/A } else {
0N/A upper = mid;
0N/A }
0N/A
0N/A // Take giant steps at first (4096, then 256, then 16, then 1)
0N/A const int LOG2_RADIX = 4 /*smaller steps in debug mode:*/ debug_only(-1);
0N/A const int RADIX = (1 << LOG2_RADIX);
0N/A for (int step = (1 << (LOG2_RADIX*3)); step > 1; step >>= LOG2_RADIX) {
0N/A while ((mid = lower + step) < upper) {
0N/A assert_LU_OK;
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_searches);
0N/A if (mid->pc_offset() < pc_offset) {
0N/A lower = mid;
0N/A } else {
0N/A upper = mid;
0N/A break;
0N/A }
0N/A }
0N/A assert_LU_OK;
0N/A }
0N/A
0N/A // Sneak up on the value with a linear search of length ~16.
0N/A while (true) {
0N/A assert_LU_OK;
0N/A mid = lower + 1;
0N/A NOT_PRODUCT(++nmethod_stats.pc_desc_searches);
0N/A if (mid->pc_offset() < pc_offset) {
0N/A lower = mid;
0N/A } else {
0N/A upper = mid;
0N/A break;
0N/A }
0N/A }
0N/A#undef assert_LU_OK
0N/A
0N/A if (match_desc(upper, pc_offset, approximate)) {
0N/A assert(upper == linear_search(this, pc_offset, approximate), "search ok");
0N/A _pc_desc_cache.add_pc_desc(upper);
0N/A return upper;
0N/A } else {
0N/A assert(NULL == linear_search(this, pc_offset, approximate), "search ok");
0N/A return NULL;
0N/A }
0N/A}
0N/A
0N/A
0N/Abool nmethod::check_all_dependencies() {
0N/A bool found_check = false;
0N/A // wholesale check of all dependencies
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A if (deps.check_dependency() != NULL) {
0N/A found_check = true;
0N/A NOT_DEBUG(break);
0N/A }
0N/A }
0N/A return found_check; // tell caller if we found anything
0N/A}
0N/A
0N/Abool nmethod::check_dependency_on(DepChange& changes) {
0N/A // What has happened:
0N/A // 1) a new class dependee has been added
0N/A // 2) dependee and all its super classes have been marked
0N/A bool found_check = false; // set true if we are upset
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A // Evaluate only relevant dependencies.
0N/A if (deps.spot_check_dependency_at(changes) != NULL) {
0N/A found_check = true;
0N/A NOT_DEBUG(break);
0N/A }
0N/A }
0N/A return found_check;
0N/A}
0N/A
0N/Abool nmethod::is_evol_dependent_on(klassOop dependee) {
0N/A instanceKlass *dependee_ik = instanceKlass::cast(dependee);
0N/A objArrayOop dependee_methods = dependee_ik->methods();
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A if (deps.type() == Dependencies::evol_method) {
0N/A methodOop method = deps.method_argument(0);
0N/A for (int j = 0; j < dependee_methods->length(); j++) {
0N/A if ((methodOop) dependee_methods->obj_at(j) == method) {
0N/A // RC_TRACE macro has an embedded ResourceMark
0N/A RC_TRACE(0x01000000,
0N/A ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)",
0N/A _method->method_holder()->klass_part()->external_name(),
0N/A _method->name()->as_C_string(),
0N/A _method->signature()->as_C_string(), compile_id(),
0N/A method->method_holder()->klass_part()->external_name(),
0N/A method->name()->as_C_string(),
0N/A method->signature()->as_C_string()));
0N/A if (TraceDependencies || LogCompilation)
0N/A deps.log_dependency(dependee);
0N/A return true;
0N/A }
0N/A }
0N/A }
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A// Called from mark_for_deoptimization, when dependee is invalidated.
0N/Abool nmethod::is_dependent_on_method(methodOop dependee) {
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A if (deps.type() != Dependencies::evol_method)
0N/A continue;
0N/A methodOop method = deps.method_argument(0);
0N/A if (method == dependee) return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/Abool nmethod::is_patchable_at(address instr_addr) {
1668N/A assert(insts_contains(instr_addr), "wrong nmethod used");
0N/A if (is_zombie()) {
0N/A // a zombie may never be patched
0N/A return false;
0N/A }
0N/A return true;
0N/A}
0N/A
0N/A
0N/Aaddress nmethod::continuation_for_implicit_exception(address pc) {
0N/A // Exception happened outside inline-cache check code => we are inside
0N/A // an active nmethod => use cpc to determine a return address
1668N/A int exception_offset = pc - code_begin();
0N/A int cont_offset = ImplicitExceptionTable(this).at( exception_offset );
0N/A#ifdef ASSERT
0N/A if (cont_offset == 0) {
0N/A Thread* thread = ThreadLocalStorage::get_thread_slow();
0N/A ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY
0N/A HandleMark hm(thread);
0N/A ResourceMark rm(thread);
0N/A CodeBlob* cb = CodeCache::find_blob(pc);
0N/A assert(cb != NULL && cb == this, "");
0N/A tty->print_cr("implicit exception happened at " INTPTR_FORMAT, pc);
0N/A print();
0N/A method()->print_codes();
0N/A print_code();
0N/A print_pcs();
0N/A }
0N/A#endif
1250N/A if (cont_offset == 0) {
1250N/A // Let the normal error handling report the exception
1250N/A return NULL;
1250N/A }
1668N/A return code_begin() + cont_offset;
0N/A}
0N/A
0N/A
0N/A
0N/Avoid nmethod_init() {
0N/A // make sure you didn't forget to adjust the filler fields
0N/A assert(sizeof(nmethod) % oopSize == 0, "nmethod size must be multiple of a word");
0N/A}
0N/A
0N/A
0N/A//-------------------------------------------------------------------------------------------
0N/A
0N/A
0N/A// QQQ might we make this work from a frame??
0N/AnmethodLocker::nmethodLocker(address pc) {
0N/A CodeBlob* cb = CodeCache::find_blob(pc);
0N/A guarantee(cb != NULL && cb->is_nmethod(), "bad pc for a nmethod found");
0N/A _nm = (nmethod*)cb;
0N/A lock_nmethod(_nm);
0N/A}
0N/A
0N/Avoid nmethodLocker::lock_nmethod(nmethod* nm) {
0N/A if (nm == NULL) return;
0N/A Atomic::inc(&nm->_lock_count);
0N/A guarantee(!nm->is_zombie(), "cannot lock a zombie method");
0N/A}
0N/A
0N/Avoid nmethodLocker::unlock_nmethod(nmethod* nm) {
0N/A if (nm == NULL) return;
0N/A Atomic::dec(&nm->_lock_count);
0N/A guarantee(nm->_lock_count >= 0, "unmatched nmethod lock/unlock");
0N/A}
0N/A
1204N/A
1204N/A// -----------------------------------------------------------------------------
1204N/A// nmethod::get_deopt_original_pc
1204N/A//
1204N/A// Return the original PC for the given PC if:
1204N/A// (a) the given PC belongs to a nmethod and
1204N/A// (b) it is a deopt PC
1204N/Aaddress nmethod::get_deopt_original_pc(const frame* fr) {
1204N/A if (fr->cb() == NULL) return NULL;
1204N/A
1204N/A nmethod* nm = fr->cb()->as_nmethod_or_null();
1204N/A if (nm != NULL && nm->is_deopt_pc(fr->pc()))
1204N/A return nm->get_original_pc(fr);
1204N/A
1204N/A return NULL;
0N/A}
0N/A
0N/A
0N/A// -----------------------------------------------------------------------------
1135N/A// MethodHandle
1135N/A
1135N/Abool nmethod::is_method_handle_return(address return_pc) {
1135N/A if (!has_method_handle_invokes()) return false;
1135N/A PcDesc* pd = pc_desc_at(return_pc);
1135N/A if (pd == NULL)
1135N/A return false;
1135N/A return pd->is_method_handle_invoke();
1135N/A}
1135N/A
1135N/A
1135N/A// -----------------------------------------------------------------------------
0N/A// Verification
0N/A
989N/Aclass VerifyOopsClosure: public OopClosure {
989N/A nmethod* _nm;
989N/A bool _ok;
989N/Apublic:
989N/A VerifyOopsClosure(nmethod* nm) : _nm(nm), _ok(true) { }
989N/A bool ok() { return _ok; }
989N/A virtual void do_oop(oop* p) {
989N/A if ((*p) == NULL || (*p)->is_oop()) return;
989N/A if (_ok) {
989N/A _nm->print_nmethod(true);
989N/A _ok = false;
989N/A }
989N/A tty->print_cr("*** non-oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)",
989N/A (intptr_t)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
989N/A }
989N/A virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
989N/A};
989N/A
0N/Avoid nmethod::verify() {
0N/A
0N/A // Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
0N/A // seems odd.
0N/A
0N/A if( is_zombie() || is_not_entrant() )
0N/A return;
0N/A
0N/A // Make sure all the entry points are correctly aligned for patching.
0N/A NativeJump::check_verified_entry_alignment(entry_point(), verified_entry_point());
0N/A
0N/A assert(method()->is_oop(), "must be valid");
0N/A
0N/A ResourceMark rm;
0N/A
0N/A if (!CodeCache::contains(this)) {
1410N/A fatal(err_msg("nmethod at " INTPTR_FORMAT " not in zone", this));
0N/A }
0N/A
0N/A if(is_native_method() )
0N/A return;
0N/A
0N/A nmethod* nm = CodeCache::find_nmethod(verified_entry_point());
0N/A if (nm != this) {
1410N/A fatal(err_msg("findNMethod did not find this nmethod (" INTPTR_FORMAT ")",
1410N/A this));
0N/A }
0N/A
0N/A for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
0N/A if (! p->verify(this)) {
0N/A tty->print_cr("\t\tin nmethod at " INTPTR_FORMAT " (pcs)", this);
0N/A }
0N/A }
0N/A
989N/A VerifyOopsClosure voc(this);
989N/A oops_do(&voc);
989N/A assert(voc.ok(), "embedded oops must be OK");
989N/A verify_scavenge_root_oops();
989N/A
0N/A verify_scopes();
0N/A}
0N/A
0N/A
0N/Avoid nmethod::verify_interrupt_point(address call_site) {
0N/A // This code does not work in release mode since
0N/A // owns_lock only is available in debug mode.
0N/A CompiledIC* ic = NULL;
0N/A Thread *cur = Thread::current();
0N/A if (CompiledIC_lock->owner() == cur ||
0N/A ((cur->is_VM_thread() || cur->is_ConcurrentGC_thread()) &&
0N/A SafepointSynchronize::is_at_safepoint())) {
0N/A ic = CompiledIC_at(call_site);
0N/A CHECK_UNHANDLED_OOPS_ONLY(Thread::current()->clear_unhandled_oops());
0N/A } else {
0N/A MutexLocker ml_verify (CompiledIC_lock);
0N/A ic = CompiledIC_at(call_site);
0N/A }
0N/A PcDesc* pd = pc_desc_at(ic->end_of_call());
0N/A assert(pd != NULL, "PcDesc must exist");
0N/A for (ScopeDesc* sd = new ScopeDesc(this, pd->scope_decode_offset(),
1253N/A pd->obj_decode_offset(), pd->should_reexecute(),
1253N/A pd->return_oop());
0N/A !sd->is_top(); sd = sd->sender()) {
0N/A sd->verify();
0N/A }
0N/A}
0N/A
0N/Avoid nmethod::verify_scopes() {
0N/A if( !method() ) return; // Runtime stubs have no scope
0N/A if (method()->is_native()) return; // Ignore stub methods.
0N/A // iterate through all interrupt point
0N/A // and verify the debug information is valid.
0N/A RelocIterator iter((nmethod*)this);
0N/A while (iter.next()) {
0N/A address stub = NULL;
0N/A switch (iter.type()) {
0N/A case relocInfo::virtual_call_type:
0N/A verify_interrupt_point(iter.addr());
0N/A break;
0N/A case relocInfo::opt_virtual_call_type:
0N/A stub = iter.opt_virtual_call_reloc()->static_stub();
0N/A verify_interrupt_point(iter.addr());
0N/A break;
0N/A case relocInfo::static_call_type:
0N/A stub = iter.static_call_reloc()->static_stub();
0N/A //verify_interrupt_point(iter.addr());
0N/A break;
0N/A case relocInfo::runtime_call_type:
0N/A address destination = iter.reloc()->value();
0N/A // Right now there is no way to find out which entries support
0N/A // an interrupt point. It would be nice if we had this
0N/A // information in a table.
0N/A break;
0N/A }
0N/A assert(stub == NULL || stub_contains(stub), "static call stub outside stub section");
0N/A }
0N/A}
0N/A
0N/A
0N/A// -----------------------------------------------------------------------------
0N/A// Non-product code
0N/A#ifndef PRODUCT
0N/A
989N/Aclass DebugScavengeRoot: public OopClosure {
989N/A nmethod* _nm;
989N/A bool _ok;
989N/Apublic:
989N/A DebugScavengeRoot(nmethod* nm) : _nm(nm), _ok(true) { }
989N/A bool ok() { return _ok; }
989N/A virtual void do_oop(oop* p) {
989N/A if ((*p) == NULL || !(*p)->is_scavengable()) return;
989N/A if (_ok) {
989N/A _nm->print_nmethod(true);
989N/A _ok = false;
989N/A }
989N/A tty->print_cr("*** non-perm oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)",
989N/A (intptr_t)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
989N/A (*p)->print();
989N/A }
989N/A virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
989N/A};
0N/A
989N/Avoid nmethod::verify_scavenge_root_oops() {
989N/A if (!on_scavenge_root_list()) {
989N/A // Actually look inside, to verify the claim that it's clean.
989N/A DebugScavengeRoot debug_scavenge_root(this);
989N/A oops_do(&debug_scavenge_root);
989N/A if (!debug_scavenge_root.ok())
989N/A fatal("found an unadvertised bad non-perm oop in the code cache");
0N/A }
989N/A assert(scavenge_root_not_marked(), "");
0N/A}
0N/A
100N/A#endif // PRODUCT
0N/A
0N/A// Printing operations
0N/A
0N/Avoid nmethod::print() const {
0N/A ResourceMark rm;
0N/A ttyLocker ttyl; // keep the following output all in one block
0N/A
0N/A tty->print("Compiled ");
0N/A
0N/A if (is_compiled_by_c1()) {
0N/A tty->print("(c1) ");
0N/A } else if (is_compiled_by_c2()) {
0N/A tty->print("(c2) ");
1612N/A } else if (is_compiled_by_shark()) {
1612N/A tty->print("(shark) ");
0N/A } else {
0N/A tty->print("(nm) ");
0N/A }
0N/A
0N/A print_on(tty, "nmethod");
0N/A tty->cr();
0N/A if (WizardMode) {
0N/A tty->print("((nmethod*) "INTPTR_FORMAT ") ", this);
0N/A tty->print(" for method " INTPTR_FORMAT , (address)method());
0N/A tty->print(" { ");
0N/A if (is_in_use()) tty->print("in_use ");
0N/A if (is_not_entrant()) tty->print("not_entrant ");
0N/A if (is_zombie()) tty->print("zombie ");
0N/A if (is_unloaded()) tty->print("unloaded ");
989N/A if (on_scavenge_root_list()) tty->print("scavenge_root ");
0N/A tty->print_cr("}:");
0N/A }
0N/A if (size () > 0) tty->print_cr(" total in heap [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A (address)this,
0N/A (address)this + size(),
0N/A size());
0N/A if (relocation_size () > 0) tty->print_cr(" relocation [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A relocation_begin(),
0N/A relocation_end(),
0N/A relocation_size());
1682N/A if (consts_size () > 0) tty->print_cr(" constants [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
1682N/A consts_begin(),
1682N/A consts_end(),
1682N/A consts_size());
1668N/A if (insts_size () > 0) tty->print_cr(" main code [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
1668N/A insts_begin(),
1668N/A insts_end(),
1668N/A insts_size());
0N/A if (stub_size () > 0) tty->print_cr(" stub code [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A stub_begin(),
0N/A stub_end(),
0N/A stub_size());
1483N/A if (oops_size () > 0) tty->print_cr(" oops [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
1483N/A oops_begin(),
1483N/A oops_end(),
1483N/A oops_size());
0N/A if (scopes_data_size () > 0) tty->print_cr(" scopes data [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A scopes_data_begin(),
0N/A scopes_data_end(),
0N/A scopes_data_size());
0N/A if (scopes_pcs_size () > 0) tty->print_cr(" scopes pcs [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A scopes_pcs_begin(),
0N/A scopes_pcs_end(),
0N/A scopes_pcs_size());
0N/A if (dependencies_size () > 0) tty->print_cr(" dependencies [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A dependencies_begin(),
0N/A dependencies_end(),
0N/A dependencies_size());
0N/A if (handler_table_size() > 0) tty->print_cr(" handler table [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A handler_table_begin(),
0N/A handler_table_end(),
0N/A handler_table_size());
0N/A if (nul_chk_table_size() > 0) tty->print_cr(" nul chk table [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
0N/A nul_chk_table_begin(),
0N/A nul_chk_table_end(),
0N/A nul_chk_table_size());
0N/A}
0N/A
100N/Avoid nmethod::print_code() {
100N/A HandleMark hm;
100N/A ResourceMark m;
100N/A Disassembler::decode(this);
100N/A}
100N/A
100N/A
100N/A#ifndef PRODUCT
0N/A
0N/Avoid nmethod::print_scopes() {
0N/A // Find the first pc desc for all scopes in the code and print it.
0N/A ResourceMark rm;
0N/A for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
0N/A if (p->scope_decode_offset() == DebugInformationRecorder::serialized_null)
0N/A continue;
0N/A
0N/A ScopeDesc* sd = scope_desc_at(p->real_pc(this));
0N/A sd->print_on(tty, p);
0N/A }
0N/A}
0N/A
0N/Avoid nmethod::print_dependencies() {
0N/A ResourceMark rm;
0N/A ttyLocker ttyl; // keep the following output all in one block
0N/A tty->print_cr("Dependencies:");
0N/A for (Dependencies::DepStream deps(this); deps.next(); ) {
0N/A deps.print_dependency();
0N/A klassOop ctxk = deps.context_type();
0N/A if (ctxk != NULL) {
0N/A Klass* k = Klass::cast(ctxk);
0N/A if (k->oop_is_instance() && ((instanceKlass*)k)->is_dependent_nmethod(this)) {
30N/A tty->print_cr(" [nmethod<=klass]%s", k->external_name());
0N/A }
0N/A }
0N/A deps.log_dependency(); // put it into the xml log also
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid nmethod::print_relocations() {
0N/A ResourceMark m; // in case methods get printed via the debugger
0N/A tty->print_cr("relocations:");
0N/A RelocIterator iter(this);
0N/A iter.print();
0N/A if (UseRelocIndex) {
0N/A jint* index_end = (jint*)relocation_end() - 1;
0N/A jint index_size = *index_end;
0N/A jint* index_start = (jint*)( (address)index_end - index_size );
0N/A tty->print_cr(" index @" INTPTR_FORMAT ": index_size=%d", index_start, index_size);
0N/A if (index_size > 0) {
0N/A jint* ip;
0N/A for (ip = index_start; ip+2 <= index_end; ip += 2)
0N/A tty->print_cr(" (%d %d) addr=" INTPTR_FORMAT " @" INTPTR_FORMAT,
0N/A ip[0],
0N/A ip[1],
0N/A header_end()+ip[0],
0N/A relocation_begin()-1+ip[1]);
0N/A for (; ip < index_end; ip++)
0N/A tty->print_cr(" (%d ?)", ip[0]);
0N/A tty->print_cr(" @" INTPTR_FORMAT ": index_size=%d", ip, *ip++);
0N/A tty->print_cr("reloc_end @" INTPTR_FORMAT ":", ip);
0N/A }
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid nmethod::print_pcs() {
0N/A ResourceMark m; // in case methods get printed via debugger
0N/A tty->print_cr("pc-bytecode offsets:");
0N/A for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) {
0N/A p->print(this);
0N/A }
0N/A}
0N/A
100N/A#endif // PRODUCT
0N/A
0N/Aconst char* nmethod::reloc_string_for(u_char* begin, u_char* end) {
0N/A RelocIterator iter(this, begin, end);
0N/A bool have_one = false;
0N/A while (iter.next()) {
0N/A have_one = true;
0N/A switch (iter.type()) {
0N/A case relocInfo::none: return "no_reloc";
0N/A case relocInfo::oop_type: {
0N/A stringStream st;
0N/A oop_Relocation* r = iter.oop_reloc();
0N/A oop obj = r->oop_value();
0N/A st.print("oop(");
0N/A if (obj == NULL) st.print("NULL");
0N/A else obj->print_value_on(&st);
0N/A st.print(")");
0N/A return st.as_string();
0N/A }
0N/A case relocInfo::virtual_call_type: return "virtual_call";
0N/A case relocInfo::opt_virtual_call_type: return "optimized virtual_call";
0N/A case relocInfo::static_call_type: return "static_call";
0N/A case relocInfo::static_stub_type: return "static_stub";
0N/A case relocInfo::runtime_call_type: return "runtime_call";
0N/A case relocInfo::external_word_type: return "external_word";
0N/A case relocInfo::internal_word_type: return "internal_word";
0N/A case relocInfo::section_word_type: return "section_word";
0N/A case relocInfo::poll_type: return "poll";
0N/A case relocInfo::poll_return_type: return "poll_return";
0N/A case relocInfo::type_mask: return "type_bit_mask";
0N/A }
0N/A }
0N/A return have_one ? "other" : NULL;
0N/A}
0N/A
0N/A// Return a the last scope in (begin..end]
0N/AScopeDesc* nmethod::scope_desc_in(address begin, address end) {
0N/A PcDesc* p = pc_desc_near(begin+1);
0N/A if (p != NULL && p->real_pc(this) <= end) {
0N/A return new ScopeDesc(this, p->scope_decode_offset(),
1253N/A p->obj_decode_offset(), p->should_reexecute(),
1253N/A p->return_oop());
0N/A }
0N/A return NULL;
0N/A}
0N/A
1155N/Avoid nmethod::print_nmethod_labels(outputStream* stream, address block_begin) {
1155N/A if (block_begin == entry_point()) stream->print_cr("[Entry Point]");
1155N/A if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]");
1155N/A if (block_begin == exception_begin()) stream->print_cr("[Exception Handler]");
1155N/A if (block_begin == stub_begin()) stream->print_cr("[Stub Code]");
1204N/A if (block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]");
1611N/A
1611N/A if (has_method_handle_invokes())
1611N/A if (block_begin == deopt_mh_handler_begin()) stream->print_cr("[Deopt MH Handler Code]");
1611N/A
1155N/A if (block_begin == consts_begin()) stream->print_cr("[Constants]");
1611N/A
1155N/A if (block_begin == entry_point()) {
1155N/A methodHandle m = method();
1155N/A if (m.not_null()) {
1155N/A stream->print(" # ");
1155N/A m->print_value_on(stream);
1155N/A stream->cr();
1155N/A }
1155N/A if (m.not_null() && !is_osr_method()) {
1155N/A ResourceMark rm;
1155N/A int sizeargs = m->size_of_parameters();
1155N/A BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, sizeargs);
1155N/A VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, sizeargs);
1155N/A {
1155N/A int sig_index = 0;
1155N/A if (!m->is_static())
1155N/A sig_bt[sig_index++] = T_OBJECT; // 'this'
1155N/A for (SignatureStream ss(m->signature()); !ss.at_return_type(); ss.next()) {
1155N/A BasicType t = ss.type();
1155N/A sig_bt[sig_index++] = t;
1155N/A if (type2size[t] == 2) {
1155N/A sig_bt[sig_index++] = T_VOID;
1155N/A } else {
1155N/A assert(type2size[t] == 1, "size is 1 or 2");
1155N/A }
1155N/A }
1155N/A assert(sig_index == sizeargs, "");
1155N/A }
1155N/A const char* spname = "sp"; // make arch-specific?
1155N/A intptr_t out_preserve = SharedRuntime::java_calling_convention(sig_bt, regs, sizeargs, false);
1155N/A int stack_slot_offset = this->frame_size() * wordSize;
1155N/A int tab1 = 14, tab2 = 24;
1155N/A int sig_index = 0;
1155N/A int arg_index = (m->is_static() ? 0 : -1);
1155N/A bool did_old_sp = false;
1155N/A for (SignatureStream ss(m->signature()); !ss.at_return_type(); ) {
1155N/A bool at_this = (arg_index == -1);
1155N/A bool at_old_sp = false;
1155N/A BasicType t = (at_this ? T_OBJECT : ss.type());
1155N/A assert(t == sig_bt[sig_index], "sigs in sync");
1155N/A if (at_this)
1155N/A stream->print(" # this: ");
1155N/A else
1155N/A stream->print(" # parm%d: ", arg_index);
1155N/A stream->move_to(tab1);
1155N/A VMReg fst = regs[sig_index].first();
1155N/A VMReg snd = regs[sig_index].second();
1155N/A if (fst->is_reg()) {
1155N/A stream->print("%s", fst->name());
1155N/A if (snd->is_valid()) {
1155N/A stream->print(":%s", snd->name());
1155N/A }
1155N/A } else if (fst->is_stack()) {
1155N/A int offset = fst->reg2stack() * VMRegImpl::stack_slot_size + stack_slot_offset;
1155N/A if (offset == stack_slot_offset) at_old_sp = true;
1155N/A stream->print("[%s+0x%x]", spname, offset);
1155N/A } else {
1155N/A stream->print("reg%d:%d??", (int)(intptr_t)fst, (int)(intptr_t)snd);
1155N/A }
1155N/A stream->print(" ");
1155N/A stream->move_to(tab2);
1155N/A stream->print("= ");
1155N/A if (at_this) {
1155N/A m->method_holder()->print_value_on(stream);
1155N/A } else {
1155N/A bool did_name = false;
1155N/A if (!at_this && ss.is_object()) {
1155N/A symbolOop name = ss.as_symbol_or_null();
1155N/A if (name != NULL) {
1155N/A name->print_value_on(stream);
1155N/A did_name = true;
1155N/A }
1155N/A }
1155N/A if (!did_name)
1155N/A stream->print("%s", type2name(t));
1155N/A }
1155N/A if (at_old_sp) {
1155N/A stream->print(" (%s of caller)", spname);
1155N/A did_old_sp = true;
1155N/A }
1155N/A stream->cr();
1155N/A sig_index += type2size[t];
1155N/A arg_index += 1;
1155N/A if (!at_this) ss.next();
1155N/A }
1155N/A if (!did_old_sp) {
1155N/A stream->print(" # ");
1155N/A stream->move_to(tab1);
1155N/A stream->print("[%s+0x%x]", spname, stack_slot_offset);
1155N/A stream->print(" (%s of caller)", spname);
1155N/A stream->cr();
1155N/A }
1155N/A }
1155N/A }
1155N/A}
1155N/A
0N/Avoid nmethod::print_code_comment_on(outputStream* st, int column, u_char* begin, u_char* end) {
0N/A // First, find an oopmap in (begin, end].
0N/A // We use the odd half-closed interval so that oop maps and scope descs
0N/A // which are tied to the byte after a call are printed with the call itself.
1668N/A address base = code_begin();
0N/A OopMapSet* oms = oop_maps();
0N/A if (oms != NULL) {
0N/A for (int i = 0, imax = oms->size(); i < imax; i++) {
0N/A OopMap* om = oms->at(i);
0N/A address pc = base + om->offset();
0N/A if (pc > begin) {
0N/A if (pc <= end) {
100N/A st->move_to(column);
100N/A st->print("; ");
100N/A om->print_on(st);
0N/A }
0N/A break;
0N/A }
0N/A }
0N/A }
100N/A
100N/A // Print any debug info present at this pc.
0N/A ScopeDesc* sd = scope_desc_in(begin, end);
0N/A if (sd != NULL) {
100N/A st->move_to(column);
0N/A if (sd->bci() == SynchronizationEntryBCI) {
0N/A st->print(";*synchronization entry");
0N/A } else {
0N/A if (sd->method().is_null()) {
100N/A st->print("method is NULL");
0N/A } else if (sd->method()->is_native()) {
100N/A st->print("method is native");
0N/A } else {
0N/A address bcp = sd->method()->bcp_from(sd->bci());
0N/A Bytecodes::Code bc = Bytecodes::java_code_at(bcp);
0N/A st->print(";*%s", Bytecodes::name(bc));
0N/A switch (bc) {
0N/A case Bytecodes::_invokevirtual:
0N/A case Bytecodes::_invokespecial:
0N/A case Bytecodes::_invokestatic:
0N/A case Bytecodes::_invokeinterface:
0N/A {
0N/A Bytecode_invoke* invoke = Bytecode_invoke_at(sd->method(), sd->bci());
0N/A st->print(" ");
0N/A if (invoke->name() != NULL)
0N/A invoke->name()->print_symbol_on(st);
0N/A else
0N/A st->print("<UNKNOWN>");
0N/A break;
0N/A }
0N/A case Bytecodes::_getfield:
0N/A case Bytecodes::_putfield:
0N/A case Bytecodes::_getstatic:
0N/A case Bytecodes::_putstatic:
0N/A {
1522N/A Bytecode_field* field = Bytecode_field_at(sd->method(), sd->bci());
0N/A st->print(" ");
1522N/A if (field->name() != NULL)
1522N/A field->name()->print_symbol_on(st);
0N/A else
0N/A st->print("<UNKNOWN>");
0N/A }
0N/A }
0N/A }
0N/A }
100N/A
0N/A // Print all scopes
0N/A for (;sd != NULL; sd = sd->sender()) {
100N/A st->move_to(column);
0N/A st->print("; -");
0N/A if (sd->method().is_null()) {
100N/A st->print("method is NULL");
0N/A } else {
0N/A sd->method()->print_short_name(st);
0N/A }
0N/A int lineno = sd->method()->line_number_from_bci(sd->bci());
0N/A if (lineno != -1) {
0N/A st->print("@%d (line %d)", sd->bci(), lineno);
0N/A } else {
0N/A st->print("@%d", sd->bci());
0N/A }
0N/A st->cr();
0N/A }
0N/A }
0N/A
0N/A // Print relocation information
0N/A const char* str = reloc_string_for(begin, end);
0N/A if (str != NULL) {
0N/A if (sd != NULL) st->cr();
100N/A st->move_to(column);
0N/A st->print("; {%s}", str);
0N/A }
1668N/A int cont_offset = ImplicitExceptionTable(this).at(begin - code_begin());
0N/A if (cont_offset != 0) {
100N/A st->move_to(column);
1668N/A st->print("; implicit exception: dispatches to " INTPTR_FORMAT, code_begin() + cont_offset);
0N/A }
0N/A
0N/A}
0N/A
100N/A#ifndef PRODUCT
100N/A
0N/Avoid nmethod::print_value_on(outputStream* st) const {
0N/A print_on(st, "nmethod");
0N/A}
0N/A
0N/Avoid nmethod::print_calls(outputStream* st) {
0N/A RelocIterator iter(this);
0N/A while (iter.next()) {
0N/A switch (iter.type()) {
0N/A case relocInfo::virtual_call_type:
0N/A case relocInfo::opt_virtual_call_type: {
0N/A VerifyMutexLocker mc(CompiledIC_lock);
0N/A CompiledIC_at(iter.reloc())->print();
0N/A break;
0N/A }
0N/A case relocInfo::static_call_type:
0N/A st->print_cr("Static call at " INTPTR_FORMAT, iter.reloc()->addr());
0N/A compiledStaticCall_at(iter.reloc())->print();
0N/A break;
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid nmethod::print_handler_table() {
0N/A ExceptionHandlerTable(this).print();
0N/A}
0N/A
0N/Avoid nmethod::print_nul_chk_table() {
1668N/A ImplicitExceptionTable(this).print(code_begin());
0N/A}
0N/A
0N/Avoid nmethod::print_statistics() {
0N/A ttyLocker ttyl;
0N/A if (xtty != NULL) xtty->head("statistics type='nmethod'");
0N/A nmethod_stats.print_native_nmethod_stats();
0N/A nmethod_stats.print_nmethod_stats();
0N/A DebugInformationRecorder::print_statistics();
0N/A nmethod_stats.print_pc_stats();
0N/A Dependencies::print_statistics();
0N/A if (xtty != NULL) xtty->tail("statistics");
0N/A}
0N/A
0N/A#endif // PRODUCT