Index: /trunk/source/lisp-kernel/arm-exceptions.c
===================================================================
--- /trunk/source/lisp-kernel/arm-exceptions.c	(revision 14514)
+++ /trunk/source/lisp-kernel/arm-exceptions.c	(revision 14515)
@@ -97,9 +97,13 @@
   pc program_counter = xpPC(xp);
   opcode instr = *program_counter, prev_instr;
+  int delta = -3;
 
   if (IS_ALLOC_TRAP(instr)) {
     /* The alloc trap must have been preceded by a cmp and a
        load from tcr.allocbase. */
-    prev_instr = program_counter[-3];
+    if (IS_BRANCH_AROUND_ALLOC_TRAP(program_counter[-1])) {
+      delta = -4;
+    }
+    prev_instr = program_counter[delta];
 
     if (IS_SUB_RM_FROM_ALLOCPTR(prev_instr)) {
@@ -114,5 +118,5 @@
       natural disp = ror(prev_instr&0xff,(prev_instr&0xf00)>>7);
 
-      instr = program_counter[-4];
+      instr = program_counter[delta-1];
       if (IS_SUB_LO_FROM_ALLOCPTR(instr)) {
         return -((signed_natural)(disp | (instr & 0xff)));
Index: /trunk/source/lisp-kernel/arm-exceptions.h
===================================================================
--- /trunk/source/lisp-kernel/arm-exceptions.h	(revision 14514)
+++ /trunk/source/lisp-kernel/arm-exceptions.h	(revision 14515)
@@ -86,4 +86,5 @@
 #define IS_SET_ALLOCPTR_RESULT_RD(i) (((i)&0x0fff0fff) == 0x01a0000c)
 #define IS_CLR_ALLOCPTR_TAG(i)       (((i)&0x0fffffff) == 0x03ccc007)
+#define IS_BRANCH_AROUND_ALLOC_TRAP(i) (((i)&0x0fffffff) == 0x0a000000)
 
 
Index: /trunk/source/lisp-kernel/arm-macros.s
===================================================================
--- /trunk/source/lisp-kernel/arm-macros.s	(revision 14514)
+++ /trunk/source/lisp-kernel/arm-macros.s	(revision 14515)
@@ -255,7 +255,10 @@
 
 define(`trap_unless_lisptag_equal',`
+       	new_macro_labels()
 	__(extract_lisptag($3,$1))
         __(cmp $3,#$2)
-	__(uuo_error_reg_not_lisptag(ne,$3,$2))
+        __(beq macro_label(ok))
+	__(uuo_error_reg_not_lisptag(al,$3,$2))
+macro_label(ok):                
 ')
 
@@ -265,18 +268,27 @@
 
 define(`trap_unless_fixnum',`
+        __(new_macro_labels())
         __(test_fixnum($1))
-        __(uuo_error_reg_not_lisptag(ne,$1,tag_fixnum))
+        __(beq macro_label(ok))
+        __(uuo_error_reg_not_lisptag(al,$1,tag_fixnum))
+macro_label(ok):        
         ')
                 
 define(`trap_unless_fulltag_equal',`
+        new_macro_labels()
 	__(extract_fulltag($3,$1))
         __(cmp $3,#$2)
-        __(uuo_error_reg_not_fulltag(ne,$1,$2))
+        __(beq macro_label(ok))
+        __(uuo_error_reg_not_fulltag(al,$1,$2))
+macro_label(ok):        
 ')
 	
 define(`trap_unless_typecode_equal',`
+        new_macro_labels()
         __(extract_typecode($3,$1))
         __(cmp $3,#$2)
-        __(uuo_error_reg_not_xtype(ne,$2))
+        __(beq macro_label(ok))
+        __(uuo_error_reg_not_xtype(al,$2))
+macro_label(ok):                
 ')
         
@@ -312,5 +324,5 @@
         __(cmpne imm0,#subtag_function)
         __(ldreq pc,[nfn,#_function.entrypoint])
-        __(uuo_error_not_callable(ne,nfn))
+        __(uuo_error_not_callable(al,nfn))
 
 ')
@@ -352,8 +364,11 @@
 
 define(`Cons',`
+       	new_macro_labels()
         __(add allocptr,allocptr,#-cons.size+fulltag_cons)
         __(ldr allocbase,[rcontext,#tcr.save_allocbase])
         __(cmp allocptr,allocbase)
-        __(uuo_alloc_trap(lo))
+        __(bhi macro_label(ok))
+        __(uuo_alloc_trap(al))
+macro_label(ok):                
         __(str $3,[allocptr,#cons.cdr])
         __(str $2,[allocptr,#cons.car])
@@ -388,9 +403,12 @@
 
 define(`Misc_Alloc',`
+        new_macro_labels()
 	__(sub $3,$3,#fulltag_misc)
 	__(sub allocptr,allocptr,$3)
         __(ldr allocbase,[rcontext,#tcr.save_allocbase])
         __(cmp allocptr,allocbase)
-        __(uuo_alloc_trap(lo))
+        __(bhi macro_label(ok))
+        __(uuo_alloc_trap(al))
+macro_label(ok):                
 	__(str $2,[allocptr,#misc_header_offset])
 	__(mov $1,allocptr)
@@ -400,8 +418,11 @@
 /*  Parameters $1, $2 as above; $3 = physical size constant. */
 define(`Misc_Alloc_Fixed',`
+        new_macro_labels()
         __(add allocptr,allocptr,#(-$3)+fulltag_misc)
         __(ldr allocbase,[rcontext,#tcr.save_allocbase])
         __(cmp allocptr,allocbase)
-        __(uuo_alloc_trap(lo))
+        __(bhi macro_label(ok))
+        __(uuo_alloc_trap(al))
+macro_label(ok):                
 	__(str $2,[allocptr,#misc_header_offset])
 	__(mov $1,allocptr)
@@ -439,5 +460,6 @@
         __(ldr $1,[rcontext,#tcr.interrupt_pending])
         __(cmp $1,0)
-        __(uuo_interrupt_now(gt))
+        __(ble $2)
+        __(uuo_interrupt_now(al))
         ')
         
@@ -448,5 +470,5 @@
         __(cmp $1,#0)
         __(blt macro_label(done))
-        __(check_enabled_pending_interrupt($1))
+        __(check_enabled_pending_interrupt($1,macro_label(done)))
 macro_label(done):
 ')
Index: /trunk/source/lisp-kernel/arm-spentry.s
===================================================================
--- /trunk/source/lisp-kernel/arm-spentry.s	(revision 14514)
+++ /trunk/source/lisp-kernel/arm-spentry.s	(revision 14515)
@@ -388,5 +388,7 @@
 	__(ldr imm0,[rcontext,#tcr.tlb_limit])
 	__(cmp imm0,imm1)
-	__(uuo_tlb_too_small(ls,imm1))
+        __(bhi 1f)
+	__(uuo_tlb_too_small(al,imm1))
+1:              
 	__(cmp imm1,#0)
 	__(ldr imm2,[rcontext,#tcr.tlb_pointer])
@@ -631,5 +633,7 @@
         __(beq 9f)
         __(cmp imm0,imm1)
-        __(uuo_tlb_too_small(ls,imm1))
+        __(bhi 1f)
+        __(uuo_tlb_too_small(al,imm1))
+1:              
         __(ldr temp2,[rcontext,#tcr.tlb_pointer])
         __(ldr imm0,[rcontext,#tcr.db_link])
@@ -661,5 +665,7 @@
         __(beq 9f)
         __(cmp imm0,imm1)
-        __(uuo_tlb_too_small(ls,imm1))
+        __(bhi 1f)
+        __(uuo_tlb_too_small(al,imm1))
+1:              
         __(ldr temp2,[rcontext,#tcr.tlb_pointer])
         __(ldr imm0,[rcontext,#tcr.db_link])
@@ -669,5 +675,7 @@
         __(ldreq temp0,[arg_z,#symbol.vcell])
         __(cmp temp0,#unbound_marker)
-        __(uuo_error_unbound(eq,arg_z))
+        __(bne 2f)
+        __(uuo_error_unbound(al,arg_z))
+2:              
         __(vpush1(temp1))   /* old tlb contents */
         __(vpush1(imm1))    /* tlb index */
@@ -1043,5 +1051,7 @@
 _spentry(stack_misc_alloc)
         __(tst arg_y,#unsigned_byte_24_mask)
-        __(uuo_error_reg_not_xtype(ne,arg_y,xtype_unsigned_byte_24))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_y,xtype_unsigned_byte_24))
+1:              
         __(unbox_fixnum(imm0,arg_z))
         __(extract_fulltag(imm1,imm0))
@@ -1605,5 +1615,7 @@
         __(vector_length(imm0,arg_y,imm1))
         __(cmp arg_z,imm0)
-        __(uuo_error_vector_bounds(hs,arg_z,arg_y))
+        __(blo 1f)
+        __(uuo_error_vector_bounds(al,arg_z,arg_y))
+1:              
         __(extract_lowbyte(imm1,imm1)) /* imm1 = subtag  */
         __(b C(misc_ref_common)) 
@@ -1616,5 +1628,7 @@
         __(vector_length(imm0,arg_y,imm1))
         __(cmp arg_z,imm0)
-        __(uuo_error_vector_bounds(hs,arg_z,arg_y))
+        __(blo 1f)
+        __(uuo_error_vector_bounds(al,arg_z,arg_y))
+1:              
         __(unbox_fixnum(imm1,arg_x))
         __(b C(misc_ref_common))
@@ -1856,5 +1870,7 @@
         __(extract_typecode(imm0,arg_z))
         __(cmp imm0,#subtag_bignum)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_integer))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_integer))
+1:              
         __(getvheader(imm1,arg_z))
         __(header_length(imm0,imm1)) /* boxed length = scaled size  */
@@ -1873,5 +1889,7 @@
         __(vector_length(imm0,arg_x,imm1))
         __(cmp arg_y,imm0)
-        __(uuo_error_vector_bounds(hs,arg_y,arg_x))
+        __(blo 1f)
+        __(uuo_error_vector_bounds(al,arg_y,arg_x))
+1:              
         __(unbox_fixnum(imm1,temp0))
         __(b C(misc_set_common))
@@ -1887,5 +1905,7 @@
         __(vector_length(imm0,arg_x,imm1))
         __(cmp arg_y,imm0)
-        __(uuo_error_vector_bounds(hs,arg_y,arg_x))
+        __(blo 1f)
+        __(uuo_error_vector_bounds(al,arg_y,arg_x))
+1:              
         __(extract_lowbyte(imm1,imm1))
         __(b C(misc_set_common))
@@ -2036,12 +2056,14 @@
 _spentry(stack_misc_alloc_init)
         __(tst arg_x,#unsigned_byte_24_mask)
-        __(uuo_error_reg_not_xtype(ne,arg_x,xtype_unsigned_byte_24))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_x,xtype_unsigned_byte_24))
+1:              
         __(unbox_fixnum(imm0,arg_y))
         __(extract_fulltag(imm1,imm0))
         __(cmp imm1,#fulltag_nodeheader)
-        __(bne 1f)
+        __(bne stack_misc_alloc_init_ivector)
         __(dnode_align(imm1,arg_x,node_size))
         __(cmp imm1,#stack_alloc_limit)
-        __(bge 0f)
+        __(bge stack_misc_alloc_init_no_room)
         __(mov imm0,#subtag_u32_vector)
         __(orr imm0,imm0,arg_x,lsl #num_subtag_bits-fixnumshift)
@@ -2055,30 +2077,4 @@
         __(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_y,#max_32_bit_ivector_subtag<<fixnumshift)
-        __(movle imm1,arg_x)
-        __(ble 8f)
-        __(cmp arg_y,#max_8_bit_ivector_subtag<<fixnumshift)
-        __(movle imm1,arg_x,lsr #fixnumshift)
-        __(ble 8f)
-        __(cmp arg_y,#max_16_bit_ivector_subtag<<fixnumshift)
-        __(movle imm1,arg_x,lsr #1)
-        __(ble 8f)
-        __(cmp arg_y,#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)
 
  
@@ -2087,12 +2083,5 @@
 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)
+
 
 
@@ -2188,5 +2177,7 @@
         __(movc16(imm1,two_digit_bignum_header))
         __(cmp imm1,imm2)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_s64))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_s64))
+1:              
         __(vrefr(imm1,arg_z,1))
         __(vrefr(imm0,arg_z,0))
@@ -2219,5 +2210,6 @@
         __(ldreq arg_z,[arg_y,#symbol.vcell])
         __(cmp arg_z,#unbound_marker)
-        __(uuo_error_unbound(eq,arg_y))
+        __(bxne lr)
+        __(uuo_error_unbound(al,arg_y))
         __(bx lr)
 
@@ -2248,9 +2240,13 @@
         __(extract_lisptag(imm0,arg_z))
         __(cmp imm0,#tag_misc)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_s32))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_s32))
+1:              
         __(getvheader(imm0,arg_z))
         __(movc16(imm1,one_digit_bignum_header))
         __(cmp imm0,imm1)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_s32))
+        __(beq 2f)
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_s32))
+2:              
         __(vrefr(imm0,arg_z,0))
         __(bx lr)        
@@ -2269,5 +2265,7 @@
         __(extract_lisptag(imm0,arg_z))
         __(cmp imm0,#tag_misc)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_u32))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_u32))
+1:              
         __(getvheader(imm0,arg_z))
         __(cmp imm0,imm1)
@@ -2280,9 +2278,9 @@
         __(cmpeq imm1,#0)
         __(bxeq lr)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_u32))
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_u32))
 7:              
         __(movs imm1,imm0,asr #31)
         __(bxeq lr)
-        __(uuo_error_reg_not_xtype(ne,arg_z,xtype_u32))
+        __(uuo_error_reg_not_xtype(al,arg_z,xtype_u32))
 
 
@@ -2368,5 +2366,6 @@
         __(ldrlt temp0,[rcontext,#tcr.interrupt_pending])
         __(cmp temp0,#0)
-        __(uuo_interrupt_now(gt))
+        __(bxle lr)
+        __(uuo_interrupt_now(al))
         __(bx lr)
 	
@@ -2424,5 +2423,6 @@
         __(cmp temp1,#0)
         __(bxlt lr)
-        __(check_enabled_pending_interrupt(imm0))
+        __(check_enabled_pending_interrupt(imm0,1f))
+1:              
         __(bx lr)
 5:       /* Missed a suspend request; force suspend now if we're restoring
@@ -2449,12 +2449,18 @@
         __(ldreq imm1,[arg_x,#arrayH.rank])
         __(cmpeq imm1,#2<<fixnumshift)
-        __(uuo_error_reg_not_xtype(ne,arg_x,xtype_array2d))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,arg_x,xtype_array2d))
+1:              
         /* It's a 2-dimensional array.  Check bounds */
         __(ldr imm0,[arg_x,#arrayH.dim0])
         __(cmp arg_y,imm0)
-        __(uuo_error_array_bounds(hs,arg_y,arg_x))
+        __(blo 2f)
+        __(uuo_error_array_bounds(al,arg_y,arg_x))
+2:              
         __(ldr imm0,[arg_x,#arrayH.dim0+node_size])
         __(cmp arg_z,imm0)
-        __(uuo_error_array_bounds(hs,arg_z,arg_x))
+        __(blo 3f)
+        __(uuo_error_array_bounds(al,arg_z,arg_x))
+3:              
         __(unbox_fixnum(imm0,imm0))
         __(mul temp0,arg_y,imm0) /* no MLA on ARMv5 */
@@ -2481,5 +2487,7 @@
         __(ldreq imm1,[temp0,#arrayH.rank])
         __(cmp imm1,#3<<fixnumshift)
-        __(uuo_error_reg_not_xtype(ne,temp0,xtype_array3d))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,temp0,xtype_array3d))
+1:              
         /* It's a 3-dimensional array.  Check bounds */
         __(ldr imm2,[temp0,arrayH.dim0+(node_size*2)])
@@ -2487,9 +2495,15 @@
         __(ldr imm0,[temp0,#arrayH.dim0])
         __(cmp arg_z,imm2)
-        __(uuo_error_array_bounds(hs,arg_z,temp0))
+        __(blo 2f)
+        __(uuo_error_array_bounds(al,arg_z,temp0))
+2:              
         __(cmp arg_y,imm1)
-        __(uuo_error_array_bounds(hs,arg_y,temp0))
+        __(blo 3f)
+        __(uuo_error_array_bounds(al,arg_y,temp0))
+3:              
         __(cmp arg_x,imm0)
-        __(uuo_error_array_bounds(hs,arg_x,temp0))
+        __(blo 4f)
+        __(uuo_error_array_bounds(al,arg_x,temp0))
+4:              
         __(unbox_fixnum(imm2,imm2))
         __(unbox_fixnum(imm1,imm1))
@@ -2517,5 +2531,7 @@
         __(ldreq imm0,[temp0,#arrayH.rank])
         __(cmpeq imm0,#2<<fixnumshift)
-        __(uuo_error_reg_not_xtype(ne,temp0,xtype_array2d))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,temp0,xtype_array2d))
+1:              
         __(trap_unless_fixnum(arg_x))
         __(trap_unless_fixnum(arg_y))
@@ -2523,8 +2539,12 @@
         __(ldr imm0,[temp0,#arrayH.dim0])
         __(cmp arg_x,imm0)
-        __(uuo_error_array_bounds(hs,arg_x,temp0))
+        __(blo 2f)
+        __(uuo_error_array_bounds(al,arg_x,temp0))
+2:              
         __(ldr imm0,[temp0,#arrayH.dim0+node_size])
         __(cmp arg_y,imm0)
-        __(uuo_error_array_bounds(hs,arg_y,temp0))
+        __(blo 3f)
+        __(uuo_error_array_bounds(al,arg_y,temp0))
+3:              
         __(unbox_fixnum(imm0,imm0))
         __(mul temp1,arg_x,imm0)
@@ -2548,5 +2568,7 @@
         __(ldreq imm0,[temp1,#arrayH.rank])
         __(cmpeq imm0,#3<<fixnumshift)
-        __(uuo_error_reg_not_xtype(ne,temp1,xtype_array3d))
+        __(beq 1f)
+        __(uuo_error_reg_not_xtype(al,temp1,xtype_array3d))
+1:              
         __(trap_unless_fixnum(temp0))
         __(trap_unless_fixnum(arg_x))
@@ -2557,10 +2579,16 @@
         __(ldr imm0,[temp1,#arrayH.dim0])
         __(cmp arg_y,imm2)
-        __(uuo_error_array_bounds(hs,arg_y,temp1))
+        __(blo 2f)
+        __(uuo_error_array_bounds(al,arg_y,temp1))
+2:              
         __(cmp arg_x,imm1)
-        __(uuo_error_array_bounds(hs,arg_x,temp1))
+        __(blo 3f)
+        __(uuo_error_array_bounds(al,arg_x,temp1))
+3:              
         __(unbox_fixnum(imm1,imm1))
         __(cmp temp0,imm0)
-        __(uuo_error_array_bounds(hs,temp0,temp1))
+        __(blo 4f)
+        __(uuo_error_array_bounds(al,temp0,temp1))
+4:              
         __(mul arg_x,imm2,arg_x)
         __(mul imm1,imm2,imm1)
@@ -4174,5 +4202,7 @@
         __(_cdr(arg_y,arg_y))
         __(cmp imm2,imm0)
-        __(uuo_tlb_too_small(ls,imm0))
+        __(bhi 4f)
+        __(uuo_tlb_too_small(al,imm0))
+4:              
         __(ldr arg_x,[rcontext,#tcr.tlb_pointer])
         __(ldr temp0,[arg_x,imm0])
@@ -4204,3 +4234,39 @@
         __(b _SPmisc_alloc)
 _endfn        
-	_endfile
+_exportfn(stack_misc_alloc_init_no_room)
+/* 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.  */
+        __(mov imm0,#stack_alloc_marker)
+        __(mov imm1,sp)
+        __(stmdb sp!,{imm0,imm1})
+        __(b _SPmisc_alloc_init)
+_endfn        
+_exportfn(stack_misc_alloc_init_ivector)
+        __(mov imm0,arg_x,lsl #num_subtag_bits-fixnumshift)
+        __(orr imm0,imm0,arg_y,lsr #fixnumshift)
+        __(cmp arg_y,#max_32_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x)
+        __(ble 8f)
+        __(cmp arg_y,#max_8_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x,lsr #fixnumshift)
+        __(ble 8f)
+        __(cmp arg_y,#max_16_bit_ivector_subtag<<fixnumshift)
+        __(movle imm1,arg_x,lsr #1)
+        __(ble 8f)
+        __(cmp arg_y,#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 stack_misc_alloc_init_no_room)
+        __(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)
+_endfn        
+        	_endfile
