Index: /trunk/source/lisp-kernel/x86-macros.s
===================================================================
--- /trunk/source/lisp-kernel/x86-macros.s	(revision 8241)
+++ /trunk/source/lisp-kernel/x86-macros.s	(revision 8242)
@@ -20,26 +20,26 @@
                         		
 define([ref_global],[
-	mov lisp_global($1),$2
+	__(mov lisp_global($1),$2)
 ])
 
 define([set_global],[
-	mov $1,lisp_global($2)
+	__(mov $1,lisp_global($2))
 ])
 
 define([ref_nrs_value],[
-	mov nrs.$1+symbol.vcell,$2
+	__(mov nrs.$1+symbol.vcell,$2)
 ])
 	
 define([set_nrs_value],[
-	mov $1,nrs.$2+symbol.vcell
+	__(mov $1,nrs.$2+symbol.vcell)
 ])
 							
 define([unbox_fixnum],[
-	mov $1,$2
-	sar [$]fixnumshift,$2
+	__(mov $1,$2)
+	__(sar [$]fixnumshift,$2)
 ])
 
 define([box_fixnum],[
-        imulq [$]fixnumone,$1,$2
+        __(imulq [$]fixnumone,$1,$2)
 ])	
 
@@ -47,53 +47,7 @@
 /* box_fixnum, with no effect on flags */
 define([box_fixnum_no_flags],[
-        leaq (,$1,8),$2
+        __(leaq (,$1,8),$2)
 ])
                                 
-define([save_node_regs],[
-	push %arg_z
-	push %arg_y
-	push %arg_x
-	push %temp0
-	push %temp1
-	push %temp2
-	push %save0
-	push %save1
-	push %save2
-	push %save3
-	push %ra0
-	push %fn
-])
-
-/* This needs to be done before we transition back to the lisp stack  */
-/* from the foreign stack.   */
-		
-define([zero_node_regs],[
-	xor %fn,%fn
-	mov %fn,%ra0
-	mov %fn,%save3
-	mov %fn,%save2
-	mov %fn,%save1
-	mov %fn,%save0
-	mov %fn,%temp2
-	mov %fn,%temp1
-	mov %fn,%temp0
-	mov %fn,%arg_x
-	mov %fn,%arg_y
-	mov %fn,arg_z
-])	
-define([restore_node_regs],[
-	pop %fn
-	pop %ra0
-	pop %save3
-	pop %save2
-	pop %save1
-	pop %save0
-	pop %temp2
-	pop %temp1
-	pop %temp0
-	pop %arg_x
-	pop %arg_y
-	pop %arg_z
-])	
 
 /* Zero $3 bytes worth of dnodes, starting at offset $2 relative  */
@@ -104,6 +58,6 @@
 	.macro zero_dnodes
 	.if $2
-	movapd %fpzero,$1($0)
-	zero_dnodes $0,$1+dnode_size,$2-dnode_size
+	__(movapd %fpzero,$1($0))
+	__(zero_dnodes $0,$1+dnode_size,$2-dnode_size)
 	.endif
 	.endmacro
@@ -111,5 +65,5 @@
 	.macro zero_dnodes base,disp,nbytes
 	.ifgt \nbytes
-	movapd %fpzero,\disp(\base)
+	__(movapd %fpzero,\disp(\base))
 	zero_dnodes \base,"\disp+dnode_size","\nbytes-dnode_size"
 	.endif
