< prev index next >

src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp


562       // Verify that OS save/restore AVX registers.                                                                                  
563       stub = VM_Version::cpuinfo_cont_addr();                                                                                        
564     }                                                                                                                                
565 
566     // We test if stub is already set (by the stack overflow code                                                                    
567     // above) so it is not overwritten by the code that follows. This                                                                
568     // check is not required on other platforms, because on other                                                                    
569     // platforms we check for SIGSEGV only or SIGBUS only, where here                                                                
570     // we have to check for both SIGSEGV and SIGBUS.                                                                                 
571     if (thread->thread_state() == _thread_in_Java && stub == NULL) {                                                                 
572       // Java thread running in Java code => find exception handler if any                                                           
573       // a fault inside compiled code, the interpreter, or a stub                                                                    
574 
575       if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {                                        
576         stub = SharedRuntime::get_poll_stub(pc);                                                                                     
577 #if defined(__APPLE__)                                                                                                               
578       // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.                                                     
579       // 64-bit Darwin may also use a SIGBUS (seen with compressed oops).                                                            
580       // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from                                                     
581       // being called, so only do so if the implicit NULL check is not necessary.                                                    
582       } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {                              
583 #else                                                                                                                                
584       } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {                                                               
585 #endif                                                                                                                               
586         // BugId 4454115: A read from a MappedByteBuffer can fault                                                                   
587         // here if the underlying file has been truncated.                                                                           
588         // Do not crash the VM in such a case.                                                                                       
589         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);                                                                              
590         CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;                                                 
591         if (nm != NULL && nm->has_unsafe_access()) {                                                                                 
592           address next_pc = Assembler::locate_next_instruction(pc);                                                                  
593           stub = SharedRuntime::handle_unsafe_access(thread, next_pc);                                                               
594         }                                                                                                                            
595       }                                                                                                                              
596       else                                                                                                                           
597 
598 #ifdef AMD64                                                                                                                         
599       if (sig == SIGFPE  &&                                                                                                          
600           (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {                                                            
601         stub =                                                                                                                       

562       // Verify that OS save/restore AVX registers.
563       stub = VM_Version::cpuinfo_cont_addr();
564     }
565 
566     // We test if stub is already set (by the stack overflow code
567     // above) so it is not overwritten by the code that follows. This
568     // check is not required on other platforms, because on other
569     // platforms we check for SIGSEGV only or SIGBUS only, where here
570     // we have to check for both SIGSEGV and SIGBUS.
571     if (thread->thread_state() == _thread_in_Java && stub == NULL) {
572       // Java thread running in Java code => find exception handler if any
573       // a fault inside compiled code, the interpreter, or a stub
574 
575       if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
576         stub = SharedRuntime::get_poll_stub(pc);
577 #if defined(__APPLE__)
578       // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
579       // 64-bit Darwin may also use a SIGBUS (seen with compressed oops).
580       // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
581       // being called, so only do so if the implicit NULL check is not necessary.
582       } else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) {
583 #else
584       } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
585 #endif
586         // BugId 4454115: A read from a MappedByteBuffer can fault
587         // here if the underlying file has been truncated.
588         // Do not crash the VM in such a case.
589         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
590         CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
591         if (nm != NULL && nm->has_unsafe_access()) {
592           address next_pc = Assembler::locate_next_instruction(pc);
593           stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
594         }
595       }
596       else
597 
598 #ifdef AMD64
599       if (sig == SIGFPE  &&
600           (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
601         stub =

637           // pending. We want to dismiss that exception. From the win_32                                                             
638           // side it also seems that if it really was the fist causing                                                               
639           // the exception that we do the d2i by hand with different                                                                 
640           // rounding. Seems kind of weird.                                                                                          
641           // NOTE: that we take the exception at the NEXT floating point instruction.                                                
642           assert(pc[0] == 0xDB, "not a FIST opcode");                                                                                
643           assert(pc[1] == 0x14, "not a FIST opcode");                                                                                
644           assert(pc[2] == 0x24, "not a FIST opcode");                                                                                
645           return true;                                                                                                               
646         } else if (op == 0xF7) {                                                                                                     
647           // IDIV                                                                                                                    
648           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);             
649         } else {                                                                                                                     
650           // TODO: handle more cases if we are using other x86 instructions                                                          
651           //   that can generate SIGFPE signal on bsd.                                                                               
652           tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);                                                                     
653           fatal("please update this code.");                                                                                         
654         }                                                                                                                            
655 #endif // AMD64                                                                                                                      
656       } else if ((sig == SIGSEGV || sig == SIGBUS) &&                                                                                
657                !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {                                                
658           // Determination of interpreter/vtable stub/compiled code null exception                                                   
659           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);                       
660       }                                                                                                                              
661     } else if (thread->thread_state() == _thread_in_vm &&                                                                            
662                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */                                                                 
663                thread->doing_unsafe_access()) {                                                                                      
664         address next_pc = Assembler::locate_next_instruction(pc);                                                                    
665         stub = SharedRuntime::handle_unsafe_access(thread, next_pc);                                                                 
666     }                                                                                                                                
667 
668     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in                                                        
669     // and the heap gets shrunk before the field access.                                                                             
670     if ((sig == SIGSEGV) || (sig == SIGBUS)) {                                                                                       
671       address addr = JNI_FastGetField::find_slowcase_pc(pc);                                                                         
672       if (addr != (address)-1) {                                                                                                     
673         stub = addr;                                                                                                                 
674       }                                                                                                                              
675     }                                                                                                                                
676 

637           // pending. We want to dismiss that exception. From the win_32
638           // side it also seems that if it really was the fist causing
639           // the exception that we do the d2i by hand with different
640           // rounding. Seems kind of weird.
641           // NOTE: that we take the exception at the NEXT floating point instruction.
642           assert(pc[0] == 0xDB, "not a FIST opcode");
643           assert(pc[1] == 0x14, "not a FIST opcode");
644           assert(pc[2] == 0x24, "not a FIST opcode");
645           return true;
646         } else if (op == 0xF7) {
647           // IDIV
648           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
649         } else {
650           // TODO: handle more cases if we are using other x86 instructions
651           //   that can generate SIGFPE signal on bsd.
652           tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
653           fatal("please update this code.");
654         }
655 #endif // AMD64
656       } else if ((sig == SIGSEGV || sig == SIGBUS) &&
657                  MacroAssembler::uses_implicit_null_check(info->si_addr)) {
658           // Determination of interpreter/vtable stub/compiled code null exception
659           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
660       }
661     } else if (thread->thread_state() == _thread_in_vm &&
662                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
663                thread->doing_unsafe_access()) {
664         address next_pc = Assembler::locate_next_instruction(pc);
665         stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
666     }
667 
668     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
669     // and the heap gets shrunk before the field access.
670     if ((sig == SIGSEGV) || (sig == SIGBUS)) {
671       address addr = JNI_FastGetField::find_slowcase_pc(pc);
672       if (addr != (address)-1) {
673         stub = addr;
674       }
675     }
676 
< prev index next >