3790N/A * Copyright (c) 2007, 2012, Oracle and/or its affiliates. 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. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// Routine exists to make tracebacks look decent in debugger 0N/A// while we are recursed in the frame manager/c++ interpreter. 0N/A// We could use an address in the frame manager but having 0N/A// frames look natural in the debugger is a plus. 0N/A // c++ interpreter entry point this holds that entry point label. 304N/A// default registers for state and sender_sp 304N/A// state and sender_sp are the same on 32bit because we have no choice. 304N/A// state could be rsi on 64bit but it is an arg reg and not callee save 304N/A// so r13 is better choice. 0N/A// address AbstractInterpreter::_remove_activation_preserving_args_entry; 0N/A// Is this pc anywhere within code owned by the interpreter? 0N/A// This only works for pc that might possibly be exposed to frame 0N/A// walkers. It clearly misses all of the actual c++ interpreter 0N/A // Must return a result for interpreter or compiler. In SSE 0N/A // mode, results are returned in xmm0 and the FPU stack must 0N/A // Store as float and empty fpu stack 0N/A // retrieve result from frame 0N/A __ ret(0);
// return from result handler 0N/A// tosca based result to c++ interpreter stack based result. 0N/A// Result goes to top of native stack. 0N/A // A result is in the tosca (abi result) from either a native method call or compiled 0N/A // code. Place this result on the java expression stack so C++ interpreter can use it. 304N/A // Result is in ST(0)/xmm0 0N/A __ jmp(t);
// return from result handler 0N/A // A result is in the java expression stack of the interpreted method that has just 0N/A // returned. Place this result on the java expression stack of the caller. 304N/A // The current interpreter activation in rsi/r13 is for the method just returning its 0N/A // result. So we know that the result of this method is on the top of the current 0N/A // execution stack (which is pre-pushed) and will be return to the top of the caller 0N/A // stack. The top of the callers stack is the bottom of the locals of the current 0N/A // Because of the way activation are managed by the frame manager the value of rsp is 0N/A // below both the stack top of the current activation and naturally the stack top 0N/A // of the calling activation. This enable this routine to leave the return address 0N/A // to the frame manager on the stack and do a vanilla return. 304N/A // On entry: rsi/r13 - interpreter state of activation returning a (potential) result 0N/A // rax - new stack top for caller activation (i.e. activation in _prev_link) 0N/A // Can destroy rdx, rcx. 0N/A // return top two words on current expression stack to caller's expression stack 0N/A // The caller's expression stack is adjacent to the current frame manager's intepretState 0N/A // except we allocated one extra word for this intepretState so we won't overwrite it 0N/A // when we return a two word result. 0N/A // A result is in the java expression stack of the interpreted method that has just 0N/A // returned. Place this result in the native abi that the caller expects. 0N/A // Similar to generate_stack_to_stack_converter above. Called at a similar time from the 0N/A // frame manager execept in this situation the caller is native code (c1/c2/call_stub) 0N/A // and so rather than return result onto caller's java expression stack we return the 0N/A // result in the expected location based on the native abi. 304N/A // On entry: rsi/r13 - interpreter state of activation returning a (potential) result 0N/A // Other registers changed [rax/rdx/ST(0) as needed for the result returned] 0N/A // make it look good in the debugger 0N/A // On entry the "locals" argument points to locals[0] (or where it would be in case no locals in 0N/A // a static method). "state" contains any previous frame manager state which we must save a link 0N/A // to in the newly generated state object. On return "state" is a pointer to the newly allocated 0N/A // state object. We must allocate and initialize a new interpretState object and the method 0N/A // expression stack. Because the returned result (if any) of the method will be placed on the caller's 0N/A // expression stack and this will overlap with locals[0] (and locals[1] if double/long) we must 0N/A // be sure to leave space on the caller's stack so that this result will not overwrite values when 0N/A // locals[0] and locals[1] do not exist (and in fact are return address and saved rbp). So when 0N/A // we are non-native we in essence ensure that locals[0-1] exist. We play an extra trick in 0N/A // non-product builds and initialize this last local with the previous interpreterState as 0N/A // this makes things look real nice in the debugger. 0N/A // Assumes locals == &locals[0] 0N/A // Assumes state == any previous frame manager state (assuming call path from c++ interpreter) 0N/A // Assumes rax = return address 0N/A // rcx == senders_sp 0N/A // Modifies rcx, rdx, rax 0N/A // state == address of new interpreterState 0N/A // rsp == bottom of method's expression stack. 0N/A // On entry sp is the sender's sp. This includes the space for the arguments 0N/A // that the sender pushed. If the sender pushed no args (a static) and the 0N/A // caller returns a long then we need two words on the sender's stack which 0N/A // are not present (although when we return a restore full size stack the 0N/A // space will be present). If we didn't allocate two words here then when 0N/A // we "push" the result of the caller's stack we would overwrite the return 0N/A // address and the saved rbp. Not good. So simply allocate 2 words now 0N/A // just to be safe. This is the "static long no_params() method" issue. 0N/A // We don't need this for native calls because they return result in 0N/A // register and the stack is expanded in the caller before we store 0N/A // the results on the stack. 0N/A // Now that we are assure of space for stack result, setup typical linkage 0N/A // initialize the "shadow" frame so that use since C++ interpreter not directly 0N/A // recursive. Simpler to recurse but we can't trim expression stack as we call 0N/A // entries run from -1..x where &monitor[x] == 0N/A // Must not attempt to lock method until we enter interpreter as gc won't be able to find the 0N/A // initial frame. However we allocate a free monitor so we don't have to shuffle the expression stack 0N/A // synchronize method 0N/A // Allocate initial monitor and pre initialize it 0N/A // get synchronization object 0N/A // add space for monitor & lock 0N/A // compute full expression stack limit 0N/A // Allocate expression stack 304N/A // Make sure stack is properly aligned and sized for the abi 0N/A// Helpers for commoning out cases in the various type of method entries. 0N/A// increment invocation count & check for overflow 0N/A// Note: checking for negative value instead of overflow 0N/A// so we have a 'sticky' overflow test 0N/A// rcx: invocation counter 0N/A // Update standard invocation counters 0N/A // profile_method is non-null only for interpreted method so 0N/A // profile_method != NULL == !native_call 0N/A // BytecodeInterpreter only calls for native so code is elided. 0N/A // C++ interpreter on entry 0N/A // rbp - interpreter frame pointer 0N/A // On return (i.e. jump to entry_point) [ back to invocation of interpreter ] 0N/A // rcx - rcvr (assuming there is one) 0N/A // top of stack return address of interpreter caller 0N/A // C++ interpreter only 0N/A // InterpreterRuntime::frequency_counter_overflow takes one argument 0N/A // indicating if the counter overflow occurs at a backwards branch (non-NULL bcp). 0N/A // The call returns the address of the verified entry point for the method or NULL 0N/A // if the compilation did not complete (either went background or bailed out). 0N/A // for c++ interpreter can rsi really be munged? 0N/A // see if we've got enough room on the stack for locals plus overhead. 0N/A // the expression stack grows down incrementally, so the normal guard 0N/A // page mechanism will work for that. 0N/A // Registers live on entry: 0N/A // rdx: number of additional locals this frame needs (what we must check) 0N/A // rdx: number of additional locals this frame needs (what we must check) 0N/A // destroyed on exit 0N/A // NOTE: since the additional locals are also always pushed (wasn't obvious in 0N/A // generate_method_entry) so the guard should work for them too. 0N/A // monitor entry size: see picture of stack set (generate_method_entry) and frame_i486.hpp 0N/A // total overhead size: entry_size + (saved rbp, thru expr stack bottom). 0N/A // compute rsp as if this were going to be the last frame on 0N/A // the stack before the red zone 0N/A // save rsi == caller's bytecode ptr (c++ previous interp. state) 0N/A // QQQ problem here?? rsi overload???? 0N/A // locals + overhead, in bytes 0N/A // Always give one monitor to allow us to start interp if sync method. 0N/A // Any additional monitors need a check when moving the expression stack 0N/A // verify that thread stack base is non-zero 0N/A // verify that thread stack size is non-zero 0N/A // Add stack base to locals and subtract stack size 0N/A // We should have a magic number here for the size of the c++ interpreter frame. 0N/A // We can't actually tell this ahead of time. The debug version size is around 3k 0N/A // product is 1k and fastdebug is 4k 0N/A // Use the maximum number of pages we might bang. 0N/A // Only need this if we are stack banging which is temporary while 0N/A // check against the current stack bottom 0N/A // throw exception return address becomes throwing pc 0N/A // all done with frame size check 0N/A// Find preallocated monitor and lock method (C++ interpreter) 304N/A // assumes state == rsi/r13 == pointer to current interpreterState 304N/A // minimally destroys rax, rdx|c_rarg1, rdi 0N/A // synchronize method 0N/A // find initial monitor i.e. monitors[-1] 0N/A __ stop(
"method doesn't need synchronization");
0N/A // get synchronization object 304N/A // can destroy rax, rdx|c_rarg1, rcx, and (via call_VM) rdi! 0N/A// Call an accessor method (assuming it is resolved, otherwise drop into vanilla (slow path) entry 304N/A // rsi/r13: senderSP must preserved for slow path, set SP to it on fast path 0N/A // do fastpath for resolved accessor methods 0N/A // If we need a safepoint check, generate full interpreter entry. 0N/A // ASM/C++ Interpreter 0N/A // Code: _aload_0, _(i|a)getfield, _(i|a)return or any rewrites thereof; parameter size = 1 0N/A // Note: We can only use this code if the getfield has been resolved 0N/A // and if we don't have a null-pointer exception => check for 0N/A // these conditions first and use slow path if necessary. 0N/A // check if local 0 != NULL and read field 0N/A // read first instruction word and extract bytecode @ 1 and index @ 2 0N/A // Shift codes right to get the index on the right. 0N/A // The bytecode fetched looks like <index><0xb4><0x2a> 0N/A // rcx: receiver - do not destroy since it is needed for slow path! 0N/A // rdx: constant pool cache index 0N/A // rdi: constant pool cache 0N/A // check if getfield has been resolved and read constant pool cache entry 0N/A // check the validity of the cache entry by testing whether _indices field 0N/A // contains Bytecode::_getfield in b1 byte. 0N/A // Note: constant pool entry is not valid before bytecode is resolved 0N/A // Need to differentiate between igetfield, agetfield, bgetfield etc. 0N/A // because they are different sizes. 0N/A // Use the type from the constant pool cache 3932N/A // Make sure we don't need to mask rdx after the above shift 0N/A // All the rest are a 32 bit wordsize 0N/A // _ireturn/_areturn 0N/A // generate a vanilla interpreter entry as the slow path 0N/A // We will enter c++ interpreter looking like it was 0N/A // called by the call_stub this will cause it to return 0N/A // a tosca result to the invoker which might have been 0N/A // the c++ interpreter itself. 2346N/A // We need to generate have a routine that generates code to: 2346N/A // * load the value in the referent field 2346N/A // * passes that value to the pre-barrier. 2346N/A // In the case of G1 this will record the value of the 2346N/A // referent in an SATB buffer if marking is active. 2346N/A // This will cause concurrent marking to mark the referent 2346N/A // If G1 is not enabled then attempt to go through the accessor entry point 2346N/A // Reference.get is an accessor 0N/A// C++ Interpreter stub for calling a native method. 0N/A// This sets up a somewhat different looking stack for calling the native method 0N/A// than the typical interpreter frame setup but still has the pointer to 0N/A// an interpreter state. 0N/A // determine code generation flags 0N/A // rcx: receiver (unused) 304N/A // rsi/r13: previous interpreter state (if called from C++ interpreter) must preserve 0N/A // get parameter size (always needed) 0N/A // rcx: size of parameters 0N/A // for natives the size of locals is zero 0N/A // compute beginning of parameters /locals 0N/A // initialize fixed part of activation frame 0N/A // Assumes rax = return address 0N/A // allocate and initialize new interpreterState and method expression stack 0N/A // IN(locals) -> locals 0N/A // IN(state) -> previous frame manager state (NULL from stub/c1/c2) 0N/A // destroys rax, rcx, rdx 0N/A // OUT (state) -> new interpreterState 0N/A // OUT(rsp) -> bottom of methods expression stack 0N/A // start with NULL previous state 304N/A // duplicate the alignment rsp got after setting stack_base 0N/A __ stop(
"broken stack frame setup in interpreter");
0N/A // Since at this point in the method invocation the exception handler 0N/A // would try to exit the monitor of synchronized methods which hasn't 0N/A // been entered yet, we set the thread local variable 0N/A // _do_not_unlock_if_synchronized to true. The remove_activation will 0N/A // make sure method is native & not abstract 0N/A __ stop(
"tried to execute non-native method as native");
0N/A __ stop(
"tried to execute abstract method in interpreter");
0N/A // increment invocation count & check for overflow 0N/A // reset the _do_not_unlock_if_synchronized flag 0N/A // check for synchronized native methods 0N/A // Note: This must happen *after* invocation counter check, since 0N/A // when overflow happens, the method should not be locked. 0N/A // potentially kills rax, rcx, rdx, rdi 0N/A // no synchronization necessary 0N/A // allocate space for parameters 0N/A // get signature handler 0N/A // call signature handler 0N/A // The generated handlers do not touch RBX (the method oop). 0N/A // However, large signatures cannot be cached and are generated 0N/A // each time here. The slow-path generator will blow RBX 0N/A // sometime, so we must reload it after the call. 0N/A // result handler is in rax 0N/A // set result handler 304N/A // get native function entry point 0N/A // pass mirror handle if static call 0N/A // copy mirror into activation object 0N/A // pass handle to mirror 0N/A __ stop(
"Wrong thread state in native stub");
0N/A // Change state to native (we save the return address in the thread, since it might not 0N/A // be pushed on the stack when we do a a stack traversal). It is enough that the pc() 0N/A // points into the right code segment. It does not have to be the correct return pc. 0N/A // result potentially in rdx:rax or ST0 0N/A // The potential result is in ST(0) & rdx:rax 0N/A // With C++ interpreter we leave any possible result in ST(0) until we are in result handler and then 0N/A // we do the appropriate stuff for returning the result. rdx:rax must always be saved because just about 0N/A // anything we do here will destroy it, st(0) is only saved if we re-enter the vm where it would 0N/A // It is safe to do these pushes because state is _thread_in_native and return address will be found 0N/A // via _last_native_pc and not via _last_jave_sp 304N/A // Must save the value of ST(0)/xmm0 since it could be destroyed before we get to result handler 304N/A // save rax:rdx for potential use by result handler. 4442N/A // Verify or restore cpu control state after JNI call 0N/A // change thread state 0N/A // Write serialization page so VM thread can do a pseudo remote membar. 0N/A // We use the current thread pointer to calculate a thread specific 0N/A // offset to write to within the page. This minimizes bus traffic 0N/A // due to cache line collision. 0N/A // check for safepoint operation in progress and/or pending suspend requests 0N/A // threads running native code and they are expected to self-suspend 0N/A // when leaving the _thread_in_native state. We need to check for 0N/A // pending suspend requests here. 0N/A // Don't use call_VM as it will see a possible pending exception and forward it 0N/A // and never return here preventing us from clearing _last_native_pc down below. 0N/A // Also can't use call_VM_leaf either as it will check to see if rsi & rdi are 0N/A // change thread state 0N/A // reset handle block 0N/A // If result was an oop then unbox and save it in the frame 0N/A // keep stack depth as expected by pushing oop which will eventually be discarded 0N/A // QQQ Seems like for native methods we simply return and the caller will see the pending 0N/A // exception and do the right thing. Certainly the interpreter will, don't know about 0N/A // compiled methods. 0N/A // Seems that the answer to above is no this is wrong. The old code would see the exception 0N/A // and forward it before doing the unlocking and notifying jvmdi that method has exited. 0N/A // This seems wrong need to investigate the spec. 0N/A // handle exceptions (exception handling will handle unlocking!) 0N/A // There are potential results on the stack (rax/rdx, ST(0)) we ignore these and simply 0N/A // return and let caller deal with exception. This skips the unlocking here which 0N/A // seems wrong but seems to be what asm interpreter did. Can't find this in the spec. 0N/A // Note: must preverve method in rbx 0N/A // remove activation 0N/A // The skips unlocking!! This seems to be what asm interpreter does but seems 0N/A // very wrong. Not clear if this violates the spec. 0N/A // do unlocking if necessary 0N/A // the code below should be shared with interpreter macro assembler implementation 0N/A // BasicObjectLock will be first in list, since this is a synchronized method. However, need 0N/A // to check that the object has not been unlocked by an explicit monitorexit bytecode. 0N/A // Entry already unlocked, need to throw exception 0N/A // unlock can blow rbx so restore it for path that needs it below 0N/A // the exception handler code notifies the runtime of method exits 0N/A // too. If this happens before, method entry/exit notifications are 0N/A // not properly paired (was bug - gri 11/22/99). 0N/A // restore potential result in rdx:rax, call result handler to restore potential result in ST0 & handle result 0N/A __ call(t);
// call result handler to convert to tosca form 0N/A // remove activation 0N/A // invocation counter overflow 0N/A // Handle overflow of counter and compile method 0N/A// Generate entries that will put a result type index into rcx 0N/A // Generate entries that will put a result type index into rcx 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // rax,rdx are live here 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // st(0) is live here 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // st(0) is live here 0N/A // deopt needs to jump to here to enter the interpreter (return a result) 0N/A // Deopt return common 0N/A // an index is present in rcx that lets us move any possible result being 0N/A // return to the interpreter's stack 0N/A // Because we have a full sized interpreter frame on the youngest 0N/A // activation the stack is pushed too deep to share the tosca to 0N/A // stack converters directly. We shrink the stack to the desired 0N/A // amount and then push result and then re-extend the stack. 0N/A // We could have the code in size_activation layout a short 0N/A // frame for the top activation but that would look different 0N/A // than say sparc (which needs a full size activation because 0N/A // the windows are in the way. Really it could be short? QQQ 0N/A // setup rsp so we can push the "result" as needed. 304N/A // Address index(noreg, rcx, Address::times_ptr); 304N/A // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack))); 0N/A // result if any on stack already ) 0N/A// Generate the code to handle a more_monitors message from the c++ interpreter 304N/A // 1. compute new pointers // rsp: old expression stack top 0N/A // 2. move expression stack contents 0N/A // now zero the slot so we can find it. 0N/A// Initial entry to C++ interpreter from the call_stub. 0N/A// This entry point is called the frame manager since it handles the generation 0N/A// of interpreter activation frames via requests directly from the vm (via call_stub) 0N/A// and via requests from the interpreter. The requests from the call_stub happen 0N/A// directly thru the entry point. Requests from the interpreter happen via returning 0N/A// from the interpreter and examining the message the interpreter has returned to 0N/A// the frame manager. The frame manager can take the following requests: 0N/A// NO_REQUEST - error, should never happen. 0N/A// MORE_MONITORS - need a new monitor. Shuffle the expression stack on down and 0N/A// allocate a new monitor. 0N/A// CALL_METHOD - setup a new activation to call a new method. Very similar to what 0N/A// happens during entry during the entry via the call stub. 0N/A// RETURN_FROM_METHOD - remove an activation. Return to interpreter or call stub. 0N/A// rcx: receiver - unused (retrieved from stack as needed) 0N/A// Stack layout at entry 0N/A// [ return address ] <--- rsp 0N/A// [ expression stack ] 0N/A// We are free to blow any registers we like because the call_stub which brought us here 0N/A// initially has preserved the callee save registers already. 0N/A // Because we redispatch "recursive" interpreter entries thru this same entry point 0N/A // the "input" register usage is a little strange and not what you expect coming 0N/A // state are NULL but on "recursive" dispatches they are what you'd expect. 0N/A // rsi: current interpreter state (C++ interpreter) must preserve (null from call_stub/c1/c2) 0N/A // A single frame manager is plenty as we don't specialize for synchronized. We could and 0N/A // the code is pretty much ready. Would need to change the test below and for good measure 0N/A // modify generate_interpreter_state to only do the (pre) sync stuff stuff for synchronized 0N/A // routines. Not clear this is worth it yet. 0N/A // Fast accessor methods share this entry point. 0N/A // This works because frame manager is in the same codelet 0N/A // save sender sp (doesn't include return address 0N/A // const Address monitor_block_top (rbp, frame::interpreter_frame_monitor_block_top_offset * wordSize); 0N/A // const Address monitor_block_bot (rbp, frame::interpreter_frame_initial_sp_offset * wordSize); 0N/A // const Address monitor(rbp, frame::interpreter_frame_initial_sp_offset * wordSize - (int)sizeof(BasicObjectLock)); 0N/A // get parameter size (always needed) 0N/A // rcx: size of parameters 0N/A // see if we've got enough room on the stack for locals plus overhead. 0N/A // c++ interpreter does not use stack banging or any implicit exceptions 0N/A // leave for now to verify that check is proper. 0N/A // compute beginning of parameters (rdi) 0N/A // __ movl(rcx, rsp); 0N/A // get return address 0N/A // rdx - # of additional locals 0N/A // allocate space for locals 0N/A // explicitly initialize locals 0N/A // Assumes rax = return address 0N/A // allocate and initialize new interpreterState and method expression stack 0N/A // IN(locals) -> locals 0N/A // IN(state) -> any current interpreter activation 0N/A // destroys rax, rcx, rdx, rdi 0N/A // OUT (state) -> new interpreterState 0N/A // OUT(rsp) -> bottom of methods expression stack 0N/A // c++ interpreter does not use stack banging or any implicit exceptions 0N/A // leave for now to verify that check is proper. 0N/A // Call interpreter enter here if message is 0N/A // set and we know stack size is valid 0N/A // We can setup the frame anchor with everything we want at this point 0N/A // as we are thread_in_Java and no safepoints can occur until we go to 0N/A // vm mode. We do have to clear flags on return from vm but that is it 0N/A // Call the interpreter 0N/A // state is preserved since it is callee saved 0N/A // reset_last_Java_frame 0N/A // examine msg from interpreter to determine next action 0N/A // Allocate more monitor space, shuffle expression stack.... 0N/A // uncommon trap needs to jump to here to enter the interpreter (re-execute current bytecode) 0N/A // Load the registers we need. 0N/A //============================================================================= 0N/A // Returning from a compiled method into a deopted method. The bytecode at the 0N/A // bcp has completed. The result of the bytecode is in the native abi (the tosca 0N/A // for the template based interpreter). Any stack space that was used by the 0N/A // bytecode that has completed has been removed (e.g. parameters for an invoke) 0N/A // so all that we have to do is place any pending result on the expression stack 0N/A // and resume execution on the next bytecode. 0N/A // Current frame has caught an exception we need to dispatch to the 0N/A // handler. We can get here because a native interpreter frame caught 0N/A // an exception in which case there is no handler and we must rethrow 0N/A // If it is a vanilla interpreted frame the we simply drop into the 0N/A // interpreter and let it do the lookup. 0N/A // restore state pointer. 0N/A // Store exception with interpreter will expect it 0N/A // is current frame vanilla or native? 0N/A // We drop thru to unwind a native interpreted frame with a pending exception 0N/A // We jump here for the initial interpreter frame with exception pending 0N/A // We unwind the current acivation and forward it to our caller. 0N/A // unwind rbp, return stack to unextended value and re-push return address 0N/A // Return point from a call which returns a result in the native abi 0N/A // expression stack. 0N/A // A pending exception may be present in which case there is no result present 0N/A // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases 0N/A for (
int i =
1; i <
8; i++) {
0N/A for (
int i =
1; i <
8; i++) {
0N/A // Result if any is in tosca. The java expression stack is in the state that the 0N/A // calling convention left it (i.e. params may or may not be present) 0N/A // Copy the result from tosca and place it on java expression stack. 304N/A // Restore rsi/r13 as compiled code may not preserve it 0N/A // restore stack to what we had when we left (in case i2c extended it) 0N/A // If there is a pending exception then we don't really have a result to process 0N/A // get method just executed 0N/A // callee left args on top of expression stack, remove them 304N/A // Address index(noreg, rax, Address::times_ptr); 304N/A // __ movl(rcx, Address(noreg, rcx, Address::times_ptr, int(AbstractInterpreter::_tosca_to_stack))); 0N/A // An exception is being caught on return to a vanilla interpreter frame. 0N/A // Empty the stack and resume interpreter 0N/A // Exception present, empty stack 0N/A // Return from interpreted method we return result appropriate to the caller (i.e. "recursive" 0N/A // interpreter call, or native) and unwind this interpreter activation. 0N/A // All monitors should be unlocked. 0N/A // Copy result to callers java stack 304N/A // Address index(noreg, rax, Address::times_ptr); 304N/A // __ movl(rax, Address(noreg, rax, Address::times_ptr, int(AbstractInterpreter::_stack_to_stack))); 0N/A // returning to interpreter method from "recursive" interpreter call 0N/A // result converter left rax pointing to top of the java stack for method we are returning 0N/A // to. Now all we must do is unwind the state from the completed call 0N/A // Resume the interpreter. The current frame contains the current interpreter 0N/A // state == interpreterState object for method we are resuming 0N/A // result if any on stack already ) 0N/A // convert result and unwind initial activation 0N/A // rax - result index 304N/A // Address index(noreg, rax, Address::times_ptr); 0N/A /* Current stack picture 0N/A [ incoming parameters ] 0N/A BytecodeInterpreter object 0N/A // return restoring the stack to the original sender_sp value 0N/A // set stack to sender's sp 0N/A // OSR request, adjust return address to make current frame into adapter frame 0N/A // and enter OSR nmethod 0N/A // We are going to pop this frame. Is there another interpreter frame underneath 0N/A // Move buffer to the expected parameter location 0N/A // We know we are calling compiled so push specialized return 0N/A // method uses specialized entry, push a return so we look like call stub setup 0N/A // this path will handle fact that result is returned in registers and not 0N/A // on the java stack. 0N/A // set stack to sender's sp 0N/A // repush real return 0N/A // Enter OSR nmethod 0N/A // Call a new method. All we do is (temporarily) trim the expression stack 0N/A // push a return address to bring us back to here and leap to the new entry. 0N/A // stack points to next free location and not top element on expression stack 0N/A // method expects sp to be pointing to topmost element 0N/A // don't need a return address if reinvoking interpreter 0N/A // Make it look like call_stub calling conventions 0N/A // Get (potential) receiver 0N/A // get specialized entry 0N/A // method uses specialized entry, push a return so we look like call stub setup 0N/A // this path will handle fact that result is returned in registers and not 0N/A // on the java stack. 0N/A // Interpreted method "returned" with an exception pass it on... 0N/A // We handle result (if any) differently based on return to interpreter or call_stub 0N/A // We will unwind the current (initial) interpreter frame and forward 0N/A // the exception to the caller. We must put the exception in the 0N/A // expected register and clear pending exception and then forward. 0N/A // determine code generation flags 0N/A// Deoptimization helpers for C++ interpreter 0N/A// How much stack a method activation needs in words. 0N/A // Save space for one monitor to get into the interpreted method in case 0N/A // the method is synchronized 0N/A // total static overhead size. Account for interpreter state object, return 0N/A // address, saved rbp and 2 words for a "static long no_params() method" issue. 0N/A// returns the activation size. 0N/A // What about any vtable? 0N/A // This gets filled in later but make it something recognizable for now 0N/A // *current->register_addr(GR_Iprev_state) = (intptr_t) prev; 0N/A // Make the prev callee look proper 0N/A // Need +1 here because stack_base points to the word just above the first expr stack entry 0N/A // and stack_limit is supposed to point to the word just below the last expr stack entry. 0N/A // See generate_compute_interpreter_state. 0N/A "Stack top out of range");
0N/A // NOTE this code must exactly mimic what InterpreterGenerator::generate_compute_interpreter_state() 0N/A // does as far as allocating an interpreter frame. 0N/A // If interpreter_frame!=NULL, set up the method, locals, and monitors. 0N/A // The frame interpreter_frame, if not NULL, is guaranteed to be the right size, 0N/A // as determined by a previous call to this method. 0N/A // It is also guaranteed to be walkable even though it is in a skeletal state 0N/A // NOTE: return size is in words not bytes 0N/A // NOTE: tempcount is the current size of the java expression stack. For top most 0N/A // frames we will allocate a full sized expression stack and not the curback 0N/A // version that non-top frames have. 0N/A // Calculate the amount our frame will be adjust by the callee. For top frame 0N/A // NOTE: ia64 seems to do this wrong (or at least backwards) in that it 0N/A // calculates the extra locals based on itself. Not what the callee does 0N/A // to it. So it ignores last_frame_adjust value. Seems suspicious as far 0N/A // as getting sender_sp correct. 0N/A // First calculate the frame size without any java expression stack 0N/A // Now with full size expression stack 0N/A // and now with only live portion of the expression stack 0N/A // the size the activation is right now. Only top frame is full size 0N/A /* Now fillin the interpreterState object */ 0N/A // The state object is the first thing on the frame and easily located 0N/A // Find the locals pointer. This is rather simple on x86 because there is no 0N/A // confusing rounding at the callee to account for. We can trivially locate 0N/A // our locals based on the current fp(). 0N/A // Note: the + 2 is for handling the "static long no_params() method" issue. 0N/A // (too bad I don't really remember that issue well...) 0N/A // If the caller is interpreted we need to make sure that locals points to the first 0N/A // argument that the caller passed and not in an area where the stack might have been extended. 0N/A // because the stack to stack to converter needs a proper locals value in order to remove the 0N/A // arguments from the caller and place the result in the proper location. Hmm maybe it'd be 0N/A // simpler if we simply stored the result in the BytecodeInterpreter object and let the c++ code 0N/A // adjust the stack?? HMMM QQQ 0N/A // locals must agree with the caller because it will be used to set the 0N/A // caller's tos when we return. 0N/A // stack() is prepushed. 0N/A // locals = caller->unextended_sp() + (method->size_of_parameters() - 1); 0N/A // os::breakpoint(); 0N/A // this is where a c2i would have placed locals (except for the +2) 0N/A /* +1 because stack is always prepushed */ 0N/A // BytecodeInterpreter::pd_layout_interpreterState(cur_state, interpreter_return_address, interpreter_frame->fp()); 0N/A#
endif // CC_INTERP (all)