+
+ /*
+ * Look at current instruction: TWNE temp, NL3. We're here because
+ * temp > NL3 and temp is the end of the allocation, and NL3 is
+ * current-region-end-addr.
+ *
+ * We need to adjust temp and alloc-tn.
+ */
+
+ pc = (unsigned int *) (*os_context_pc_addr(context));
+ inst = pc[0];
+ end_addr = (inst >> 11) & 0x1f;
+ target = (inst >> 16) & 0x1f;
+
+ target_ptr = *os_context_register_addr(context, target);
+
+#if 0
+ fprintf(stderr, "handle_allocation_trap at %p:\n", pc);
+ fprintf(stderr, "boxed_region.free_pointer: %p\n", boxed_region.free_pointer);
+ fprintf(stderr, "boxed_region.end_addr: %p\n", boxed_region.end_addr);
+ fprintf(stderr, "target reg: %d, end_addr reg: %d\n", target, end_addr);
+ fprintf(stderr, "target: %x\n", *os_context_register_addr(context, target));
+ fprintf(stderr, "end_addr: %x\n", *os_context_register_addr(context, end_addr));
+#endif
+
+#if 0
+ fprintf(stderr, "handle_allocation_trap at %p:\n", pc);
+ fprintf(stderr, " trap inst = 0x%08x\n", inst);
+ fprintf(stderr, " target reg = %s\n", lisp_register_names[target]);
+#endif
+
+ /*
+ * Go back and look at the add/addi instruction. The second src arg
+ * is the size of the allocation. Get it and call alloc to allocate
+ * new space.
+ */
+ inst = pc[-1];
+ opcode = inst >> 26;
+#if 0
+ fprintf(stderr, " add inst = 0x%08x, opcode = %d\n", inst, opcode);
+#endif
+ if (opcode == 14) {
+ /*
+ * ADDI temp-tn, alloc-tn, size
+ *
+ * Extract the size
+ */
+ size = (inst & 0xffff);
+ } else if (opcode == 31) {
+ /*
+ * ADD temp-tn, alloc-tn, size-tn
+ *
+ * Extract the size
+ */
+ int reg;
+
+ reg = (inst >> 11) & 0x1f;
+#if 0
+ fprintf(stderr, " add, reg = %s\n", lisp_register_names[reg]);