From 1d39325916f72219cd230cb02a7277c9a1123c71 Mon Sep 17 00:00:00 2001
From: cwang <cwang>
Date: Thu, 29 Jul 2004 20:14:53 +0000
Subject: [PATCH] A slow version of symbol-value that works for NIL. If we use
 4-bit low-tag we can go back to the faster version.

---
 compiler/amd64/cell.lisp | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/compiler/amd64/cell.lisp b/compiler/amd64/cell.lisp
index f95ee28c0..890c5ee25 100644
--- a/compiler/amd64/cell.lisp
+++ b/compiler/amd64/cell.lisp
@@ -7,7 +7,7 @@
 ;;; Scott Fahlman or slisp-group@cs.cmu.edu.
 ;;;
 (ext:file-comment
- "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/amd64/cell.lisp,v 1.3 2004/07/06 20:12:08 cwang Exp $")
+ "$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/amd64/cell.lisp,v 1.4 2004/07/29 20:14:53 cwang Rel $")
 ;;;
 ;;; **********************************************************************
 ;;;
@@ -89,18 +89,35 @@
 ;;; With Symbol-Value, we check that the value isn't the trap object.  So
 ;;; Symbol-Value of NIL is NIL.
 ;;;
+;;; This is a slow version. We don't need to check for nil if we move to 4-bit
+;;; low-tag.
 (define-vop (symbol-value)
   (:translate symbol-value)
   (:policy :fast-safe)
   (:args (object :scs (descriptor-reg) :to (:result 1)))
   (:results (value :scs (descriptor-reg any-reg)))
+  (:temporary (:sc unsigned-reg) temp)
   (:vop-var vop)
   (:save-p :compute-only)
   (:generator 9
-    (let ((err-lab (generate-error-code vop unbound-symbol-error object)))
+    (let ((err-lab (generate-error-code vop unbound-symbol-error object))
+	  (itsnil (gen-label))
+	  (done (gen-label)))
+
+      (inst mov temp nil-value)
+      (inst cmp object temp)
+      (inst jmp :e itsnil)
+
+      ;; not nil
       (loadw value object symbol-value-slot other-pointer-type)
       (inst cmp value unbound-marker-type)
-      (inst jmp :e err-lab))))
+      (inst jmp :e err-lab)
+      (inst jmp done)
+      
+      (emit-label itsnil)
+      (inst mov value nil-value)
+
+      (emit-label done))))
 
 (define-vop (fast-symbol-value cell-ref)
   (:variant symbol-value-slot other-pointer-type)
-- 
GitLab