frame_sparc.cpp revision 1879
0N/A * Copyright (c) 1997, 2010, 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. 0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A// Unified register numbering scheme: each 32-bits counts as a register 0N/A// number, so all the V9 registers take 2 slots. 0N/Aconst static int R_L_nums[] = {0+0
40,
2+0
40,
4+0
40,
6+0
40,
8+0
40,
10+0
40,
12+0
40,
14+0
40};
0N/Aconst static int R_I_nums[] = {0+0
60,
2+0
60,
4+0
60,
6+0
60,
8+0
60,
10+0
60,
12+0
60,
14+0
60};
0N/Aconst static int R_O_nums[] = {0+0
20,
2+0
20,
4+0
20,
6+0
20,
8+0
20,
10+0
20,
12+0
20,
14+0
20};
0N/Aconst static int R_G_nums[] = {0+000,
2+000,
4+000,
6+000,
8+000,
10+000,
12+000,
14+000};
0N/A for (i = 0; i <
8; i++) {
0N/A for (i = 0; i <
8; i++) {
0N/A // Only the GPRs get handled this way 0N/A // don't talk about bad registers 0N/A // 32-bit registers for in, out and local 0N/A // HMM ought to return NULL for any non-concrete (odd) vmreg 0N/A // this all tied up in the fact we put out double oopMaps for 0N/A // register locations. When that is fixed we'd will return NULL 0N/A // (or assert here). 0N/A // Only the window'd GPRs get handled this way; not the globals. 0N/A// We are shifting windows. That means we are moving all %i to %o, 0N/A// getting rid of all current %l, and keeping all %g. This is only 0N/A// complicated if any of the location pointers for these are valid. 0N/A// The normal case is that everything is in its standard register window 0N/A// home, and _location_valid[0] is zero. In that case, this routine 0N/A// does exactly nothing. 0N/A if (!
update_map())
return;
// this only applies to maps with locations 0N/A // if we cleared some non-%g locations, we may have to do some shifting 0N/A // copy %i0-%i5 to %o0-%o5, if they have special locations 107N/A // This can happen in within stubs which spill argument registers 107N/A // around a dynamic link operation, such as resolve_opt_virtual_call. 107N/A for (
int i = 0; i <
8; i++) {
107N/A // sp must be within the stack 107N/A // unextended sp must be within the stack and above or equal sp 107N/A // an fp must be within the stack and above (but not equal) sp 107N/A // If the current frame is known to the code cache then we can attempt to 107N/A // to construct the sender and do some validation of it. This goes a long way 107N/A // toward eliminating issues when we get in frame construction code 107N/A // First check if frame is complete and tester is reliable 0N/A // Unfortunately we can only check frame complete for runtime stubs and nmethod 107N/A // other generic buffer blobs are more problematic so we just assume they are 107N/A // ok. adapter blobs never have a frame complete and are never ok. 107N/A // an entry frame must have a valid fp. 107N/A // Validate the JavaCallWrapper an entry frame must have 107N/A // We must always be able to find a recognizable pc 107N/A // It should be safe to construct the sender though it might not be valid 107N/A // Do we have a valid fp? 107N/A // an fp must be within the stack and above (but not equal) current frame's _FP 107N/A // If the potential sender is the interpreter then we can do some more checking 107N/A // Could just be some random pointer within the codeBlob 107N/A // We should never be able to see an adapter if the current frame is something from code cache 107N/A // Validate the JavaCallWrapper an entry frame must have 107N/A // If the frame size is 0 something is bad because every nmethod has a non-zero frame size 107N/A // because you must allocate window space 107N/A // The sender should positively be an nmethod or call_stub. On sparc we might in fact see something else. 107N/A // The cause of this is because at a save instruction the O7 we get is a leftover from an earlier 107N/A // window use. So if a runtime stub creates two frames (common in fastdebug/jvmg) then we see the 0N/A // stale pc. So if the sender blob is not something we'd expect we have little choice but to declare 107N/A // the stack unwalkable. pd_get_top_frame_for_signal_handler tries to recover from this by unwinding 107N/A // that initial frame and retrying. 107N/A // Could put some more validation for the potential non-interpreted sender 107N/A // frame we'd create by calling sender if I could think of any. Wait for next crash in forte... 0N/A // One idea is seeing if the sender_pc we have is one that we'd expect to call to current cb 0N/A // We've validated the potential sender that would be created 0N/A // Must be native-compiled frame. Since sender will try and use fp to find 0N/A // linkages it must be safe 0N/A // could try and do some more potential verification of native frame if we could think of some... 0N/A// Construct an unpatchable, deficient frame 0N/A // Without a valid unextended_sp() we can't convert the pc to "original" 0N/A // make a deficient frame which doesn't know where its PC is 0N/A // Any frame we ever build should always "safe" therefore we should not have to call 0N/A // In case of native stubs, the pc retrieved here might be 0N/A // wrong. (the _last_native_pc will have the right value) 0N/A // So do not put add any asserts on the _pc here. 0N/A // Check for MethodHandle call sites. 0N/A // The SP is already adjusted by this MH call site, don't 0N/A // overwrite this value with the wrong interpreter value. 0N/A // compute adjustment to this frame's SP made by its interpreted callee 0N/A // It is important that the frame is fully constructed when we do 0N/A // this lookup as get_deopt_original_pc() needs a correct value for 0N/A // unextended_sp() which uses _sp_adjustment_by_callee. 0N/A for(
int i = 0; i < n; ++i)
0N/A // Java frame called from C; skip all C frames and return top C 0N/A // frame of that chunk as the sender 0N/A // Since we are walking the stack now this nested anchor is obviously walkable 0N/A // even if it wasn't when it was stacked. 0N/A // Capture _last_Java_pc (if needed) and mark anchor walkable. 0N/A // Default is not to follow arguments; update it accordingly below 0N/A // Note: The version of this operation on any platform with callee-save 0N/A // registers must update the register map (if not null). 0N/A // In order to do this correctly, the various subtypes of 0N/A // of frame (interpreted, compiled, glue, native), 0N/A // must be distinguished. There is no need on SPARC for 0N/A // such distinctions, because all callee-save registers are 0N/A // preserved for all frames via SPARC-specific mechanisms. 0N/A // *** HOWEVER, *** if and when we make any floating-point 0N/A // registers callee-saved, then we will have to copy over 0N/A // the RegisterMap update logic from the Intel code. 0N/A // The constructor of the sender must know whether this frame is interpreted so it can set the 0N/A // sender's _sp_adjustment_by_callee field. An osr adapter frame was originally 0N/A // interpreted but its pc is in the code cache (for c1 -> osr_frame_return_id stub), so it must be 0N/A // explicitly recognized. 0N/A // Update the locations of implicitly saved registers to be their 0N/A // addresses in the register save area. 0N/A // For %o registers, the addresses of %i registers in the next younger 0N/A // Tell GC to use argument oopmaps for some runtime stubs that need it. 0N/A // For C1, the runtime stub might not have oop maps, so set this flag 0N/A // outside of update_register_map. 0N/A // QQQ this assert is invalid (or too strong anyway) sice _pc could 0N/A // be original pc and frame could have the deopt pc. 0N/A // assert(_pc == *O7_addr() + pc_return_offset, "frame has wrong pc"); 0N/A Find the (biased) sp that is just younger than old_sp starting at sp. 0N/A If not found return NULL. Register windows are assumed to be flushed. 0N/A // too many frames have gone by; invalid parameters given to this function 0N/A Determine if "sp" is a valid stack pointer. "sp" is assumed to be younger than 0N/A "valid_sp". So if "sp" is valid itself then it should be possible to walk frames 0N/A from "sp" to "valid_sp". The assumption is that the registers windows for the 0N/A thread stack in question are flushed. 107N/A // set constant pool cache entry for interpreter 107N/A // Is there anything to do? 107N/A // These are reasonable sanity checks 107N/A // These are hacks to keep us out of trouble. 107N/A // The problem with these is that they mask other problems 107N/A if (
fp() <=
sp()) {
// this attempts to deal with unsigned comparison above 107N/A // do some validation of frame elements 0N/A // validate the method we'd find in this potential sender 0N/A // stack frames shouldn't be much larger than max_stack elements 0N/A // validate constantPoolCacheOop 0N/A // We'd have to be pretty unlucky to be mislead at this point 0N/A#
endif /* CC_INTERP */ 0N/A// Windows have been flushed on entry (but not marked). Capture the pc that 0N/A// is the return address to the frame that contains "sp" as its stack pointer. 0N/A// This pc resides in the called of the frame corresponding to "sp". 0N/A// As a side effect we mark this JavaFrameAnchor as having flushed the windows. 0N/A// This side effect lets us mark stacked JavaFrameAnchors (stacked in the 0N/A// call_helper) as flushed when we have flushed the windows for the most 0N/A// recent (i.e. current) JavaFrameAnchor. This saves useless flushing calls 0N/A// and lets us find the pc just once rather than multiple times as it did 0N/A// in the bad old _post_Java_state days. 0N/A // try and find the sp just younger than _last_Java_sp 0N/A // Really this should never fail otherwise VM call must have non-standard 0N/A // frame linkage (bad) or stack is not properly flushed (worse). 0N/A // Eventually make an assert 0N/A // We always flush in case the profiler wants it but we won't mark 0N/A // the windows as flushed unless we have a last_Java_frame 0N/A // convert offset to index to deal with tsi 0N/A // Prior to notifying the runtime of the method_exit the possible result 0N/A // value is saved to l_scratch and d_scratch. 0N/A#
else /* CC_INTERP */ 0N/A#
endif /* CC_INTERP */ 0N/A // On 64-bit the result for 1/8/16/32-bit result types is in the other case T_VOID :
/* Nothing to do */ break;
// Lesp pointer is one word lower than the top item on the stack.