frame.cpp revision 1119
0N/A * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A#
include "incls/_precompiled.incl" 0N/A // for whichever bits are set, pull in the corresponding map->_location 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// 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 // Unsafe to use the is_deoptimzed tester after changing pc 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// Schedule deoptimization of an nmethod activation with this frame. 0N/A // Store the original pc before an patch (or request to self-deopt) 0N/A // in the published location of the frame. 0N/A // This is a fix for register window patching race 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 // We are at a safepoint so the target thread can only be 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 // 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 // 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 // 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 }
// NeedsDeoptSuspend 0N/A // Save the original pc before we patch in the new one 0N/A// Note: called by profiler - NOT for current thread 0N/A// If we don't recognize this frame, walk back up the stack until we do 0N/A // Find the first Java frame on the stack starting with input frame 0N/A // top frame is compiled frame or deoptimized frame 0N/A// Interpreter frames 0N/A // The bcx was just converted from bci to bcp. 0N/A // Convert the mdx in parallel. 0N/A int mdi =
mdx -
1;
// We distinguish valid mdi from zero by adding one. 0N/A // The bcx was just converted from bcp to bci. 0N/A // Convert the mdx in parallel. 0N/A // Always allow the mdp to be cleared. 0N/A// // This verification needs to be checked before being enabled 0N/A// interpreter_frame_verify_monitor(current); 0N/A// Interpreter locals and expression stack locations. 0N/A // Number of elements on the interpreter expression stack 0N/A // Callers should span by stackElementWords 0N/A// (frame::interpreter_frame_sender_sp accessor is in frame_<arch>.cpp) 0N/A // locks for synchronization 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/A // skip directory names 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. 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 726N/A// handler can catch and handle the crash. Here we assume the frame is valid. 0N/A// First letter indicates type of the frame: 0N/A// J: Java frame (compiled) 726N/A// j: Java frame (interpreted) 726N/A// v: Other frames running VM generated code (e.g. stubs, adapters, etc.) 0N/A// We don't need detailed frame type as that in frame::print_name(). "C" 726N/A// suggests the problem is in user lib; everything else is likely a VM bug. st->
print(
"v ~DeoptimizationBlob");
The interpreter_frame_expression_stack_at method in the case of SPARC needs the max_stack value of the method in order to compute the expression stack address. It uses the methodOop in order to get the max_stack value but during GC this methodOop value saved on the frame is changed by reverse_and_push and hence cannot be used. So we save the max_stack value in the FrameClosure object and pass it down to the interpreter_frame_expression_stack_at method // In case of exceptions, the expression stack is invalid and the esp will be reset to express // this condition. Therefore, we call f only if addr is 'inside' the stack (i.e., addr >= esp for Intel). int _offset;
// TOS-relative offset, decremented with each argument bool _is_static;
// true if the callee is a static method // compute size of arguments "args cannot be on stack anymore");
// initialize InterpretedArgumentOopFinder // Entry frame has following form (n arguments) // visits and GC's all the arguments in entry frame _f =
NULL;
// will be set later // Handle the monitor elements in the activation // Hmm what about the mdp? // Interpreter frame in the midst of a call have a methodOop within the // Process a callee's arguments if we are at a call site // (i.e., if we are at an invoke bytecode) // This is used sometimes for calling into the VM, not for another // interpreted or compiled frame. // we are at a call site & the expression stack is not empty // => process callee's arguments // Note: The expression stack can be empty if an exception // cases we empty the expression stack completely be- // fore handling the exception (the exception handling // code in the interpreter calls a blocking runtime // routine which can cause this code to be executed). // process locals & expression stack // process locals & expression stack // Process locals then interpreter expression stack // Not always true - too bad. May have dead oops without tags in locals. // assert(*p == NULL || !(*p)->is_oop(), "oop not tagged on interpreter locals"); // There is no stack no matter what the esp is pointing to (native methods // might look like expression stack is nonempty). // Point the top of the expression stack above arguments to a call so // arguments aren't gc'ed as both stack values for callee and callee // arguments in callee's locals. // In case of exceptions, the expression stack is invalid and the esp // will be reset to express this condition. Therefore, we call f only // if addr is 'inside' the stack (i.e., addr >= esp for Intel). // Preserve potential arguments for a callee. We handle this by dispatching // on the codeblob. For c2i, we do // In cases where perm gen is collected, GC will want to mark // oops referenced from nmethods active on thread stacks so as to // prevent them from being collected. However, this visit should be // restricted to certain phases of the collection only. The // closure decides how it wants nmethods to be traced. int _offset;
// the current offset, incremented with each argument bool _is_static;
// true if the callee is a static method // Extract low order register number from register array. // In LP64-land, the high-order bits are valid but unhelpful. // initialize CompiledArgumentOopFinder // Get receiver out of callers frame, i.e. find parameter 0 in callers // frame. Consult ADLC for where parameter 0 is to be found. Then // check local reg_map for it being a callee-save register or argument // register, both of which are saved in the local frame. If not found // there, it must be an in-stack argument of the caller. // Note: caller.sp() points to callee-arguments // First consult the ADLC on where it puts parameter 0 for this signature. // If it is passed in a register, it got spilled in the stub frame. "should not call this otherwise");
"should not call this otherwise");
// must collect argument oops, as nobody else is doing it // Traverse the Handle Block saved in the entry frame // simulate GC crash here to dump java thread in error report // set bcx to bci to become methodOop position independent during GC // set bcx back to bcp for interpreter // call processor specific epilog function // Need cast because on _LP64 the conversion to oop is ambiguous. Constant // can be either long or int. *p = (
oop)(
int)
0xbabebabe;
tty->
print_cr(
"--------------------------------------------------------------------------------");
// could be is_runtime_frame // so remove error: ShouldNotReachHere(); // get current interpreter 'pc' #
endif // ENABLE_ZAP_DEAD_LOCALS // for now make sure receiver type is correct // make sure we have the right receiver type // verify that the value is in the right part of the frame //----------------------------------------------------------------------------------- // StackFrameStream implementation