@@ -123,11 +77,11 @@
 define([TSP_Alloc_Fixed],[
 	define([TSP_Alloc_Size],[((($1+node_size) & ~(dnode_size-1))+dnode_size)])
-	subq [$]TSP_Alloc_Size,%rcontext:tcr.next_tsp
-        movq %rcontext:tcr.save_tsp,%stack_temp
-        movq %rcontext:tcr.next_tsp,$2
+	__(subq [$]TSP_Alloc_Size,%rcontext:tcr.next_tsp)
+        __(movq %rcontext:tcr.save_tsp,%stack_temp)
+        __(movq %rcontext:tcr.next_tsp,$2)
 	zero_dnodes $2,0,TSP_Alloc_Size
-	movq %stack_temp,($2)
-        movq %rbp,tsp_frame.save_rbp($2)
-        movq $2,%rcontext:tcr.save_tsp
+	__(movq %stack_temp,($2))
+        __(movq %rbp,tsp_frame.save_rbp($2))
+        __(movq $2,%rcontext:tcr.save_tsp)
 	undefine([TSP_Alloc_Size])
 ])
@@ -139,19 +93,19 @@
 	new_macro_labels()
         subq $1,%rcontext:tcr.next_tsp
-        movq %rcontext:tcr.save_tsp,%stack_temp
-        movq %rcontext:tcr.next_tsp,$2
-	jmp macro_label(test)
+        __(movq %rcontext:tcr.save_tsp,%stack_temp)
+        __(movq %rcontext:tcr.next_tsp,$2)
+	__(jmp macro_label(test))
 macro_label(loop):
-	movapd %fpzero,0($2)
-	addq $dnode_size,$2
+	__(movapd %fpzero,0($2))
+	__(addq $dnode_size,$2)
 macro_label(test):	
-	subq $dnode_size,$1
-	jge macro_label(loop)
-        movq %rcontext:tcr.next_tsp,$2
-	movd %stack_temp,$1
-	movq $1,($2)
-        movq %rbp,tsp_frame.save_rbp($2)
-        movq $2,%rcontext:tcr.save_tsp
-	addq $dnode_size,$2
+	__(subq $dnode_size,$1)
+	__(jge macro_label(loop))
+        __(movq %rcontext:tcr.next_tsp,$2)
+	__(movd %stack_temp,$1)
+	__(movq $1,($2))
+        __(movq %rbp,tsp_frame.save_rbp($2))
+        __(movq $2,%rcontext:tcr.save_tsp)
+	__(addq $dnode_size,$2)
 ])
 	
@@ -160,6 +114,6 @@
 define([Allocate_Catch_Frame],[
 	TSP_Alloc_Fixed(catch_frame.size,$1)
-	movq [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1)
-	addq [$]dnode_size+fulltag_misc,$1
+	__(movq [$](catch_frame.element_count<<subtag_shift)|subtag_catch_frame,dnode_size($1))
+	__(addq [$]dnode_size+fulltag_misc,$1)
 ])
 
