< prev index next >

src/hotspot/os/windows/os_windows.cpp

Print this page
@@ -2377,11 +2377,12 @@
  #endif
  
  //-----------------------------------------------------------------------------
  LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
    if (InterceptOSException) return EXCEPTION_CONTINUE_SEARCH;
-   DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
+   PEXCEPTION_RECORD exception_record = exceptionInfo->ExceptionRecord;
+   DWORD exception_code = exception_record->ExceptionCode;
  #ifdef _M_AMD64
    address pc = (address) exceptionInfo->ContextRecord->Rip;
  #else
    address pc = (address) exceptionInfo->ContextRecord->Eip;
  #endif

@@ -2396,13 +2397,12 @@
    // Execution protection violation - win32 running on AMD64 only
    // Handled first to avoid misdiagnosis as a "normal" access violation;
    // This is safe to do because we have a new/unique ExceptionInformation
    // code for this condition.
    if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
-     PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
-     int exception_subcode = (int) exceptionRecord->ExceptionInformation[0];
-     address addr = (address) exceptionRecord->ExceptionInformation[1];
+     int exception_subcode = (int) exception_record->ExceptionInformation[0];
+     address addr = (address) exception_record->ExceptionInformation[1];
  
      if (exception_subcode == EXCEPTION_INFO_EXEC_VIOLATION) {
        int page_size = os::vm_page_size();
  
        // Make sure the pc and the faulting address are sane.

@@ -2462,11 +2462,11 @@
          }
        }
  
        // Last unguard failed or not unguarding
        tty->print_raw_cr("Execution protection violation");
-       report_error(t, exception_code, addr, exceptionInfo->ExceptionRecord,
+       report_error(t, exception_code, addr, exception_record,
                     exceptionInfo->ContextRecord);
        return EXCEPTION_CONTINUE_SEARCH;
      }
    }
  #endif // _WIN64

@@ -2478,45 +2478,44 @@
    }
  
    if (t != NULL && t->is_Java_thread()) {
      JavaThread* thread = (JavaThread*) t;
      bool in_java = thread->thread_state() == _thread_in_Java;
+     bool in_native = thread->thread_state() == _thread_in_native;
+     bool in_vm = thread->thread_state() == _thread_in_vm;
  
      // Handle potential stack overflows up front.
      if (exception_code == EXCEPTION_STACK_OVERFLOW) {
        if (thread->stack_guards_enabled()) {
          if (in_java) {
            frame fr;
-           PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
-           address addr = (address) exceptionRecord->ExceptionInformation[1];
            if (os::win32::get_frame_at_stack_banging_point(thread, exceptionInfo, pc, &fr)) {
              assert(fr.is_java_frame(), "Must be a Java frame");
              SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
            }
          }
          // Yellow zone violation.  The o/s has unprotected the first yellow
          // zone page for us.  Note:  must call disable_stack_yellow_zone to
          // update the enabled status, even if the zone contains only one page.
-         assert(thread->thread_state() != _thread_in_vm, "Undersized StackShadowPages");
+         assert(!in_vm, "Undersized StackShadowPages");
          thread->disable_stack_yellow_reserved_zone();
          // If not in java code, return and hope for the best.
          return in_java
              ? Handle_Exception(exceptionInfo, SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW))
              :  EXCEPTION_CONTINUE_EXECUTION;
        } else {
          // Fatal red zone violation.
          thread->disable_stack_red_zone();
          tty->print_raw_cr("An unrecoverable stack overflow has occurred.");
-         report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
+         report_error(t, exception_code, pc, exception_record,
                        exceptionInfo->ContextRecord);
          return EXCEPTION_CONTINUE_SEARCH;
        }
      } else if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
