/*
* 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 "asm/assembler.hpp"
#include "interpreter/bytecodeHistogram.hpp"
#include "interpreter/interpreter.hpp"
#include "interpreter/interpreterGenerator.hpp"
#include "interpreter/interpreterRuntime.hpp"
#include "interpreter/templateTable.hpp"
#include "oops/arrayOop.hpp"
#include "oops/methodDataOop.hpp"
#include "oops/methodOop.hpp"
#include "oops/oop.inline.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/jvmtiThreadState.hpp"
#include "runtime/arguments.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/sharedRuntime.hpp"
#include "runtime/stubRoutines.hpp"
#include "runtime/synchronizer.hpp"
#include "runtime/vframeArray.hpp"
#ifndef CC_INTERP
//------------------------------------------------------------------------------------------------------------------------
// Note: There should be a minimal interpreter frame set up when stack
// overflow occurs since we check explicitly for it now.
//
#ifdef ASSERT
{ Label L;
// (stack grows negative)
}
#endif // ASSERT
// Restore bcp under the assumption that the current frame is still
// interpreted
__ restore_bcp();
// expression stack must be empty before entering the VM if an exception
// happened
// throw exception
return entry;
}
// expression stack must be empty before entering the VM if an exception happened
// setup parameters
// ??? convention: expect aberrant index in register rbx,
__ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException), rax, rbx);
return entry;
}
// object is at TOS
// expression stack must be empty before entering the VM if an exception
// happened
rax);
return entry;
}
address TemplateInterpreterGenerator::generate_exception_handler_common(const char* name, const char* message, bool pass_oop) {
if (pass_oop) {
// object is at TOS
}
// expression stack must be empty before entering the VM if an exception happened
// setup parameters
if (pass_oop) {
} else {
} else {
}
}
// throw exception
return entry;
}
// NULL last_sp until next java call
return entry;
}
#ifdef COMPILER2
// The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases
for (int i = 1; i < 8; i++) {
}
} else if (UseSSE < 2) {
}
#endif
} else {
}
// In SSE mode, interpreter returns FP results in xmm0 but they need
// to end up back on the FPU so it can operate on them.
}
__ MacroAssembler::verify_FPU(state == ftos || state == dtos ? 1 : 0, "generate_return_entry_for in interpreter");
// Restore stack bottom in case i2c adjusted stack
// and NULL it as marker that rsp is now tos until next java call
__ restore_bcp();
__ restore_locals();
if (EnableInvokeDynamic) {
}
// out of the main line of code...
if (EnableInvokeDynamic) {
}
return entry;
}
// In SSE mode, FP results are in xmm0
}
__ MacroAssembler::verify_FPU(state == ftos || state == dtos ? 1 : 0, "generate_deopt_entry_for in interpreter");
// The stack is not extended by deopt but we must NULL last_sp as this
// entry is like a "return".
__ restore_bcp();
__ restore_locals();
// handle exceptions
{ Label L;
}
return entry;
}
int i = 0;
switch (type) {
case T_BOOLEAN: i = 0; break;
case T_CHAR : i = 1; break;
case T_BYTE : i = 2; break;
case T_SHORT : i = 3; break;
case T_INT : // fall through
case T_LONG : // fall through
case T_VOID : i = 4; break;
case T_DOUBLE : i = 6; break;
case T_OBJECT : // fall through
case T_ARRAY : i = 7; break;
default : ShouldNotReachHere();
}
return i;
}
switch (type) {
case T_INT : /* nothing to do */ break;
case T_DOUBLE :
case T_FLOAT :
// Must return a result for interpreter or compiler. In SSE
// mode, results are returned in xmm0 and the FPU stack must
// be empty.
// Load ST0
// Store as float and empty fpu stack
// and reload
} else {
// restore ST0
}
// and pop the temp
}
break;
case T_OBJECT :
// retrieve result from frame
// and verify it
break;
default : ShouldNotReachHere();
}
return entry;
}
address TemplateInterpreterGenerator::generate_safept_entry_for(TosState state, address runtime_entry) {
return entry;
}
// Helpers for commoning out cases in the various type of method entries.
//
// increment invocation count & check for overflow
//
// Note: checking for negative value instead of overflow
// so we have a 'sticky' overflow test
//
// rbx,: method
// rcx: invocation counter
//
void InterpreterGenerator::generate_counter_incr(Label* overflow, Label* profile_method, Label* profile_method_continue) {
// Note: In tiered we increment either counters in methodOop or in MDO depending if we're profiling or not.
if (TieredCompilation) {
if (ProfileInterpreter) {
// Are we profiling?
// Increment counter in the MDO
const Address mdo_invocation_counter(rax, in_bytes(methodDataOopDesc::invocation_counter_offset()) +
__ increment_mask_and_jump(mdo_invocation_counter, increment, mask, rcx, false, Assembler::zero, overflow);
}
// Increment counter in methodOop (we don't need to load it, it's in rcx).
__ increment_mask_and_jump(invocation_counter, increment, mask, rcx, true, Assembler::zero, overflow);
} else {
if (ProfileInterpreter) { // %%% Merge this into methodDataOop
}
// Update standard invocation counters
// profile_method is non-null only for interpreted method so
// profile_method != NULL == !native_call
// BytecodeInterpreter only calls for native so code is elided.
// Test to see if we should create a method data oop
// if no method data exists, go to profile_method
}
}
}
// Asm interpreter on entry
// rdi - locals
// rsi - bcp
// rbx, - method
// rdx - cpool
// rbp, - interpreter frame
// C++ interpreter on entry
// rsi - new interpreter state pointer
// rbp - interpreter frame pointer
// rbx - method
// On return (i.e. jump to entry_point) [ back to invocation of interpreter ]
// rbx, - method
// rcx - rcvr (assuming there is one)
// top of stack return address of interpreter caller
// rsp - sender_sp
// C++ interpreter only
// rsi - previous interpreter state pointer
// InterpreterRuntime::frequency_counter_overflow takes one argument
// indicating if the counter overflow occurs at a backwards branch (non-NULL bcp).
// The call returns the address of the verified entry point for the method or NULL
// if the compilation did not complete (either went background or bailed out).
// and jump to the interpreted entry.
}
// see if we've got enough room on the stack for locals plus overhead.
// the expression stack grows down incrementally, so the normal guard
// page mechanism will work for that.
//
// Registers live on entry:
//
// Asm interpreter
// rdx: number of additional locals this frame needs (what we must check)
// rbx,: methodOop
// destroyed on exit
// rax,
// NOTE: since the additional locals are also always pushed (wasn't obvious in
// generate_method_entry) so the guard should work for them too.
//
// monitor entry size: see picture of stack set (generate_method_entry) and frame_x86.hpp
// total overhead size: entry_size + (saved rbp, thru expr stack bottom).
// see if the frame is greater than one page in size. If so,
// then we need to verify there is enough stack space remaining
// for the additional locals.
// compute rsp as if this were going to be the last frame on
// the stack before the red zone
// locals + overhead, in bytes
#ifdef ASSERT
// verify that thread stack base is non-zero
// verify that thread stack size is non-zero
#endif
// Add stack base to locals and subtract stack size
// Use the maximum number of pages we might bang.
// check against the current stack bottom
// Restore sender's sp as SP. This is necessary if the sender's
// frame is an extended compiled frame (see gen_c2i_adapter())
// and safer anyway in case of JSR292 adaptations.
// Note: the restored frame is not necessarily interpreted.
// Use the shared runtime version of the StackOverflowError.
// all done with frame size check
}
// Allocate monitor and lock method (asm interpreter)
// rbx, - methodOop
//
// synchronize method
const Address monitor_block_top (rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize);
#ifdef ASSERT
{ Label L;
}
#endif // ASSERT
// get synchronization object
__ movptr(rax, Address(rdi, Interpreter::local_offset_in_bytes(0))); // get receiver (assume this is frequent case)
}
// add space for monitor & lock
}
//
// Generate a fixed interpreter frame. This is identical setup for interpreted methods
// and for native methods hence the shared code.
// initialize fixed part of activation frame
if (ProfileInterpreter) {
} else {
}
if (native_call) {
} else {
}
}
// End of helpers
//
// Various method entries
//------------------------------------------------------------------------------------------------------------------------
//
//
// Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry
// rbx,: methodOop
// rcx: receiver (preserve for slow entry into asm interpreter)
// rsi: senderSP must preserved for slow path, set SP to it on fast path
// do fastpath for resolved accessor methods
if (UseFastAccessorMethods) {
// If we need a safepoint check, generate full interpreter entry.
// ASM/C++ Interpreter
// Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; parameter size = 1
// Note: We can only use this code if the getfield has been resolved
// and if we don't have a null-pointer exception => check for
// these conditions first and use slow path if necessary.
// rbx,: method
// rcx: receiver
// check if local 0 != NULL and read field
// read first instruction word and extract bytecode @ 1 and index @ 2
// Shift codes right to get the index on the right.
// The bytecode fetched looks like <index><0xb4><0x2a>
// rax,: local 0
// rbx,: method
// rcx: receiver - do not destroy since it is needed for slow path!
// rcx: scratch
// rdx: constant pool cache index
// rdi: constant pool cache
// rsi: sender sp
// check if getfield has been resolved and read constant pool cache entry
// check the validity of the cache entry by testing whether _indices field
// contains Bytecode::_getfield in b1 byte.
rdx,
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::indices_offset()));
// Note: constant pool entry is not valid before bytecode is resolved
rdx,
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::f2_offset()));
rdx,
Address::times_ptr, constantPoolCacheOopDesc::base_offset() + ConstantPoolCacheEntry::flags_offset()));
// Need to differentiate between igetfield, agetfield, bgetfield etc.
// because they are different sizes.
// Use the type from the constant pool cache
// Make sure we don't need to mask rdx after the above shift
#ifdef ASSERT
#endif // ASSERT
// All the rest are a 32 bit wordsize
// This is ok for now. Since fast accessors should be going away
// _ireturn/_areturn
// generate a vanilla interpreter entry as the slow path
(void) generate_normal_entry(false);
return entry_point;
}
return NULL;
}
// Method entry for java.lang.ref.Reference.get.
#ifndef SERIALGC
// Code: _aload_0, _getfield, _areturn
// parameter size = 1
//
// The code that gets generated by this routine is split into 2 parts:
// 1. The "intrinsified" code for G1 (or any SATB based GC),
// 2. The slow path - which is an expansion of the regular method entry.
//
// Notes:-
// * In the G1 code we do not check whether we need to block for
// a safepoint. If G1 is enabled then we must execute the specialized
// code for Reference.get (except when the Reference object is null)
// so that we can log the value in the referent field with an SATB
// update buffer.
// If the code for the getfield template is modified so that the
// G1 pre-barrier code is executed when the current method is
// Reference.get() then going through the normal method entry
// will be fine.
// * The G1 code below can, however, check the receiver object (the instance
// of java.lang.Reference) and jump to the slow path if null. If the
// Reference object is null then we obviously cannot fetch the referent
// and so we don't need to call the G1 pre-barrier. Thus we can use the
// regular method entry code to generate the NPE.
//
// This code is based on generate_accessor_enty.
// rbx,: methodOop
// rcx: receiver (preserve for slow entry into asm interpreter)
// rsi: senderSP must preserved for slow path, set SP to it on fast path
if (UseG1GC) {
// Check if local 0 != NULL
// If the receiver is null then it is OK to jump to the slow path.
// rax: local 0 (must be preserved across the G1 barrier call)
//
// rbx: method (at this point it's scratch)
// rcx: receiver (at this point it's scratch)
// rdx: scratch
// rdi: scratch
//
// rsi: sender sp
// Preserve the sender sp in case the pre-barrier
// calls the runtime
// Load the value of the referent field.
// Generate the G1 pre-barrier code to log the value of
// the referent field in an SATB buffer.
rax /* pre_val */,
rcx /* thread */,
rbx /* tmp */,
true /* tosca_save */,
true /* expand_call */);
// _areturn
(void) generate_normal_entry(false);
return entry;
}
#endif // SERIALGC
// If G1 is not enabled then attempt to go through the accessor entry point
// Reference.get is an accessor
return generate_accessor_entry();
}
//
// Interpreter stub for calling a native method. (asm interpreter)
// This sets up a somewhat different looking stack for calling the native method
// than the typical interpreter frame setup.
//
// determine code generation flags
// rbx,: methodOop
// rsi: sender sp
// rsi: previous interpreter state (C++ interpreter) must preserve
const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset());
// get parameter size (always needed)
// native calls don't need the stack size check since they have no expression stack
// and the arguments are already on the stack and we only add a handful of words
// to the stack
// rbx,: methodOop
// rcx: size of parameters
// rsi: sender sp
// for natives the size of locals is zero
// compute beginning of parameters (rdi)
// add 2 zero-initialized slots for native calls
// NULL result handler
// NULL oop temp (mirror or jni oop result)
// initialize fixed part of activation frame
generate_fixed_frame(true);
// make sure method is native & not abstract
#ifdef ASSERT
{
Label L;
}
{ Label L;
}
#endif
// Since at this point in the method invocation the exception handler
// would try to exit the monitor of synchronized methods which hasn't
// been entered yet, we set the thread local variable
// _do_not_unlock_if_synchronized to true. The remove_activation will
// check this flag.
// increment invocation count & check for overflow
if (inc_counter) {
}
bang_stack_shadow_pages(true);
// reset the _do_not_unlock_if_synchronized flag
// check for synchronized methods
// Must happen AFTER invocation_counter check and stack overflow check,
// so method is not locked if overflows.
//
if (synchronized) {
lock_method();
} else {
// no synchronization necessary
#ifdef ASSERT
{ Label L;
}
#endif
}
// start execution
#ifdef ASSERT
{ Label L;
}
#endif
// work registers
// allocate space for parameters
// get signature handler
{ Label L;
}
// call signature handler
// The generated handlers do not touch RBX (the method oop).
// However, large signatures cannot be cached and are generated
// each time here. The slow-path generator will blow RBX
// sometime, so we must reload it after the call.
// result handler is in rax,
// set result handler
// pass mirror handle if static call
{ Label L;
// get mirror
// copy mirror into activation frame
// pass handle to mirror
}
// get native function entry point
{ Label L;
}
// pass JNIEnv
// set_last_Java_frame_before_call
// It is enough that the pc()
// points into the right code segment. It does not have to be the correct return pc.
// change thread state
#ifdef ASSERT
{ Label L;
}
#endif
// Change state to native
// result potentially in rdx:rax or ST0
// Verify or restore cpu control state after JNI call
// save potential result in ST(0) & rdx:rax
// (if result handler is the T_FLOAT or T_DOUBLE handler, result must be in ST0 -
// the check is necessary to avoid potential Intel FPU overflow problems by saving/restoring 'empty' FPU registers)
// It is safe to do this push because state is _thread_in_native and return address will be found
// via _last_native_pc and not via _last_jave_sp
// NOTE: the order of theses push(es) is known to frame::interpreter_frame_result.
// If the order changes or anything else is added to the stack the code in
// interpreter_frame_result will have to be changed.
{ Label L;
float_handler.addr());
double_handler.addr());
}
// change thread state
if (UseMembar) {
// Force this write out before the read below
} else {
// Write serialization page so VM thread can do a pseudo remote membar.
// We use the current thread pointer to calculate a thread specific
// offset to write to within the page. This minimizes bus traffic
// due to cache line collision.
}
}
if (AlwaysRestoreFPU) {
// Make sure the control word is correct.
}
Label L;
// Don't use call_VM as it will see a possible pending exception and forward it
// and never return here preventing us from clearing _last_native_pc down below.
// Also can't use call_VM_leaf either as it will check to see if rsi & rdi are
// by hand.
//
}
// change thread state
// reset handle block
// If result was an oop then unbox and save it in the frame
{ Label L;
// unbox
// keep stack depth as expected by pushing oop which will eventually be discarded
}
{
__ cmpl(Address(thread, JavaThread::stack_guard_state_offset()), JavaThread::stack_guard_yellow_disabled);
}
// restore rsi to have legal interpreter frame,
// i.e., bci == 0 <=> rsi == code_base()
// Can't call_VM until bcp is within reasonable.
// handle exceptions (exception handling will handle unlocking!)
{ Label L;
// Note: At some point we may want to unify this with the code used in call_VM_base();
// i.e., we should use the StubRoutines::forward_exception code. For now this
// doesn't work here because the rsp is not correctly set at this point.
__ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_pending_exception));
}
// do unlocking if necessary
{ Label L;
// the code below should be shared with interpreter macro assembler implementation
// BasicObjectLock will be first in list, since this is a synchronized method. However, need
// to check that the object has not been unlocked by an explicit monitorexit bytecode.
const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * wordSize - (int)sizeof(BasicObjectLock));
// Entry already unlocked, need to throw exception
__ MacroAssembler::call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
}
}
// the exception handler code notifies the runtime of method exits
// not properly paired (was bug - gri 11/22/99).
// restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result
// remove activation
if (inc_counter) {
// Handle overflow of counter and compile method
}
return entry_point;
}
//
// Generic interpreted method entry to (asm) interpreter
//
// determine code generation flags
// rbx,: methodOop
// rsi: sender sp
const Address invocation_counter(rbx, methodOopDesc::invocation_counter_offset() + InvocationCounter::counter_offset());
// get parameter size (always needed)
// rbx,: methodOop
// rcx: size of parameters
// rsi: sender_sp (could differ from sp+wordSize if we were called via c2i )
// see if we've got enough room on the stack for locals plus overhead.
// get return address
// compute beginning of parameters (rdi)
// rdx - # of additional locals
// allocate space for locals
// explicitly initialize locals
{
}
// initialize fixed part of activation frame
generate_fixed_frame(false);
// make sure method is not native & not abstract
#ifdef ASSERT
{
Label L;
}
{ Label L;
}
#endif
// Since at this point in the method invocation the exception handler
// would try to exit the monitor of synchronized methods which hasn't
// been entered yet, we set the thread local variable
// _do_not_unlock_if_synchronized to true. The remove_activation will
// check this flag.
// increment invocation count & check for overflow
if (inc_counter) {
if (ProfileInterpreter) {
}
}
bang_stack_shadow_pages(false);
// reset the _do_not_unlock_if_synchronized flag
// check for synchronized methods
// Must happen AFTER invocation_counter check and stack overflow check,
// so method is not locked if overflows.
//
if (synchronized) {
// Allocate monitor and lock method
lock_method();
} else {
// no synchronization necessary
#ifdef ASSERT
{ Label L;
}
#endif
}
// start execution
#ifdef ASSERT
{ Label L;
}
#endif
// jvmti support
// invocation counter overflow
if (inc_counter) {
if (ProfileInterpreter) {
// We have decided to profile this method in the interpreter
}
// Handle overflow of counter and compile method
}
return entry_point;
}
//------------------------------------------------------------------------------------------------------------------------
// Entry points
//
// Here we generate the various kind of entries into the interpreter.
// The two main entry type are generic bytecode methods and native call method.
// These both come in synchronized and non-synchronized versions but the
// frame layout they create is very similar. The other method entry
// types are really just special purpose entries that are really entry
// and interpretation all in one. These are for trivial methods like
// accessor, empty, or special math methods.
//
// When control flow reaches any of the entry types for the interpreter
// the following holds ->
//
// Arguments:
//
// rbx,: methodOop
// rcx: receiver
//
//
// Stack layout immediately at entry
//
// [ return address ] <--- rsp
// [ parameter n ]
// ...
// [ parameter 1 ]
// [ expression stack ] (caller's java expression stack)
// Assuming that we don't go to one of the trivial specialized
// entries the stack will look like below when we are ready to execute
// the first bytecode (or call the native routine). The register usage
// will be as the template based interpreter expects (see interpreter_x86.hpp).
//
// local variables follow incoming parameters immediately; i.e.
// the return address is moved to the end of the locals).
//
// [ monitor entry ] <--- rsp
// ...
// [ monitor entry ]
// [ expr. stack bottom ]
// [ saved rsi ]
// [ current rdi ]
// [ methodOop ]
// [ saved rbp, ] <--- rbp,
// [ return address ]
// [ local variable m ]
// ...
// [ local variable 1 ]
// [ parameter n ]
// ...
// [ parameter 1 ] <--- rdi
// determine code generation flags
bool synchronized = false;
switch (kind) {
case Interpreter::zerolocals : break;
case Interpreter::native : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(false); break;
case Interpreter::native_synchronized : entry_point = ((InterpreterGenerator*)this)->generate_native_entry(true); break;
case Interpreter::empty : entry_point = ((InterpreterGenerator*)this)->generate_empty_entry(); break;
case Interpreter::accessor : entry_point = ((InterpreterGenerator*)this)->generate_accessor_entry(); break;
case Interpreter::abstract : entry_point = ((InterpreterGenerator*)this)->generate_abstract_entry(); break;
case Interpreter::java_lang_math_exp : entry_point = ((InterpreterGenerator*)this)->generate_math_entry(kind); break;
default:
break;
}
if (entry_point) return entry_point;
}
// These should never be compiled since the interpreter will prefer
// the compiled version to the intrinsic version.
switch (method_kind(m)) {
case Interpreter::java_lang_math_exp :
return false;
default:
return true;
}
}
// How much stack a method activation needs in words.
// Save space for one monitor to get into the interpreted method in case
// the method is synchronized
// total overhead size: entry_size + (saved rbp, thru expr stack bottom).
}
// asm based interpreter deoptimization helpers
int tempcount,
int popframe_extra_args,
int moncount,
int callee_param_count,
int callee_locals,
bool is_top_frame,
bool is_bottom_frame) {
// Note: This calculation must exactly parallel the frame setup
// in AbstractInterpreterGenerator::generate_method_entry.
// If interpreter_frame!=NULL, set up the method, locals, and monitors.
// The frame interpreter_frame, if not NULL, is guaranteed to be the right size,
// as determined by a previous call to this method.
// It is also guaranteed to be walkable even though it is in a skeletal state
// NOTE: return size is in words not bytes
// fixed size of an interpreter frame:
// Our locals were accounted for by the caller (or last_frame_adjust on the transistion)
// Since the callee parameters already account for the callee's params we only need to account for
// the extra locals.
if (interpreter_frame != NULL) {
#ifdef ASSERT
if (!EnableInvokeDynamic)
// @@@ FIXME: Should we correct interpreter_frame_sender_sp in the calling sequences?
// Probably, since deoptimization doesn't work yet.
assert(caller->unextended_sp() == interpreter_frame->interpreter_frame_sender_sp(), "Frame not properly walkable");
#endif
// NOTE the difference in using sender_sp and interpreter_frame_sender_sp
// interpreter_frame_sender_sp is the original sp of the caller (the unextended_sp)
// and sender_sp is fp+8
#ifdef ASSERT
if (caller->is_interpreted_frame()) {
}
#endif
// Set last_sp
// All frames but the initial (oldest) interpreter frame we fill in have a
// value for sender_sp that allows walking the stack but isn't
// truly correct. Correct the value here.
if (extra_locals != 0 &&
}
}
return size;
}
//------------------------------------------------------------------------------------------------------------------------
// Exceptions
// Entry point in previous activation (i.e., if the caller was interpreted)
// Restore sp to interpreter_frame_last_sp even though we are going
// to empty the expression stack for the exception processing.
// rax,: exception
__ restore_locals();
// Entry point for exceptions thrown within interpreter code
// expression stack is undefined here
// rax,: exception
// rsi: exception bcp
// expression stack must be empty before entering the VM in case of an exception
// find exception handler address and preserve exception oop
__ call_VM(rdx, CAST_FROM_FN_PTR(address, InterpreterRuntime::exception_handler_for_exception), rax);
// rax,: exception handler entry point
// rdx: preserved exception oop
// rsi: bcp for exception handler
// If the exception is not handled in the current frame the frame is removed and
// the exception is rethrown (i.e. exception continuation is _rethrow_exception).
//
// Note: At this point the bci is still the bxi for the instruction which caused
// the exception and the expression stack is empty. Thus, for any VM calls
// at this point, GC will find a legal oop map (with empty expression stack).
// In current activation
// tos: exception
// rsi: exception bcp
//
// JVMTI PopFrame support
//
// Set the popframe_processing bit in pending_popframe_condition indicating that we are
// currently handling popframe, so that call_VMs that may happen later do not trigger new
// popframe handling cycles.
{
// Check to see whether we are returning to a deoptimized frame.
// (The PopFrame call ensures that the caller of the popped frame is
// either interpreted or compiled and deoptimizes it if compiled.)
// In this case, we can't call dispatch_next() after the frame is
// popped, but instead must save the incoming arguments and restore
// them after deoptimization has occurred.
//
// Note that we don't compare the return PC against the
// deoptimization blob's unpack entry because of the presence of
// adapter frames in C2.
// Compute size of arguments for saving when returning to deoptimized caller
__ restore_locals();
// Save these arguments
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, Deoptimization::popframe_preserve_args), thread, rax, rdi);
/* throw_monitor_exception */ false,
/* install_monitor_exception */ false,
/* notify_jvmdi */ false);
// Inform deoptimization that it is responsible for restoring these arguments
__ movl(Address(thread, JavaThread::popframe_condition_offset()), JavaThread::popframe_force_deopt_reexecution_bit);
// Continue in deoptimization handler
}
/* throw_monitor_exception */ false,
/* install_monitor_exception */ false,
/* notify_jvmdi */ false);
// Finish with popframe handling
// A previous I2C followed by a deoptimization might have moved the
// outgoing arguments further up the stack. PopFrame expects the
// mutations to those outgoing arguments to be preserved and other
// constraints basically require this frame to look exactly as
// though it had previously invoked an interpreted activation with
// no space between the top of the expression stack (current
// last_sp) and the top of stack. Rather than force deopt to
// maintain this kind of invariant all the time we call a small
// fixup routine to move the mutated arguments onto the top of our
// expression stack if necessary.
// PC must point into interpreter here
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, InterpreterRuntime::popframe_move_outgoing_args), thread, rax, rbx);
// Restore the last_sp and null it out
__ restore_bcp();
__ restore_locals();
// The method data pointer was incremented already during
// call profiling. We have to restore the mdp for the current bcp.
if (ProfileInterpreter) {
}
// Clear the popframe condition flag
// end of PopFrame support
// preserve exception over this code sequence
// remove the activation (without doing throws on illegalMonitorExceptions)
// restore exception
// Inbetween activations - previous activation type unknown yet
// compute continuation point - the continuation point expects
// the following registers set up:
//
// rax: exception
// rsp: expression stack of caller
// rbp: rbp, of caller
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), thread, rdx);
// Note that an "issuing PC" is actually the next PC after the call
}
//
// JVMTI ForceEarlyReturn support
//
__ restore_bcp();
__ restore_locals();
// Clear the earlyret state
false, /* throw_monitor_exception */
false, /* install_monitor_exception */
true); /* notify_jvmdi */
return entry;
} // end of ForceEarlyReturn support
//------------------------------------------------------------------------------------------------------------------------
// Helper for vtos entry point generation
void TemplateInterpreterGenerator::set_vtos_entry_points (Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) {
Label L;
}
//------------------------------------------------------------------------------------------------------------------------
// Generation of individual instructions
// helpers for generate_and_dispatch
generate_all(); // down here so it can be "virtual"
}
//------------------------------------------------------------------------------------------------------------------------
// Non-product code
#ifndef PRODUCT
// prepare expression stack
// pass tosca registers as arguments & call tracer
// return
return entry;
}
}
}
}
// Call a little run-time stub to avoid blow-up for each bytecode.
// The run-time runtime saves the right registers, depending on
// the tosca in-state for the given template.
"entry must have been generated");
}
Label L;
}
#endif // !PRODUCT
#endif // CC_INTERP