Changeset 6513
- Timestamp:
- May 9, 2007, 1:41:33 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ccl/lisp-kernel/ppc-exceptions.c (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ccl/lisp-kernel/ppc-exceptions.c
r6388 r6513 577 577 if (newlimit > (natural) (a->high)) { 578 578 if (extend) { 579 if (! resize_dynamic_heap(a->active, (newlimit-oldlimit)+lisp_heap_gc_threshold)) { 580 return false; 581 } 579 natural extend_by = lisp_heap_gc_threshold; 580 do { 581 if (resize_dynamic_heap(a->active, (newlimit-oldlimit)+extend_by)) { 582 break; 583 } 584 extend_by = align_to_power_of_2(extend_by>>1, log2_allocation_quantum); 585 if (extend_by < 4<<20) { 586 return false; 587 } 588 } while (1); 582 589 } else { 583 590 return false; … … 868 875 869 876 OSStatus 870 handle_protection_violation(ExceptionInformation *xp, siginfo_t *info, TCR *tcr )877 handle_protection_violation(ExceptionInformation *xp, siginfo_t *info, TCR *tcr, int old_valence) 871 878 { 872 879 BytePtr addr; … … 884 891 if (addr && (addr == tcr->safe_ref_address)) { 885 892 adjust_exception_pc(xp,4); 893 886 894 xpGPR(xp,imm0) = 0; 887 895 return 0; … … 902 910 } 903 911 } 904 callback_for_trap(nrs_CMAIN.vcell, xp, (pc)xpPC(xp), SIGBUS, (natural)addr, is_write_fault(xp,info)); 912 if (old_valence == TCR_STATE_LISP) { 913 callback_for_trap(nrs_CMAIN.vcell, xp, (pc)xpPC(xp), SIGBUS, (natural)addr, is_write_fault(xp,info)); 914 } 905 915 return -1; 906 916 } … … 1207 1217 ExceptionInformation *xp, 1208 1218 TCR *tcr, 1209 siginfo_t *info) 1219 siginfo_t *info, 1220 int old_valence) 1210 1221 { 1211 1222 unsigned oldMQ; … … 1225 1236 } else if ((xnum == SIGSEGV) || 1226 1237 (xnum == SIGBUS)) { 1227 status = handle_protection_violation(xp, info, tcr );1238 status = handle_protection_violation(xp, info, tcr, old_valence); 1228 1239 } else if (xnum == SIGFPE) { 1229 1240 status = handle_sigfpe(xp, tcr); … … 1729 1740 1730 1741 void 1731 signal_handler(int signum, siginfo_t *info, ExceptionInformation *context, TCR *tcr )1742 signal_handler(int signum, siginfo_t *info, ExceptionInformation *context, TCR *tcr, int old_valence) 1732 1743 { 1733 1744 xframe_list xframe_link; 1734 int old_valence;1735 1745 1736 1746 #ifdef DARWIN … … 1754 1764 1755 1765 wait_for_exception_lock_in_handler(tcr, context, &xframe_link); 1756 if ((noErr != PMCL_exception_handler(signum, context, tcr, info ))) {1766 if ((noErr != PMCL_exception_handler(signum, context, tcr, info, old_valence))) { 1757 1767 char msg[512]; 1758 1768 snprintf(msg, sizeof(msg), "Unhandled exception %d at 0x%lx, context->regs at #x%lx", signum, xpPC(context), (natural)xpGPRvector(context)); … … 2050 2060 fprintf(stderr, "[0x%x acquired exception lock for interrupt]\n",tcr); 2051 2061 #endif 2052 PMCL_exception_handler(signum, context, tcr, info );2062 PMCL_exception_handler(signum, context, tcr, info, old_valence); 2053 2063 if (disp) { 2054 2064 xpGPR(context,allocptr) -= disp; … … 2229 2239 #ifdef DARWIN 2230 2240 2241 2231 2242 #define TCR_FROM_EXCEPTION_PORT(p) ((TCR *)((natural)p)) 2232 2243 #define TCR_TO_EXCEPTION_PORT(tcr) ((mach_port_t)((natural)(tcr))) 2233 2244 2245 2246 #if USE_MACH_EXCEPTION_LOCK 2234 2247 pthread_mutex_t _mach_exception_lock, *mach_exception_lock; 2235 2248 #endif 2236 2249 2237 2250 #define LISP_EXCEPTIONS_HANDLED_MASK \ … … 2500 2513 mach_msg_type_number_t thread_state_count; 2501 2514 ExceptionInformation *pseudosigcontext; 2502 int i, j ;2515 int i, j, old_valence = tcr->valence; 2503 2516 kern_return_t result; 2504 2517 natural stackp; … … 2526 2539 ts.__r4 = (natural)pseudosigcontext; 2527 2540 ts.__r5 = (natural)tcr; 2541 ts.__r6 = (natural)old_valence; 2528 2542 ts.__lr = (natural)pseudo_sigreturn; 2529 2543 … … 2549 2563 2550 2564 void 2551 pseudo_signal_handler(int signum, ExceptionInformation *context, TCR *tcr )2552 { 2553 signal_handler(signum, NULL, context, tcr );2565 pseudo_signal_handler(int signum, ExceptionInformation *context, TCR *tcr, int old_valence) 2566 { 2567 signal_handler(signum, NULL, context, tcr, old_valence); 2554 2568 } 2555 2569 … … 2660 2674 #endif 2661 2675 2662 if (pthread_mutex_trylock(mach_exception_lock) == 0) { 2676 if ( 2677 #if USE_MACH_EXCEPTION_LOCK 2678 pthread_mutex_trylock(mach_exception_lock) == 0 2679 #else 2680 1 2681 #endif 2682 ) { 2663 2683 if (tcr->flags & (1<<TCR_FLAG_BIT_PENDING_EXCEPTION)) { 2664 2684 CLR_TCR_FLAG(tcr,TCR_FLAG_BIT_PENDING_EXCEPTION); … … 2718 2738 } 2719 2739 } 2740 #if USE_MACH_EXCEPTION_LOCK 2720 2741 #ifdef DEBUG_MACH_EXCEPTIONS 2721 2742 fprintf(stderr, "releasing Mach exception lock in exception thread\n"); 2722 2743 #endif 2723 2744 pthread_mutex_unlock(mach_exception_lock); 2745 #endif 2724 2746 } else { 2725 2747 SET_TCR_FLAG(tcr,TCR_FLAG_BIT_PENDING_EXCEPTION); … … 2813 2835 kern_return_t kret; 2814 2836 if (__exception_port_set == MACH_PORT_NULL) { 2837 #if USE_MACH_EXCEPTION_LOCK 2815 2838 mach_exception_lock = &_mach_exception_lock; 2816 2839 pthread_mutex_init(mach_exception_lock, NULL); 2817 2840 #endif 2818 2841 kret = mach_port_allocate(mach_task_self(), 2819 2842 MACH_PORT_RIGHT_PORT_SET, … … 3090 3113 3091 3114 LOCK(lisp_global(TCR_AREA_LOCK), current); 3115 #if USE_MACH_EXCEPTION_LOCK 3092 3116 pthread_mutex_lock(mach_exception_lock); 3117 #endif 3093 3118 3094 3119 if (suspend_mach_thread(mach_thread)) { … … 3118 3143 3119 3144 } 3145 #if USE_MACH_EXCEPTION_LOCK 3120 3146 pthread_mutex_unlock(mach_exception_lock); 3147 #endif 3121 3148 UNLOCK(lisp_global(TCR_AREA_LOCK), current); 3122 3149 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.
