Index: /trunk/ccl/lisp-kernel/x86-spentry64.s
===================================================================
--- /trunk/ccl/lisp-kernel/x86-spentry64.s	(revision 6530)
+++ /trunk/ccl/lisp-kernel/x86-spentry64.s	(revision 6531)
@@ -37,4 +37,6 @@
 	jump_fname()
 ])
+
+        
 
 _spentry(bad_funcall)	
@@ -55,8 +57,8 @@
 	__(xorq %imm1,%imm0)
 	__(movq %imm0,misc_data_offset(%arg_z))
-	__(jmp *%ra0)	
+	__(ret)	
 _endsubp(fix_overflow)
 
-	
+
 /* Make a lisp integer (fixnum or two-digit bignum) from the signed  */
 /* 64-bit value in %imm0.   */
@@ -73,7 +75,8 @@
 	__(Misc_Alloc_Fixed(%arg_z,aligned_bignum_size(2)))
 	__(movq %mm0,misc_data_offset(%arg_z))
-0:	__(jmp *%ra0)
+0:	__(repret)
 _endsubp(makes64)	
-				
+
+        				
 
 /* %imm1:%imm0 constitute a signed integer, almost certainly a bignum.  */
@@ -111,12 +114,13 @@
 	__(movq %mm0,misc_data_offset(%arg_z))
 	__(movq %mm1,misc_data_offset+8(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 3:	__(mov $three_digit_bignum_header,%imm0)
 	__(Misc_Alloc_Fixed(%arg_z,aligned_bignum_size(3)))
 	__(movq %mm0,misc_data_offset(%arg_z))
 	__(movd %mm1,misc_data_offset+8(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 _endfn
 
+        
 /* %imm1:%imm0 constitute an unsigned integer, almost certainly a bignum.  */
 /* Make a lisp integer out of those 128 bits ..  */
@@ -152,5 +156,5 @@
 	__(movq %mm0,misc_data_offset(%arg_z))
 	__(movd %mm1,misc_data_offset+8(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 4:	__(movq $four_digit_bignum_header,%imm0)
 	__(Misc_Alloc_Fixed(%arg_z,aligned_bignum_size(4)))
@@ -160,5 +164,5 @@
 6:	__(movq %mm0,misc_data_offset(%arg_z))
 	__(movq %mm0,misc_data_offset+8(%arg_z))
-	__(jmpq *%ra0)
+	__(ret)
 _endfn
 
@@ -186,6 +190,6 @@
 _startfn(C(misc_ref_common))
 	__(movzbl %imm1_b,%imm1_l)
-        __(lea local_label(misc_ref_jmp)(%rip),%temp2)
-	__(jmp *(%temp2,%imm1,8))
+        __(lea local_label(misc_ref_jmp)(%rip),%imm2)
+	__(jmp *(%imm2,%imm1,8))
 	.p2align 3
 local_label(misc_ref_jmp):	
@@ -475,5 +479,5 @@
 local_label(misc_ref_node):
 	__(movq misc_data_offset(%arg_y,%arg_z),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_u64):
 	__(movq misc_data_offset(%arg_y,%arg_z),%imm0)
@@ -484,9 +488,9 @@
 	__(Misc_Alloc_Fixed(%arg_z,double_float.size))
 	__(movsd %fp1,double_float.value(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_fixnum_vector):	
 	__(movq misc_data_offset(%arg_y,%arg_z),%imm0)
         __(box_fixnum(%imm0,%arg_z))
-        __(jmp *%ra0)
+        __(ret)
 local_label(misc_ref_s64):	
 	__(movq misc_data_offset(%arg_y,%arg_z),%imm0)
@@ -497,5 +501,5 @@
 	__(movl misc_data_offset(%arg_y,%imm0),%imm0_l)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_s32):
 	__(movq %arg_z,%imm0)
@@ -503,5 +507,5 @@
 	__(movslq misc_data_offset(%arg_y,%imm0),%imm0)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_single_float_vector):
 	__(movq %arg_z,%imm0)
@@ -511,5 +515,5 @@
 	__(shl $32,%imm0)
 	__(lea subtag_single_float(%imm0),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_u8):
 	__(movq %arg_z,%imm0)
@@ -517,5 +521,5 @@
 	__(movzbl misc_data_offset(%arg_y,%imm0),%imm0_l)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_s8):	
 	__(movq %arg_z,%imm0)
@@ -523,5 +527,5 @@
 	__(movsbq misc_data_offset(%arg_y,%imm0),%imm0)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_string):
 	__(movq %arg_z,%imm0)
@@ -530,5 +534,5 @@
 	__(shlq $charcode_shift,%imm0)
 	__(leaq subtag_character(%imm0),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_new_string):
 	__(movq %arg_z,%imm0)
@@ -537,5 +541,5 @@
 	__(shlq $charcode_shift,%imm0)
 	__(leaq subtag_character(%imm0),%arg_z)
-	__(jmp *%ra0)        
+	__(ret)        
 local_label(misc_ref_u16):	
 	__(movq %arg_z,%imm0)
@@ -543,5 +547,5 @@
 	__(movzwl misc_data_offset(%arg_y,%imm0),%imm0_l)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_s16):	
 	__(movq %arg_z,%imm0)
@@ -549,5 +553,5 @@
 	__(movswq misc_data_offset(%arg_y,%imm0),%imm0)
 	__(box_fixnum(%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_bit_vector):
 	__(unbox_fixnum(%arg_z,%imm0))
@@ -560,5 +564,5 @@
 	__(andl $fixnum_one,%imm0_l)
 	__(movq %imm0,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_ref_invalid):
 	__(movq $XBADVEC,%arg_x)
@@ -628,6 +632,6 @@
 _startfn(C(misc_set_common))
 	__(movzbl %imm1_b,%imm1_l)
-        __(lea local_label(misc_set_jmp)(%rip),%temp2)
-	__(jmp *(%temp2,%imm1,8))
+        __(lea local_label(misc_set_jmp)(%rip),%imm2)
+	__(jmp *(%imm2,%imm1,8))
 	.p2align 3
 local_label(misc_set_jmp):		
@@ -939,5 +943,5 @@
 	__(jne local_label(misc_set_bad))
 9:	__(movq %imm0,misc_data_offset(%arg_x,%arg_y))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_fixnum_vector):
 	__(movq %arg_z,%imm0)
@@ -946,5 +950,5 @@
 	__(jne local_label(misc_set_bad))
 	__(movq %imm0,misc_data_offset(%arg_x,%arg_y))
-	__(jmp *%ra0)	
+	__(ret)	
 local_label(misc_set_s64):
 	__(movq %arg_z,%imm0)
@@ -964,5 +968,5 @@
 	__(jne local_label(misc_set_bad))
 9:	__(movq %imm0,misc_data_offset(%arg_x,%arg_y))
-	__(jmp *%ra0)	
+	__(ret)	
 local_label(misc_set_bad):
 	__(movq %arg_z,%arg_y)
@@ -980,5 +984,5 @@
 	__(movq double_float.value(%arg_z),%imm0)
 	__(movq %imm0,misc_dfloat_offset(%arg_x,%arg_y))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_s32):	
 	__(movq %arg_z,%imm0)
@@ -993,5 +997,5 @@
 	__(shr $fixnumshift,%imm0)
 	__(movl %imm0_l,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_single_float_vector):
 	__(cmpb $tag_single_float,%arg_z_b)
@@ -1002,5 +1006,5 @@
 	__(shr $32,%imm0)
 	__(movl %imm0_l,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_u32):
 	__(movq %arg_y,%imm1)	
@@ -1011,5 +1015,5 @@
 	__(unbox_fixnum(%arg_z,%imm0))
 	__(movl %imm0_l,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_bit_vector):	
 	__(testq $~fixnumone,%arg_z)
@@ -1023,8 +1027,8 @@
 local_label(misc_set_set_bit):	
 	__(btsq %imm0,misc_data_offset(%arg_x,%imm1,8))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_clr_bit):	
 	__(btrq %imm0,misc_data_offset(%arg_x,%imm1,8))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_u8):	
 	__(testq $~(0xff<<fixnumshift),%arg_z)