@@ -168,45 +122,45 @@
 define([Make_Catch],[
 	Allocate_Catch_Frame(%imm2)
-	movq %rcontext:tcr.catch_top,%imm0
-	movq %rcontext:tcr.db_link,%imm1
-	movq %arg_z,catch_frame.catch_tag(%imm2)
-	movq %imm0,catch_frame.link(%imm2)
-	movq [$]$1,catch_frame.mvflag(%imm2)
-	movq %rcontext:tcr.xframe,%imm0
-	movq %rsp,catch_frame.rsp(%imm2)
-	movq %rbp,catch_frame.rbp(%imm2)
-        movq %rcontext:tcr.foreign_sp,%stack_temp
-	movq %imm1,catch_frame.db_link(%imm2)
-	movq %save3,catch_frame._save3(%imm2)
-	movq %save2,catch_frame._save2(%imm2)
-	movq %save1,catch_frame._save1(%imm2)
-	movq %save0,catch_frame._save0(%imm2)
-	movq %imm0,catch_frame.xframe(%imm2)
-	movq %stack_temp,catch_frame.foreign_sp(%imm2)
-	movq %xfn,catch_frame.pc(%imm2)
-	movq %imm2,%rcontext:tcr.catch_top
+	__(movq %rcontext:tcr.catch_top,%imm0)
+	__(movq %rcontext:tcr.db_link,%imm1)
+	__(movq %arg_z,catch_frame.catch_tag(%imm2))
+	__(movq %imm0,catch_frame.link(%imm2))
+	__(movq [$]$1,catch_frame.mvflag(%imm2))
+	__(movq %rcontext:tcr.xframe,%imm0)
+	__(movq %rsp,catch_frame.rsp(%imm2))
+	__(movq %rbp,catch_frame.rbp(%imm2))
+        __(movq %rcontext:tcr.foreign_sp,%stack_temp)
+	__(movq %imm1,catch_frame.db_link(%imm2))
+	__(movq %save3,catch_frame._save3(%imm2))
+	__(movq %save2,catch_frame._save2(%imm2))
+	__(movq %save1,catch_frame._save1(%imm2))
+	__(movq %save0,catch_frame._save0(%imm2))
+	__(movq %imm0,catch_frame.xframe(%imm2))
+	__(movq %stack_temp,catch_frame.foreign_sp(%imm2))
+	__(movq %xfn,catch_frame.pc(%imm2))
+	__(movq %imm2,%rcontext:tcr.catch_top)
 ])	
 
 define([nMake_Catch],[
 	Allocate_Catch_Frame(%imm2)
-	movq %rcontext:tcr.catch_top,%imm0
-	movq %rcontext:tcr.db_link,%imm1
-	movq %arg_z,catch_frame.catch_tag(%imm2)
-	movq %imm0,catch_frame.link(%imm2)
-        lea node_size(%rsp),%imm0
-	movq [$]$1,catch_frame.mvflag(%imm2)
-	movq %imm0,catch_frame.rsp(%imm2)
-	movq %rcontext:tcr.xframe,%imm0
-	movq %rbp,catch_frame.rbp(%imm2)
-        movq %rcontext:tcr.foreign_sp,%stack_temp
-	movq %imm1,catch_frame.db_link(%imm2)
-	movq %save3,catch_frame._save3(%imm2)
-	movq %save2,catch_frame._save2(%imm2)
-	movq %save1,catch_frame._save1(%imm2)
-	movq %save0,catch_frame._save0(%imm2)
-	movq %imm0,catch_frame.xframe(%imm2)
-	movq %stack_temp,catch_frame.foreign_sp(%imm2)
-	movq %xfn,catch_frame.pc(%imm2)
-	movq %imm2,%rcontext:tcr.catch_top
+	__(movq %rcontext:tcr.catch_top,%imm0)
+	__(movq %rcontext:tcr.db_link,%imm1)
+	__(movq %arg_z,catch_frame.catch_tag(%imm2))
+	__(movq %imm0,catch_frame.link(%imm2))
+        __(lea node_size(%rsp),%imm0)
+	__(movq [$]$1,catch_frame.mvflag(%imm2))
+	__(movq %imm0,catch_frame.rsp(%imm2))
+	__(movq %rcontext:tcr.xframe,%imm0)
+	__(movq %rbp,catch_frame.rbp(%imm2))
+        __(movq %rcontext:tcr.foreign_sp,%stack_temp)
+	__(movq %imm1,catch_frame.db_link(%imm2))
+	__(movq %save3,catch_frame._save3(%imm2))
+	__(movq %save2,catch_frame._save2(%imm2))
+	__(movq %save1,catch_frame._save1(%imm2))
+	__(movq %save0,catch_frame._save0(%imm2))
+	__(movq %imm0,catch_frame.xframe(%imm2))
+	__(movq %stack_temp,catch_frame.foreign_sp(%imm2))
+	__(movq %xfn,catch_frame.pc(%imm2))
+	__(movq %imm2,%rcontext:tcr.catch_top)
 ])	
         	
@@ -229,16 +183,16 @@
 /* to interrupt; the interrupting code has to recognize and possibly  */
 /* emulate the instructions in between   */
