frame.cpp revision 2062
0N/A/*
2027N/A * Copyright (c) 1997, 2011, 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 "gc_interface/collectedHeap.inline.hpp"
1879N/A#include "interpreter/interpreter.hpp"
1879N/A#include "interpreter/oopMapCache.hpp"
1879N/A#include "memory/resourceArea.hpp"
1879N/A#include "memory/universe.inline.hpp"
1879N/A#include "oops/markOop.hpp"
1879N/A#include "oops/methodDataOop.hpp"
1879N/A#include "oops/methodOop.hpp"
1879N/A#include "oops/oop.inline.hpp"
1879N/A#include "oops/oop.inline2.hpp"
1879N/A#include "runtime/frame.inline.hpp"
1879N/A#include "runtime/handles.inline.hpp"
1879N/A#include "runtime/javaCalls.hpp"
1879N/A#include "runtime/monitorChunk.hpp"
1879N/A#include "runtime/sharedRuntime.hpp"
1879N/A#include "runtime/signature.hpp"
1879N/A#include "runtime/stubCodeGenerator.hpp"
1879N/A#include "runtime/stubRoutines.hpp"
1929N/A#include "utilities/decoder.hpp"
1929N/A
1879N/A#ifdef TARGET_ARCH_x86
1879N/A# include "nativeInst_x86.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_sparc
1879N/A# include "nativeInst_sparc.hpp"
1879N/A#endif
1879N/A#ifdef TARGET_ARCH_zero
1879N/A# include "nativeInst_zero.hpp"
1879N/A#endif
0N/A
0N/ARegisterMap::RegisterMap(JavaThread *thread, bool update_map) {
0N/A _thread = thread;
0N/A _update_map = update_map;
0N/A clear();
0N/A debug_only(_update_for_id = NULL;)
0N/A#ifndef PRODUCT
0N/A for (int i = 0; i < reg_count ; i++ ) _location[i] = NULL;
0N/A#endif /* PRODUCT */
0N/A}
0N/A
0N/ARegisterMap::RegisterMap(const RegisterMap* map) {
0N/A assert(map != this, "bad initialization parameter");
0N/A assert(map != NULL, "RegisterMap must be present");
0N/A _thread = map->thread();
0N/A _update_map = map->update_map();
0N/A _include_argument_oops = map->include_argument_oops();
0N/A debug_only(_update_for_id = map->_update_for_id;)
0N/A pd_initialize_from(map);
0N/A if (update_map()) {
0N/A for(int i = 0; i < location_valid_size; i++) {
0N/A LocationValidType bits = !update_map() ? 0 : map->_location_valid[i];
0N/A _location_valid[i] = bits;
0N/A // for whichever bits are set, pull in the corresponding map->_location
0N/A int j = i*location_valid_type_size;
0N/A while (bits != 0) {
0N/A if ((bits & 1) != 0) {
0N/A assert(0 <= j && j < reg_count, "range check");
0N/A _location[j] = map->_location[j];
0N/A }
0N/A bits >>= 1;
0N/A j += 1;
0N/A }
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid RegisterMap::clear() {
0N/A set_include_argument_oops(true);
0N/A if (_update_map) {
0N/A for(int i = 0; i < location_valid_size; i++) {
0N/A _location_valid[i] = 0;
0N/A }
0N/A pd_clear();
0N/A } else {
0N/A pd_initialize();
0N/A }
0N/A}
0N/A
0N/A#ifndef PRODUCT
0N/A
0N/Avoid RegisterMap::print_on(outputStream* st) const {
0N/A st->print_cr("Register map");
0N/A for(int i = 0; i < reg_count; i++) {
0N/A
0N/A VMReg r = VMRegImpl::as_VMReg(i);
0N/A intptr_t* src = (intptr_t*) location(r);
0N/A if (src != NULL) {
0N/A
417N/A r->print_on(st);
417N/A st->print(" [" INTPTR_FORMAT "] = ", src);
0N/A if (((uintptr_t)src & (sizeof(*src)-1)) != 0) {
417N/A st->print_cr("<misaligned>");
0N/A } else {
417N/A st->print_cr(INTPTR_FORMAT, *src);
0N/A }
0N/A }
0N/A }
0N/A}
0N/A
0N/Avoid RegisterMap::print() const {
0N/A print_on(tty);
0N/A}
0N/A
0N/A#endif
0N/A// This returns the pc that if you were in the debugger you'd see. Not
0N/A// the idealized value in the frame object. This undoes the magic conversion
0N/A// that happens for deoptimized frames. In addition it makes the value the
0N/A// hardware would want to see in the native frame. The only user (at this point)
0N/A// is deoptimization. It likely no one else should ever use it.
0N/A
0N/Aaddress frame::raw_pc() const {
0N/A if (is_deoptimized_frame()) {
1204N/A nmethod* nm = cb()->as_nmethod_or_null();
1204N/A if (nm->is_method_handle_return(pc()))
1204N/A return nm->deopt_mh_handler_begin() - pc_return_offset;
1204N/A else
1204N/A return nm->deopt_handler_begin() - pc_return_offset;
0N/A } else {
0N/A return (pc() - pc_return_offset);
0N/A }
0N/A}
0N/A
0N/A// Change the pc in a frame object. This does not change the actual pc in
0N/A// actual frame. To do that use patch_pc.
0N/A//
0N/Avoid frame::set_pc(address newpc ) {
0N/A#ifdef ASSERT
0N/A if (_cb != NULL && _cb->is_nmethod()) {
0N/A assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant violation");
0N/A }
0N/A#endif // ASSERT
0N/A
0N/A // Unsafe to use the is_deoptimzed tester after changing pc
0N/A _deopt_state = unknown;
0N/A _pc = newpc;
0N/A _cb = CodeCache::find_blob_unsafe(_pc);
0N/A
0N/A}
0N/A
0N/A// type testers
0N/Abool frame::is_deoptimized_frame() const {
0N/A assert(_deopt_state != unknown, "not answerable");
0N/A return _deopt_state == is_deoptimized;
0N/A}
0N/A
0N/Abool frame::is_native_frame() const {
0N/A return (_cb != NULL &&
0N/A _cb->is_nmethod() &&
0N/A ((nmethod*)_cb)->is_native_method());
0N/A}
0N/A
0N/Abool frame::is_java_frame() const {
0N/A if (is_interpreted_frame()) return true;
0N/A if (is_compiled_frame()) return true;
0N/A return false;
0N/A}
0N/A
0N/A
0N/Abool frame::is_compiled_frame() const {
0N/A if (_cb != NULL &&
0N/A _cb->is_nmethod() &&
0N/A ((nmethod*)_cb)->is_java_method()) {
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A
0N/A
0N/Abool frame::is_runtime_frame() const {
0N/A return (_cb != NULL && _cb->is_runtime_stub());
0N/A}
0N/A
0N/Abool frame::is_safepoint_blob_frame() const {
0N/A return (_cb != NULL && _cb->is_safepoint_stub());
0N/A}
0N/A
0N/A// testers
0N/A
0N/Abool frame::is_first_java_frame() const {
0N/A RegisterMap map(JavaThread::current(), false); // No update
0N/A frame s;
0N/A for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map));
0N/A return s.is_first_frame();
0N/A}
0N/A
0N/A
0N/Abool frame::entry_frame_is_first() const {
0N/A return entry_frame_call_wrapper()->anchor()->last_Java_sp() == NULL;
0N/A}
0N/A
0N/A
0N/Abool frame::should_be_deoptimized() const {
0N/A if (_deopt_state == is_deoptimized ||
0N/A !is_compiled_frame() ) return false;
0N/A assert(_cb != NULL && _cb->is_nmethod(), "must be an nmethod");
0N/A nmethod* nm = (nmethod *)_cb;
0N/A if (TraceDependencies) {
0N/A tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false");
0N/A nm->print_value_on(tty);
0N/A tty->cr();
0N/A }
0N/A
0N/A if( !nm->is_marked_for_deoptimization() )
0N/A return false;
0N/A
0N/A // If at the return point, then the frame has already been popped, and
0N/A // only the return needs to be executed. Don't deoptimize here.
0N/A return !nm->is_at_poll_return(pc());
0N/A}
0N/A
0N/Abool frame::can_be_deoptimized() const {
0N/A if (!is_compiled_frame()) return false;
0N/A nmethod* nm = (nmethod*)_cb;
0N/A
0N/A if( !nm->can_be_deoptimized() )
0N/A return false;
0N/A
0N/A return !nm->is_at_poll_return(pc());
0N/A}
0N/A
1647N/Avoid frame::deoptimize(JavaThread* thread) {
1647N/A // Schedule deoptimization of an nmethod activation with this frame.
0N/A assert(_cb != NULL && _cb->is_nmethod(), "must be");
0N/A nmethod* nm = (nmethod*)_cb;
0N/A
0N/A // This is a fix for register window patching race
1647N/A if (NeedsDeoptSuspend && Thread::current() != thread) {
1647N/A assert(SafepointSynchronize::is_at_safepoint(),
1647N/A "patching other threads for deopt may only occur at a safepoint");
0N/A
0N/A // It is possible especially with DeoptimizeALot/DeoptimizeRandom that
0N/A // we could see the frame again and ask for it to be deoptimized since
0N/A // it might move for a long time. That is harmless and we just ignore it.
0N/A if (id() == thread->must_deopt_id()) {
0N/A assert(thread->is_deopt_suspend(), "lost suspension");
0N/A return;
0N/A }
0N/A
0N/A // We are at a safepoint so the target thread can only be
0N/A // in 4 states:
0N/A // blocked - no problem
0N/A // blocked_trans - no problem (i.e. could have woken up from blocked
0N/A // during a safepoint).
0N/A // native - register window pc patching race
0N/A // native_trans - momentary state
0N/A //
0N/A // We could just wait out a thread in native_trans to block.
0N/A // Then we'd have all the issues that the safepoint code has as to
0N/A // whether to spin or block. It isn't worth it. Just treat it like
0N/A // native and be done with it.
0N/A //
1647N/A // Examine the state of the thread at the start of safepoint since
1647N/A // threads that were in native at the start of the safepoint could
1647N/A // come to a halt during the safepoint, changing the current value
1647N/A // of the safepoint_state.
1647N/A JavaThreadState state = thread->safepoint_state()->orig_thread_state();
0N/A if (state == _thread_in_native || state == _thread_in_native_trans) {
0N/A // Since we are at a safepoint the target thread will stop itself
0N/A // before it can return to java as long as we remain at the safepoint.
0N/A // Therefore we can put an additional request for the thread to stop
0N/A // no matter what no (like a suspend). This will cause the thread
0N/A // to notice it needs to do the deopt on its own once it leaves native.
0N/A //
0N/A // The only reason we must do this is because on machine with register
0N/A // windows we have a race with patching the return address and the
0N/A // window coming live as the thread returns to the Java code (but still
0N/A // in native mode) and then blocks. It is only this top most frame
0N/A // that is at risk. So in truth we could add an additional check to
0N/A // see if this frame is one that is at risk.
0N/A RegisterMap map(thread, false);
0N/A frame at_risk = thread->last_frame().sender(&map);
0N/A if (id() == at_risk.id()) {
0N/A thread->set_must_deopt_id(id());
0N/A thread->set_deopt_suspend();
0N/A return;
0N/A }
0N/A }
0N/A } // NeedsDeoptSuspend
0N/A
0N/A
1204N/A // If the call site is a MethodHandle call site use the MH deopt
1204N/A // handler.
1204N/A address deopt = nm->is_method_handle_return(pc()) ?
1204N/A nm->deopt_mh_handler_begin() :
1204N/A nm->deopt_handler_begin();
1204N/A
0N/A // Save the original pc before we patch in the new one
0N/A nm->set_original_pc(this, pc());
0N/A patch_pc(thread, deopt);
1204N/A
0N/A#ifdef ASSERT
0N/A {
0N/A RegisterMap map(thread, false);
0N/A frame check = thread->last_frame();
0N/A while (id() != check.id()) {
0N/A check = check.sender(&map);
0N/A }
0N/A assert(check.is_deoptimized_frame(), "missed deopt");
0N/A }
0N/A#endif // ASSERT
0N/A}
0N/A
0N/Aframe frame::java_sender() const {
0N/A RegisterMap map(JavaThread::current(), false);
0N/A frame s;
0N/A for (s = sender(&map); !(s.is_java_frame() || s.is_first_frame()); s = s.sender(&map)) ;
0N/A guarantee(s.is_java_frame(), "tried to get caller of first java frame");
0N/A return s;
0N/A}
0N/A
0N/Aframe frame::real_sender(RegisterMap* map) const {
0N/A frame result = sender(map);
0N/A while (result.is_runtime_frame()) {
0N/A result = result.sender(map);
0N/A }
0N/A return result;
0N/A}
0N/A
0N/A// Note: called by profiler - NOT for current thread
0N/Aframe frame::profile_find_Java_sender_frame(JavaThread *thread) {
0N/A// If we don't recognize this frame, walk back up the stack until we do
0N/A RegisterMap map(thread, false);
0N/A frame first_java_frame = frame();
0N/A
0N/A // Find the first Java frame on the stack starting with input frame
0N/A if (is_java_frame()) {
0N/A // top frame is compiled frame or deoptimized frame
0N/A first_java_frame = *this;
0N/A } else if (safe_for_sender(thread)) {
0N/A for (frame sender_frame = sender(&map);
0N/A sender_frame.safe_for_sender(thread) && !sender_frame.is_first_frame();
0N/A sender_frame = sender_frame.sender(&map)) {
0N/A if (sender_frame.is_java_frame()) {
0N/A first_java_frame = sender_frame;
0N/A break;
0N/A }
0N/A }
0N/A }
0N/A return first_java_frame;
0N/A}
0N/A
0N/A// Interpreter frames
0N/A
0N/A
0N/Avoid frame::interpreter_frame_set_locals(intptr_t* locs) {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A *interpreter_frame_locals_addr() = locs;
0N/A}
0N/A
0N/AmethodOop frame::interpreter_frame_method() const {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A methodOop m = *interpreter_frame_method_addr();
0N/A assert(m->is_perm(), "bad methodOop in interpreter frame");
0N/A assert(m->is_method(), "not a methodOop");
0N/A return m;
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_method(methodOop method) {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A *interpreter_frame_method_addr() = method;
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_bcx(intptr_t bcx) {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A if (ProfileInterpreter) {
0N/A bool formerly_bci = is_bci(interpreter_frame_bcx());
0N/A bool is_now_bci = is_bci(bcx);
0N/A *interpreter_frame_bcx_addr() = bcx;
0N/A
0N/A intptr_t mdx = interpreter_frame_mdx();
0N/A
0N/A if (mdx != 0) {
0N/A if (formerly_bci) {
0N/A if (!is_now_bci) {
0N/A // The bcx was just converted from bci to bcp.
0N/A // Convert the mdx in parallel.
0N/A methodDataOop mdo = interpreter_frame_method()->method_data();
0N/A assert(mdo != NULL, "");
0N/A int mdi = mdx - 1; // We distinguish valid mdi from zero by adding one.
0N/A address mdp = mdo->di_to_dp(mdi);
0N/A interpreter_frame_set_mdx((intptr_t)mdp);
0N/A }
0N/A } else {
0N/A if (is_now_bci) {
0N/A // The bcx was just converted from bcp to bci.
0N/A // Convert the mdx in parallel.
0N/A methodDataOop mdo = interpreter_frame_method()->method_data();
0N/A assert(mdo != NULL, "");
0N/A int mdi = mdo->dp_to_di((address)mdx);
0N/A interpreter_frame_set_mdx((intptr_t)mdi + 1); // distinguish valid from 0.
0N/A }
0N/A }
0N/A }
0N/A } else {
0N/A *interpreter_frame_bcx_addr() = bcx;
0N/A }
0N/A}
0N/A
0N/Ajint frame::interpreter_frame_bci() const {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A intptr_t bcx = interpreter_frame_bcx();
0N/A return is_bci(bcx) ? bcx : interpreter_frame_method()->bci_from((address)bcx);
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_bci(jint bci) {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A assert(!is_bci(interpreter_frame_bcx()), "should not set bci during GC");
0N/A interpreter_frame_set_bcx((intptr_t)interpreter_frame_method()->bcp_from(bci));
0N/A}
0N/A
0N/Aaddress frame::interpreter_frame_bcp() const {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A intptr_t bcx = interpreter_frame_bcx();
0N/A return is_bci(bcx) ? interpreter_frame_method()->bcp_from(bcx) : (address)bcx;
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_bcp(address bcp) {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A assert(!is_bci(interpreter_frame_bcx()), "should not set bcp during GC");
0N/A interpreter_frame_set_bcx((intptr_t)bcp);
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_mdx(intptr_t mdx) {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A assert(ProfileInterpreter, "must be profiling interpreter");
0N/A *interpreter_frame_mdx_addr() = mdx;
0N/A}
0N/A
0N/Aaddress frame::interpreter_frame_mdp() const {
0N/A assert(ProfileInterpreter, "must be profiling interpreter");
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A intptr_t bcx = interpreter_frame_bcx();
0N/A intptr_t mdx = interpreter_frame_mdx();
0N/A
0N/A assert(!is_bci(bcx), "should not access mdp during GC");
0N/A return (address)mdx;
0N/A}
0N/A
0N/Avoid frame::interpreter_frame_set_mdp(address mdp) {
0N/A assert(is_interpreted_frame(), "interpreted frame expected");
0N/A if (mdp == NULL) {
0N/A // Always allow the mdp to be cleared.
0N/A interpreter_frame_set_mdx((intptr_t)mdp);
0N/A }
0N/A intptr_t bcx = interpreter_frame_bcx();
0N/A assert(!is_bci(bcx), "should not set mdp during GC");
0N/A interpreter_frame_set_mdx((intptr_t)mdp);
0N/A}
0N/A
0N/ABasicObjectLock* frame::next_monitor_in_interpreter_frame(BasicObjectLock* current) const {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A#ifdef ASSERT
0N/A interpreter_frame_verify_monitor(current);
0N/A#endif
0N/A BasicObjectLock* next = (BasicObjectLock*) (((intptr_t*) current) + interpreter_frame_monitor_size());
0N/A return next;
0N/A}
0N/A
0N/ABasicObjectLock* frame::previous_monitor_in_interpreter_frame(BasicObjectLock* current) const {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A#ifdef ASSERT
0N/A// // This verification needs to be checked before being enabled
0N/A// interpreter_frame_verify_monitor(current);
0N/A#endif
0N/A BasicObjectLock* previous = (BasicObjectLock*) (((intptr_t*) current) - interpreter_frame_monitor_size());
0N/A return previous;
0N/A}
0N/A
0N/A// Interpreter locals and expression stack locations.
0N/A
0N/Aintptr_t* frame::interpreter_frame_local_at(int index) const {
0N/A const int n = Interpreter::local_offset_in_bytes(index)/wordSize;
0N/A return &((*interpreter_frame_locals_addr())[n]);
0N/A}
0N/A
0N/Aintptr_t* frame::interpreter_frame_expression_stack_at(jint offset) const {
0N/A const int i = offset * interpreter_frame_expression_stack_direction();
1426N/A const int n = i * Interpreter::stackElementWords;
0N/A return &(interpreter_frame_expression_stack()[n]);
0N/A}
0N/A
0N/Ajint frame::interpreter_frame_expression_stack_size() const {
0N/A // Number of elements on the interpreter expression stack
0N/A // Callers should span by stackElementWords
1426N/A int element_size = Interpreter::stackElementWords;
0N/A if (frame::interpreter_frame_expression_stack_direction() < 0) {
0N/A return (interpreter_frame_expression_stack() -
0N/A interpreter_frame_tos_address() + 1)/element_size;
0N/A } else {
0N/A return (interpreter_frame_tos_address() -
0N/A interpreter_frame_expression_stack() + 1)/element_size;
0N/A }
0N/A}
0N/A
0N/A
0N/A// (frame::interpreter_frame_sender_sp accessor is in frame_<arch>.cpp)
0N/A
0N/Aconst char* frame::print_name() const {
0N/A if (is_native_frame()) return "Native";
0N/A if (is_interpreted_frame()) return "Interpreted";
0N/A if (is_compiled_frame()) {
0N/A if (is_deoptimized_frame()) return "Deoptimized";
0N/A return "Compiled";
0N/A }
0N/A if (sp() == NULL) return "Empty";
0N/A return "C";
0N/A}
0N/A
0N/Avoid frame::print_value_on(outputStream* st, JavaThread *thread) const {
0N/A NOT_PRODUCT(address begin = pc()-40;)
0N/A NOT_PRODUCT(address end = NULL;)
0N/A
0N/A st->print("%s frame (sp=" INTPTR_FORMAT " unextended sp=" INTPTR_FORMAT, print_name(), sp(), unextended_sp());
0N/A if (sp() != NULL)
0N/A st->print(", fp=" INTPTR_FORMAT ", pc=" INTPTR_FORMAT, fp(), pc());
0N/A
0N/A if (StubRoutines::contains(pc())) {
0N/A st->print_cr(")");
0N/A st->print("(");
0N/A StubCodeDesc* desc = StubCodeDesc::desc_for(pc());
0N/A st->print("~Stub::%s", desc->name());
0N/A NOT_PRODUCT(begin = desc->begin(); end = desc->end();)
0N/A } else if (Interpreter::contains(pc())) {
0N/A st->print_cr(")");
0N/A st->print("(");
0N/A InterpreterCodelet* desc = Interpreter::codelet_containing(pc());
0N/A if (desc != NULL) {
0N/A st->print("~");
0N/A desc->print();
0N/A NOT_PRODUCT(begin = desc->code_begin(); end = desc->code_end();)
0N/A } else {
0N/A st->print("~interpreter");
0N/A }
0N/A }
0N/A st->print_cr(")");
0N/A
0N/A if (_cb != NULL) {
0N/A st->print(" ");
0N/A _cb->print_value_on(st);
0N/A st->cr();
0N/A#ifndef PRODUCT
0N/A if (end == NULL) {
1668N/A begin = _cb->code_begin();
1668N/A end = _cb->code_end();
0N/A }
0N/A#endif
0N/A }
0N/A NOT_PRODUCT(if (WizardMode && Verbose) Disassembler::decode(begin, end);)
0N/A}
0N/A
0N/A
0N/Avoid frame::print_on(outputStream* st) const {
0N/A print_value_on(st,NULL);
0N/A if (is_interpreted_frame()) {
0N/A interpreter_frame_print_on(st);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid frame::interpreter_frame_print_on(outputStream* st) const {
0N/A#ifndef PRODUCT
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A jint i;
0N/A for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
0N/A intptr_t x = *interpreter_frame_local_at(i);
0N/A st->print(" - local [" INTPTR_FORMAT "]", x);
0N/A st->fill_to(23);
0N/A st->print_cr("; #%d", i);
0N/A }
0N/A for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
0N/A intptr_t x = *interpreter_frame_expression_stack_at(i);
0N/A st->print(" - stack [" INTPTR_FORMAT "]", x);
0N/A st->fill_to(23);
0N/A st->print_cr("; #%d", i);
0N/A }
0N/A // locks for synchronization
0N/A for (BasicObjectLock* current = interpreter_frame_monitor_end();
0N/A current < interpreter_frame_monitor_begin();
0N/A current = next_monitor_in_interpreter_frame(current)) {
1255N/A st->print(" - obj [");
0N/A current->obj()->print_value_on(st);
1255N/A st->print_cr("]");
1255N/A st->print(" - lock [");
0N/A current->lock()->print_on(st);
1255N/A st->print_cr("]");
0N/A }
0N/A // monitor
0N/A st->print_cr(" - monitor[" INTPTR_FORMAT "]", interpreter_frame_monitor_begin());
0N/A // bcp
0N/A st->print(" - bcp [" INTPTR_FORMAT "]", interpreter_frame_bcp());
0N/A st->fill_to(23);
0N/A st->print_cr("; @%d", interpreter_frame_bci());
0N/A // locals
0N/A st->print_cr(" - locals [" INTPTR_FORMAT "]", interpreter_frame_local_at(0));
0N/A // method
0N/A st->print(" - method [" INTPTR_FORMAT "]", (address)interpreter_frame_method());
0N/A st->fill_to(23);
0N/A st->print("; ");
0N/A interpreter_frame_method()->print_name(st);
0N/A st->cr();
0N/A#endif
0N/A}
0N/A
0N/A// Return whether the frame is in the VM or os indicating a Hotspot problem.
0N/A// Otherwise, it's likely a bug in the native library that the Java code calls,
0N/A// hopefully indicating where to submit bugs.
0N/Astatic void print_C_frame(outputStream* st, char* buf, int buflen, address pc) {
0N/A // C/C++ frame
0N/A bool in_vm = os::address_is_in_vm(pc);
0N/A st->print(in_vm ? "V" : "C");
0N/A
0N/A int offset;
0N/A bool found;
0N/A
0N/A // libname
0N/A found = os::dll_address_to_library_name(pc, buf, buflen, &offset);
0N/A if (found) {
0N/A // skip directory names
0N/A const char *p1, *p2;
0N/A p1 = buf;
0N/A int len = (int)strlen(os::file_separator());
0N/A while ((p2 = strstr(p1, os::file_separator())) != NULL) p1 = p2 + len;
0N/A st->print(" [%s+0x%x]", p1, offset);
0N/A } else {
0N/A st->print(" " PTR_FORMAT, pc);
0N/A }
0N/A
0N/A // function name - os::dll_address_to_function_name() may return confusing
0N/A // names if pc is within jvm.dll or libjvm.so, because JVM only has
0N/A // JVM_xxxx and a few other symbols in the dynamic symbol table. Do this
0N/A // only for native libraries.
1929N/A if (!in_vm || Decoder::can_decode_C_frame_in_vm()) {
0N/A found = os::dll_address_to_function_name(pc, buf, buflen, &offset);
0N/A
0N/A if (found) {
0N/A st->print(" %s+0x%x", buf, offset);
0N/A }
0N/A }
0N/A}
0N/A
0N/A// frame::print_on_error() is called by fatal error handler. Notice that we may
0N/A// crash inside this function if stack frame is corrupted. The fatal error
0N/A// handler can catch and handle the crash. Here we assume the frame is valid.
0N/A//
0N/A// First letter indicates type of the frame:
0N/A// J: Java frame (compiled)
0N/A// j: Java frame (interpreted)
0N/A// V: VM frame (C/C++)
0N/A// v: Other frames running VM generated code (e.g. stubs, adapters, etc.)
0N/A// C: C/C++ frame
0N/A//
0N/A// We don't need detailed frame type as that in frame::print_name(). "C"
0N/A// suggests the problem is in user lib; everything else is likely a VM bug.
0N/A
0N/Avoid frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose) const {
0N/A if (_cb != NULL) {
0N/A if (Interpreter::contains(pc())) {
0N/A methodOop m = this->interpreter_frame_method();
0N/A if (m != NULL) {
0N/A m->name_and_sig_as_C_string(buf, buflen);
0N/A st->print("j %s", buf);
0N/A st->print("+%d", this->interpreter_frame_bci());
0N/A } else {
0N/A st->print("j " PTR_FORMAT, pc());
0N/A }
0N/A } else if (StubRoutines::contains(pc())) {
0N/A StubCodeDesc* desc = StubCodeDesc::desc_for(pc());
0N/A if (desc != NULL) {
0N/A st->print("v ~StubRoutines::%s", desc->name());
0N/A } else {
0N/A st->print("v ~StubRoutines::" PTR_FORMAT, pc());
0N/A }
0N/A } else if (_cb->is_buffer_blob()) {
0N/A st->print("v ~BufferBlob::%s", ((BufferBlob *)_cb)->name());
0N/A } else if (_cb->is_nmethod()) {
0N/A methodOop m = ((nmethod *)_cb)->method();
0N/A if (m != NULL) {
0N/A m->name_and_sig_as_C_string(buf, buflen);
0N/A st->print("J %s", buf);
0N/A } else {
0N/A st->print("J " PTR_FORMAT, pc());
0N/A }
0N/A } else if (_cb->is_runtime_stub()) {
0N/A st->print("v ~RuntimeStub::%s", ((RuntimeStub *)_cb)->name());
0N/A } else if (_cb->is_deoptimization_stub()) {
0N/A st->print("v ~DeoptimizationBlob");
0N/A } else if (_cb->is_exception_stub()) {
0N/A st->print("v ~ExceptionBlob");
0N/A } else if (_cb->is_safepoint_stub()) {
0N/A st->print("v ~SafepointBlob");
0N/A } else {
0N/A st->print("v blob " PTR_FORMAT, pc());
0N/A }
0N/A } else {
0N/A print_C_frame(st, buf, buflen, pc());
0N/A }
0N/A}
0N/A
0N/A
0N/A/*
0N/A The interpreter_frame_expression_stack_at method in the case of SPARC needs the
0N/A max_stack value of the method in order to compute the expression stack address.
0N/A It uses the methodOop in order to get the max_stack value but during GC this
0N/A methodOop value saved on the frame is changed by reverse_and_push and hence cannot
0N/A be used. So we save the max_stack value in the FrameClosure object and pass it
0N/A down to the interpreter_frame_expression_stack_at method
0N/A*/
0N/Aclass InterpreterFrameClosure : public OffsetClosure {
0N/A private:
0N/A frame* _fr;
0N/A OopClosure* _f;
0N/A int _max_locals;
0N/A int _max_stack;
0N/A
0N/A public:
0N/A InterpreterFrameClosure(frame* fr, int max_locals, int max_stack,
0N/A OopClosure* f) {
0N/A _fr = fr;
0N/A _max_locals = max_locals;
0N/A _max_stack = max_stack;
0N/A _f = f;
0N/A }
0N/A
0N/A void offset_do(int offset) {
0N/A oop* addr;
0N/A if (offset < _max_locals) {
0N/A addr = (oop*) _fr->interpreter_frame_local_at(offset);
0N/A assert((intptr_t*)addr >= _fr->sp(), "must be inside the frame");
0N/A _f->do_oop(addr);
0N/A } else {
0N/A addr = (oop*) _fr->interpreter_frame_expression_stack_at((offset - _max_locals));
0N/A // In case of exceptions, the expression stack is invalid and the esp will be reset to express
0N/A // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel).
0N/A bool in_stack;
0N/A if (frame::interpreter_frame_expression_stack_direction() > 0) {
0N/A in_stack = (intptr_t*)addr <= _fr->interpreter_frame_tos_address();
0N/A } else {
0N/A in_stack = (intptr_t*)addr >= _fr->interpreter_frame_tos_address();
0N/A }
0N/A if (in_stack) {
0N/A _f->do_oop(addr);
0N/A }
0N/A }
0N/A }
0N/A
0N/A int max_locals() { return _max_locals; }
0N/A frame* fr() { return _fr; }
0N/A};
0N/A
0N/A
0N/Aclass InterpretedArgumentOopFinder: public SignatureInfo {
0N/A private:
1138N/A OopClosure* _f; // Closure to invoke
1138N/A int _offset; // TOS-relative offset, decremented with each argument
1138N/A bool _has_receiver; // true if the callee has a receiver
0N/A frame* _fr;
0N/A
0N/A void set(int size, BasicType type) {
0N/A _offset -= size;
0N/A if (type == T_OBJECT || type == T_ARRAY) oop_offset_do();
0N/A }
0N/A
0N/A void oop_offset_do() {
0N/A oop* addr;
0N/A addr = (oop*)_fr->interpreter_frame_tos_at(_offset);
0N/A _f->do_oop(addr);
0N/A }
0N/A
0N/A public:
2062N/A InterpretedArgumentOopFinder(Symbol* signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) {
0N/A // compute size of arguments
1138N/A int args_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
0N/A assert(!fr->is_interpreted_frame() ||
0N/A args_size <= fr->interpreter_frame_expression_stack_size(),
0N/A "args cannot be on stack anymore");
0N/A // initialize InterpretedArgumentOopFinder
0N/A _f = f;
0N/A _fr = fr;
0N/A _offset = args_size;
0N/A }
0N/A
0N/A void oops_do() {
1138N/A if (_has_receiver) {
0N/A --_offset;
0N/A oop_offset_do();
0N/A }
0N/A iterate_parameters();
0N/A }
0N/A};
0N/A
0N/A
0N/A// Entry frame has following form (n arguments)
0N/A// +-----------+
0N/A// sp -> | last arg |
0N/A// +-----------+
0N/A// : ::: :
0N/A// +-----------+
0N/A// (sp+n)->| first arg|
0N/A// +-----------+
0N/A
0N/A
0N/A
0N/A// visits and GC's all the arguments in entry frame
0N/Aclass EntryFrameOopFinder: public SignatureInfo {
0N/A private:
0N/A bool _is_static;
0N/A int _offset;
0N/A frame* _fr;
0N/A OopClosure* _f;
0N/A
0N/A void set(int size, BasicType type) {
0N/A assert (_offset >= 0, "illegal offset");
0N/A if (type == T_OBJECT || type == T_ARRAY) oop_at_offset_do(_offset);
0N/A _offset -= size;
0N/A }
0N/A
0N/A void oop_at_offset_do(int offset) {
1409N/A assert (offset >= 0, "illegal offset");
0N/A oop* addr = (oop*) _fr->entry_frame_argument_at(offset);
0N/A _f->do_oop(addr);
0N/A }
0N/A
0N/A public:
2062N/A EntryFrameOopFinder(frame* frame, Symbol* signature, bool is_static) : SignatureInfo(signature) {
0N/A _f = NULL; // will be set later
0N/A _fr = frame;
0N/A _is_static = is_static;
0N/A _offset = ArgumentSizeComputer(signature).size() - 1; // last parameter is at index 0
0N/A }
0N/A
0N/A void arguments_do(OopClosure* f) {
0N/A _f = f;
0N/A if (!_is_static) oop_at_offset_do(_offset+1); // do the receiver
0N/A iterate_parameters();
0N/A }
0N/A
0N/A};
0N/A
2062N/Aoop* frame::interpreter_callee_receiver_addr(Symbol* signature) {
0N/A ArgumentSizeComputer asc(signature);
0N/A int size = asc.size();
0N/A return (oop *)interpreter_frame_tos_at(size);
0N/A}
0N/A
0N/A
0N/Avoid frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A assert(map != NULL, "map must be set");
0N/A Thread *thread = Thread::current();
0N/A methodHandle m (thread, interpreter_frame_method());
0N/A jint bci = interpreter_frame_bci();
0N/A
0N/A assert(Universe::heap()->is_in(m()), "must be valid oop");
0N/A assert(m->is_method(), "checking frame value");
0N/A assert((m->is_native() && bci == 0) || (!m->is_native() && bci >= 0 && bci < m->code_size()), "invalid bci value");
0N/A
0N/A // Handle the monitor elements in the activation
0N/A for (
0N/A BasicObjectLock* current = interpreter_frame_monitor_end();
0N/A current < interpreter_frame_monitor_begin();
0N/A current = next_monitor_in_interpreter_frame(current)
0N/A ) {
0N/A#ifdef ASSERT
0N/A interpreter_frame_verify_monitor(current);
0N/A#endif
0N/A current->oops_do(f);
0N/A }
0N/A
0N/A // process fixed part
0N/A f->do_oop((oop*)interpreter_frame_method_addr());
0N/A f->do_oop((oop*)interpreter_frame_cache_addr());
0N/A
0N/A // Hmm what about the mdp?
0N/A#ifdef CC_INTERP
0N/A // Interpreter frame in the midst of a call have a methodOop within the
0N/A // object.
0N/A interpreterState istate = get_interpreterState();
0N/A if (istate->msg() == BytecodeInterpreter::call_method) {
0N/A f->do_oop((oop*)&istate->_result._to_call._callee);
0N/A }
0N/A
0N/A#endif /* CC_INTERP */
0N/A
1828N/A#if !defined(PPC) || defined(ZERO)
0N/A if (m->is_native()) {
0N/A#ifdef CC_INTERP
0N/A f->do_oop((oop*)&istate->_oop_temp);
0N/A#else
0N/A f->do_oop((oop*)( fp() + interpreter_frame_oop_temp_offset ));
0N/A#endif /* CC_INTERP */
0N/A }
1601N/A#else // PPC
1601N/A if (m->is_native() && m->is_static()) {
1601N/A f->do_oop(interpreter_frame_mirror_addr());
1601N/A }
1601N/A#endif // PPC
0N/A
0N/A int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
0N/A
2062N/A Symbol* signature = NULL;
1138N/A bool has_receiver = false;
0N/A
0N/A // Process a callee's arguments if we are at a call site
0N/A // (i.e., if we are at an invoke bytecode)
0N/A // This is used sometimes for calling into the VM, not for another
0N/A // interpreted or compiled frame.
0N/A if (!m->is_native()) {
2027N/A Bytecode_invoke call = Bytecode_invoke_check(m, bci);
2027N/A if (call.is_valid()) {
2062N/A signature = call.signature();
2027N/A has_receiver = call.has_receiver();
0N/A if (map->include_argument_oops() &&
0N/A interpreter_frame_expression_stack_size() > 0) {
0N/A ResourceMark rm(thread); // is this right ???
0N/A // we are at a call site & the expression stack is not empty
0N/A // => process callee's arguments
0N/A //
0N/A // Note: The expression stack can be empty if an exception
605N/A // occurred during method resolution/execution. In all
0N/A // cases we empty the expression stack completely be-
0N/A // fore handling the exception (the exception handling
0N/A // code in the interpreter calls a blocking runtime
0N/A // routine which can cause this code to be executed).
0N/A // (was bug gri 7/27/98)
1138N/A oops_interpreted_arguments_do(signature, has_receiver, f);
0N/A }
0N/A }
0N/A }
0N/A
1426N/A InterpreterFrameClosure blk(this, max_locals, m->max_stack(), f);
1426N/A
1426N/A // process locals & expression stack
1426N/A InterpreterOopMap mask;
1426N/A if (query_oop_map_cache) {
1426N/A m->mask_for(bci, &mask);
0N/A } else {
1426N/A OopMapCache::compute_one_oop_map(m, bci, &mask);
0N/A }
1426N/A mask.iterate_oop(&blk);
0N/A}
0N/A
0N/A
2062N/Avoid frame::oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f) {
1138N/A InterpretedArgumentOopFinder finder(signature, has_receiver, this, f);
0N/A finder.oops_do();
0N/A}
0N/A
989N/Avoid frame::oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* reg_map) {
0N/A assert(_cb != NULL, "sanity check");
0N/A if (_cb->oop_maps() != NULL) {
0N/A OopMapSet::oops_do(this, reg_map, f);
0N/A
0N/A // Preserve potential arguments for a callee. We handle this by dispatching
0N/A // on the codeblob. For c2i, we do
0N/A if (reg_map->include_argument_oops()) {
0N/A _cb->preserve_callee_argument_oops(*this, reg_map, f);
0N/A }
0N/A }
0N/A // In cases where perm gen is collected, GC will want to mark
0N/A // oops referenced from nmethods active on thread stacks so as to
0N/A // prevent them from being collected. However, this visit should be
0N/A // restricted to certain phases of the collection only. The
989N/A // closure decides how it wants nmethods to be traced.
989N/A if (cf != NULL)
989N/A cf->do_code_blob(_cb);
0N/A}
0N/A
0N/Aclass CompiledArgumentOopFinder: public SignatureInfo {
0N/A protected:
0N/A OopClosure* _f;
1138N/A int _offset; // the current offset, incremented with each argument
1138N/A bool _has_receiver; // true if the callee has a receiver
0N/A frame _fr;
0N/A RegisterMap* _reg_map;
0N/A int _arg_size;
0N/A VMRegPair* _regs; // VMReg list of arguments
0N/A
0N/A void set(int size, BasicType type) {
0N/A if (type == T_OBJECT || type == T_ARRAY) handle_oop_offset();
0N/A _offset += size;
0N/A }
0N/A
0N/A virtual void handle_oop_offset() {
0N/A // Extract low order register number from register array.
0N/A // In LP64-land, the high-order bits are valid but unhelpful.
0N/A VMReg reg = _regs[_offset].first();
0N/A oop *loc = _fr.oopmapreg_to_location(reg, _reg_map);
0N/A _f->do_oop(loc);
0N/A }
0N/A
0N/A public:
2062N/A CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, OopClosure* f, frame fr, const RegisterMap* reg_map)
0N/A : SignatureInfo(signature) {
0N/A
0N/A // initialize CompiledArgumentOopFinder
0N/A _f = f;
0N/A _offset = 0;
1138N/A _has_receiver = has_receiver;
0N/A _fr = fr;
0N/A _reg_map = (RegisterMap*)reg_map;
1138N/A _arg_size = ArgumentSizeComputer(signature).size() + (has_receiver ? 1 : 0);
0N/A
0N/A int arg_size;
2062N/A _regs = SharedRuntime::find_callee_arguments(signature, has_receiver, &arg_size);
0N/A assert(arg_size == _arg_size, "wrong arg size");
0N/A }
0N/A
0N/A void oops_do() {
1138N/A if (_has_receiver) {
0N/A handle_oop_offset();
0N/A _offset++;
0N/A }
0N/A iterate_parameters();
0N/A }
0N/A};
0N/A
2062N/Avoid frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) {
0N/A ResourceMark rm;
1138N/A CompiledArgumentOopFinder finder(signature, has_receiver, f, *this, reg_map);
0N/A finder.oops_do();
0N/A}
0N/A
0N/A
0N/A// Get receiver out of callers frame, i.e. find parameter 0 in callers
0N/A// frame. Consult ADLC for where parameter 0 is to be found. Then
0N/A// check local reg_map for it being a callee-save register or argument
0N/A// register, both of which are saved in the local frame. If not found
0N/A// there, it must be an in-stack argument of the caller.
0N/A// Note: caller.sp() points to callee-arguments
0N/Aoop frame::retrieve_receiver(RegisterMap* reg_map) {
0N/A frame caller = *this;
0N/A
0N/A // First consult the ADLC on where it puts parameter 0 for this signature.
0N/A VMReg reg = SharedRuntime::name_for_receiver();
0N/A oop r = *caller.oopmapreg_to_location(reg, reg_map);
0N/A assert( Universe::heap()->is_in_or_null(r), "bad receiver" );
0N/A return r;
0N/A}
0N/A
0N/A
0N/Aoop* frame::oopmapreg_to_location(VMReg reg, const RegisterMap* reg_map) const {
0N/A if(reg->is_reg()) {
0N/A // If it is passed in a register, it got spilled in the stub frame.
0N/A return (oop *)reg_map->location(reg);
0N/A } else {
113N/A int sp_offset_in_bytes = reg->reg2stack() * VMRegImpl::stack_slot_size;
113N/A return (oop*)(((address)unextended_sp()) + sp_offset_in_bytes);
0N/A }
0N/A}
0N/A
1926N/ABasicLock* frame::get_native_monitor() {
1926N/A nmethod* nm = (nmethod*)_cb;
1926N/A assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(),
1926N/A "Should not call this unless it's a native nmethod");
1926N/A int byte_offset = in_bytes(nm->native_basic_lock_sp_offset());
0N/A assert(byte_offset >= 0, "should not see invalid offset");
0N/A return (BasicLock*) &sp()[byte_offset / wordSize];
0N/A}
0N/A
1926N/Aoop frame::get_native_receiver() {
1926N/A nmethod* nm = (nmethod*)_cb;
1926N/A assert(_cb != NULL && _cb->is_nmethod() && nm->method()->is_native(),
1926N/A "Should not call this unless it's a native nmethod");
1926N/A int byte_offset = in_bytes(nm->native_receiver_sp_offset());
0N/A assert(byte_offset >= 0, "should not see invalid offset");
0N/A oop owner = ((oop*) sp())[byte_offset / wordSize];
0N/A assert( Universe::heap()->is_in(owner), "bad receiver" );
0N/A return owner;
0N/A}
0N/A
0N/Avoid frame::oops_entry_do(OopClosure* f, const RegisterMap* map) {
0N/A assert(map != NULL, "map must be set");
0N/A if (map->include_argument_oops()) {
0N/A // must collect argument oops, as nobody else is doing it
0N/A Thread *thread = Thread::current();
0N/A methodHandle m (thread, entry_frame_call_wrapper()->callee_method());
2062N/A EntryFrameOopFinder finder(this, m->signature(), m->is_static());
0N/A finder.arguments_do(f);
0N/A }
0N/A // Traverse the Handle Block saved in the entry frame
0N/A entry_frame_call_wrapper()->oops_do(f);
0N/A}
0N/A
0N/A
989N/Avoid frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) {
1119N/A#ifndef PRODUCT
1119N/A // simulate GC crash here to dump java thread in error report
1119N/A if (CrashGCForDumpingJavaThread) {
1119N/A char *t = NULL;
1119N/A *t = 'c';
1119N/A }
1119N/A#endif
1119N/A if (is_interpreted_frame()) {
1119N/A oops_interpreted_do(f, map, use_interpreter_oop_map_cache);
1119N/A } else if (is_entry_frame()) {
1119N/A oops_entry_do(f, map);
1119N/A } else if (CodeCache::contains(pc())) {
1119N/A oops_code_blob_do(f, cf, map);
1612N/A#ifdef SHARK
1612N/A } else if (is_fake_stub_frame()) {
1612N/A // nothing to do
1612N/A#endif // SHARK
0N/A } else {
0N/A ShouldNotReachHere();
0N/A }
0N/A}
0N/A
989N/Avoid frame::nmethods_do(CodeBlobClosure* cf) {
0N/A if (_cb != NULL && _cb->is_nmethod()) {
989N/A cf->do_code_blob(_cb);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid frame::gc_prologue() {
0N/A if (is_interpreted_frame()) {
0N/A // set bcx to bci to become methodOop position independent during GC
0N/A interpreter_frame_set_bcx(interpreter_frame_bci());
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid frame::gc_epilogue() {
0N/A if (is_interpreted_frame()) {
0N/A // set bcx back to bcp for interpreter
0N/A interpreter_frame_set_bcx((intptr_t)interpreter_frame_bcp());
0N/A }
0N/A // call processor specific epilog function
0N/A pd_gc_epilog();
0N/A}
0N/A
0N/A
0N/A# ifdef ENABLE_ZAP_DEAD_LOCALS
0N/A
0N/Avoid frame::CheckValueClosure::do_oop(oop* p) {
0N/A if (CheckOopishValues && Universe::heap()->is_in_reserved(*p)) {
0N/A warning("value @ " INTPTR_FORMAT " looks oopish (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current());
0N/A }
0N/A}
0N/Aframe::CheckValueClosure frame::_check_value;
0N/A
0N/A
0N/Avoid frame::CheckOopClosure::do_oop(oop* p) {
0N/A if (*p != NULL && !(*p)->is_oop()) {
0N/A warning("value @ " INTPTR_FORMAT " should be an oop (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current());
0N/A }
0N/A}
0N/Aframe::CheckOopClosure frame::_check_oop;
0N/A
0N/Avoid frame::check_derived_oop(oop* base, oop* derived) {
0N/A _check_oop.do_oop(base);
0N/A}
0N/A
0N/A
0N/Avoid frame::ZapDeadClosure::do_oop(oop* p) {
0N/A if (TraceZapDeadLocals) tty->print_cr("zapping @ " INTPTR_FORMAT " containing " INTPTR_FORMAT, p, (address)*p);
0N/A // Need cast because on _LP64 the conversion to oop is ambiguous. Constant
0N/A // can be either long or int.
0N/A *p = (oop)(int)0xbabebabe;
0N/A}
0N/Aframe::ZapDeadClosure frame::_zap_dead;
0N/A
0N/Avoid frame::zap_dead_locals(JavaThread* thread, const RegisterMap* map) {
0N/A assert(thread == Thread::current(), "need to synchronize to do this to another thread");
0N/A // Tracing - part 1
0N/A if (TraceZapDeadLocals) {
0N/A ResourceMark rm(thread);
0N/A tty->print_cr("--------------------------------------------------------------------------------");
0N/A tty->print("Zapping dead locals in ");
0N/A print_on(tty);
0N/A tty->cr();
0N/A }
0N/A // Zapping
0N/A if (is_entry_frame ()) zap_dead_entry_locals (thread, map);
0N/A else if (is_interpreted_frame()) zap_dead_interpreted_locals(thread, map);
0N/A else if (is_compiled_frame()) zap_dead_compiled_locals (thread, map);
0N/A
0N/A else
0N/A // could be is_runtime_frame
0N/A // so remove error: ShouldNotReachHere();
0N/A ;
0N/A // Tracing - part 2
0N/A if (TraceZapDeadLocals) {
0N/A tty->cr();
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid frame::zap_dead_interpreted_locals(JavaThread *thread, const RegisterMap* map) {
0N/A // get current interpreter 'pc'
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A methodOop m = interpreter_frame_method();
0N/A int bci = interpreter_frame_bci();
0N/A
0N/A int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals();
0N/A
1426N/A // process dynamic part
1426N/A InterpreterFrameClosure value_blk(this, max_locals, m->max_stack(),
1426N/A &_check_value);
1426N/A InterpreterFrameClosure oop_blk(this, max_locals, m->max_stack(),
1426N/A &_check_oop );
1426N/A InterpreterFrameClosure dead_blk(this, max_locals, m->max_stack(),
1426N/A &_zap_dead );
0N/A
1426N/A // get frame map
1426N/A InterpreterOopMap mask;
1426N/A m->mask_for(bci, &mask);
1426N/A mask.iterate_all( &oop_blk, &value_blk, &dead_blk);
0N/A}
0N/A
0N/A
0N/Avoid frame::zap_dead_compiled_locals(JavaThread* thread, const RegisterMap* reg_map) {
0N/A
0N/A ResourceMark rm(thread);
0N/A assert(_cb != NULL, "sanity check");
0N/A if (_cb->oop_maps() != NULL) {
113N/A OopMapSet::all_do(this, reg_map, &_check_oop, check_derived_oop, &_check_value);
0N/A }
0N/A}
0N/A
0N/A
0N/Avoid frame::zap_dead_entry_locals(JavaThread*, const RegisterMap*) {
0N/A if (TraceZapDeadLocals) warning("frame::zap_dead_entry_locals unimplemented");
0N/A}
0N/A
0N/A
0N/Avoid frame::zap_dead_deoptimized_locals(JavaThread*, const RegisterMap*) {
0N/A if (TraceZapDeadLocals) warning("frame::zap_dead_deoptimized_locals unimplemented");
0N/A}
0N/A
0N/A# endif // ENABLE_ZAP_DEAD_LOCALS
0N/A
0N/Avoid frame::verify(const RegisterMap* map) {
0N/A // for now make sure receiver type is correct
0N/A if (is_interpreted_frame()) {
0N/A methodOop method = interpreter_frame_method();
0N/A guarantee(method->is_method(), "method is wrong in frame::verify");
0N/A if (!method->is_static()) {
0N/A // fetch the receiver
0N/A oop* p = (oop*) interpreter_frame_local_at(0);
0N/A // make sure we have the right receiver type
0N/A }
0N/A }
0N/A COMPILER2_PRESENT(assert(DerivedPointerTable::is_empty(), "must be empty before verify");)
989N/A oops_do_internal(&VerifyOopClosure::verify_oop, NULL, (RegisterMap*)map, false);
0N/A}
0N/A
0N/A
0N/A#ifdef ASSERT
0N/Abool frame::verify_return_pc(address x) {
0N/A if (StubRoutines::returns_to_call_stub(x)) {
0N/A return true;
0N/A }
0N/A if (CodeCache::contains(x)) {
0N/A return true;
0N/A }
0N/A if (Interpreter::contains(x)) {
0N/A return true;
0N/A }
0N/A return false;
0N/A}
0N/A#endif
0N/A
0N/A
0N/A#ifdef ASSERT
0N/Avoid frame::interpreter_frame_verify_monitor(BasicObjectLock* value) const {
0N/A assert(is_interpreted_frame(), "Not an interpreted frame");
0N/A // verify that the value is in the right part of the frame
0N/A address low_mark = (address) interpreter_frame_monitor_end();
0N/A address high_mark = (address) interpreter_frame_monitor_begin();
0N/A address current = (address) value;
0N/A
0N/A const int monitor_size = frame::interpreter_frame_monitor_size();
0N/A guarantee((high_mark - current) % monitor_size == 0 , "Misaligned top of BasicObjectLock*");
0N/A guarantee( high_mark > current , "Current BasicObjectLock* higher than high_mark");
0N/A
0N/A guarantee((current - low_mark) % monitor_size == 0 , "Misaligned bottom of BasicObjectLock*");
0N/A guarantee( current >= low_mark , "Current BasicObjectLock* below than low_mark");
0N/A}
0N/A#endif
0N/A
0N/A
0N/A//-----------------------------------------------------------------------------------
0N/A// StackFrameStream implementation
0N/A
0N/AStackFrameStream::StackFrameStream(JavaThread *thread, bool update) : _reg_map(thread, update) {
0N/A assert(thread->has_last_Java_frame(), "sanity check");
0N/A _fr = thread->last_frame();
0N/A _is_done = false;
0N/A}