From b2b7e307cb9401164574e25c5a31ec3e870fd48b Mon Sep 17 00:00:00 2001
From: Chris Hanson <org/chris-hanson/cph>
Date: Tue, 21 Feb 2017 21:44:48 -0800
Subject: [PATCH] Eliminate random-byte-vector outside of Edwin.

---
 src/compiler/base/toplev.scm     | 3 +--
 src/compiler/machines/C/cout.scm | 6 +++---
 src/compiler/machines/C/ctop.scm | 4 ++--
 src/runtime/infstr.scm           | 8 +++++---
 src/runtime/random.scm           | 8 --------
 src/runtime/runtime.pkg          | 1 -
 6 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/src/compiler/base/toplev.scm b/src/compiler/base/toplev.scm
index 6c30328a1..2b2de22e2 100644
--- a/src/compiler/base/toplev.scm
+++ b/src/compiler/base/toplev.scm
@@ -152,8 +152,7 @@ USA.
 		 compiler:generate-lap-files?
 		 (pathname-new-type output-pathname "lap")
 		 (lambda (lap-output-port)
-		   (fluid-let ((*debugging-key*
-				(random-byte-vector 32)))
+		   (fluid-let ((*debugging-key* (random-bytevector 32)))
 		     (compile-scode/file/hook
 		      input-pathname
 		      output-pathname
diff --git a/src/compiler/machines/C/cout.scm b/src/compiler/machines/C/cout.scm
index 1ae4ec43b..4e7012d92 100644
--- a/src/compiler/machines/C/cout.scm
+++ b/src/compiler/machines/C/cout.scm
@@ -425,7 +425,7 @@ USA.
 (define (make-nonce)
   (if *disable-nonces?*
       "nonce"
-      (vector-8b->hexadecimal (random-byte-vector 8))))
+      (bytevector->hexadecimal (random-bytevector 8))))
 
 (define (top-level/stackify handle ntags code-fn
 			    decl-code-name code-name code-blocks
@@ -504,12 +504,12 @@ USA.
 (define (declare-dynamic-initialization handle)
   (c:line (c:call "DECLARE_DYNAMIC_INITIALIZATION"
 		  (c:string handle)
-		  (c:string (vector-8b->hexadecimal (random-byte-vector 8))))))
+		  (c:string (bytevector->hexadecimal (random-bytevector 8))))))
 
 (define (declare-dynamic-object-initialization handle)
   (c:line (c:call "DECLARE_DYNAMIC_OBJECT_INITIALIZATION"
 		  (c:string handle)
-		  (c:string (vector-8b->hexadecimal (random-byte-vector 8))))))
+		  (c:string (bytevector->hexadecimal (random-bytevector 8))))))
 
 (define (declare-subcodes decl-name blocks)
   (if (and (pair? blocks)
diff --git a/src/compiler/machines/C/ctop.scm b/src/compiler/machines/C/ctop.scm
index fad9471f7..63657e852 100644
--- a/src/compiler/machines/C/ctop.scm
+++ b/src/compiler/machines/C/ctop.scm
@@ -77,7 +77,7 @@ USA.
   (fluid-let ((*compiler-file-handle*
 	       (string-append
 		"(anonymous scode "
-		(vector-8b->hexadecimal (random-byte-vector 8))
+		(bytevector->hexadecimal (random-bytevector 8))
 		")")))
     (action)))
 
@@ -96,7 +96,7 @@ USA.
   (let ((typifier
 	 ;; Guarantee unique temporary files for liarc.  We could
 	 ;; instead change how the files are loaded.
-	 (let ((suffix (vector-8b->hexadecimal (random-byte-vector #x10))))
+	 (let ((suffix (bytevector->hexadecimal (random-bytevector #x10))))
 	   (lambda (type)
 	     (lambda (pathname)
 	       (pathname-new-type
diff --git a/src/runtime/infstr.scm b/src/runtime/infstr.scm
index fbfc60c95..5b0ff6645 100644
--- a/src/runtime/infstr.scm
+++ b/src/runtime/infstr.scm
@@ -360,11 +360,13 @@ USA.
 	      (vector-ref v index)))))
 
 (define (dbg-info-key? object)
-  (and (string? object)
-       (fix:= (string-length object) 32)))
+  (or (and (bytevector? object)
+	   (fix:= (bytevector-length object) 32))
+      (and (legacy-string? object)
+	   (fix:= (legacy-string-length object) 32))))
 
 (define (dbg-info-key=? a b)
-  (string=? a b))
+  (equal? a b))
 
 (define (debug-info-pathname? object)
   (or (pathname? object)
diff --git a/src/runtime/random.scm b/src/runtime/random.scm
index d63520d30..47198da5f 100644
--- a/src/runtime/random.scm
+++ b/src/runtime/random.scm
@@ -166,14 +166,6 @@ USA.
 		1.)
 	 flimit.))
 
-(define (random-byte-vector n #!optional state)
-  (let ((state (get-random-state state 'RANDOM-BYTE-VECTOR))
-	(s (make-vector-8b n)))
-    (do ((i 0 (fix:+ i 1)))
-	((fix:= i n))
-      (vector-8b-set! s i (small-random-integer 256 state)))
-    s))
-
 (define (random-bytevector n #!optional state)
   (let ((state (get-random-state state 'random-bytevector))
 	(bytes (make-bytevector n)))
diff --git a/src/runtime/runtime.pkg b/src/runtime/runtime.pkg
index c4475fd38..8cd24ea5f 100644
--- a/src/runtime/runtime.pkg
+++ b/src/runtime/runtime.pkg
@@ -4056,7 +4056,6 @@ USA.
 	  make-random-source
 	  make-random-state
 	  random
-	  random-byte-vector
 	  random-bytevector
 	  random-integer
 	  random-real
-- 
2.25.1