[5361] in Athena Bugs

home help back first fref pref prev next nref lref last post

RT strlen() optimization

daemon@ATHENA.MIT.EDU (John Carr)
Sat Jun 30 09:17:21 1990

To: bugs@ATHENA.MIT.EDU
Date: Sat, 30 Jun 90 09:17:09 EDT
From: John Carr <jfc@ATHENA.MIT.EDU>


*** /source/bsd-4.3/rt/lib/libc/ca/gen/strlen.s	Tue Sep 19 14:20:23 1989
--- strlen.s	Sat Jun 30 09:13:46 1990
***************
*** 8,14 ****
  /* $Source: /ibm/acis/usr/src/lib/libc/ca/gen/RCS/strlen.s,v $ */
  
  	.data
! rcsid:	.asciz	"$Header:strlen.s 12.0$"
  	.text
  
  #include "LINKG.h"
--- 8,14 ----
  /* $Source: /ibm/acis/usr/src/lib/libc/ca/gen/RCS/strlen.s,v $ */
  
  	.data
! rcsid:	.asciz	"$Header:strlen.s 12.1$"
  	.text
  
  #include "LINKG.h"
***************
*** 22,29 ****
  	nilz	r5,r2,0x03	# Round string addr down to word boundary
  	s	r2,r5		# More of the rounding
  	sli	r5,3		# Calc offset into following switch statement
! 	get	r4,$0f		# Get address of beginning of switch statement
! 	a	r4,r5		# Add displacement of the case
  	brx	r4		# Branch to calculated case and
  	ls	r4,0(r2)	# get first word (possibly rounded down).
   # at this point:
--- 22,28 ----
  	nilz	r5,r2,0x03	# Round string addr down to word boundary
  	s	r2,r5		# More of the rounding
  	sli	r5,3		# Calc offset into following switch statement
! 	get	r4,$0f(r5)	# Add address of beginning of switch statement
  	brx	r4		# Branch to calculated case and
  	ls	r4,0(r2)	# get first word (possibly rounded down).
   # at this point:
***************
*** 32,39 ****
   # r4 contains 4 byes with string's initial bytes somewhere in r2
   # The following is a switch statement. Initially, control jumps to one of
   # the labels 0, 1, 2 or 3 depending on where string's first byte is in r2
!  # 
! 9:	inc	r2,4		# point to next word
   # code at 0f, 1f, 2f must be exactly 8 bytes long to match switch above
   # The switch:
  0:
--- 31,37 ----
   # r4 contains 4 byes with string's initial bytes somewhere in r2
   # The following is a switch statement. Initially, control jumps to one of
   # the labels 0, 1, 2 or 3 depending on where string's first byte is in r2
! 	.align	2
   # code at 0f, 1f, 2f must be exactly 8 bytes long to match switch above
   # The switch:
  0:
***************
*** 52,58 ****
  	nilz	r5,r4,0x00ff	# get byte 3 from r4
  	jeq	3f
  	ls	r4,4(r2)
! 	b	9b		# null not found in byte 3, try next word 
  
   # Come to one of labels 0, 1, 2 or 3 when a null byte was found and
   # adjust r2 to point to the zero byte
--- 50,57 ----
  	nilz	r5,r4,0x00ff	# get byte 3 from r4
  	jeq	3f
  	ls	r4,4(r2)
! 	bx	0b		# null not found in byte 3, try next word 
! 	inc	r2,4
  
   # Come to one of labels 0, 1, 2 or 3 when a null byte was found and
   # adjust r2 to point to the zero byte

home help back first fref pref prev next nref lref last post