@@ -1034,5 +1038,5 @@
 	__(shrq $3,%imm1)
 	__(movb %imm0_b,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_s8):
 	__(movq %arg_z,%imm0)
@@ -1047,5 +1051,5 @@
 	__(shrq $3,%imm1)
 	__(movb %imm0_b,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_string):
 	__(cmpb $subtag_character,%arg_z_b)
@@ -1056,5 +1060,5 @@
 	__(shrq $3,%imm1)
 	__(movb %imm0_b,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_new_string):
 	__(cmpb $subtag_character,%arg_z_b)
@@ -1065,5 +1069,5 @@
 	__(shrq $1,%imm1)
 	__(movl %imm0_l,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)        
+	__(ret)        
 local_label(misc_set_s16):	
 	__(movq %arg_z,%imm0)
@@ -1078,5 +1082,5 @@
 	__(shrq $fixnumshift,%imm0)
 	__(movw %imm0_w,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_u16):
 	__(movq %arg_y,%imm1)
@@ -1086,5 +1090,5 @@
 	__(unbox_fixnum(%arg_z,%imm0))
 	__(movw %imm0_w,misc_data_offset(%arg_x,%imm1))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_set_invalid):
 	__(push $XSETBADVEC)
@@ -1100,6 +1104,6 @@
 	.globl C(ret1valn)
 __(tra(C(ret1valn)))
-	__(pop %ra0)
-	__(push %arg_z)
+        __(movq (%rsp),%ra0)
+        __(movq %arg_z,(%rsp))
 	__(set_nargs(1))
 	__(jmpq *%ra0)
@@ -1118,6 +1122,6 @@
 	__(cmovneq -node_size(%rsp,%nargs_q),%arg_z)
 	__(leaveq)
-	__(popq %ra0)
-	__(jmp *%ra0)
+        __(ret)
+
 	
 /* actually need to return values ; always need to copy   */
@@ -1155,6 +1159,6 @@
 
 _spentry(mkcatch1v)
-	__(Make_Catch(0))
-	__(jmp *%ra0)
+	__(nMake_Catch(0))
+	__(ret)
 _endsubp(mkcatch1v)
 
@@ -1164,10 +1168,26 @@
 	__(jmp *%ra0)
 _endsubp(mkunwind)
+        
+/* this takes a return address in %ra0; it's "new" in that it does the
+   double binding of *interrupt-level* out-of-line */
+_spentry(nmkunwind)
+	__(movq %rcontext:tcr.tlb_pointer,%arg_x)
+        __(movq INTERRUPT_LEVEL_BINDING_INDEX(%arg_x),%arg_y)
+	__(push %arg_y)
+	__(push $INTERRUPT_LEVEL_BINDING_INDEX)
+	__(push %rcontext:tcr.db_link)
+	__(movq %rsp,%rcontext:tcr.db_link)
+	__(movq $-1<<fixnumshift,INTERRUPT_LEVEL_BINDING_INDEX(%arg_x))
+	__(movq $undefined,%arg_z)
+	__(Make_Catch(fixnumone))
+        __(movq %arg_y,%arg_z)
+        __(jmp _SPbind_interrupt_level)
+_endsubp(nmkunwind)
 
 _spentry(mkcatchmv)
-	__(Make_Catch(fixnumone))
-	__(jmp *%ra0)
+	__(nMake_Catch(fixnumone))
+	__(ret)
 _endsubp(mkcatchmv)
-
+        
 _spentry(throw)
 	__(movq %rcontext:tcr.catch_top,%imm1)
@@ -1204,4 +1224,5 @@
 	__(jz local_label(_threw_one_value_dont_unbind))
 	__(lea local_label(_threw_one_value_dont_unbind)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPunbind_to)
 __(tra(local_label(_threw_one_value_dont_unbind)))
@@ -1233,5 +1254,6 @@
 	__(cmpq %imm0,%imm1)
 	__(je local_label(_threw_multiple_dont_unbind))
-	__(leaq local_label(_threw_multiple_dont_unbind)(%rip),%r10)
+	__(leaq local_label(_threw_multiple_dont_unbind)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPunbind_to)
 __(tra(local_label(_threw_multiple_dont_unbind)))
@@ -1285,4 +1307,5 @@
 	__(push %ra0)
 	__(leaq local_label(_nthrowv_back_from_unbind)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPunbind_to)
 __(tra(local_label(_nthrowv_back_from_unbind)))
@@ -1371,4 +1394,5 @@
 /* Ready to call cleanup code. set up tra, jmp to %xfn   */
 	__(leaq local_label(_nthrowv_called_cleanup)(%rip),%ra0)
+        __(push %ra0)
 	__(movb $0,%rcontext:tcr.unwinding)
 	__(jmp *%xfn)
@@ -1421,4 +1445,5 @@
 	__(push %ra0)
 	__(leaq local_label(_nthrow1v_back_from_unbind)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPunbind_to)
 __(tra(local_label(_nthrow1v_back_from_unbind)))
@@ -1479,4 +1504,5 @@
 	__(leaq local_label(_nthrow1v_called_cleanup)(%rip),%ra0)
 	__(movb $0,%rcontext:tcr.unwinding)
+        __(push %ra0)
 	__(jmp *%xfn)
 __(tra(local_label(_nthrow1v_called_cleanup)))
@@ -1522,4 +1548,5 @@
 	__(movq $XSYMNOBIND,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)	
 _endsubp(bind)
