X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fruntime%2Fsparc-arch.c;h=2eee865ab57459e9c7dab09a2fa7d6b328ccfb8b;hb=eac461c1f1ca91cfe282c779291d582ed6b336cb;hp=3ff810e1f4fd9418458894654b7e371a8983facb;hpb=012b1558b80a988901569412ca79d544ed30ff6a;p=sbcl.git diff --git a/src/runtime/sparc-arch.c b/src/runtime/sparc-arch.c index 3ff810e..2eee865 100644 --- a/src/runtime/sparc-arch.c +++ b/src/runtime/sparc-arch.c @@ -35,6 +35,9 @@ void arch_init(void) os_vm_address_t arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *context) { +#if 1 /* New way. */ + return (os_vm_address_t)code->si_addr; +#else /* Old way, almost certainly predates sigaction(2)-style handlers */ unsigned int badinst; unsigned int *pc; int rs1; @@ -82,6 +85,7 @@ os_vm_address_t arch_get_bad_addr(int sig, siginfo_t *code, os_context_t *contex (*os_context_register_addr(context, rs1) + *os_context_register_addr(context, rs2)); } +#endif } void arch_skip_instruction(os_context_t *context) @@ -251,6 +255,64 @@ arch_handle_single_step_trap(os_context_t *context, int trap) arch_skip_instruction(context); } +#ifdef LISP_FEATURE_GENCGC +void +arch_handle_allocation_trap(os_context_t *context) +{ + unsigned int* pc; + unsigned int or_inst; + int rs1; + int size; + int immed; + int context_index; + boolean were_in_lisp; + char* memory; + + pc = (unsigned int*) *os_context_pc_addr(context); + or_inst = pc[-1]; + + /* + * The instruction before this trap instruction had better be an OR + * instruction! + */ + if (!(((or_inst >> 30) == 2) && (((or_inst >> 19) & 0x1f) == 2))) + lose(stderr, "Whoa!!! Got an allocation trap not preceeded by an OR inst: 0x%08x!\n", + or_inst); + + /* + * An OR instruction. RS1 is the register we want to allocate to. + * RS2 (or an immediate) is the size. + */ + rs1 = (or_inst >> 14) & 0x1f; + immed = (or_inst >> 13) & 1; + + if (immed == 1) + size = or_inst & 0x1fff; + else { + size = or_inst & 0x1f; + size = *os_context_register_addr(context, size); + } + + if (foreign_function_call_active) + lose(stderr, "Whoa! allocation trap and we weren't in lisp!\n"); + fake_foreign_function_call(context); + + /* + * Allocate some memory, store the memory address in rs1. + */ + { + struct interrupt_data *data = + arch_os_get_current_thread()->interrupt_data; + data->allocation_trap_context = context; + memory = alloc(size); + data->allocation_trap_context = 0; + } + *os_context_register_addr(context, rs1) = memory; + + undo_fake_foreign_function_call(context); +} +#endif + static void sigill_handler(int signal, siginfo_t *siginfo, os_context_t *context) {