+ /*
+ * 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[-3];
+ 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]);
+#endif
+ size = *os_context_register_addr(context, reg);
+
+ }
+
+#if 0
+ fprintf(stderr, "Alloc %d to %s\n", size, lisp_register_names[target]);
+#endif
+
+#if INLINE_ALLOC_DEBUG
+ if ((((unsigned long)boxed_region.end_addr + size) / PAGE_SIZE) ==
+ (((unsigned long)boxed_region.end_addr) / PAGE_SIZE)) {
+ fprintf(stderr,"*** possibly bogus trap allocation of %d bytes at %p\n",
+ size, target_ptr);
+ fprintf(stderr, " dynamic_space_free_pointer: %p, boxed_region.end_addr %p\n",
+ dynamic_space_free_pointer, boxed_region.end_addr);
+ }
+#endif
+
+#if 0
+ fprintf(stderr, "Ready to alloc\n");
+ fprintf(stderr, "free_pointer = 0x%08x\n",
+ dynamic_space_free_pointer);
+#endif
+
+ /*
+ * alloc-tn was incremented by size. Need to decrement it by size
+ * to restore its original value. This is not true on GENCGC
+ * anymore. d_s_f_p and reg_alloc get out of sync, but the p_a
+ * bits stay intact and we set it to the proper value when it
+ * needs to be. Keep this comment here for the moment in case
+ * somebody tries to figure out what happened here.
+ */
+ /* dynamic_space_free_pointer =
+ (lispobj *) ((long) dynamic_space_free_pointer - size);
+ */
+#if 0
+ fprintf(stderr, "free_pointer = 0x%08x new\n",
+ dynamic_space_free_pointer);
+#endif
+
+ {
+ struct interrupt_data *data =
+ arch_os_get_current_thread()->interrupt_data;
+ data->allocation_trap_context = context;
+ memory = (char *) alloc(size);
+ data->allocation_trap_context = 0;
+ }
+
+#if 0
+ fprintf(stderr, "alloc returned %p\n", memory);
+ fprintf(stderr, "free_pointer = 0x%08x\n",
+ dynamic_space_free_pointer);
+#endif
+
+ /*
+ * The allocation macro wants the result to point to the end of the
+ * object!
+ */
+ memory += size;
+
+#if 0
+ fprintf(stderr, "object end at %p\n", memory);
+#endif
+
+ *os_context_register_addr(context, target) = (unsigned long) memory;
+ *os_context_register_addr(context, reg_ALLOC) =
+ (unsigned long) dynamic_space_free_pointer
+ | (*os_context_register_addr(context, reg_ALLOC)
+ & LOWTAG_MASK);
+
+ if (were_in_lisp) {
+ undo_fake_foreign_function_call(context);
+ }