-	subq $cons.size-fulltag_cons,%rcontext:tcr.save_allocptr
-	movq %rcontext:tcr.save_allocptr,%allocptr
-	rcmpq(%allocptr,%rcontext:tcr.save_allocbase)
-	jg macro_label(no_trap)
+	__(subq $cons.size-fulltag_cons,%rcontext:tcr.save_allocptr)
+	__(movq %rcontext:tcr.save_allocptr,%allocptr)
+	__(rcmpq(%allocptr,%rcontext:tcr.save_allocbase))
+	__(jg macro_label(no_trap))
 	uuo_alloc()
 macro_label(no_trap):	
-	andb $~fulltagmask,%rcontext:tcr.save_allocptr
+	__(andb $~fulltagmask,%rcontext:tcr.save_allocptr)
 /* Easy to interrupt now that tcr.save_allocptr isn't tagged as a cons    */
-	movq $2,cons.cdr(%allocptr)
-	movq $1,cons.car(%allocptr)
+	__(movq $2,cons.cdr(%allocptr))
+	__(movq $1,cons.car(%allocptr))
 	ifelse($3,[],[],[
-	 movq %allocptr,$3
+	 __(movq %allocptr,$3)
 	])
 ])
@@ -248,5 +202,5 @@
 
 define([Misc_Alloc],[
-	subq [$]fulltag_misc,%imm1
+	__(subq [$]fulltag_misc,%imm1)
 	Misc_Alloc_Internal($1)
 ])
@@ -257,39 +211,46 @@
                 
 	new_macro_labels()
-	subq %imm1,%rcontext:tcr.save_allocptr
-	movq %rcontext:tcr.save_allocptr,%allocptr
-	rcmpq(%allocptr,%rcontext:tcr.save_allocbase)
-	jg macro_label(no_trap)
+	__(subq %imm1,%rcontext:tcr.save_allocptr)
+	__(movq %rcontext:tcr.save_allocptr,%allocptr)
+	__(rcmpq(%allocptr,%rcontext:tcr.save_allocbase))
+	__(jg macro_label(no_trap))
 	uuo_alloc()
 macro_label(no_trap):	
-	movq %imm0,misc_header_offset(%allocptr)
-	andb $~fulltagmask,%rcontext:tcr.save_allocptr
+	__(movq %imm0,misc_header_offset(%allocptr))
+	__(andb $~fulltagmask,%rcontext:tcr.save_allocptr)
 /* Now that tcr.save_allocptr is untagged, it's easier to be interrupted   */
 	ifelse($1,[],[],[
-	 mov %allocptr,$1
+	 __(mov %allocptr,$1)
 	])
 ])
 	
 define([Misc_Alloc_Fixed],[
-	movq [$]$2-fulltag_misc,%imm1
+	__(movq [$]$2-fulltag_misc,%imm1)
 	Misc_Alloc_Internal($1)
 ])					
 
 define([vrefr],[
-	mov misc_data_offset+($3<<word_shift)($2),$1
+	__(mov misc_data_offset+($3<<word_shift)($2),$1)
 ])	
 
 define([jump_fn],[
-	jmpq *%fn
+	__(jmpq *%fn)
 ])
 			
 define([jump_fname],[
-	mov symbol.fcell(%fname),%fn
+	__(mov symbol.fcell(%fname),%fn)
 	jump_fn()
 ])	
 	
 define([set_nargs],[
-	movw [$]$1<<fixnumshift,%nargs
-])
+        ifelse(eval($1>15),1,[
+        __(movl [$]$1<<fixnumshift,%nargs_l)
+        ],[
+        __(xorl %nargs_l,%nargs_l)
+        ifelse(eval($1),0,[],[
+        __(addl [$]$1<<fixnumshift,%nargs_l)
+        ])])])
+        
+
 
 /* $1 = ndigits.  Assumes 4-byte digits           */
