/*
* 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 "classfile/vmSymbols.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/interpreter.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.inline.hpp"
#include "oops/methodDataOop.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/monitorChunk.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/vframe.hpp"
#include "runtime/vframeArray.hpp"
#include "runtime/vframe_hp.hpp"
#include "utilities/events.hpp"
#ifdef COMPILER2
#include "opto/runtime.hpp"
#endif
delete chunk;
}
}
// Copy the information from the compiled vframe to the
// interpreter frame we will be creating to replace vf
int index;
// Get the monitors off-stack
} else {
// Allocate monitor chunk
// Migrate the BasicLocks from the stack to the monitor chunk
assert(monitor->owner() == NULL || (!monitor->owner()->is_unlocked() && !monitor->owner()->has_bias_pattern()), "object must be null or locked, and unbiased");
}
}
// Convert the vframe locals and expressions to off stack
// values. Because we will not gc all oops can be converted to
// intptr_t (i.e. a stack slot) and we are fine. This is
// good since we are inside a HandleMark and the oops in our
// collection would go away between packing them here and
// unpacking them in unpack_on_stack.
// First the locals go off-stack
// FIXME this seems silly it creates a StackValueCollection
// in order to get the size to then copy them and
// convert the types to intptr_t size slots. Seems like it
// could do it in place... Still uses less memory than the
// old way though
case T_OBJECT:
// preserve object type
break;
case T_CONFLICT:
break;
case T_INT:
break;
default:
}
}
// Now the expressions off-stack
// Same silliness as above
case T_OBJECT:
// preserve object type
break;
case T_CONFLICT:
// This can occur when the compiler emits a state in which stack
// elements are known to be dead (because of an imminent exception).
break;
case T_INT:
break;
default:
}
}
}
int unpack_counter = 0;
int callee_parameters,
int callee_locals,
bool is_top_frame,
bool is_bottom_frame,
int exec_mode) {
// Look at bci and decide on bcp and continuation pc
// C++ interpreter doesn't need a pc since it will figure out what to do when it
// begins execution
// rather than the one associated with bcp
if (raw_bci() == SynchronizationEntryBCI) {
// We are deoptimizing while hanging in prologue code for synchronized method
} else if (should_reexecute()) { //reexecute this bytecode
} else {
use_next_mdp = true;
}
// Monitorenter and pending exceptions:
//
// For Compiler2, there should be no pending exception when deoptimizing at monitorenter
// because there is no safepoint at the null pointer check (it is either handled explicitly
// or prior to the monitorenter) and asynchronous exceptions are not made "pending" by the
// runtime interface for the slow case (see JRT_ENTRY_FOR_MONITORENTER). If an asynchronous
// exception was processed, the bytecode pointer would have to be extended one bytecode beyond
// the monitorenter to place it in the proper exception range.
//
// For Compiler1, deoptimization can occur while throwing a NullPointerException at monitorenter,
// in which case bcp should point to the monitorenter since it is within the exception's range.
"shouldn't get exception during monitorenter");
if (is_top_frame) {
if (JvmtiExport::can_pop_frame() &&
if (thread->has_pending_popframe()) {
// Pop top frame after deoptimization
#ifndef CC_INTERP
#else
// Do an uncommon trap type entry. c++ interpreter will know
// to pop frame and preserve the args
use_next_mdp = false;
#endif
} else {
// Reexecute invoke in top frame
use_next_mdp = false;
// Note: the PopFrame-related extension of the expression stack size is done in
// Deoptimization::fetch_unroll_info_helper
}
} else if (JvmtiExport::can_force_early_return() && state != NULL && state->is_earlyret_pending()) {
// Force early return from top frame after deoptimization
#ifndef CC_INTERP
#else
// TBD: Need to implement ForceEarlyReturn for CC_INTERP (ia64)
#endif
} else {
// Possibly override the previous pc computation of the top (youngest) frame
switch (exec_mode) {
case Deoptimization::Unpack_deopt:
// use what we've got
break;
case Deoptimization::Unpack_exception:
// exception is pending
// [phh] We're going to end up in some handler or other, so it doesn't
// matter what mdp we point to. See exception_handler_for_exception()
// in interpreterRuntime.cpp.
break;
case Deoptimization::Unpack_reexecute:
// redo last byte code
use_next_mdp = false;
break;
default:
}
}
}
// Setup the interpreter frame
iframe(),
// Update the pc in the frame object and overwrite the temporary pc
// we placed in the skeletal frame now that we finally know the
// exact interpreter address we should use.
}
if (ProfileInterpreter) {
}
iframe()->interpreter_frame_set_bcx((intptr_t)bcp); // cannot use bcp because frame is not initialized yet
if (ProfileInterpreter) {
if (use_next_mdp) ++bci;
}
}
// Unpack expression stack
// If this is an intermediate frame (i.e. not top frame) then this
// only unpacks the part of the expression stack not used by callee
// as parameters. The callee parameters are unpacked as part of the
// callee locals.
int i;
for(i = 0; i < expressions()->size(); i++) {
case T_INT:
break;
case T_OBJECT:
break;
case T_CONFLICT:
// A dead stack slot. Initialize to null in case it is an oop.
break;
default:
}
}
// Unpack the locals
case T_INT:
break;
case T_OBJECT:
break;
case T_CONFLICT:
// A dead location. If it is an oop then we need a NULL to prevent GC from following it
break;
default:
}
}
// An interpreted frame was popped but it returns to a deoptimized
// frame. The incoming arguments to the interpreted activation
// were preserved in thread-local storage by the
// remove_activation_preserving_args_entry in the interpreter; now
// we put them back into the just-unpacked interpreter frame.
// Note that this assumes that the locals arena grows toward lower
// addresses.
if (popframe_preserved_args_size_in_words != 0) {
#ifdef ASSERT
"expression stack size should have been extended");
#endif // ASSERT
if (frame::interpreter_frame_expression_stack_direction() < 0) {
} else {
}
base,
}
}
#ifndef PRODUCT
if (TraceDeoptimization && Verbose) {
f->print();
method()->print_value();
// method()->print_codes();
} else if (TraceDeoptimization) {
method()->print_value();
}
#endif // PRODUCT
// The expression stack and locals are in the resource area don't leave
// a dangling pointer in the vframeArray we leave around for debug
// purposes
}
int callee_parameters,
int callee_locals,
bool is_top_frame,
bool is_bottom_frame,
int popframe_extra_stack_expression_els) const {
}
vframeArray* vframeArray::allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
// Allocate the vframeArray
return result;
}
int frame_size,
const RegisterMap *reg_map) {
// Set owner first, it is used when adding monitor chunks
}
// Copy registers for callee-saved registers
for(int i = 0; i < RegisterMap::reg_count; i++) {
#ifdef AMD64
// The register map has one entry for every int (32-bit value), so
// 64-bit physical registers have two entries in the map, one for
// each half. Ignore the high halves of 64-bit registers, just like
// frame::oopmapreg_to_location does.
//
// [phh] FIXME: this is a temporary hack! This code *should* work
// correctly w/o this hack, possibly by changing RegisterMap::pd_location
// in frame_amd64.cpp and the values of the phantom high half registers
// in amd64.ad.
// if (VMReg::Name(i) < SharedInfo::stack0 && is_even(i)) {
// } else {
// jint* src = (jint*) reg_map->location(VMReg::Name(i));
// _callee_registers[i] = src != NULL ? *src : NULL_WORD;
// }
#else
#endif
set_location_valid(i, false);
} else {
set_location_valid(i, true);
}
}
}
}
void vframeArray::unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters) {
// stack picture
// unpack_frame
// [new interpreter frames ] (frames are skeletal but walkable)
// caller_frame
//
// This routine fills in the missing data for the skeletal interpreter frames
// in the above picture.
// Find the skeletal interpreter frames to unpack into
// Get the youngest frame we will unpack (last to be unpacked)
int index;
// Get the caller frame (possibly skeletal)
}
// Do the unpacking of interpreter frames; the frame at index 0 represents the top activation, so it has no callee
// Unpack the frames from the oldest (frames() -1) to the youngest (0)
if (index == 0) {
callee_parameters = callee_locals = 0;
} else {
// invokedynamic instructions don't have a class but obviously don't have a MemberName appendix.
// NOTE: Use machinery here that avoids resolving of any kind.
const bool has_member_arg =
}
index == 0,
}
}
}
}
}
#ifndef PRODUCT
if (owner_thread() != thread) return false;
int index = 0;
#if 0 // FIXME can't do this comparison
// Compare only within vframe array.
for (deoptimizedVFrame* vf = deoptimizedVFrame::cast(vframe_at(first_index())); vf; vf = vf->deoptimized_sender_or_null()) {
index++;
}
#endif
return true;
}
#endif
return (address) & _callee_registers[i];
}
#ifndef PRODUCT
// Printing
// Note: we cannot have print_on as const, as we allocate inside the method
}
}
}
}
#endif