void soft_reset (void) { /* Called synchronously. */ struct trap_recovery_info trinfo; SCHEME_OBJECT * new_stack_pointer = ((SP_OK_P (stack_pointer)) ? stack_pointer : 0); if (GET_PRIMITIVE != SHARP_F) { (trinfo . state) = STATE_PRIMITIVE; (trinfo . pc_info_1) = GET_PRIMITIVE; (trinfo . pc_info_2) = (ULONG_TO_FIXNUM (GET_LEXPR_ACTUALS)); (trinfo . extra_trap_info) = SHARP_F; } else { (trinfo . state) = STATE_UNKNOWN; (trinfo . pc_info_1) = SHARP_F; (trinfo . pc_info_2) = SHARP_F; (trinfo . extra_trap_info) = SHARP_F; } if (!ADDRESS_IN_HEAP_P (Free)) Free = heap_alloc_limit; /* Let's hope this works. */ setup_trap_frame (0, 0, 0, (&trinfo), new_stack_pointer); }
bool object_in_heap_p (SCHEME_OBJECT object) { SCHEME_OBJECT * address = (get_object_address (object)); return ((address != 0) && (ADDRESS_IN_HEAP_P (address))); }
static void continue_from_trap (int signo, SIGINFO_T info, SIGCONTEXT_T * scp) { unsigned long pc = (SIGCONTEXT_PC (scp)); SCHEME_OBJECT primitive = GET_PRIMITIVE; SCHEME_OBJECT * block_addr; unsigned int index; SCHEME_OBJECT * new_sp = 0; struct trap_recovery_info recovery_info; #ifdef PC_VALUE_MASK pc &= PC_VALUE_MASK; #endif /* Choose new SP and encode location data. */ switch (classify_pc (pc, (&block_addr), (&index))) { case pcl_primitive: new_sp = stack_pointer; SET_RECOVERY_INFO (STATE_PRIMITIVE, primitive, (ULONG_TO_FIXNUM (GET_LEXPR_ACTUALS))); break; case pcl_heap: case pcl_constant: #ifdef CC_SUPPORT_P new_sp = ((SCHEME_OBJECT *) (SIGCONTEXT_SCHSP (scp))); Free = ((SCHEME_OBJECT *) (SIGCONTEXT_RFREE (scp))); SET_RECOVERY_INFO (STATE_COMPILED_CODE, (MAKE_CC_BLOCK (block_addr)), (LONG_TO_UNSIGNED_FIXNUM (pc - ((unsigned long) block_addr)))); break; #endif case pcl_utility: #ifdef CC_SUPPORT_P new_sp = stack_pointer; SET_RECOVERY_INFO (STATE_UTILITY, (ULONG_TO_FIXNUM (index)), UNSPECIFIC); break; #endif case pcl_builtin: #ifdef CC_SUPPORT_P new_sp = ((SCHEME_OBJECT *) (SIGCONTEXT_SCHSP (scp))); Free = ((SCHEME_OBJECT *) (SIGCONTEXT_RFREE (scp))); SET_RECOVERY_INFO (STATE_BUILTIN, (ULONG_TO_FIXNUM (index)), UNSPECIFIC); break; #endif case pcl_unknown: new_sp = 0; SET_RECOVERY_INFO (STATE_UNKNOWN, (LONG_TO_UNSIGNED_FIXNUM (pc)), UNSPECIFIC); break; } /* Sanity-check the new SP. */ if (! ((ADDRESS_IN_STACK_P (new_sp)) && (ALIGNED_P (new_sp)))) new_sp = 0; /* Sanity-check Free. */ if ((new_sp != 0) && (ADDRESS_IN_HEAP_P (Free)) && (ALIGNED_P (Free))) { if (FREE_OK_P (Free)) { Free += FREE_PARANOIA_MARGIN; if (!FREE_OK_P (Free)) Free = heap_alloc_limit; } } else Free = heap_alloc_limit; /* Encode the registers. */ (recovery_info . extra_trap_info) = (MAKE_POINTER_OBJECT (TC_NON_MARKED_VECTOR, Free)); (*Free++) = (MAKE_OBJECT (TC_MANIFEST_NM_VECTOR, (2 + SIGCONTEXT_NREGS))); (*Free++) = ((SCHEME_OBJECT) pc); (*Free++) = ((SCHEME_OBJECT) (SIGCONTEXT_SP (scp))); { unsigned long * scan = ((unsigned long *) (SIGCONTEXT_FIRST_REG (scp))); unsigned long * end = (scan + SIGCONTEXT_NREGS); while (scan < end) (*Free++) = ((SCHEME_OBJECT) (*scan++)); } setup_trap_frame (signo, info, scp, (&recovery_info), new_sp); }