Changeset 7908


Ignore:
Timestamp:
Dec 13, 2007, 8:58:16 PM (13 years ago)
Author:
gb
Message:

Cache a symbol's hash code in the plist slot along with the plist, so
if a symbol has either a cached hash code or a plist, that slot is
of the form (hash-code . plist)

Drop support for hashing symbols by address, since it (at least) doesn't
interact well with readonly hash tables.

Location:
branches/working-0711/ccl
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0711/ccl/level-0/l0-hash.lisp

    r7901 r7908  
    160160  (declaim (inline compute-hash-code))
    161161  (declaim (inline eq-hash-find eq-hash-find-for-put))
    162   (declaim (inline read-lock-hash-table write-lock-hash-table  unlock-hash-table)))
     162  (declaim (inline read-lock-hash-table write-lock-hash-table  unlock-hash-table))
     163  (declaim (inline %hash-symbol)))
     164
     165
     166
     167(defun %hash-symbol (sym)
     168  (if sym   
     169    (let* ((vector (%symptr->symvector sym))
     170           (cell (%svref vector target::symbol.plist-cell)))
     171      (or (car cell)
     172          (let* ((pname (%svref vector target::symbol.pname-cell))
     173                 (hash (mixup-hash-code (%pname-hash pname (uvsize pname)))))
     174            (declare (type (simple-string pname)))
     175            (if cell
     176              (setf (car cell) hash)
     177              (progn
     178                (setf (%svref vector target::symbol.plist-cell)
     179                      (cons hash nil))
     180                hash)))))
     181    +nil-hash+))
     182             
    163183
    164184(defun %cons-hash-table (rehash-function keytrans-function compare-function vector
     
    291311      (if (eq typecode target::subtag-instance)
    292312        (values (mixup-hash-code (instance.hash key)) nil)
    293         (if #+hash-symbols-by-address nil
    294             #-hash-symbols-by-address (symbolp key)
    295           (let* ((name (if key (%svref (symptr->symvector key) target::symbol.pname-cell) "NIL")))
    296             (values (mixup-hash-code (%pname-hash name (length name))) nil))
     313        (if (symbolp key)
     314          (values (%hash-symbol key) nil)
    297315          (let ((hash (mixup-hash-code (strip-tag-to-fixnum key))))
    298316            (if (immediate-p-macro key)
     
    10791097              (if (eq typecode target::subtag-instance)
    10801098                (mixup-hash-code (instance.hash key))
    1081                 (if #+hash-symbols-by-address nil
    1082                     #-hash-symbols-by-address (symbolp key)
    1083                   (let* ((name (if key (%svref
    1084                                         (symptr->symvector key)
    1085                                         target::symbol.pname-cell) "NIL")))
    1086                     (mixup-hash-code (%pname-hash name (length name))))
     1099                (if (symbolp key)
     1100                  (%hash-symbol key)
    10871101                  (mixup-hash-code (strip-tag-to-fixnum key)))))))
    10881102         (length (uvsize vector))
     
    11291143              (if (eq typecode target::subtag-instance)
    11301144                (mixup-hash-code (instance.hash key))
    1131                 (if #+hash-symbols-by-address nil
    1132                     #-hash-symbols-by-address (symbolp key)
    1133                   (let* ((name (if key (%svref
    1134                                         (symptr->symvector key)
    1135                                         target::symbol.pname-cell) "NIL")))
    1136                     (mixup-hash-code (%pname-hash name (length name))))
     1145                (if (symbolp key)
     1146                  (%hash-symbol key)
    11371147                  (progn
    11381148                    (unless (immediate-p-macro key)
  • branches/working-0711/ccl/level-0/l0-symbol.lisp

    r6183 r7908  
    4848;;; The type-checking done on the "plist" arg shouldn't be removed.
    4949(defun set-symbol-plist (sym plist)
    50   (let* ((len (list-length plist)))
    51     (unless (and len (evenp len))
    52       (error "Bad plist: ~s" plist)))
    53   (setf (%svref (symptr->symvector (%symbol->symptr sym)) target::symbol.plist-cell) plist))
     50  (when plist
     51    (let* ((len (list-length plist)))
     52      (unless (and len (evenp len))
     53        (error "Bad plist: ~s" plist))))
     54  (let* ((vector (symptr->symvector (%symbol->symptr sym)))
     55         (cell (%svref vector target::symbol.plist-cell)))
     56    (if plist
     57      (if (consp cell)
     58        (setf (cdr cell) plist)
     59        (cdr (setf (%svref vector target::symbol.plist-cell) (cons nil plist))))
     60      (if (car cell)
     61        (setf (cdr cell) nil)
     62        (if cell (setf (cdr cell) nil))))))
    5463
    5564
     
    7079(defun symbol-plist (sym)
    7180  "Return SYMBOL's property list."
    72   (%svref (symptr->symvector (%symbol->symptr sym)) target::symbol.plist-cell))
     81  (cdr (%svref (symptr->symvector (%symbol->symptr sym)) target::symbol.plist-cell)))
    7382
    7483
     
    7786  is found, return the associated value, else return DEFAULT."
    7887  (let* ((tail (%pl-search
    79                 (%svref (symptr->symvector (%symbol->symptr sym)) target::symbol.plist-cell) key)))
     88                (cdr (%svref (symptr->symvector (%symbol->symptr sym)) target::symbol.plist-cell)) key)))
    8089    (if tail (%cadr tail) default)))
    8190
    8291(defun put (sym key value)
    8392  (let* ((symptr (%symbol->symptr sym))
    84          (plist (%svref (symptr->symvector symptr) target::symbol.plist-cell))
     93         (vector (symptr->symvector symptr))
     94         (cell  (%svref vector target::symbol.plist-cell))
     95         (plist (cdr cell))
    8596         (tail (%pl-search plist key)))
    8697    (if tail
    8798      (%rplaca (%cdr tail) value)
    88       (setf (%svref (symptr->symvector symptr) target::symbol.plist-cell) (cons key (cons value plist))))
     99      (progn
     100        (setq plist (cons key (cons value plist)))
     101        (if cell
     102          (setf (cdr cell) plist)
     103          (setf (%svref vector target::symbol.plist-cell) (cons nil plist)))))
    89104    value))
    90105
  • branches/working-0711/ccl/lib/compile-ccl.lisp

    r7893 r7908  
    456456    (:darwinx8664 "darwinx8664")))
    457457
    458 (defparameter *known-optional-features* '(:lock-accouting :count-gf-calls :hash-symbols-by-address))
     458(defparameter *known-optional-features* '(:lock-accouting :count-gf-calls))
    459459(defvar *build-time-optional-features* nil)
    460460
  • branches/working-0711/ccl/xdump/hashenv.lisp

    r7739 r7908  
    8383  nhti.nkeys)
    8484
     85(defconstant +nil-hash+ (mixup-hash-code (%pname-hash "NIL" 3)))
    8586
    8687
  • branches/working-0711/ccl/xdump/xfasload.lisp

    r7894 r7908  
    746746        (warn "Symbol at #x~x (~a): plist already set." addr str))
    747747      (setf (xload-%svref addr target::symbol.plist-cell)
    748             new))
     748            (xload-make-cons *xload-target-nil* new)))
    749749    new))
    750750     
Note: See TracChangeset for help on using the changeset viewer.