src/cpu/sparc/vm/frame_sparc.cpp

Print this page
rev 4773 : 8005849: JEP 167: Event-Based JVM Tracing
Reviewed-by: acorn, coleenp, sla
Contributed-by: Karen Kinnear <karen.kinnear@oracle.com>, Bengt Rutisson <bengt.rutisson@oracle.com>, Calvin Cheung <calvin.cheung@oracle.com>, Erik Gahlin <erik.gahlin@oracle.com>, Erik Helin <erik.helin@oracle.com>, Jesper Wilhelmsson <jesper.wilhelmsson@oracle.com>, Keith McGuigan <keith.mcguigan@oracle.com>, Mattias Tobiasson <mattias.tobiasson@oracle.com>, Markus Gronlund <markus.gronlund@oracle.com>, Mikael Auno <mikael.auno@oracle.com>, Nils Eliasson <nils.eliasson@oracle.com>, Nils Loodin <nils.loodin@oracle.com>, Rickard Backman <rickard.backman@oracle.com>, Staffan Larsen <staffan.larsen@oracle.com>, Stefan Karlsson <stefan.karlsson@oracle.com>, Yekaterina Kantserova <yekaterina.kantserova@oracle.com>


 235 
 236       bool jcw_safe = (jcw <= thread->stack_base()) && ( jcw > _FP);
 237 
 238       return jcw_safe;
 239 
 240     }
 241 
 242     intptr_t* younger_sp = sp();
 243     intptr_t* _SENDER_SP = sender_sp(); // sender is actually just _FP
 244     bool adjusted_stack = is_interpreted_frame();
 245 
 246     address   sender_pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset;
 247 
 248 
 249     // We must always be able to find a recognizable pc
 250     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 251     if (sender_pc == NULL ||  sender_blob == NULL) {
 252       return false;
 253     }
 254 










 255     // It should be safe to construct the sender though it might not be valid
 256 
 257     frame sender(_SENDER_SP, younger_sp, adjusted_stack);
 258 
 259     // Do we have a valid fp?
 260     address sender_fp = (address) sender.fp();
 261 
 262     // an fp must be within the stack and above (but not equal) current frame's _FP
 263 
 264     bool sender_fp_safe = (sender_fp <= thread->stack_base()) &&
 265                    (sender_fp > _FP);
 266 
 267     if (!sender_fp_safe) {
 268       return false;
 269     }
 270 
 271 
 272     // If the potential sender is the interpreter then we can do some more checking
 273     if (Interpreter::contains(sender_pc)) {
 274       return sender.is_interpreted_frame_valid(thread);


 277     // Could just be some random pointer within the codeBlob
 278     if (!sender.cb()->code_contains(sender_pc)) {
 279       return false;
 280     }
 281 
 282     // We should never be able to see an adapter if the current frame is something from code cache
 283     if (sender_blob->is_adapter_blob()) {
 284       return false;
 285     }
 286 
 287     if( sender.is_entry_frame()) {
 288       // Validate the JavaCallWrapper an entry frame must have
 289 
 290       address jcw = (address)sender.entry_frame_call_wrapper();
 291 
 292       bool jcw_safe = (jcw <= thread->stack_base()) && ( jcw > sender_fp);
 293 
 294       return jcw_safe;
 295     }
 296 
 297     // If the frame size is 0 something is bad because every nmethod has a non-zero frame size
 298     // because you must allocate window space
 299 
 300     if (sender_blob->frame_size() == 0) {
 301       assert(!sender_blob->is_nmethod(), "should count return address at least");
 302       return false;
 303     }
 304 
 305     // The sender should positively be an nmethod or call_stub. On sparc we might in fact see something else.
 306     // The cause of this is because at a save instruction the O7 we get is a leftover from an earlier
 307     // window use. So if a runtime stub creates two frames (common in fastdebug/debug) then we see the
 308     // stale pc. So if the sender blob is not something we'd expect we have little choice but to declare
 309     // the stack unwalkable. pd_get_top_frame_for_signal_handler tries to recover from this by unwinding
 310     // that initial frame and retrying.
 311 
 312     if (!sender_blob->is_nmethod()) {
 313       return false;
 314     }
 315 
 316     // Could put some more validation for the potential non-interpreted sender
 317     // frame we'd create by calling sender if I could think of any. Wait for next crash in forte...
 318 
 319     // One idea is seeing if the sender_pc we have is one that we'd expect to call to current cb
 320 




 235 
 236       bool jcw_safe = (jcw <= thread->stack_base()) && ( jcw > _FP);
 237 
 238       return jcw_safe;
 239 
 240     }
 241 
 242     intptr_t* younger_sp = sp();
 243     intptr_t* _SENDER_SP = sender_sp(); // sender is actually just _FP
 244     bool adjusted_stack = is_interpreted_frame();
 245 
 246     address   sender_pc = (address)younger_sp[I7->sp_offset_in_saved_window()] + pc_return_offset;
 247 
 248 
 249     // We must always be able to find a recognizable pc
 250     CodeBlob* sender_blob = CodeCache::find_blob_unsafe(sender_pc);
 251     if (sender_pc == NULL ||  sender_blob == NULL) {
 252       return false;
 253     }
 254 
 255     // Could be a zombie method
 256     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 257       return false;
 258     }
 259 
 260     // Could be a zombie method
 261     if (sender_blob->is_zombie() || sender_blob->is_unloaded()) {
 262       return false;
 263     }
 264 
 265     // It should be safe to construct the sender though it might not be valid
 266 
 267     frame sender(_SENDER_SP, younger_sp, adjusted_stack);
 268 
 269     // Do we have a valid fp?
 270     address sender_fp = (address) sender.fp();
 271 
 272     // an fp must be within the stack and above (but not equal) current frame's _FP
 273 
 274     bool sender_fp_safe = (sender_fp <= thread->stack_base()) &&
 275                    (sender_fp > _FP);
 276 
 277     if (!sender_fp_safe) {
 278       return false;
 279     }
 280 
 281 
 282     // If the potential sender is the interpreter then we can do some more checking
 283     if (Interpreter::contains(sender_pc)) {
 284       return sender.is_interpreted_frame_valid(thread);


 287     // Could just be some random pointer within the codeBlob
 288     if (!sender.cb()->code_contains(sender_pc)) {
 289       return false;
 290     }
 291 
 292     // We should never be able to see an adapter if the current frame is something from code cache
 293     if (sender_blob->is_adapter_blob()) {
 294       return false;
 295     }
 296 
 297     if( sender.is_entry_frame()) {
 298       // Validate the JavaCallWrapper an entry frame must have
 299 
 300       address jcw = (address)sender.entry_frame_call_wrapper();
 301 
 302       bool jcw_safe = (jcw <= thread->stack_base()) && ( jcw > sender_fp);
 303 
 304       return jcw_safe;
 305     }
 306 
 307     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
 308     // because you must allocate window space
 309 
 310     if (sender_blob->frame_size() <= 0) {
 311       assert(!sender_blob->is_nmethod(), "should count return address at least");
 312       return false;
 313     }
 314 
 315     // The sender should positively be an nmethod or call_stub. On sparc we might in fact see something else.
 316     // The cause of this is because at a save instruction the O7 we get is a leftover from an earlier
 317     // window use. So if a runtime stub creates two frames (common in fastdebug/debug) then we see the
 318     // stale pc. So if the sender blob is not something we'd expect we have little choice but to declare
 319     // the stack unwalkable. pd_get_top_frame_for_signal_handler tries to recover from this by unwinding
 320     // that initial frame and retrying.
 321 
 322     if (!sender_blob->is_nmethod()) {
 323       return false;
 324     }
 325 
 326     // Could put some more validation for the potential non-interpreted sender
 327     // frame we'd create by calling sender if I could think of any. Wait for next crash in forte...
 328 
 329     // One idea is seeing if the sender_pc we have is one that we'd expect to call to current cb
 330