< prev index next >

src/os/windows/vm/os_windows.cpp

Print this page




2255   for (int i = 0; exceptlabels[i].name != NULL; i++) {
2256     if (exceptlabels[i].number == exception_code) {
2257       jio_snprintf(buf, size, "%s", exceptlabels[i].name);
2258       return buf;
2259     }
2260   }
2261 
2262   return NULL;
2263 }
2264 
2265 //-----------------------------------------------------------------------------
2266 LONG Handle_IDiv_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
2267   // handle exception caused by idiv; should only happen for -MinInt/-1
2268   // (division by zero is handled explicitly)
2269 #ifdef _M_IA64
2270   assert(0, "Fix Handle_IDiv_Exception");
2271 #else
2272   #ifdef  _M_AMD64
2273   PCONTEXT ctx = exceptionInfo->ContextRecord;
2274   address pc = (address)ctx->Rip;
2275   assert(pc[0] == 0xF7, "not an idiv opcode");
2276   assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
2277   assert(ctx->Rax == min_jint, "unexpected idiv exception");
2278   // set correct result values and continue after idiv instruction
2279   ctx->Rip = (DWORD)pc + 2;        // idiv reg, reg  is 2 bytes
2280   ctx->Rax = (DWORD)min_jint;      // result





2281   ctx->Rdx = (DWORD)0;             // remainder
2282   // Continue the execution
2283   #else
2284   PCONTEXT ctx = exceptionInfo->ContextRecord;
2285   address pc = (address)ctx->Eip;
2286   assert(pc[0] == 0xF7, "not an idiv opcode");
2287   assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
2288   assert(ctx->Eax == min_jint, "unexpected idiv exception");
2289   // set correct result values and continue after idiv instruction
2290   ctx->Eip = (DWORD)pc + 2;        // idiv reg, reg  is 2 bytes
2291   ctx->Eax = (DWORD)min_jint;      // result
2292   ctx->Edx = (DWORD)0;             // remainder
2293   // Continue the execution
2294   #endif
2295 #endif
2296   return EXCEPTION_CONTINUE_EXECUTION;
2297 }
2298 
2299 //-----------------------------------------------------------------------------
2300 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {




2255   for (int i = 0; exceptlabels[i].name != NULL; i++) {
2256     if (exceptlabels[i].number == exception_code) {
2257       jio_snprintf(buf, size, "%s", exceptlabels[i].name);
2258       return buf;
2259     }
2260   }
2261 
2262   return NULL;
2263 }
2264 
2265 //-----------------------------------------------------------------------------
2266 LONG Handle_IDiv_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {
2267   // handle exception caused by idiv; should only happen for -MinInt/-1
2268   // (division by zero is handled explicitly)
2269 #ifdef _M_IA64
2270   assert(0, "Fix Handle_IDiv_Exception");
2271 #else
2272   #ifdef  _M_AMD64
2273   PCONTEXT ctx = exceptionInfo->ContextRecord;
2274   address pc = (address)ctx->Rip;
2275   assert(pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && pc[1] == 0xF7 || pc[0] == 0xF7, "not an idiv opcode");
2276   assert(pc[0] >= Assembler::REX && pc[0] <= Assembler::REX_WRXB && (pc[2] & ~0x7) == 0xF8 || (pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
2277   if (pc[0] == 0xF7) {
2278     // set correct result values and continue after idiv instruction
2279     ctx->Rip = (DWORD64)pc + 2;        // idiv reg, reg  is 2 bytes
2280   } else {
2281     ctx->Rip = (DWORD64)pc + 3;        // REX idiv reg, reg  is 3 bytes
2282   }
2283   // Do not set ctx->Rax as it already contains the correct value (either 32 or 64 bit, depending on the operation)
2284   // this is the case because the exception only happens for -MinValue/-1 and -MinValue is always in rax because of the
2285   // idiv opcode (0xF7).
2286   ctx->Rdx = (DWORD)0;             // remainder
2287   // Continue the execution
2288   #else
2289   PCONTEXT ctx = exceptionInfo->ContextRecord;
2290   address pc = (address)ctx->Eip;
2291   assert(pc[0] == 0xF7, "not an idiv opcode");
2292   assert((pc[1] & ~0x7) == 0xF8, "cannot handle non-register operands");
2293   assert(ctx->Eax == min_jint, "unexpected idiv exception");
2294   // set correct result values and continue after idiv instruction
2295   ctx->Eip = (DWORD)pc + 2;        // idiv reg, reg  is 2 bytes
2296   ctx->Eax = (DWORD)min_jint;      // result
2297   ctx->Edx = (DWORD)0;             // remainder
2298   // Continue the execution
2299   #endif
2300 #endif
2301   return EXCEPTION_CONTINUE_EXECUTION;
2302 }
2303 
2304 //-----------------------------------------------------------------------------
2305 LONG WINAPI Handle_FLT_Exception(struct _EXCEPTION_POINTERS* exceptionInfo) {


< prev index next >