@@ -298,17 +259,17 @@
 
 define([_car],[
-	movq cons.car($1),$2
+	__(movq cons.car($1),$2)
 ])	
 
 define([_rplaca],[
-	movq $2,cons.car($1)
+	__(movq $2,cons.car($1))
 ])	
 		
 define([_cdr],[
-	movq cons.cdr($1),$2
+	__(movq cons.cdr($1),$2)
 ])
 
 define([_rplacd],[
-	movq $2,cons.cdr($1)
+	__(movq $2,cons.cdr($1))
 ])	
 		
@@ -327,12 +288,12 @@
 define([do_funcall],[
 	new_macro_labels()
-	movb %temp0_b,%imm0_b
-	andb $fulltagmask,%imm0_b
-	cmpb $fulltag_symbol,%imm0_b
+	__(movb %temp0_b,%imm0_b)
+	__(andb $fulltagmask,%imm0_b)
+	__(cmpb $fulltag_symbol,%imm0_b)
 	/* %fname == %temp0   */
-	cmovgq %temp0,%fn
+	__(cmovgq %temp0,%fn)
 	jl macro_label(bad)
-	cmoveq symbol.fcell(%fname),%fn
-	jmp *%fn
+	__(cmoveq symbol.fcell(%fname),%fn)
+	__(jmp *%fn)
 macro_label(bad):		
 	__(uuo_error_not_callable)
@@ -340,5 +301,5 @@
 
 define([getvheader],[
-        movq misc_header_offset($1),$2
+        __(movq misc_header_offset($1),$2)
 ])
 
@@ -346,13 +307,13 @@
 /*    both be immediate registers   */
 define([header_size],[
-        movq $1,$2
-        shr $num_subtag_bits,$2
+        __(movq $1,$2)
+        __(shr $num_subtag_bits,$2)
 ])
 
 /* $2 (length) is fixnum element-count.   */
 define([header_length],[
-        movq $~255,$2
-        andq $1,$2
-        shr $num_subtag_bits-fixnumshift,$2
+        __(movq $~255,$2)
+        __(andq $1,$2)
+        __(shr $num_subtag_bits-fixnumshift,$2)
 ])
 
@@ -365,59 +326,59 @@
 /* $1 = vector, $2 = dest   */
 define([vector_length],[                                 
-        movq $~255,$2
-        andq misc_header_offset($1),$2
-        shr $num_subtag_bits-fixnumshift,$2
+        __(movq $~255,$2)
+        __(andq misc_header_offset($1),$2)
+        __(shr $num_subtag_bits-fixnumshift,$2)
 ])
                 
 /* GAS/ATT comparison arg order drives me nuts   */
 define([rcmpq],[
-	cmpq $2,$1
+	__(cmpq $2,$1)
 ])
 
 define([rcmpl],[
-	cmpl $2,$1
+	__(cmpl $2,$1)
 ])	
 
 define([rcmpw],[
-	cmpw $2,$1
+	__(cmpw $2,$1)
 ])	
 
 define([rcmpb],[
-	cmpb $2,$1
+	__(cmpb $2,$1)
 ])		
 
 
 define([condition_to_boolean],[
-        movl [$]t_value,$2_l
-        lea (-t_offset)($2),$3
-        cmov$1l $2_l,$3_l
+        __(movl [$]t_value,$2_l)
+        __(lea (-t_offset)($2),$3)
+        __(cmov$1l $2_l,$3_l)
 ])
 
 define([compare_reg_to_nil],[
-	cmpb $fulltag_nil,$1_b
+	__(cmpb $fulltag_nil,$1_b)
 ])		
 	
 define([extract_lisptag],[
-	movzbl $1_b,$2_l
-	andb [$]tagmask,$2_b
+	__(movzbl $1_b,$2_l)
+	__(andb [$]tagmask,$2_b)
 ])
 
 								
 define([extract_fulltag],[
-	movzbl $1_b,$2_l
-	andb [$]fulltagmask,$2_b
+	__(movzbl $1_b,$2_l)
+	__(andb [$]fulltagmask,$2_b)
 ])
 
 define([extract_subtag],[
-	movb misc_subtag_offset($1),$2
+	__(movb misc_subtag_offset($1),$2)
 ])
 
 define([extract_typecode],[
 	new_macro_labels()
-	movzbl $1_b,$2_l
-	andb $tagmask,$2_b
-	cmpb $tag_misc,$2_b
-	jne macro_label(done)
-	movb misc_subtag_offset($1),$2_b
+	__(movzbl $1_b,$2_l)
+	__(andb $tagmask,$2_b)
+	__(cmpb $tag_misc,$2_b)
+	__(jne macro_label(done))
+	__(movb misc_subtag_offset($1),$2_b)
 macro_label(done):	
 ])
@@ -426,20 +387,20 @@
 
         define([dnode_align],[
-        lea ($2+(dnode_size-1))($1),$3
-	andb $~(dnode_size-1),$3_b
+        __(lea ($2+(dnode_size-1))($1),$3)
+	__(andb $~(dnode_size-1),$3_b)
 ])
 	
 define([push_argregs],[
 	new_macro_labels()
-	testw %nargs,%nargs
-	jz macro_label(done)
-	cmpw [$]2*node_size,%nargs
-	je macro_label(yz)
-	jb macro_label(z)
-	push %arg_x
+	__(testw %nargs,%nargs)
+	__(jz macro_label(done))
+	__(cmpw [$]2*node_size,%nargs)
+	__(je macro_label(yz))
+	__(jb macro_label(z))
+	__(push %arg_x)
 macro_label(yz):
-	push %arg_y
+	__(push %arg_y)
 macro_label(z):
-	push %arg_z
+	__(push %arg_z)
 macro_label(done):
 ])	
@@ -450,14 +411,14 @@
 
 define([discard_temp_frame],[
-	movq %rcontext:tcr.save_tsp,$1
-	movq ($1),$1
-        movq $1,%rcontext:tcr.save_tsp
-        movq $1,%rcontext:tcr.next_tsp
+	__(movq %rcontext:tcr.save_tsp,$1)
+	__(movq ($1),$1)
+        __(movq $1,%rcontext:tcr.save_tsp)
+        __(movq $1,%rcontext:tcr.next_tsp)
 
 ])	
 
 define([check_pending_enabled_interrupt],[
-	btrq [$]63,%rcontext:tcr.interrupt_pending
-	jnc,pt $1
+	__(btrq [$]63,%rcontext:tcr.interrupt_pending)
+	__(jnc,pt $1)
 	interrupt_now()
 ])
@@ -470,7 +431,7 @@
 define([check_pending_interrupt],[
 	new_macro_labels()
-	movq %rcontext:tcr.tlb_pointer,$1
-	cmpq [$]0,INTERRUPT_LEVEL_BINDING_INDEX($1)
-	js,pt macro_label(done)
+	__(movq %rcontext:tcr.tlb_pointer,$1)
+	__(cmpq [$]0,INTERRUPT_LEVEL_BINDING_INDEX($1))
+	__(js,pt macro_label(done))
 	check_pending_enabled_interrupt(macro_label(done))
 macro_label(done):
@@ -486,8 +447,8 @@
         ifelse($1,[],[
         ],[
-        movq $1,%rdi
+        __(movq $1,%rdi)
         ])
-        movl [$]0x3000003,%eax
-        syscall
+        __(movl [$]0x3000003,%eax)
+        __(syscall)
 ])
 
@@ -503,5 +464,5 @@
 
 define([save_tcr_linear],[
-        movq %rcontext:tcr.linear,$1
+        __(movq %rcontext:tcr.linear,$1)
 ]) 
 	
@@ -512,6 +473,6 @@
 /*  branch or (b) immediately follows a conditional branch not taken. */
 define([repret],[
-        .byte 0xf3
-         ret
+        __(.byte 0xf3)
+        __(ret)
 ])
                                 
