471 // Returns an estimate of the current stack pointer. Result must be guaranteed
472 // to point into the calling threads stack, and be no lower than the current
473 // stack pointer.
474 address os::current_stack_pointer() {
475 int dummy;
476 address sp = (address)&dummy;
477 return sp;
478 }
479 PRAGMA_DIAG_POP
480 #else
481 // Returns the current stack pointer. Accurate value needed for
482 // os::verify_stack_alignment().
483 address os::current_stack_pointer() {
484 typedef address get_sp_func();
485 get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
486 StubRoutines::x86::get_previous_sp_entry());
487 return (*func)();
488 }
489 #endif
490
491
492 #ifndef AMD64
493 intptr_t* _get_previous_fp() {
494 intptr_t **frameptr;
495 __asm {
496 mov frameptr, ebp
497 };
498 // ebp (frameptr) is for this frame (_get_previous_fp). We want the ebp for the
499 // caller of os::current_frame*(), so go up two frames. However, for
500 // optimized builds, _get_previous_fp() will be inlined, so only go
501 // up 1 frame in that case.
502 #ifdef _NMT_NOINLINE_
503 return **(intptr_t***)frameptr;
504 #else
505 return *frameptr;
506 #endif
507 }
508 #endif // !AMD64
509
510 frame os::current_frame() {
|
471 // Returns an estimate of the current stack pointer. Result must be guaranteed
472 // to point into the calling threads stack, and be no lower than the current
473 // stack pointer.
474 address os::current_stack_pointer() {
475 int dummy;
476 address sp = (address)&dummy;
477 return sp;
478 }
479 PRAGMA_DIAG_POP
480 #else
481 // Returns the current stack pointer. Accurate value needed for
482 // os::verify_stack_alignment().
483 address os::current_stack_pointer() {
484 typedef address get_sp_func();
485 get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
486 StubRoutines::x86::get_previous_sp_entry());
487 return (*func)();
488 }
489 #endif
490
491 bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread,
492 struct _EXCEPTION_POINTERS* exceptionInfo, address pc, frame* fr) {
493 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
494 address addr = (address) exceptionRecord->ExceptionInformation[1];
495 if (Interpreter::contains(pc)) {
496 *fr = os::fetch_frame_from_context((void*)exceptionInfo->ContextRecord);
497 if (!fr->is_first_java_frame()) {
498 // get_frame_at_stack_banging_point() is only called when we
499 // have well defined stacks so java_sender() calls do not need
500 // to assert safe_for_sender() first.
501 *fr = fr->java_sender();
502 }
503 } else {
504 // more complex code with compiled code
505 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
506 CodeBlob* cb = CodeCache::find_blob(pc);
507 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
508 // Not sure where the pc points to, fallback to default
509 // stack overflow handling
510 return false;
511 } else {
512 // in compiled code, the stack banging is performed just after the return pc
513 // has been pushed on the stack
514 intptr_t* fp = (intptr_t*)exceptionInfo->ContextRecord->REG_FP;
515 intptr_t* sp = (intptr_t*)exceptionInfo->ContextRecord->REG_SP;
516 *fr = frame(sp + 1, fp, (address)*sp);
517 if (!fr->is_java_frame()) {
518 // See java_sender() comment above.
519 *fr = fr->java_sender();
520 }
521 }
522 }
523 assert(fr->is_java_frame(), "Safety check");
524 return true;
525 }
526
527 #ifndef AMD64
528 intptr_t* _get_previous_fp() {
529 intptr_t **frameptr;
530 __asm {
531 mov frameptr, ebp
532 };
533 // ebp (frameptr) is for this frame (_get_previous_fp). We want the ebp for the
534 // caller of os::current_frame*(), so go up two frames. However, for
535 // optimized builds, _get_previous_fp() will be inlined, so only go
536 // up 1 frame in that case.
537 #ifdef _NMT_NOINLINE_
538 return **(intptr_t***)frameptr;
539 #else
540 return *frameptr;
541 #endif
542 }
543 #endif // !AMD64
544
545 frame os::current_frame() {
|