@@ -2359,7 +2359,8 @@ bool os::win32::get_frame_at_stack_banging_point(JavaThread* thread,
23592359JNIEXPORT
23602360LONG WINAPI topLevelExceptionFilter (struct _EXCEPTION_POINTERS * exceptionInfo) {
23612361 if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
2362- DWORD exception_code = exceptionInfo->ExceptionRecord ->ExceptionCode ;
2362+ PEXCEPTION_RECORD exception_record = exceptionInfo->ExceptionRecord ;
2363+ DWORD exception_code = exception_record->ExceptionCode ;
23632364#ifdef _M_AMD64
23642365 address pc = (address) exceptionInfo->ContextRecord ->Rip ;
23652366#else
@@ -2378,9 +2379,8 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
23782379 // This is safe to do because we have a new/unique ExceptionInformation
23792380 // code for this condition.
23802381 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
2381- PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord ;
2382- int exception_subcode = (int ) exceptionRecord->ExceptionInformation [0 ];
2383- address addr = (address) exceptionRecord->ExceptionInformation [1 ];
2382+ int exception_subcode = (int ) exception_record->ExceptionInformation [0 ];
2383+ address addr = (address) exception_record->ExceptionInformation [1 ];
23842384
23852385 if (exception_subcode == EXCEPTION_INFO_EXEC_VIOLATION) {
23862386 int page_size = os::vm_page_size ();
@@ -2444,7 +2444,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
24442444
24452445 // Last unguard failed or not unguarding
24462446 tty->print_raw_cr (" Execution protection violation" );
2447- report_error (t, exception_code, addr, exceptionInfo-> ExceptionRecord ,
2447+ report_error (t, exception_code, addr, exception_record ,
24482448 exceptionInfo->ContextRecord );
24492449 return EXCEPTION_CONTINUE_SEARCH;
24502450 }
@@ -2458,33 +2458,30 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
24582458 if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
24592459 if (t != NULL && t->is_Java_thread ()) {
24602460 JavaThread* thread = (JavaThread*) t;
2461- PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord ;
2462- address addr = (address) exceptionRecord->ExceptionInformation [1 ];
2461+ address addr = (address) exception_record->ExceptionInformation [1 ];
24632462 if (os::is_memory_serialize_page (thread, addr)) {
24642463 // Block current thread until the memory serialize page permission restored.
24652464 os::block_on_serialize_page_trap ();
24662465 return EXCEPTION_CONTINUE_EXECUTION;
24672466 }
24682467 }
2469- }
2470-
2471- if ((exception_code == EXCEPTION_ACCESS_VIOLATION) &&
2472- VM_Version::is_cpuinfo_segv_addr (pc)) {
2473- // Verify that OS save/restore AVX registers.
2474- return Handle_Exception (exceptionInfo, VM_Version::cpuinfo_cont_addr ());
2468+ if (VM_Version::is_cpuinfo_segv_addr (pc)) {
2469+ // Verify that OS save/restore AVX registers.
2470+ return Handle_Exception (exceptionInfo, VM_Version::cpuinfo_cont_addr ());
2471+ }
24752472 }
24762473
24772474 if (t != NULL && t->is_Java_thread ()) {
24782475 JavaThread* thread = (JavaThread*) t;
24792476 bool in_java = thread->thread_state () == _thread_in_Java;
2477+ bool in_native = thread->thread_state () == _thread_in_native;
2478+ bool in_vm = thread->thread_state () == _thread_in_vm;
24802479
24812480 // Handle potential stack overflows up front.
24822481 if (exception_code == EXCEPTION_STACK_OVERFLOW) {
24832482 if (thread->stack_guards_enabled ()) {
24842483 if (in_java) {
24852484 frame fr;
2486- PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord ;
2487- address addr = (address) exceptionRecord->ExceptionInformation [1 ];
24882485 if (os::win32::get_frame_at_stack_banging_point (thread, exceptionInfo, pc, &fr)) {
24892486 assert (fr.is_java_frame (), " Must be a Java frame" );
24902487 SharedRuntime::look_for_reserved_stack_annotated_method (thread, fr);
@@ -2493,7 +2490,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
24932490 // Yellow zone violation. The o/s has unprotected the first yellow
24942491 // zone page for us. Note: must call disable_stack_yellow_zone to
24952492 // update the enabled status, even if the zone contains only one page.
2496- assert (thread-> thread_state () != _thread_in_vm , " Undersized StackShadowPages" );
2493+ assert (!in_vm , " Undersized StackShadowPages" );
24972494 thread->disable_stack_yellow_reserved_zone ();
24982495 // If not in java code, return and hope for the best.
24992496 return in_java
@@ -2503,15 +2500,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
25032500 // Fatal red zone violation.
25042501 thread->disable_stack_red_zone ();
25052502 tty->print_raw_cr (" An unrecoverable stack overflow has occurred." );
2506- report_error (t, exception_code, pc, exceptionInfo-> ExceptionRecord ,
2507- exceptionInfo->ContextRecord );
2503+ report_error (t, exception_code, pc, exception_record ,
2504+ exceptionInfo->ContextRecord );
25082505 return EXCEPTION_CONTINUE_SEARCH;
25092506 }
25102507 } else if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
2511- // Either stack overflow or null pointer exception.
25122508 if (in_java) {
2513- PEXCEPTION_RECORD exceptionRecord = exceptionInfo-> ExceptionRecord ;
2514- address addr = (address) exceptionRecord ->ExceptionInformation [1 ];
2509+ // Either stack overflow or null pointer exception.
2510+ address addr = (address) exception_record ->ExceptionInformation [1 ];
25152511 address stack_end = thread->stack_end ();
25162512 if (addr < stack_end && addr >= stack_end - os::vm_page_size ()) {
25172513 // Stack overflow.
@@ -2530,47 +2526,38 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
25302526 return Handle_Exception (exceptionInfo, stub);
25312527 }
25322528 }
2533- {
25342529#ifdef _WIN64
2535- // If it's a legal stack address map the entire region in
2536- //
2537- PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord ;
2538- address addr = (address) exceptionRecord->ExceptionInformation [1 ];
2539- if (addr > thread->stack_reserved_zone_base () && addr < thread->stack_base ()) {
2540- addr = (address)((uintptr_t )addr &
2541- (~((uintptr_t )os::vm_page_size () - (uintptr_t )1 )));
2542- os::commit_memory ((char *)addr, thread->stack_base () - addr,
2543- !ExecMem);
2544- return EXCEPTION_CONTINUE_EXECUTION;
2545- } else
2530+ // If it's a legal stack address map the entire region in
2531+ if (addr > thread->stack_reserved_zone_base () && addr < thread->stack_base ()) {
2532+ addr = (address)((uintptr_t )addr &
2533+ (~((uintptr_t )os::vm_page_size () - (uintptr_t )1 )));
2534+ os::commit_memory ((char *)addr, thread->stack_base () - addr,
2535+ !ExecMem);
2536+ return EXCEPTION_CONTINUE_EXECUTION;
2537+ }
25462538#endif
2547- {
2548- // Null pointer exception.
2549- if (!MacroAssembler::needs_explicit_null_check ((intptr_t )addr)) {
2550- address stub = SharedRuntime::continuation_for_implicit_exception (thread, pc, SharedRuntime::IMPLICIT_NULL);
2551- if (stub != NULL ) return Handle_Exception (exceptionInfo, stub);
2552- }
2553- report_error (t, exception_code, pc, exceptionInfo->ExceptionRecord ,
2554- exceptionInfo->ContextRecord );
2555- return EXCEPTION_CONTINUE_SEARCH;
2556- }
2539+ // Null pointer exception.
2540+ if (!MacroAssembler::needs_explicit_null_check ((intptr_t )addr)) {
2541+ address stub = SharedRuntime::continuation_for_implicit_exception (thread, pc, SharedRuntime::IMPLICIT_NULL);
2542+ if (stub != NULL ) return Handle_Exception (exceptionInfo, stub);
25572543 }
2544+ report_error (t, exception_code, pc, exception_record,
2545+ exceptionInfo->ContextRecord );
2546+ return EXCEPTION_CONTINUE_SEARCH;
25582547 }
25592548
25602549#ifdef _WIN64
25612550 // Special care for fast JNI field accessors.
25622551 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks
25632552 // in and the heap gets shrunk before the field access.
2564- if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
2565- address addr = JNI_FastGetField::find_slowcase_pc (pc);
2566- if (addr != (address)-1 ) {
2567- return Handle_Exception (exceptionInfo, addr);
2568- }
2553+ address slowcase_pc = JNI_FastGetField::find_slowcase_pc (pc);
2554+ if (slowcase_pc != (address)-1 ) {
2555+ return Handle_Exception (exceptionInfo, slowcase_pc);
25692556 }
25702557#endif
25712558
25722559 // Stack overflow or null pointer exception in native code.
2573- report_error (t, exception_code, pc, exceptionInfo-> ExceptionRecord ,
2560+ report_error (t, exception_code, pc, exception_record ,
25742561 exceptionInfo->ContextRecord );
25752562 return EXCEPTION_CONTINUE_SEARCH;
25762563 } // /EXCEPTION_ACCESS_VIOLATION
@@ -2583,8 +2570,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
25832570 CodeBlob* cb = CodeCache::find_blob_unsafe (pc);
25842571 nm = (cb != NULL ) ? cb->as_compiled_method_or_null () : NULL ;
25852572 }
2586- if ((thread->thread_state () == _thread_in_vm &&
2587- thread->doing_unsafe_access ()) ||
2573+ if ((in_vm && thread->doing_unsafe_access ()) ||
25882574 (nm != NULL && nm->has_unsafe_access ())) {
25892575 return Handle_Exception (exceptionInfo, SharedRuntime::handle_unsafe_access (thread, (address)Assembler::locate_next_instruction (pc)));
25902576 }
@@ -2600,16 +2586,14 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26002586
26012587 } // switch
26022588 }
2603- if (((thread->thread_state () == _thread_in_Java) ||
2604- (thread->thread_state () == _thread_in_native)) &&
2605- exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
2589+ if ((in_java || in_native) && exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
26062590 LONG result=Handle_FLT_Exception (exceptionInfo);
26072591 if (result==EXCEPTION_CONTINUE_EXECUTION) return result;
26082592 }
26092593 }
26102594
26112595 if (exception_code != EXCEPTION_BREAKPOINT) {
2612- report_error (t, exception_code, pc, exceptionInfo-> ExceptionRecord ,
2596+ report_error (t, exception_code, pc, exception_record ,
26132597 exceptionInfo->ContextRecord );
26142598 }
26152599 return EXCEPTION_CONTINUE_SEARCH;
0 commit comments