< prev index next >

src/os_cpu/windows_x86/vm/os_windows_x86.cpp

Print this page




  68 #define REG_PC Eip
  69 #endif // AMD64
  70 
  71 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  72 
  73 // Install a win32 structured exception handler around thread.
  74 void os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& method, JavaCallArguments* args, Thread* thread) {
  75   __try {
  76 
  77 #ifndef AMD64
  78     // We store the current thread in this wrapperthread location
  79     // and determine how far away this address is from the structured
  80     // execption pointer that FS:[0] points to.  This get_thread
  81     // code can then get the thread pointer via FS.
  82     //
  83     // Warning:  This routine must NEVER be inlined since we'd end up with
  84     //           multiple offsets.
  85     //
  86     volatile Thread* wrapperthread = thread;
  87 
  88     if ( ThreadLocalStorage::get_thread_ptr_offset() == 0 ) {
  89       int thread_ptr_offset;
  90       __asm {
  91         lea eax, dword ptr wrapperthread;
  92         sub eax, dword ptr FS:[0H];
  93         mov thread_ptr_offset, eax
  94       };
  95       ThreadLocalStorage::set_thread_ptr_offset(thread_ptr_offset);
  96     }
  97 #ifdef ASSERT
  98     // Verify that the offset hasn't changed since we initally captured
  99     // it. This might happen if we accidentally ended up with an
 100     // inlined version of this routine.
 101     else {
 102       int test_thread_ptr_offset;
 103       __asm {
 104         lea eax, dword ptr wrapperthread;
 105         sub eax, dword ptr FS:[0H];
 106         mov test_thread_ptr_offset, eax
 107       };
 108       assert(test_thread_ptr_offset == ThreadLocalStorage::get_thread_ptr_offset(),
 109              "thread pointer offset from SEH changed");
 110     }
 111 #endif // ASSERT
 112 #endif // !AMD64
 113 
 114     f(value, method, args, thread);
 115   } __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
 116       // Nothing to do.
 117   }
 118 }
 119 
 120 #ifdef AMD64
 121 
 122 // This is the language specific handler for exceptions
 123 // originating from dynamically generated code.
 124 // We call the standard structured exception handler
 125 // We only expect Continued Execution since we cannot unwind
 126 // from generated code.
 127 LONG HandleExceptionFromCodeCache(
 128   IN PEXCEPTION_RECORD ExceptionRecord,




  68 #define REG_PC Eip
  69 #endif // AMD64
  70 
  71 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  72 
  73 // Install a win32 structured exception handler around thread.
  74 void os::os_exception_wrapper(java_call_t f, JavaValue* value, const methodHandle& method, JavaCallArguments* args, Thread* thread) {
  75   __try {
  76 
  77 #ifndef AMD64
  78     // We store the current thread in this wrapperthread location
  79     // and determine how far away this address is from the structured
  80     // execption pointer that FS:[0] points to.  This get_thread
  81     // code can then get the thread pointer via FS.
  82     //
  83     // Warning:  This routine must NEVER be inlined since we'd end up with
  84     //           multiple offsets.
  85     //
  86     volatile Thread* wrapperthread = thread;
  87 
  88     if (os::win32::get_thread_ptr_offset() == 0) {
  89       int thread_ptr_offset;
  90       __asm {
  91         lea eax, dword ptr wrapperthread;
  92         sub eax, dword ptr FS:[0H];
  93         mov thread_ptr_offset, eax
  94       };
  95       os::win32::set_thread_ptr_offset(thread_ptr_offset);
  96     }
  97 #ifdef ASSERT
  98     // Verify that the offset hasn't changed since we initally captured
  99     // it. This might happen if we accidentally ended up with an
 100     // inlined version of this routine.
 101     else {
 102       int test_thread_ptr_offset;
 103       __asm {
 104         lea eax, dword ptr wrapperthread;
 105         sub eax, dword ptr FS:[0H];
 106         mov test_thread_ptr_offset, eax
 107       };
 108       assert(test_thread_ptr_offset == os::win32::get_thread_ptr_offset(),
 109              "thread pointer offset from SEH changed");
 110     }
 111 #endif // ASSERT
 112 #endif // !AMD64
 113 
 114     f(value, method, args, thread);
 115   } __except(topLevelExceptionFilter((_EXCEPTION_POINTERS*)_exception_info())) {
 116       // Nothing to do.
 117   }
 118 }
 119 
 120 #ifdef AMD64
 121 
 122 // This is the language specific handler for exceptions
 123 // originating from dynamically generated code.
 124 // We call the standard structured exception handler
 125 // We only expect Continued Execution since we cannot unwind
 126 // from generated code.
 127 LONG HandleExceptionFromCodeCache(
 128   IN PEXCEPTION_RECORD ExceptionRecord,


< prev index next >