@@ -1552,4 +1579,5 @@
 9:	__(movq $XSYMNOBIND,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 _endsubp(bind_self)
@@ -1572,4 +1600,5 @@
 9:	__(movq $XSYMNOBIND,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 _endsubp(bind_nil)
@@ -1606,4 +1635,5 @@
 9:	__(movq $XSYMNOBIND,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 _endsubp(bind_self_boundp_check)
@@ -1720,5 +1750,5 @@
 /* setting the bit needs to be done atomically, unless we're sure that other  */
 /* threads are suspended.)  */
-/* We can unconditionally set the suspended thread's RIP to its RA0.  */
+/* We can unconditionally set the suspended thread's RIP to the return address.  */
 
 	
@@ -1729,5 +1759,5 @@
 	__(_rplaca(%arg_y,%arg_z))
         __(ja 1f)
-0:      __(jmp *%ra0)
+0:      __(repret)
 1:      __(movq %arg_y,%imm0)
         __(subq lisp_global(heap_start),%imm0)
@@ -1742,5 +1772,5 @@
         __(lock)
         __(btsq %imm0,(%temp0,%imm1,8))
-        __(jmp *%ra0)
+        __(ret)
 _endsubp(rplaca)
 
@@ -1751,5 +1781,5 @@
 	__(_rplacd(%arg_y,%arg_z))
         __(ja 1f)
-0:      __(jmp *%ra0)
+0:      __(repret)
 1:      __(movq %arg_y,%imm0)
         __(subq lisp_global(heap_start),%imm0)
@@ -1764,5 +1794,5 @@
         __(lock)
         __(btsq %imm0,(%temp0,%imm1,8))
-        __(jmp *%ra0)
+        __(ret)
 _endsubp(rplacd)
 
@@ -1776,5 +1806,5 @@
 	__(movq %arg_z,misc_data_offset(%arg_x,%arg_y))
         __(ja 1f)
-0:      __(jmp *%ra0)
+0:      __(repret)
 1:      __(lea misc_data_offset(%arg_x,%arg_y),%imm0)
         __(subq lisp_global(heap_start),%imm0)
@@ -1789,5 +1819,5 @@
         __(lock) 
         __(btsq %imm0,(%temp0,%imm1,8))
-        __(jmp *%ra0)                
+        __(ret)                
 _endsubp(gvset)
 
@@ -1803,5 +1833,5 @@
 	__(movq %arg_z,misc_data_offset(%arg_x,%arg_y))
         __(ja 1f)
-0:      __(jmp *%ra0)
+0:      __(repret)
 1:      __(lea misc_data_offset(%arg_x,%arg_y),%imm0)
         __(subq lisp_global(heap_start),%imm0)
@@ -1826,5 +1856,5 @@
         __(lock)
         __(btsq %imm0,(%temp0,%imm1,8))
-        __(jmp *%ra0)                
+        __(ret)                
 _endsubp(set_hash_key)
 
@@ -1863,7 +1893,7 @@
 C(egc_write_barrier_end):
 2:      __(movl $t_value,%arg_z_l)
-	__(jmp *%ra0)
+	__(ret)
 3:	__(movl $nil_value,%arg_z_l)
-	__(jmp *%ra0)
+	__(ret)
 _endsubp(store_node_conditional)
 				
@@ -1904,4 +1934,5 @@
 8:	__(movq $XIMPROPERLIST,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 9:	/* Whew 	  */
@@ -1922,5 +1953,5 @@
 	__(jne 2f)
 	__(TSP_Alloc_Fixed(2*node_size,%imm0))
-	__(jmp *%ra0)
+	__(ret)
 2:	__(movq %imm0,%imm1)
 	__(add %imm1,%imm1)
@@ -1952,5 +1983,5 @@
 	__(jne 3b)
 	__(movq %temp1,%rcontext:tcr.db_link)
-	__(jmp *%ra0)
+	__(ret)
 _endsubp(progvsave)
 
@@ -2016,5 +2047,5 @@
 	__(movq %imm0,tsp_frame.fixed_overhead(%temp0))
 	__(leaq tsp_frame.fixed_overhead+fulltag_misc(%temp0),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(stack_misc_alloc_heap_alloc_ivector):
         __(movq %rcontext:tcr.foreign_sp,%imm1)
@@ -2031,5 +2062,5 @@
 	__(movq %imm0,(%temp0))
 	__(leaq fulltag_misc(%temp0),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 local_label(stack_misc_alloc_heap_alloc_gvector):	
 	__(TSP_Alloc_Fixed(0,%imm0))
@@ -2074,4 +2105,5 @@
 
 _spentry(values)
+        __(movq (%temp0),%ra0)
 	__(ref_global(ret1val_addr,%imm1))
 	__(cmpq %imm1,%ra0)
@@ -2082,12 +2114,12 @@
 	__(cmovneq -node_size(%rsp,%nargs_q),%arg_z)
 	__(movq %temp0,%rsp)
-	__(jmp *%ra0)
-0:	__(movq (%temp0),%ra0)
-	__(lea node_size(%temp0),%temp0)
+	__(ret)
+0:	__(movq 8(%temp0),%ra0)
+        __(addq $2*node_size,%temp0)
 	__(lea (%rsp,%nargs_q),%imm0)
 	__(jmp 2f)
-1:	__(lea -node_size(%imm0),%imm0)
+1:	__(subq $node_size,%imm0)
 	__(movq (%imm0),%temp1)
-	__(lea -node_size(%temp0),%temp0)
+	__(subq $node_size,%temp0)
 	__(movq %temp1,(%temp0))
 2:	__(cmpq %imm0,%rsp)
@@ -2312,4 +2344,5 @@
 	__(movl $XBADKEYS,%arg_y_l)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 9:	__(jmp *%ra0)
@@ -2387,117 +2420,4 @@
 
 
-/* Prepend all but the first four (3 words of code, inner fn) and last   */
-/* (lfbits) elements of %fn to the "arglist".   */
-	
-_spentry(call_closure)
-        __(subq $fulltag_function-fulltag_misc,%fn)
-        __(vector_length(%fn,%imm0))
-       	__(movzwl %nargs,%nargs_l)
-	
-        __(subq $5<<fixnumshift,%imm0)  /* imm0 = inherited arg count   */
-        __(cmpw $nargregs<<fixnumshift,%nargs)
-        __(jna,pt local_label(no_insert))
-	
-/* Some arguments have already been pushed.  Push imm0's worth   */
-/* of NILs, copy those arguments that have already been vpushed from   */
-/* the old TOS to the new, then insert all of the inerited args   */
-/* and go to the function.  */
-	
-        __(movq %imm0,%imm1)
-local_label(push_nil_loop):     
-        __(push $nil_value)
-        __(sub $fixnumone,%imm1)
-        __(jne local_label(push_nil_loop))
-	
-/* Need to use arg regs as temporaries here.    */
-        __(movq %rsp,%temp1)
-        __(push %arg_z)
-        __(push %arg_y)
-        __(push %arg_x)
-        __(lea 3*node_size(%rsp,%imm0),%arg_x)
-        __(lea -nargregs<<fixnumshift(%nargs_q),%arg_y)
-local_label(copy_already_loop): 
-        __(movq (%arg_x),%arg_z)
-        __(addq $fixnumone,%arg_x)
-        __(movq %arg_z,(%temp1))
-        __(addq $fixnumone,%temp1)
-        __(subq $fixnumone,%arg_y)
-        __(jne local_label(copy_already_loop))
-	
-        __(movl $4<<fixnumshift,%imm1_l) /* skip code, new fn   */
-local_label(insert_loop):               
-        __(movq misc_data_offset(%fn,%imm1),%arg_z)
-        __(addq $node_size,%imm1)
-        __(addw $fixnum_one,%nargs)
-        __(subq $node_size,%arg_x)
-        __(movq %arg_z,(%arg_x))
-        __(subq $fixnum_one,%imm0)
-        __(jne local_label(insert_loop))
-
-        /* Recover the argument registers, pushed earlier   */
-        __(pop %arg_x)
-        __(pop %arg_y)
-        __(pop %arg_z)
-        __(jmp local_label(go))
-
-/* Here if nothing was pushed by the caller.  If we're  */
-/* going to push anything, we have to reserve a stack  */
-/* frame first. (We'll need to push something if the  */
-/* sum of %nargs and %imm0 is greater than nargregs)   */
-	
-local_label(no_insert):
-        __(lea (%nargs_q,%imm0),%imm1)
-        __(cmpq $nargregs<<fixnumshift,%imm1)
-        __(jna local_label(no_insert_no_frame))
-        /* Reserve space for a stack frame   */
-        __(push $reserved_frame_marker)
-        __(push $reserved_frame_marker)
-local_label(no_insert_no_frame):        
-	/* nargregs or fewer args were already vpushed.   */
-	/* if exactly nargregs, vpush remaining inherited vars.   */
-        __(cmpw $nargregs<<fixnumshift,%nargs)
-        __(movl $4<<fixnumshift,%imm1_l) /* skip code, new fn   */
-        __(leaq 4<<fixnumshift(%imm0),%temp1)
-        __(jnz local_label(set_regs))
-local_label(vpush_remaining):  
-        __(push misc_data_offset(%fn,%imm1))
-        __(addq $node_size,%imm1)
-        __(addw $fixnumone,%nargs)
-        __(subq $node_size,%imm0)
-        __(jnz local_label(vpush_remaining))
-        __(jmp local_label(go))
-local_label(set_regs):
-	/* if nargs was > 1 (and we know that it was < 3), it must have   */
-	/* been 2.  Set arg_x, then vpush the remaining args.   */
-        __(cmpw $fixnumone,%nargs)
-        __(jle local_label(set_y_z))
-local_label(set_arg_x): 
-        __(subq $node_size,%temp1)
-        __(movq misc_data_offset(%fn,%temp1),%arg_x)
-        __(addw $fixnumone,%nargs)
-        __(subq $fixnumone,%imm0)
-        __(jne local_label(vpush_remaining))
-        __(jmp local_label(go))
-	/* Maybe set arg_y or arg_z, preceding args   */
-local_label(set_y_z):
-        __(jne local_label(set_arg_z))
-	/* Set arg_y, maybe arg_x, preceding args   */
-local_label(set_arg_y): 
-        __(subq $node_size,%temp1)
-        __(movq misc_data_offset(%fn,%temp1),%arg_y)
-        __(addw $fixnumone,%nargs)
-        __(subq $fixnum_one,%imm0)
-        __(jnz local_label(set_arg_x))
-        __(jmp local_label(go))
-local_label(set_arg_z): 
-        __(subq $node_size,%temp1)
-        __(movq misc_data_offset(%fn,%temp1),%arg_z)
-        __(addw $fixnumone,%nargs)
-        __(subq $fixnum_one,%imm0)
-        __(jne local_label(set_arg_y))
-local_label(go):        
-        __(movq misc_data_offset+(3*node_size)(%fn),%fn)
-        __(jmp *%fn)                
-_endsubp(call_closure)
 
 _spentry(getxlong)
@@ -2548,4 +2468,5 @@
 	__(movq $XNOSPREAD,%arg_y)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 _endsubp(spreadargz)
@@ -2570,10 +2491,10 @@
 	__(lea (%rbp,%imm1),%rsp)
 	__(movq 8(%rbp),%ra0)
-	__(movq 0(%rbp),%rbp)
+	__(movq (%rbp),%rbp)
+        __(pushq %ra0)
 	__(do_funcall())
         /* All args in regs; exactly the same as the tfuncallvsp case   */
 9:		
 	__(leave)
-	__(pop %ra0)
 	__(do_funcall())
 _endsubp(tfuncallgen)
@@ -2594,5 +2515,6 @@
 	__(lea (%rbp,%imm1),%rsp)
 	__(movq 8(%rbp),%ra0)
-	__(movq 0(%rbp),%rbp)
+	__(movq (%rbp),%rbp)
+        __(push %ra0)
 	__(do_funcall())	
 _endsubp(tfuncallslide)
@@ -2601,5 +2523,4 @@
 _spentry(tfuncallvsp)
 	__(leave)
-	__(pop %ra0)
 	__(do_funcall())
 _endsubp(tfuncallvsp)
@@ -2621,10 +2542,10 @@
 	__(lea (%rbp,%imm1),%rsp)
 	__(movq 8(%rbp),%ra0)
-	__(movq 0(%rbp),%rbp)
+	__(movq (%rbp),%rbp)
+        __(pushq %ra0)
 	__(jump_fname())
 /* All args in regs; exactly the same as the tcallsymvsp case   */
 9:		
 	__(leave)
-	__(pop %ra0)
 	__(jump_fname())
 _endsubp(tcallsymgen)
@@ -2645,4 +2566,5 @@
 	__(movq 8(%rbp),%ra0)
 	__(movq 0(%rbp),%rbp)
+        __(pushq %ra0)
 	__(jump_fname())
 _endsubp(tcallsymslide)
@@ -2650,5 +2572,4 @@
 _spentry(tcallsymvsp)
 	__(leave)
-	__(pop %ra0)
 	__(jump_fname())
 _endsubp(tcallsymvsp)
@@ -2672,4 +2593,5 @@
 	__(movq lisp_frame.savera0(%rbp),%ra0)
 	__(movq lisp_frame.backlink(%rbp),%rbp)
+        __(pushq %ra0)
 	__(jmp *%fn)
 /* All args in regs; exactly the same as the tcallnfnvsp case   */
@@ -2677,5 +2599,4 @@
 	__(movq %temp0,%fn)
 	__(leave)
-	__(pop %ra0)
 	__(jmp *%fn)
 _endsubp(tcallnfngen)
@@ -2697,4 +2618,5 @@
 	__(movq lisp_frame.savera0(%rbp),%ra0)
 	__(movq lisp_frame.backlink(%rbp),%rbp)
+        __(pushq %ra0)
 	__(jmp *%fn)
 _endsubp(tcallnfnslide)
@@ -2703,5 +2625,4 @@
 	__(movq %temp0,%fn)
 	__(leave)
-	__(pop %ra0)
 	__(jmp *%fn)
 _endsubp(tcallnfnvsp)
@@ -2726,5 +2647,5 @@
 	__(movsd %fpzero,macptr.domain(%arg_z))
 	__(movsd %fpzero,macptr.type(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(movq %rcontext:tcr.foreign_sp,%imm1)
         __(subq $dnode_size,%rcontext:tcr.foreign_sp)
@@ -2756,5 +2677,5 @@
 2:	__(cmpq %imm0,%imm1)
 	__(jne 1b)		
-	__(jmp *%ra0)
+	__(repret)
 9:	__(movq %rcontext:tcr.foreign_sp,%imm1)
         __(subq $dnode_size,%rcontext:tcr.foreign_sp)
@@ -2783,5 +2704,5 @@
 	__(jge 0b)
 	__(movq %temp1,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 2:	__(TSP_Alloc_Fixed(0,%imm0))
 	__(jmp 4f)
@@ -2790,5 +2711,5 @@
 	__(jge 3b)
 	__(movq %temp1,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 _endsubp(makestacklist)
 
@@ -2859,5 +2780,5 @@
 	__(dnode_align(%imm1,node_size,%imm1))
 	__(Misc_Alloc(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 local_label(misc_alloc_not_u56):
 	__(uuo_error_reg_not_type(Rarg_y,error_object_not_unsigned_byte_56))
@@ -3053,4 +2974,5 @@
 	__(movq %whole_reg,%arg_z)
 	__(set_nargs(2))
+        __(push %ra0)
 	__(jmp _SPksignalerr)
 _endfn(C(destbind1))	
@@ -3066,4 +2988,5 @@
 	__(movq %whole_reg,%arg_z)
 	__(set_nargs(2))
+        __(push %ra0)        
 	__(jmp _SPksignalerr)
 _endsubp(macro_bind)
@@ -3097,5 +3020,5 @@
 	__(shr $num_subtag_bits,%imm0)
 	__(movslq misc_data_offset-4(%arg_z,%imm0,4),%imm0)
-8:	__(jmp *%ra0)
+8:	__(repret)
 9:	__(uuo_error_reg_not_type(Rarg_z,error_object_not_integer))
 _endsubp(integer_sign)
@@ -3258,5 +3181,4 @@
 
 _spentry(misc_alloc_init)
-	__(push %ra0)
 	__(push %rbp)
 	__(movq %rsp,%rbp)
@@ -3265,9 +3187,9 @@
 	__(movq %arg_x,%arg_y)
 	__(lea local_label(misc_alloc_init_back)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPmisc_alloc)
 __(tra(local_label(misc_alloc_init_back)))
 	__(pop %arg_y)
 	__(leave)
-	__(pop %ra0)
 	__(movq $nrs.init_misc,%fname)
 	__(set_nargs(2))
@@ -3276,5 +3198,4 @@
 
 _spentry(stack_misc_alloc_init)
-	__(push %ra0)
 	__(push %rbp)
 	__(movq %rsp,%rbp)
@@ -3283,9 +3204,9 @@
 	__(movq %arg_x,%arg_y)
 	__(lea local_label(stack_misc_alloc_init_back)(%rip),%ra0)
+        __(push %ra0)
 	__(jmp _SPstack_misc_alloc)
 __(tra(local_label(stack_misc_alloc_init_back)))
 	__(pop %arg_y)
 	__(leave)
-	__(pop %ra0)
 	__(movq $nrs.init_misc,%fname)
 	__(set_nargs(2))
@@ -3299,6 +3220,5 @@
 C(popj):
 	__(leave)
-	__(pop %ra0)
-	__(jmp *%ra0)
+        __(ret)
 _endsubp(popj)
 
@@ -3311,5 +3231,5 @@
 	__(jne 1f)
 	__(sarq $fixnumshift,%imm0)
-	__(jmp *%ra0)
+	__(ret)
 1:	__(andb $tagmask,%imm0_b)
 	__(cmpb $tag_misc,%imm0_b)
@@ -3326,9 +3246,9 @@
 	__(testq %imm0,%imm0)
 	__(js 9f)
-	__(jmp *%ra0)
+	__(repret)
 3:	__(movq misc_data_offset(%arg_z),%imm0)
 	__(cmpl $0,misc_data_offset+8(%arg_z))
 	__(jne 9f)
-	__(jmp *%ra0)
+	__(repret)
 9:	__(uuo_error_reg_not_type(Rarg_z,error_object_not_u64))
 _endsubp(getu64)
@@ -3350,5 +3270,5 @@
 	__(movq misc_data_offset(%arg_z),%imm0)
 	__(jne 9f)
-8:	__(jmp *%ra0)
+8:	__(repret)
 9:	__(uuo_error_reg_not_type(Rarg_z,error_object_not_u64))
 _endsubp(gets64)
@@ -3370,10 +3290,10 @@
 	__(Misc_Alloc(%arg_z))
 	__(movq %mm0,misc_data_offset(%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 3:	__(movl $three_digit_bignum_header,%imm0_l)
 	__(movl $aligned_bignum_size(3),%imm1_l)
 	__(Misc_Alloc(%arg_z))
 	__(movq %mm0,misc_data_offset(%arg_z))
-9:	__(jmp *%ra0)
+9:	__(repret)
 _endsubp(makeu64)
 
@@ -3390,5 +3310,5 @@
 	__(jne 8f)
 7:	__(movq symbol.vcell(%arg_y),%arg_z)
-8:	__(jmp *%ra0)		
+8:	__(repret)		
 _endsubp(specref)
 
@@ -3403,5 +3323,5 @@
 	__(je 1f)
 	__(movq %arg_z,(%imm1,%imm0))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(lea fulltag_misc-fulltag_symbol(%arg_y),%arg_x)
 	__(movq $1<<fixnumshift,%arg_y)
@@ -3422,5 +3342,5 @@
 	__(jne,pt 9f)
 	__(uuo_error_reg_unbound(Rarg_y))
-9:	__(jmp *%ra0)		
+9:	__(repret)		
 _endsubp(specrefcheck)
 
@@ -3457,5 +3377,5 @@
 	__(movq %arg_y,(%arg_x,%temp1))
 	__(movq %imm1,%rcontext:tcr.db_link)
-	__(jmp *%ra0)	
+	__(ret)	
 _endsubp(unbind)
 
@@ -3471,5 +3391,5 @@
 	__(jne 1b)
 	__(movq %imm1,%rcontext:tcr.db_link)
-	__(jmp *%ra0)	
+	__(ret)	
 _endsubp(unbind_n)
 
@@ -3485,5 +3405,5 @@
 	__(jne 1b)
 	__(movq %imm1,%rcontext:tcr.db_link)
-	__(jmp *%ra0)	
+	__(ret)	
 _endsubp(unbind_to)
 
@@ -3548,9 +3468,9 @@
  	__(movq %imm1,%rcontext:tcr.db_link)
 	__(js,pn 1f)
-0:	__(jmp *%ra0)
+0:	__(repret)
 1:	__(testq %temp0,%temp0)
 	__(js 0b)
 	__(check_pending_enabled_interrupt(2f))
-2:	__(jmp *%ra0)	
+2:	__(repret)	
 _endsubp(unbind_interrupt_level)
 
@@ -3562,5 +3482,5 @@
 	__(shrq $fixnumshift,%imm0)
 	__(jne _SPunbind_n)
-	__(jmp *%ra0)
+	__(repret)
 _endsubp(progvrestore)
 	
@@ -3575,5 +3495,5 @@
 	__(addq %arg_y,%arg_z)
 	__(jo,pn C(fix_one_bit_overflow))
-	__(jmp *%ra0)
+	__(repret)
 1:	__(jump_builtin(_builtin_plus,2))
 _endsubp(builtin_plus)
@@ -3590,5 +3510,5 @@
 	__(subq %arg_y,%arg_z)
 	__(jo,pn C(fix_one_bit_overflow))
-	__(jmp *%ra0)
+	__(repret)
 1:	__(jump_builtin(_builtin_minus,2))
 _endsubp(builtin_minus)
@@ -3607,5 +3527,5 @@
 	__(jo 1f)
 	__(mov %imm0,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 1:	__(unbox_fixnum(%arg_z,%imm0))
 	__(unbox_fixnum(%arg_y,%imm1))
@@ -3626,5 +3546,5 @@
 	__(rcmpq(%arg_z,%arg_y))
 	__(condition_to_boolean(e,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_eq,2))
 _endsubp(builtin_eq)
@@ -3638,5 +3558,5 @@
 	__(rcmpq(%arg_z,%arg_y))
 	__(condition_to_boolean(ne,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_ne,2))
 _endsubp(builtin_ne)
@@ -3650,5 +3570,5 @@
 	__(rcmpq(%arg_y,%arg_z))
 	__(condition_to_boolean(g,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_gt,2))
 _endsubp(builtin_gt)
@@ -3662,5 +3582,5 @@
 	__(rcmpq(%arg_y,%arg_z))
 	__(condition_to_boolean(ge,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_ge,2))
 _endsubp(builtin_ge)
@@ -3674,5 +3594,5 @@
 	__(rcmpq(%arg_y,%arg_z))
 	__(condition_to_boolean(l,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_lt,2))
 _endsubp(builtin_lt)
@@ -3686,5 +3606,5 @@
 	__(rcmpq(%arg_y,%arg_z))
 	__(condition_to_boolean(le,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_le,2))
 _endsubp(builtin_le)
@@ -3707,7 +3627,7 @@
 	__(jump_builtin(_builtin_eql,2))
 1:	__(movl $t_value,%arg_z_l)
-	__(jmp *%ra0)
+	__(ret)
 2:	__(movl $nil_value,%arg_z_l)
-	__(jmp *%ra0)	
+	__(ret)	
 _endsubp(builtin_eql)
 
@@ -3725,20 +3645,20 @@
 	__(movq %arg_z,%arg_y)
 	__(vector_length(%arg_y,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	/* vector header   */
 	__(movq vectorH.logsize(%arg_z),%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 2:	/* list.  Maybe null, maybe dotted or circular.   */
-	__(movq $-fixnumone,%temp2)
+	__(movq $-fixnumone,%imm2)
 	__(movq %arg_z,%temp0)	/* fast pointer   */
 	__(movq %arg_z,%temp1)  /* slow pointer   */
 3:	__(extract_lisptag(%temp0,%imm0))	
 	__(compare_reg_to_nil(%temp0))
-	__(leaq fixnumone(%temp2),%temp2)
+	__(leaq fixnumone(%imm2),%imm2)
 	__(je 9f)
 	__(cmpb $tag_list,%imm0_b)
 	__(jne 8f)
 	__(extract_lisptag(%temp1,%imm1))
-	__(testb $fixnumone,%temp2_b)
+	__(testb $fixnumone,%imm2_b)
 	__(_cdr(%temp0,%temp0))
 	__(je 3b)
@@ -3751,6 +3671,6 @@
 	__(jump_builtin(_builtin_length,1))
 9:	
-	__(movq %temp2,%arg_z)
-	__(jmp *%ra0)		
+	__(movq %imm2,%arg_z)
+	__(ret)		
 _endsubp(builtin_length)
 
@@ -3766,7 +3686,7 @@
 	__(jb 2f)
 	__(movl $nil_value,%arg_z_l)
-	__(jmp *%ra0)
+	__(ret)
 1:	__(movl $t_value,%arg_z_l)
-	__(jmp *%ra0)
+	__(ret)
 2:	
 	__(jump_builtin(_builtin_seqtype,1))
@@ -3794,8 +3714,8 @@
 	__(jnz 4f)
 	__(movq %arg_x,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 4:	__(cmpb $fulltag_nil,%arg_z_b)
 5:	__(jnz 1b)
-	__(jmp *%ra0)			
+	__(repret)			
 _endsubp(builtin_assq)	
 
@@ -3815,5 +3735,5 @@
 	__(movq %temp0,%arg_z)
 3:	__(jnz 1b)
-4:	__(jmp *%ra0)				
+4:	__(repret)				
 _endsubp(builtin_memq)
 
@@ -3837,5 +3757,5 @@
 	__(bt %imm0,%arg_z)
 	__(condition_to_boolean(b,%imm0,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jump_builtin(_builtin_logbitp,2))
 _endsubp(builtin_logbitp)
@@ -3847,5 +3767,5 @@
 	__(jne 1f)
 	__(orq %arg_y,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 1:	
 	__(jump_builtin(_builtin_logior,2))
@@ -3859,5 +3779,5 @@
 	__(jne 1f)
 	__(andq %arg_y,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 1:		
 	__(jump_builtin(_builtin_logand,2))
@@ -3869,5 +3789,5 @@
 	__(negq %arg_z)
 	__(jo,pn C(fix_one_bit_overflow))
-	__(jmp *%ra0)
+	__(repret)
 1:		
 	__(jump_builtin(_builtin_negate,1))	
@@ -3880,5 +3800,5 @@
 	__(jne 1f)
 	__(xorq %arg_y,%arg_z)
-	__(jmp *%ra0)
+	__(ret)
 1:		
 	__(jump_builtin(_builtin_logxor,2))
@@ -3894,8 +3814,4 @@
 _endsubp(builtin_aset1)
 
-/* We have to be a little careful here	%cl has to be used for  */
-/*   the (unboxed) shift count in all variable-length shifts, and  */
-/*   %temp2 = %rcx.  Zero all but the low 8 (or 6) bits of %rcx,  */
-/*   so that the shift count doesn't confuse the GC.  */
 
 _spentry(builtin_ash)
@@ -3909,5 +3825,5 @@
 	__(jnz 1f)
 	__(movq %arg_y,%arg_z)	/* shift by 0   */
-	__(jmp *%ra0)
+	__(ret)
 1:	__(jns 3f)
 	__(rcmpq(%imm0,$-63))
@@ -3915,12 +3831,11 @@
 	__(sar $63,%imm1)
 	__(box_fixnum(%imm1,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 2:	/* Right-shift by small fixnum   */
 	__(negb %imm0_b)
 	__(movzbl %imm0_b,%ecx)
 	__(sar %cl,%imm1)
-	__(xorl %ecx,%ecx)
 	__(box_fixnum(%imm1,%arg_z))
-	__(jmp *%ra0)
+	__(ret)
 3:      /* Left shift by fixnum. We cant shift by more than 63 bits, though  */
 	/* shifting by 64 is actually easy.   */
@@ -3938,9 +3853,7 @@
 	__(shld %cl,%imm0,%imm1)
 	__(shl %cl,%imm0)
-	__(xorb %cl,%cl)
 	__(jmp C(makes128))
 5:	__(shld %cl,%imm0,%imm1)
 	__(shl %cl,%imm0)
-	__(xorb %cl,%cl)
 	__(jmp C(makes128))
 9:	
@@ -3987,4 +3900,6 @@
 0:              
 	/* Save lisp registers   */
+        __(push %rbp)
+	__(movq %rsp,%rbp)
 	__(push %temp0)
 	__(push %temp1)
@@ -3996,9 +3911,6 @@
 	__(push %save1)
 	__(push %save2)
-	__(push %save3)
+	__(push %save3)         /* 10 registers pushed after %rbp */
 	__(push %fn)
-	__(push %ra0)
-	__(push %rbp)
-	__(movq %rsp,%rbp)
 	__(movq %rsp,%rcontext:tcr.save_vsp)
         __(movq %rbp,%rcontext:tcr.save_rbp)
@@ -4059,5 +3971,4 @@
 	__(clr %temp0)
 	__(clr %fn)
-	__(clr %ra0)
 	__(pxor %fpzero,%fpzero)
         /* Darwin's math library seems to be pretty casual
@@ -4070,6 +3981,5 @@
 	__(movq $TCR_STATE_LISP,%rcontext:tcr.valence)
 	__(movq %rcontext:tcr.save_vsp,%rsp)
-	__(pop %rbp)
-	__(pop %ra0)
+        __(movq %rcontext:tcr.save_rbp,%rbp)
 	__(pop %fn)
 	__(pop %save3)
@@ -4085,5 +3995,6 @@
 	__(check_pending_interrupt(%temp0))
 	__(pop %temp0)
-	__(jmp *%ra0)
+        __(leave)
+	__(ret)
 _endsubp(ffcall)
 
@@ -4097,4 +4008,6 @@
 0:              
 	/* Save lisp registers   */
+        __(push %rbp)
+        __(movq %rsp,%rbp)
 	__(push %temp0)
 	__(push %temp1)
@@ -4109,7 +4022,4 @@
         __(movq macptr.address(%arg_y),%rbx)  /* %rbx non-volatile */
 	__(push %fn)
-	__(push %ra0)
-	__(push %rbp)
-	__(movq %rsp,%rbp)
 	__(movq %rsp,%rcontext:tcr.save_vsp)
         __(movq %rbp,%rcontext:tcr.save_rbp)
@@ -4174,5 +4084,4 @@
 	__(clr %temp0)
 	__(clr %fn)
-	__(clr %ra0)
 	__(pxor %fpzero,%fpzero)
         /* Darwin's math library seems to be pretty casual
@@ -4185,6 +4094,5 @@
 	__(movq $TCR_STATE_LISP,%rcontext:tcr.valence)
 	__(movq %rcontext:tcr.save_vsp,%rsp)
-	__(pop %rbp)
-	__(pop %ra0)
+        __(movq %rcontext:tcr.save_rbp,%rbp)
 	__(pop %fn)
 	__(pop %save3)
@@ -4200,9 +4108,12 @@
 	__(check_pending_interrupt(%temp0))
 	__(pop %temp0)
-	__(jmp *%ra0)
+        __(leave)
+        __(ret)
 _endsubp(ffcall_returning_registers)
         
 _spentry(syscall)
 	/* Save lisp registers   */
+	__(push %rbp)
+	__(movq %rsp,%rbp)
 	__(push %temp0)
 	__(push %temp1)
@@ -4216,8 +4127,6 @@
 	__(push %save3)
 	__(push %fn)
-	__(push %ra0)
-	__(push %rbp)
-	__(movq %rsp,%rbp)
 	__(movq %rsp,%rcontext:tcr.save_vsp)
+        __(movq %rbp,%rcontext:tcr.save_rbp)
         __(movq %rcontext:tcr.foreign_sp,%rsp)
 	__(movq $TCR_STATE_FOREIGN,%rcontext:tcr.valence)
@@ -4251,10 +4160,8 @@
 	__(clr %temp0)
 	__(clr %fn)
-	__(clr %ra0)
 	__(pxor %fpzero,%fpzero)
 	__(movq $TCR_STATE_LISP,%rcontext:tcr.valence)
 	__(movq %rcontext:tcr.save_vsp,%rsp)
-	__(pop %rbp)
-	__(pop %ra0)
+        __(movq %rcontext:tcr.save_rbp,%rbp)
 	__(pop %fn)
 	__(pop %save3)
@@ -4269,5 +4176,6 @@
 	__(check_pending_interrupt(%temp0))
 	__(pop %temp0)
-	__(jmp *%ra0)
+        __(leave)
+	__(ret)
 _endsubp(syscall)		
 
@@ -4405,5 +4313,4 @@
 	__(clr %temp0)
 	__(clr %fn)
-	__(clr %ra0)
 	__(pxor %fpzero,%fpzero)
 	__(movq $TCR_STATE_LISP,%rcontext:tcr.valence)
@@ -4416,6 +4323,7 @@
         __(movq %rcontext:tcr.save_rbp,%rbp)
 	__(movq $nrs.callbacks,%fname)
+	__(lea local_label(back_from_callback)(%rip),%ra0)
 	__(set_nargs(2))
-	__(lea local_label(back_from_callback)(%rip),%ra0)
+        __(push %ra0)
 	__(jump_fname())
 __(tra(local_label(back_from_callback)))
@@ -4604,5 +4512,154 @@
         __(jmp 8b)
 _endsubp(aset3)
+
         
+
+
+/* Prepend all but the first five (4 words of code, inner fn) and last   */
+/* (lfbits) elements of %fn to the "arglist".   */
+	
+_spentry(call_closure)
+        new_local_labels()
+        __(subq $fulltag_function-fulltag_misc,%fn)
+        __(vector_length(%fn,%imm0))
+       	__(movzwl %nargs,%nargs_l)
+	
+        __(subq $6<<fixnumshift,%imm0)  /* imm0 = inherited arg count   */
+        __(lea (%nargs_q,%imm0),%imm1)
+        __(cmpw $nargregs<<fixnumshift,%imm1_w)
+        __(jna,pt local_label(regs_only))
+        __(pop %ra0)
+        __(cmpw $nargregs<<fixnumshift,%nargs)
+        __(jna,pt local_label(no_insert))
+	
+/* Some arguments have already been pushed.  Push imm0's worth   */
+/* of NILs, copy those arguments that have already been vpushed from   */
+/* the old TOS to the new, then insert all of the inerited args   */
+/* and go to the function.  */
+	
+        __(movq %imm0,%imm1)
+local_label(push_nil_loop):     
+        __(push $nil_value)
+        __(sub $fixnumone,%imm1)
+        __(jne local_label(push_nil_loop))
+	
+/* Need to use arg regs as temporaries here.    */
+        __(movq %rsp,%temp1)
+        __(push %arg_z)
+        __(push %arg_y)
+        __(push %arg_x)
+        __(lea 3*node_size(%rsp,%imm0),%arg_x)
+        __(lea -nargregs<<fixnumshift(%nargs_q),%arg_y)
+local_label(copy_already_loop): 
+        __(movq (%arg_x),%arg_z)
+        __(addq $fixnumone,%arg_x)
+        __(movq %arg_z,(%temp1))
+        __(addq $fixnumone,%temp1)
+        __(subq $fixnumone,%arg_y)
+        __(jne local_label(copy_already_loop))
+	
+        __(movl $5<<fixnumshift,%imm1_l) /* skip code, new fn   */
+local_label(insert_loop):               
+        __(movq misc_data_offset(%fn,%imm1),%arg_z)
+        __(addq $node_size,%imm1)
+        __(addw $fixnum_one,%nargs)
+        __(subq $node_size,%arg_x)
+        __(movq %arg_z,(%arg_x))
+        __(subq $fixnum_one,%imm0)
+        __(jne local_label(insert_loop))
+
+        /* Recover the argument registers, pushed earlier   */
+        __(pop %arg_x)
+        __(pop %arg_y)
+        __(pop %arg_z)
+        __(jmp local_label(go))
+
+/* Here if nothing was pushed by the caller.  If we're  */
+/* going to push anything, we have to reserve a stack  */
+/* frame first. (We'll need to push something if the  */
+/* sum of %nargs and %imm0 is greater than nargregs)   */
+	
+local_label(no_insert):
+        __(lea (%nargs_q,%imm0),%imm1)
+        __(cmpq $nargregs<<fixnumshift,%imm1)
+        __(jna local_label(no_insert_no_frame))
+        /* Reserve space for a stack frame   */
+        __(push $reserved_frame_marker)
+        __(push $reserved_frame_marker)
+local_label(no_insert_no_frame):        
+	/* nargregs or fewer args were already vpushed.   */
+	/* if exactly nargregs, vpush remaining inherited vars.   */
+        __(cmpw $nargregs<<fixnumshift,%nargs)
+        __(movl $5<<fixnumshift,%imm1_l) /* skip code, new fn   */
+        __(leaq 5<<fixnumshift(%imm0),%temp1)
+        __(jnz local_label(set_regs))
+local_label(vpush_remaining):  
+        __(push misc_data_offset(%fn,%imm1))
+        __(addq $node_size,%imm1)
+        __(addw $fixnumone,%nargs)
+        __(subq $node_size,%imm0)
+        __(jnz local_label(vpush_remaining))
+        __(jmp local_label(go))
+local_label(set_regs):
+	/* if nargs was > 1 (and we know that it was < 3), it must have   */
+	/* been 2.  Set arg_x, then vpush the remaining args.   */
+        __(cmpw $fixnumone,%nargs)
+        __(jle local_label(set_y_z))
+local_label(set_arg_x): 
+        __(subq $node_size,%temp1)
+        __(movq misc_data_offset(%fn,%temp1),%arg_x)
+        __(addw $fixnumone,%nargs)
+        __(subq $fixnumone,%imm0)
+        __(jne local_label(vpush_remaining))
+        __(jmp local_label(go))
+	/* Maybe set arg_y or arg_z, preceding args   */
+local_label(set_y_z):
+        __(jne local_label(set_arg_z))
+	/* Set arg_y, maybe arg_x, preceding args   */
+local_label(set_arg_y): 
+        __(subq $node_size,%temp1)
+        __(movq misc_data_offset(%fn,%temp1),%arg_y)
+        __(addw $fixnumone,%nargs)
+        __(subq $fixnum_one,%imm0)
+        __(jnz local_label(set_arg_x))
+        __(jmp local_label(go))
+local_label(set_arg_z): 
+        __(subq $node_size,%temp1)
+        __(movq misc_data_offset(%fn,%temp1),%arg_z)
+        __(addw $fixnumone,%nargs)
+        __(subq $fixnum_one,%imm0)
+        __(jne local_label(set_arg_y))
+local_label(go):        
+        __(movq misc_data_offset+(4*node_size)(%fn),%fn)
+        __(push %ra0)
+        __(jmp *%fn)
+local_label(regs_only):
+        __(leaq 5<<fixnumshift(%imm0),%temp1)
+        __(testw %nargs,%nargs)
+        __(jne local_label(some_args))
+        __(cmpw $node_size,%imm0)
+        __(movq misc_data_offset-node_size(%fn,%temp1),%arg_z)
+        __(je local_label(rgo))
+        __(cmpw $2*node_size,%imm0)
+        __(movq misc_data_offset-(node_size*2)(%fn,%temp1),%arg_y)
+        __(je local_label(rgo))
+        __(movq misc_data_offset-(node_size*3)(%fn,%temp1),%arg_x)
+local_label(rgo):
+        __(addw %imm0_w,%nargs)
+        __(jmp *misc_data_offset+(4*node_size)(%fn))
+local_label(some_args):         
+        __(cmpw $2*node_size,%nargs)
+        __(jz local_label(rtwo))
+        /* One arg was passed, could be one or two inherited args */
+        __(cmpw $node_size,%imm0)
+        __(movq misc_data_offset-node_size(%fn,%temp1),%arg_y)
+        __(je local_label(rgo))
+        __(movq misc_data_offset-(node_size*2)(%fn,%temp1),%arg_x)
+        __(jmp local_label(rgo))
+local_label(rtwo):     
+        __(movq misc_data_offset-node_size(%fn,%temp1),%arg_x)
+        __(jmp local_label(rgo))
+_endsubp(call_closure)
+                                        
         
 _spentry(poweropen_callbackX)
