/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "gc_interface/collectedHeap.inline.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/oopMapCache.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.inline.hpp"
#include "oops/markOop.hpp"
#include "oops/methodDataOop.hpp"
#include "oops/methodOop.hpp"
#include "oops/oop.inline.hpp"
#include "oops/oop.inline2.hpp"
#include "prims/methodHandles.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/javaCalls.hpp"
#include "runtime/monitorChunk.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/stubRoutines.hpp"
#include "utilities/decoder.hpp"
#ifdef TARGET_ARCH_x86
# include "nativeInst_x86.hpp"
#endif
#ifdef TARGET_ARCH_sparc
# include "nativeInst_sparc.hpp"
#endif
#ifdef TARGET_ARCH_zero
# include "nativeInst_zero.hpp"
#endif
#ifdef TARGET_ARCH_arm
# include "nativeInst_arm.hpp"
#endif
#ifdef TARGET_ARCH_ppc
# include "nativeInst_ppc.hpp"
#endif
clear();
#ifndef PRODUCT
#endif /* PRODUCT */
}
if (update_map()) {
for(int i = 0; i < location_valid_size; i++) {
_location_valid[i] = bits;
// for whichever bits are set, pull in the corresponding map->_location
int j = i*location_valid_type_size;
while (bits != 0) {
if ((bits & 1) != 0) {
}
bits >>= 1;
j += 1;
}
}
}
}
set_include_argument_oops(true);
if (_update_map) {
for(int i = 0; i < location_valid_size; i++) {
_location_valid[i] = 0;
}
pd_clear();
} else {
}
}
#ifndef PRODUCT
for(int i = 0; i < reg_count; i++) {
} else {
}
}
}
}
}
#endif
// This returns the pc that if you were in the debugger you'd see. Not
// the idealized value in the frame object. This undoes the magic conversion
// that happens for deoptimized frames. In addition it makes the value the
// hardware would want to see in the native frame. The only user (at this point)
// is deoptimization. It likely no one else should ever use it.
if (is_deoptimized_frame()) {
else
} else {
return (pc() - pc_return_offset);
}
}
// Change the pc in a frame object. This does not change the actual pc in
// actual frame. To do that use patch_pc.
//
#ifdef ASSERT
}
#endif // ASSERT
// Unsafe to use the is_deoptimzed tester after changing pc
}
// type testers
return false; // FIXME: some LambdaForm frames should be ignored
}
return _deopt_state == is_deoptimized;
}
_cb->is_nmethod() &&
}
if (is_interpreted_frame()) return true;
if (is_compiled_frame()) return true;
return false;
}
_cb->is_nmethod() &&
return true;
}
return false;
}
}
}
// testers
frame s;
return s.is_first_frame();
}
}
if (_deopt_state == is_deoptimized ||
!is_compiled_frame() ) return false;
if (TraceDependencies) {
}
if( !nm->is_marked_for_deoptimization() )
return false;
// If at the return point, then the frame has already been popped, and
// only the return needs to be executed. Don't deoptimize here.
}
if (!is_compiled_frame()) return false;
if( !nm->can_be_deoptimized() )
return false;
}
// Schedule deoptimization of an nmethod activation with this frame.
// This is a fix for register window patching race
"patching other threads for deopt may only occur at a safepoint");
// It is possible especially with DeoptimizeALot/DeoptimizeRandom that
// we could see the frame again and ask for it to be deoptimized since
// it might move for a long time. That is harmless and we just ignore it.
return;
}
// We are at a safepoint so the target thread can only be
// in 4 states:
// blocked - no problem
// blocked_trans - no problem (i.e. could have woken up from blocked
// during a safepoint).
// native - register window pc patching race
// native_trans - momentary state
//
// We could just wait out a thread in native_trans to block.
// Then we'd have all the issues that the safepoint code has as to
// whether to spin or block. It isn't worth it. Just treat it like
// native and be done with it.
//
// Examine the state of the thread at the start of safepoint since
// threads that were in native at the start of the safepoint could
// come to a halt during the safepoint, changing the current value
// of the safepoint_state.
// Since we are at a safepoint the target thread will stop itself
// before it can return to java as long as we remain at the safepoint.
// Therefore we can put an additional request for the thread to stop
// no matter what no (like a suspend). This will cause the thread
// to notice it needs to do the deopt on its own once it leaves native.
//
// The only reason we must do this is because on machine with register
// windows we have a race with patching the return address and the
// window coming live as the thread returns to the Java code (but still
// in native mode) and then blocks. It is only this top most frame
// that is at risk. So in truth we could add an additional check to
// see if this frame is one that is at risk.
return;
}
}
} // NeedsDeoptSuspend
// If the call site is a MethodHandle call site use the MH deopt
// handler.
nm->deopt_mh_handler_begin() :
// Save the original pc before we patch in the new one
#ifdef ASSERT
{
}
}
#endif // ASSERT
}
frame s;
return s;
}
while (result.is_runtime_frame() ||
result.is_ignored_frame()) {
}
return result;
}
// Note: called by profiler - NOT for current thread
// If we don't recognize this frame, walk back up the stack until we do
// Find the first Java frame on the stack starting with input frame
if (is_java_frame()) {
// top frame is compiled frame or deoptimized frame
first_java_frame = *this;
} else if (safe_for_sender(thread)) {
if (sender_frame.is_java_frame()) {
break;
}
}
}
return first_java_frame;
}
// Interpreter frames
}
return m;
}
}
if (ProfileInterpreter) {
if (mdx != 0) {
if (formerly_bci) {
if (!is_now_bci) {
// The bcx was just converted from bci to bcp.
// Convert the mdx in parallel.
}
} else {
if (is_now_bci) {
// The bcx was just converted from bcp to bci.
// Convert the mdx in parallel.
}
}
}
} else {
}
}
}
}
}
}
}
}
// Always allow the mdp to be cleared.
}
}
#ifdef ASSERT
#endif
BasicObjectLock* next = (BasicObjectLock*) (((intptr_t*) current) + interpreter_frame_monitor_size());
return next;
}
#ifdef ASSERT
// // This verification needs to be checked before being enabled
// interpreter_frame_verify_monitor(current);
#endif
BasicObjectLock* previous = (BasicObjectLock*) (((intptr_t*) current) - interpreter_frame_monitor_size());
return previous;
}
// Interpreter locals and expression stack locations.
return &((*interpreter_frame_locals_addr())[n]);
}
const int i = offset * interpreter_frame_expression_stack_direction();
const int n = i * Interpreter::stackElementWords;
return &(interpreter_frame_expression_stack()[n]);
}
// Number of elements on the interpreter expression stack
// Callers should span by stackElementWords
if (frame::interpreter_frame_expression_stack_direction() < 0) {
return (interpreter_frame_expression_stack() -
} else {
return (interpreter_frame_tos_address() -
}
}
// (frame::interpreter_frame_sender_sp accessor is in frame_<arch>.cpp)
if (is_native_frame()) return "Native";
if (is_interpreted_frame()) return "Interpreted";
if (is_compiled_frame()) {
if (is_deoptimized_frame()) return "Deoptimized";
return "Compiled";
}
return "C";
}
st->print("%s frame (sp=" INTPTR_FORMAT " unextended sp=" INTPTR_FORMAT, print_name(), sp(), unextended_sp());
} else {
}
}
#ifndef PRODUCT
}
#endif
}
}
if (is_interpreted_frame()) {
}
}
#ifndef PRODUCT
jint i;
for (i = 0; i < interpreter_frame_method()->max_locals(); i++ ) {
intptr_t x = *interpreter_frame_local_at(i);
}
for (i = interpreter_frame_expression_stack_size() - 1; i >= 0; --i ) {
}
// locks for synchronization
}
// monitor
// bcp
// locals
// method
#endif
}
// Return whether the frame is in the VM or os indicating a Hotspot problem.
// Otherwise, it's likely a bug in the native library that the Java code calls,
// hopefully indicating where to submit bugs.
// C/C++ frame
int offset;
bool found;
// libname
if (found) {
// skip directory names
} else {
}
// function name - os::dll_address_to_function_name() may return confusing
// names if pc is within jvm.dll or libjvm.so, because JVM only has
// JVM_xxxx and a few other symbols in the dynamic symbol table. Do this
// only for native libraries.
if (found) {
}
}
}
// frame::print_on_error() is called by fatal error handler. Notice that we may
// crash inside this function if stack frame is corrupted. The fatal error
// handler can catch and handle the crash. Here we assume the frame is valid.
//
// First letter indicates type of the frame:
// J: Java frame (compiled)
// j: Java frame (interpreted)
// V: VM frame (C/C++)
// v: Other frames running VM generated code (e.g. stubs, adapters, etc.)
// C: C/C++ frame
//
// We don't need detailed frame type as that in frame::print_name(). "C"
// suggests the problem is in user lib; everything else is likely a VM bug.
methodOop m = this->interpreter_frame_method();
if (m != NULL) {
} else {
}
} else {
}
} else if (_cb->is_buffer_blob()) {
} else if (_cb->is_nmethod()) {
if (m != NULL) {
} else {
}
} else if (_cb->is_runtime_stub()) {
} else if (_cb->is_deoptimization_stub()) {
} else if (_cb->is_exception_stub()) {
} else if (_cb->is_safepoint_stub()) {
} else {
}
} else {
}
}
/*
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
*/
private:
int _max_locals;
int _max_stack;
public:
OopClosure* f) {
_f = f;
}
if (offset < _max_locals) {
} else {
// 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).
bool in_stack;
if (frame::interpreter_frame_expression_stack_direction() > 0) {
} else {
}
if (in_stack) {
}
}
}
};
private:
}
void oop_offset_do() {
}
public:
InterpretedArgumentOopFinder(Symbol* signature, bool has_receiver, frame* fr, OopClosure* f) : SignatureInfo(signature), _has_receiver(has_receiver) {
// compute size of arguments
"args cannot be on stack anymore");
// initialize InterpretedArgumentOopFinder
_f = f;
}
void oops_do() {
if (_has_receiver) {
--_offset;
}
}
};
// Entry frame has following form (n arguments)
// +-----------+
// sp -> | last arg |
// +-----------+
// : ::: :
// +-----------+
// (sp+n)->| first arg|
// +-----------+
// visits and GC's all the arguments in entry frame
private:
bool _is_static;
int _offset;
}
}
public:
}
_f = f;
}
};
}
assert((m->is_native() && bci == 0) || (!m->is_native() && bci >= 0 && bci < m->code_size()), "invalid bci value");
// Handle the monitor elements in the activation
for (
) {
#ifdef ASSERT
#endif
}
// process fixed part
// Hmm what about the mdp?
#ifdef CC_INTERP
// Interpreter frame in the midst of a call have a methodOop within the
// object.
}
#endif /* CC_INTERP */
if (m->is_native()) {
#ifdef CC_INTERP
#else
#endif /* CC_INTERP */
}
#else // PPC
}
#endif // PPC
bool has_receiver = false;
// 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.
if (!m->is_native()) {
if (map->include_argument_oops() &&
// 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
// occurred during method resolution/execution. In all
// 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).
// (was bug gri 7/27/98)
}
}
}
// process locals & expression stack
if (query_oop_map_cache) {
} else {
}
}
}
// Preserve potential arguments for a callee. We handle this by dispatching
// on the codeblob. For c2i, we do
if (reg_map->include_argument_oops()) {
}
}
// 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.
}
protected:
int _arg_size;
}
virtual void handle_oop_offset() {
// Extract low order register number from register array.
// In LP64-land, the high-order bits are valid but unhelpful.
}
public:
CompiledArgumentOopFinder(Symbol* signature, bool has_receiver, OopClosure* f, frame fr, const RegisterMap* reg_map)
: SignatureInfo(signature) {
// initialize CompiledArgumentOopFinder
_f = f;
_offset = 0;
int arg_size;
}
void oops_do() {
if (_has_receiver) {
_offset++;
}
}
};
void frame::oops_compiled_arguments_do(Symbol* signature, bool has_receiver, const RegisterMap* reg_map, OopClosure* f) {
}
// 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.
assert(Universe::heap()->is_in_or_null(r), err_msg("bad receiver: " INTPTR_FORMAT " (" INTX_FORMAT ")", (intptr_t) r, (intptr_t) r));
return r;
}
// If it is passed in a register, it got spilled in the stub frame.
} else {
}
}
"Should not call this unless it's a native nmethod");
}
"Should not call this unless it's a native nmethod");
return owner;
}
if (map->include_argument_oops()) {
// must collect argument oops, as nobody else is doing it
finder.arguments_do(f);
}
// Traverse the Handle Block saved in the entry frame
entry_frame_call_wrapper()->oops_do(f);
}
void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) {
#ifndef PRODUCT
// simulate GC crash here to dump java thread in error report
if (CrashGCForDumpingJavaThread) {
char *t = NULL;
*t = 'c';
}
#endif
if (is_interpreted_frame()) {
} else if (is_entry_frame()) {
oops_entry_do(f, map);
#ifdef SHARK
} else if (is_fake_stub_frame()) {
// nothing to do
#endif // SHARK
} else {
}
}
}
}
if (is_interpreted_frame()) {
// set bcx to bci to become methodOop position independent during GC
}
}
if (is_interpreted_frame()) {
// set bcx back to bcp for interpreter
}
// call processor specific epilog function
pd_gc_epilog();
}
# ifdef ENABLE_ZAP_DEAD_LOCALS
warning("value @ " INTPTR_FORMAT " looks oopish (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current());
}
}
warning("value @ " INTPTR_FORMAT " should be an oop (" INTPTR_FORMAT ") (thread = " INTPTR_FORMAT ")", p, (address)*p, Thread::current());
}
}
}
if (TraceZapDeadLocals) tty->print_cr("zapping @ " INTPTR_FORMAT " containing " INTPTR_FORMAT, p, (address)*p);
// Need cast because on _LP64 the conversion to oop is ambiguous. Constant
// can be either long or int.
*p = (oop)(int)0xbabebabe;
}
// Tracing - part 1
if (TraceZapDeadLocals) {
}
// Zapping
else
// could be is_runtime_frame
// so remove error: ShouldNotReachHere();
;
// Tracing - part 2
if (TraceZapDeadLocals) {
}
}
// get current interpreter 'pc'
// process dynamic part
&_check_value);
&_check_oop );
&_zap_dead );
// get frame map
}
}
}
}
}
# endif // ENABLE_ZAP_DEAD_LOCALS
// for now make sure receiver type is correct
if (is_interpreted_frame()) {
// fetch the receiver
// make sure we have the right receiver type
}
}
}
#ifdef ASSERT
if (StubRoutines::returns_to_call_stub(x)) {
return true;
}
return true;
}
if (Interpreter::contains(x)) {
return true;
}
return false;
}
#endif
#ifdef ASSERT
// verify that the value is in the right part of the frame
}
#endif
#ifndef PRODUCT
// boundaries: sp and the 'real' frame pointer
// print frame info at the highest boundary
if (info_address != frame_pointer) {
// print frame_pointer explicitly if not marked by the frame info
}
// Label values common to most frames
}
if (is_interpreted_frame()) {
// Label the method and current bci
if (m->max_locals() > 0) {
// Report each local and mark as owned by this frame
for (int l = 0; l < m->max_locals(); l++) {
}
}
// Compute the actual expression stack size
// Report each stack element and mark as owned by this frame
for (int e = 0; e < mask.expression_stack_size(); e++) {
err_msg("stack %d", e));
}
}
if (interpreter_frame_monitor_begin() != interpreter_frame_monitor_end()) {
}
} else if (is_entry_frame()) {
// For now just label the frame
} else if (is_compiled_frame()) {
// For now just label the frame
(_deopt_state == is_deoptimized) ?
" (deoptimized)" :
2);
} else if (is_native_frame()) {
// For now just label the frame
} else {
// provide default info if not handled before
}
}
// platform dependent additional data
}
#endif
//-----------------------------------------------------------------------------------
// StackFrameStream implementation
_is_done = false;
}
#ifndef PRODUCT
}
#ifdef ASSERT
bool error = false;
continue;
}
tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", prev.location, *prev.location, prev.description);
tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", fv.location, *fv.location, fv.description);
error = true;
}
} else {
}
}
}
#endif // ASSERT
// Sometimes values like the fp can be invalid values if the
// register map wasn't updated during the walk. Trim out values
// that aren't actually in the stack of the thread.
int min_index = 0;
}
}
} else {
}
}
}
cur--;
}
} else {
tty->print_cr(" " INTPTR_FORMAT ": " INTPTR_FORMAT " %s", fv.location, *fv.location, fv.description);
cur--;
}
}
}
#endif // ndef PRODUCT