-       // Either stack overflow or null pointer exception.
        if (in_java) {
-         PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
-         address addr = (address) exceptionRecord->ExceptionInformation[1];
+         // Either stack overflow or null pointer exception.
+         address addr = (address) exception_record->ExceptionInformation[1];
          address stack_end = thread->stack_end();
          if (addr < stack_end && addr >= stack_end - os::vm_page_size()) {
            // Stack overflow.
            assert(!os::uses_stack_guard_pages(),
                   "should be caught by red zone code above.");

@@ -2531,51 +2530,42 @@
            if (SafepointMechanism::is_poll_address(addr)) {
              address stub = SharedRuntime::get_poll_stub(pc);
              return Handle_Exception(exceptionInfo, stub);
            }
          }
-         {
  #ifdef _WIN64
-           // If it's a legal stack address map the entire region in
-           //
-           PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
-           address addr = (address) exceptionRecord->ExceptionInformation[1];
-           if (thread->is_in_usable_stack(addr)) {
-             addr = (address)((uintptr_t)addr &
-                              (~((uintptr_t)os::vm_page_size() - (uintptr_t)1)));
-             os::commit_memory((char *)addr, thread->stack_base() - addr,
-                               !ExecMem);
-             return EXCEPTION_CONTINUE_EXECUTION;
-           } else
+         // If it's a legal stack address map the entire region in
+         if (thread->is_in_usable_stack(addr)) {
+           addr = (address)((uintptr_t)addr &
+                             (~((uintptr_t)os::vm_page_size() - (uintptr_t)1)));
+           os::commit_memory((char *)addr, thread->stack_base() - addr,
+                             !ExecMem);
+           return EXCEPTION_CONTINUE_EXECUTION;
+         }
  #endif
-           {
-             // Null pointer exception.
-             if (MacroAssembler::uses_implicit_null_check((void*)addr)) {
-               address stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
-               if (stub != NULL) return Handle_Exception(exceptionInfo, stub);
-             }
-             report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
-                          exceptionInfo->ContextRecord);
-             return EXCEPTION_CONTINUE_SEARCH;
-           }
+         // Null pointer exception.
+         if (MacroAssembler::uses_implicit_null_check((void*)addr)) {
+           address stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
+           if (stub != NULL) return Handle_Exception(exceptionInfo, stub);
          }
+         report_error(t, exception_code, pc, exception_record,
+                       exceptionInfo->ContextRecord);
+         return EXCEPTION_CONTINUE_SEARCH;
        }
  
  #ifdef _WIN64
        // Special care for fast JNI field accessors.
        // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks
        // in and the heap gets shrunk before the field access.
-       if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
-         address addr = JNI_FastGetField::find_slowcase_pc(pc);
-         if (addr != (address)-1) {
-           return Handle_Exception(exceptionInfo, addr);
-         }
+       address slowcase_pc = JNI_FastGetField::find_slowcase_pc(pc);
+       if (slowcase_pc != (address)-1) {
+         return Handle_Exception(exceptionInfo, slowcase_pc);
        }
  #endif
  
        // Stack overflow or null pointer exception in native code.
-       report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
+       report_error(t, exception_code, pc, exception_record,
                     exceptionInfo->ContextRecord);
        return EXCEPTION_CONTINUE_SEARCH;
      } // /EXCEPTION_ACCESS_VIOLATION
      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  

@@ -2585,15 +2575,12 @@
        if (in_java) {
          CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
          nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
        }
  
-       bool is_unsafe_arraycopy = (thread->thread_state() == _thread_in_native || in_java) && UnsafeCopyMemory::contains_pc(pc);
-       if (((thread->thread_state() == _thread_in_vm ||
-            thread->thread_state() == _thread_in_native ||
-            is_unsafe_arraycopy) &&
-           thread->doing_unsafe_access()) ||
+       bool is_unsafe_arraycopy = (in_native || in_java) && UnsafeCopyMemory::contains_pc(pc);
+       if (((in_vm || in_native || is_unsafe_arraycopy) && thread->doing_unsafe_access()) ||
            (nm != NULL && nm->has_unsafe_access())) {
          address next_pc =  Assembler::locate_next_instruction(pc);
          if (is_unsafe_arraycopy) {
            next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
          }

@@ -2609,20 +2596,18 @@
        case EXCEPTION_INT_OVERFLOW:
          return Handle_IDiv_Exception(exceptionInfo);
  
        } // switch
      }
-     if (((thread->thread_state() == _thread_in_Java) ||
-          (thread->thread_state() == _thread_in_native)) &&
-          exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
+     if ((in_java || in_native) && exception_code != EXCEPTION_UNCAUGHT_CXX_EXCEPTION) {
        LONG result=Handle_FLT_Exception(exceptionInfo);
        if (result==EXCEPTION_CONTINUE_EXECUTION) return result;
      }
    }
  
    if (exception_code != EXCEPTION_BREAKPOINT) {
-     report_error(t, exception_code, pc, exceptionInfo->ExceptionRecord,
+     report_error(t, exception_code, pc, exception_record,
                   exceptionInfo->ContextRecord);
    }
    return EXCEPTION_CONTINUE_SEARCH;
  }
  
< prev index next >