337 // Returns an estimate of the current stack pointer. Result must be guaranteed
338 // to point into the calling threads stack, and be no lower than the current
339 // stack pointer.
340 address os::current_stack_pointer() {
341 int dummy;
342 address sp = (address)&dummy;
343 return sp;
344 }
345 PRAGMA_DIAG_POP
346 #else
347 // Returns the current stack pointer. Accurate value needed for
348 // os::verify_stack_alignment().
349 address os::current_stack_pointer() {
350 typedef address get_sp_func();
351 get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
352 StubRoutines::x86::get_previous_sp_entry());
353 return (*func)();
354 }
355 #endif
356
357
358 #ifndef AMD64
359 intptr_t* _get_previous_fp() {
360 intptr_t **frameptr;
361 __asm {
362 mov frameptr, ebp
363 };
364 // ebp (frameptr) is for this frame (_get_previous_fp). We want the ebp for the
365 // caller of os::current_frame*(), so go up two frames. However, for
366 // optimized builds, _get_previous_fp() will be inlined, so only go
367 // up 1 frame in that case.
368 #ifdef _NMT_NOINLINE_
369 return **(intptr_t***)frameptr;
370 #else
371 return *frameptr;
372 #endif
373 }
374 #endif // !AMD64
375
376 frame os::current_frame() {
|
337 // Returns an estimate of the current stack pointer. Result must be guaranteed
338 // to point into the calling threads stack, and be no lower than the current
339 // stack pointer.
340 address os::current_stack_pointer() {
341 int dummy;
342 address sp = (address)&dummy;
343 return sp;
344 }
345 PRAGMA_DIAG_POP
346 #else
347 // Returns the current stack pointer. Accurate value needed for
348 // os::verify_stack_alignment().
349 address os::current_stack_pointer() {
350 typedef address get_sp_func();
351 get_sp_func* func = CAST_TO_FN_PTR(get_sp_func*,
352 StubRoutines::x86::get_previous_sp_entry());
353 return (*func)();
354 }
355 #endif
356
357 bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread,
358 struct _EXCEPTION_POINTERS* exceptionInfo, address pc, frame* fr) {
359 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
360 address addr = (address) exceptionRecord->ExceptionInformation[1];
361 if (Interpreter::contains(pc)) {
362 *fr = os::fetch_frame_from_context((void*)exceptionInfo->ContextRecord);
363 if (!fr->is_first_java_frame()) {
364 // get_frame_at_stack_banging_point() is only called when we
365 // have well defined stacks so java_sender() calls do not need
366 // to assert safe_for_sender() first.
367 *fr = fr->java_sender();
368 }
369 } else {
370 // more complex code with compiled code
371 assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
372 CodeBlob* cb = CodeCache::find_blob(pc);
373 if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
374 // Not sure where the pc points to, fallback to default
375 // stack overflow handling
376 return false;
377 } else {
378 // in compiled code, the stack banging is performed just after the return pc
379 // has been pushed on the stack
380 intptr_t* fp = (intptr_t*)exceptionInfo->ContextRecord->REG_FP;
381 intptr_t* sp = (intptr_t*)exceptionInfo->ContextRecord->REG_SP;
382 *fr = frame(sp + 1, fp, (address)*sp);
383 if (!fr->is_java_frame()) {
384 // See java_sender() comment above.
385 *fr = fr->java_sender();
386 }
387 }
388 }
389 assert(fr->is_java_frame(), "Safety check");
390 return true;
391 }
392
393 #ifndef AMD64
394 intptr_t* _get_previous_fp() {
395 intptr_t **frameptr;
396 __asm {
397 mov frameptr, ebp
398 };
399 // ebp (frameptr) is for this frame (_get_previous_fp). We want the ebp for the
400 // caller of os::current_frame*(), so go up two frames. However, for
401 // optimized builds, _get_previous_fp() will be inlined, so only go
402 // up 1 frame in that case.
403 #ifdef _NMT_NOINLINE_
404 return **(intptr_t***)frameptr;
405 #else
406 return *frameptr;
407 #endif
408 }
409 #endif // !AMD64
410
411 frame os::current_frame() {
|