563 // Verify that OS save/restore AVX registers.
564 stub = VM_Version::cpuinfo_cont_addr();
565 }
566
567 // We test if stub is already set (by the stack overflow code
568 // above) so it is not overwritten by the code that follows. This
569 // check is not required on other platforms, because on other
570 // platforms we check for SIGSEGV only or SIGBUS only, where here
571 // we have to check for both SIGSEGV and SIGBUS.
572 if (thread->thread_state() == _thread_in_Java && stub == NULL) {
573 // Java thread running in Java code => find exception handler if any
574 // a fault inside compiled code, the interpreter, or a stub
575
576 if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
577 stub = SharedRuntime::get_poll_stub(pc);
578 #if defined(__APPLE__)
579 // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
580 // 64-bit Darwin may also use a SIGBUS (seen with compressed oops).
581 // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
582 // being called, so only do so if the implicit NULL check is not necessary.
583 } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
584 #else
585 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
586 #endif
587 // BugId 4454115: A read from a MappedByteBuffer can fault
588 // here if the underlying file has been truncated.
589 // Do not crash the VM in such a case.
590 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
591 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
592 if (nm != NULL && nm->has_unsafe_access()) {
593 address next_pc = Assembler::locate_next_instruction(pc);
594 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
595 }
596 }
597 else
598
599 #ifdef AMD64
600 if (sig == SIGFPE &&
601 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
602 stub =
603 SharedRuntime::
638 // pending. We want to dismiss that exception. From the win_32
639 // side it also seems that if it really was the fist causing
640 // the exception that we do the d2i by hand with different
641 // rounding. Seems kind of weird.
642 // NOTE: that we take the exception at the NEXT floating point instruction.
643 assert(pc[0] == 0xDB, "not a FIST opcode");
644 assert(pc[1] == 0x14, "not a FIST opcode");
645 assert(pc[2] == 0x24, "not a FIST opcode");
646 return true;
647 } else if (op == 0xF7) {
648 // IDIV
649 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
650 } else {
651 // TODO: handle more cases if we are using other x86 instructions
652 // that can generate SIGFPE signal on bsd.
653 tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
654 fatal("please update this code.");
655 }
656 #endif // AMD64
657 } else if ((sig == SIGSEGV || sig == SIGBUS) &&
658 !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
659 // Determination of interpreter/vtable stub/compiled code null exception
660 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
661 }
662 } else if (thread->thread_state() == _thread_in_vm &&
663 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
664 thread->doing_unsafe_access()) {
665 address next_pc = Assembler::locate_next_instruction(pc);
666 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
667 }
668
669 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
670 // and the heap gets shrunk before the field access.
671 if ((sig == SIGSEGV) || (sig == SIGBUS)) {
672 address addr = JNI_FastGetField::find_slowcase_pc(pc);
673 if (addr != (address)-1) {
674 stub = addr;
675 }
676 }
677
678 // Check to see if we caught the safepoint code in the
|
563 // Verify that OS save/restore AVX registers.
564 stub = VM_Version::cpuinfo_cont_addr();
565 }
566
567 // We test if stub is already set (by the stack overflow code
568 // above) so it is not overwritten by the code that follows. This
569 // check is not required on other platforms, because on other
570 // platforms we check for SIGSEGV only or SIGBUS only, where here
571 // we have to check for both SIGSEGV and SIGBUS.
572 if (thread->thread_state() == _thread_in_Java && stub == NULL) {
573 // Java thread running in Java code => find exception handler if any
574 // a fault inside compiled code, the interpreter, or a stub
575
576 if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
577 stub = SharedRuntime::get_poll_stub(pc);
578 #if defined(__APPLE__)
579 // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
580 // 64-bit Darwin may also use a SIGBUS (seen with compressed oops).
581 // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
582 // being called, so only do so if the implicit NULL check is not necessary.
583 } else if (sig == SIGBUS && !MacroAssembler::uses_implicit_null_check(info->si_addr)) {
584 #else
585 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
586 #endif
587 // BugId 4454115: A read from a MappedByteBuffer can fault
588 // here if the underlying file has been truncated.
589 // Do not crash the VM in such a case.
590 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
591 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
592 if (nm != NULL && nm->has_unsafe_access()) {
593 address next_pc = Assembler::locate_next_instruction(pc);
594 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
595 }
596 }
597 else
598
599 #ifdef AMD64
600 if (sig == SIGFPE &&
601 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
602 stub =
603 SharedRuntime::
638 // pending. We want to dismiss that exception. From the win_32
639 // side it also seems that if it really was the fist causing
640 // the exception that we do the d2i by hand with different
641 // rounding. Seems kind of weird.
642 // NOTE: that we take the exception at the NEXT floating point instruction.
643 assert(pc[0] == 0xDB, "not a FIST opcode");
644 assert(pc[1] == 0x14, "not a FIST opcode");
645 assert(pc[2] == 0x24, "not a FIST opcode");
646 return true;
647 } else if (op == 0xF7) {
648 // IDIV
649 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
650 } else {
651 // TODO: handle more cases if we are using other x86 instructions
652 // that can generate SIGFPE signal on bsd.
653 tty->print_cr("unknown opcode 0x%X with SIGFPE.", op);
654 fatal("please update this code.");
655 }
656 #endif // AMD64
657 } else if ((sig == SIGSEGV || sig == SIGBUS) &&
658 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
659 // Determination of interpreter/vtable stub/compiled code null exception
660 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
661 }
662 } else if (thread->thread_state() == _thread_in_vm &&
663 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
664 thread->doing_unsafe_access()) {
665 address next_pc = Assembler::locate_next_instruction(pc);
666 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
667 }
668
669 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
670 // and the heap gets shrunk before the field access.
671 if ((sig == SIGSEGV) || (sig == SIGBUS)) {
672 address addr = JNI_FastGetField::find_slowcase_pc(pc);
673 if (addr != (address)-1) {
674 stub = addr;
675 }
676 }
677
678 // Check to see if we caught the safepoint code in the
|