From cdf11377fbdb369d3a3810dd9bd01a8a73007255 Mon Sep 17 00:00:00 2001
From: Raymond Toy <toy.raymond@gmail.com>
Date: Sat, 22 Dec 2012 08:29:09 -0800
Subject: [PATCH] Fix ticket:60.

This fixes the immediate issue, but there are still problems with
very long strings.  The bit-index for such strings won't fit in an
(unsigned-byte 32).

vm-fndb.lisp:
o Correct the defknown to have the correct arg types (vm::offset
  instead of index).

vm-tran.lisp:
o Update deftransform to use vm::offset instead of index.
---
 src/compiler/generic/vm-fndb.lisp |  4 ++--
 src/compiler/generic/vm-tran.lisp | 32 +++++++++++++++----------------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/src/compiler/generic/vm-fndb.lisp b/src/compiler/generic/vm-fndb.lisp
index 0c726f3b9..80e56309a 100644
--- a/src/compiler/generic/vm-fndb.lisp
+++ b/src/compiler/generic/vm-fndb.lisp
@@ -307,8 +307,8 @@
   ())
 
 (defknown bit-bash-copy
-	  ((simple-unboxed-array (*)) index
-	   (simple-unboxed-array (*)) index index)
+	  ((simple-unboxed-array (*)) vm::offset
+	   (simple-unboxed-array (*)) vm::offset vm::offset)
   t
   ())
 
diff --git a/src/compiler/generic/vm-tran.lisp b/src/compiler/generic/vm-tran.lisp
index 62bf92b80..3376163a9 100644
--- a/src/compiler/generic/vm-tran.lisp
+++ b/src/compiler/generic/vm-tran.lisp
@@ -240,22 +240,22 @@
 (deftransform replace ((string1 string2 &key (start1 0) (start2 0)
 				end1 end2)
 		       (simple-string simple-string &rest t))
-  '(locally (declare (optimize (safety 0)))
-     (bit-bash-copy string2
-		    (the index
-			 (+ (the index (* start2 vm:char-bits))
-			    vector-data-bit-offset))
-		    string1
-		    (the index
-			 (+ (the index (* start1 vm:char-bits))
-			    vector-data-bit-offset))
-		    (the index
-			 (* (min (the index (- (or end1 (length string1))
-					       start1))
-				 (the index (- (or end2 (length string2))
-					       start2)))
-			    vm:char-bits)))
-    string1))
+   '(locally (declare (optimize (safety 0)))
+      (bit-bash-copy string2
+		     (the vm::offset
+			  (+ (the vm::offset (* start2 vm:char-bits))
+			     vector-data-bit-offset))
+		     string1
+		     (the vm::offset
+			  (+ (the vm::offset (* start1 vm:char-bits))
+			     vector-data-bit-offset))
+		     (the vm::offset
+			  (* (min (the vm::offset (- (or end1 (length string1))
+						     start1))
+				  (the vm::offset (- (or end2 (length string2))
+						     start2)))
+			     vm:char-bits)))
+      string1))
 
 ;; The original version of this deftransform seemed to cause the
 ;; compiler to spend huge amounts of time deriving the type of the
-- 
GitLab