Index: /branches/arm/lisp-kernel/arm-spentry.s
===================================================================
--- /branches/arm/lisp-kernel/arm-spentry.s	(revision 13844)
+++ /branches/arm/lisp-kernel/arm-spentry.s	(revision 13845)
@@ -1192,11 +1192,14 @@
         __(dnode_align(imm1,arg_y,node_size))
         __(cmp imm1,#stack_alloc_limit)
-        __(bge 9f)
+        __(bhs stack_misc_alloc_no_room)
         __(mov imm0,#subtag_u32_vector)
         __(orr imm0,imm0,arg_y,lsl #num_subtag_bits-fixnumshift)
+        __(mov temp0,#stack_alloc_marker)
+        __(mov temp1,sp)
         __(stack_allocate_zeroed_ivector(imm0,imm1))
         __(unbox_fixnum(imm0,arg_z))
         __(strb imm0,[sp])
         __(add arg_z,sp,#fulltag_misc)
+        __(stmdb sp!,{temp0,temp1})
         __(bx lr)
 1:      __(mov imm0,arg_y,lsl #num_subtag_bits-fixnumshift)
@@ -1218,17 +1221,13 @@
 8:      __(dnode_align(imm1,imm1,node_size))
         __(cmp imm1,#stack_alloc_limit)
-        __(bhs 9f)
+        __(bhs stack_misc_alloc_no_room)
+        __(mov temp0,#stack_alloc_marker)
+        __(mov temp1,sp)
         __(stack_allocate_zeroed_ivector(imm0,imm1))
         __(add arg_z,sp,#fulltag_misc)
-        __(bx lr)
-9: 
-
-/* Too large to safely fit on tstack.  Heap-cons the vector, but make  */
-/* sure that there's an empty tsp frame to keep the compiler happy.  */
-0:
-        __(movc16(imm0,make_header(1,subtag_u32_vector)))
-        __(mov imm1,#0)
-        __(stmdb sp!,{imm0,imm1})
-        __(b _SPmisc_alloc)
+        __(stmdb sp!,{temp0,temp1})
+        __(bx lr)
+
+
 
 
@@ -1624,5 +1623,8 @@
 /* the current frame, then do funcall.  */
 _spentry(tfuncallslide)
-        __(restore_lisp_frame(imm0))
+        __(ldr fn,[sp,#lisp_frame.savefn])
+        __(ldr imm0,[sp,#lisp_frame.savevsp])
+        __(ldr lr,[sp,#lisp_frame.savelr])
+        __(discard_lisp_frame())
         /* can use temp0 as a temporary  */
         __(sub imm1,nargs,#nargregs<<fixnumshift)
@@ -1861,4 +1863,6 @@
         __(mov imm1,imm0,lsl #num_subtag_bits-fixnumshift)
         __(orr imm1,imm1,#subtag_u32_vector)
+        __(mov temp2,sp)
+        __(mov arg_x,#stack_alloc_marker)
         __(stack_allocate_zeroed_ivector(imm1,temp1))
         __(unbox_fixnum(imm1,temp0))
@@ -1866,4 +1870,5 @@
         __(add arg_z,sp,#fulltag_misc)
         __(add imm0,sp,nargs)
+        __(stmdb sp!,{arg_x,temp2})
         __(b 2f)
 1:
@@ -2174,39 +2179,61 @@
         __(bl _SPmisc_alloc)
         __(restore_lisp_frame(imm0))
+        __(mov arg_y,temp2)
+initialize_vector:              
         __(ref_nrs_symbol(fname,init_misc,imm0))
         __(set_nargs(2))
-        __(mov arg_y,temp2)
         __(jump_fname())
 
 /* As in stack_misc_alloc above, only with a non-default initial-value.  */
-/* The funny part here is that we build a lisp frame, then push a vector
-/* on top of it.  Shuffle things around, carefully. */        
-                
+/* Note that this effectively inlines _SPstack_misc_alloc. */                
  
 _spentry(stack_misc_alloc_init)
-        __(build_lisp_frame(imm0))
-        __(mov arg_x,sp)
-        __(mov fn,#0)
-        __(mov temp2,arg_z) /* initval  */
-        __(mov arg_z,arg_y) /* subtag  */
-        __(mov arg_y,arg_x) /* element-count  */
-        __(bl _SPstack_misc_alloc)
-        __(mov imm0,#0)
-        __(ldr lr,[arg_x,#lisp_frame.savelr])
-        __(ldr fn,[arg_x,#lisp_frame.savefn])
-        __(ldr vsp,[arg_x,#lisp_frame.savevsp])
-        __(ldr imm1,[sp])
-        __(add imm2,imm1,#lisp_frame.size)
-        __(str imm2,[sp])
-        __(str imm0,[arg_x,#lisp_frame.savelr])
-        __(str imm0,[arg_x,#lisp_frame.savefn])
-        __(str imm0,[arg_x,#lisp_frame.savevsp])
-        __(str imm0,[arg_x,#lisp_frame.marker])
-        __(str imm1,[sp,#lisp_frame.size]!)
-        __(add arg_z,arg_z,#lisp_frame.size)
-        __(ref_nrs_symbol(fname,init_misc,imm0))
-        __(set_nargs(2))
-        __(mov arg_y,temp2)
-        __(jump_fname())
+        __(tst arg_x,#unsigned_byte_24_mask)
+        __(uuo_error_reg_not_xtype(ne,arg_x,xtype_unsigned_byte_24))
+        __(unbox_fixnum(imm0,arg_y))
+        __(extract_fulltag(imm1,imm0))
+        __(cmp imm1,#fulltag_nodeheader)
+        __(bne 1f)
+        __(dnode_align(imm1,arg_x,node_size))
+        __(cmp imm1,#stack_alloc_limit)
+        __(bge 0f)
+        __(mov imm0,#subtag_u32_vector)
+        __(orr imm0,imm0,arg_x,lsl #num_subtag_bits-fixnumshift)
+        __(mov temp0,#stack_alloc_marker)
+        __(mov temp1,sp)
+        __(stack_allocate_zeroed_ivector(imm0,imm1))
+        __(unbox_fixnum(imm0,arg_y))
+        __(strb imm0,[sp])
+        __(mov arg_y,arg_z)
+        __(add arg_z,sp,#fulltag_misc)
+        __(stmdb sp!,{temp0,temp1})
+        __(b initialize_vector)
+1:      __(mov imm0,arg_x,lsl #num_subtag_bits-fixnumshift)
+        __(orr imm0,imm0,arg_y,lsr #fixnumshift)
+        __(cmp arg_z,#max_32_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x)
+        __(ble 8f)
+        __(cmp arg_z,#max_8_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x,lsr #fixnumshift)
+        __(ble 8f)
+        __(cmp arg_z,#max_16_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x,lsr #1)
+        __(ble 8f)
+        __(cmp arg_z,#subtag_double_float)
+        __(moveq imm1,arg_x,lsl #1)
+        __(addeq imm1,imm1,#node_size)
+        __(addne imm1,arg_x,#7<<fixnumshift)
+        __(movne imm1,imm1,lsr#3+fixnumshift)
+8:      __(dnode_align(imm1,imm1,node_size))
+        __(cmp imm1,#stack_alloc_limit)
+        __(bhs 0f)
+        __(mov temp0,#stack_alloc_marker)
+        __(mov temp1,sp)
+        __(stack_allocate_zeroed_ivector(imm0,imm1))
+        __(mov arg_y,arg_z)
+        __(add arg_z,sp,#fulltag_misc)
+        __(stmdb sp!,{temp0,temp1})
+        __(b initialize_vector)
+
  
 _spentry(popj)
@@ -2214,4 +2241,12 @@
 C(popj):
         __(return_lisp_frame(imm0))
+	
+/* Too large to safely fit on tstack.  Heap-cons the vector, but make  */
+/* sure that there's an empty tsp frame to keep the compiler happy.  */
+0:
+        __(mov imm0,#stack_alloc_marker)
+        __(mov imm1,sp)
+        __(stmdb sp!,{imm0,imm1})
+        __(b _SPmisc_alloc_init)
 
 
@@ -4075,4 +4110,11 @@
         __(bx lr)
         
+/* Too large to safely fit on tstack.  Heap-cons the vector, but make  */
+/* sure that there's an empty tsp frame to keep the compiler happy.  */
+stack_misc_alloc_no_room:       
+        __(mov imm0,#stack_alloc_marker)
+        __(mov imm1,sp)
+        __(stmdb sp!,{imm0,imm1})
+        __(b _SPmisc_alloc)
         
 	_endfile
