Jan 28, 2013, 4:34:15 PM (7 years ago)

This is a work-in-progress; there will need to be new binaries
and similar changes for other architectures.

compiler/nx2.lisp: do late constant-folding on comparisons. (This depends

on being able to use operators for T and NIL in the backend; since backends
don't necessarily support that, check first.)

compiler/optimizers.lisp: bind temporaries for 3-arg numeric comparisons.

compiler/vinsn.lisp: do dead-code elimination at the vinsn level. Because

of the way that "aligned labels" work on x86, introduce an :align vinsn
attribute. Add/change some utilities for finding next/previous vinsn, etc.

compiler/X86/x862.lisp: Handle operators for T/NIL. Peephole optimize

things like (if (let ...)) where the LET returns a constant value and
we need to discard some words from the stack.

compiler/X86/X8664/x8664-arch.lisp: Bump image version

compiler/X86/X8664/x8664-vinsns.lisp: EMIT-ALIGNED-LABEL has :align


level-0/l0-hash.lisp: Don't assume that GC maintains weak-deletions; do

assume that it maintains count/deleted-count, so lock-based code adjusts
those slots atomically.

level-0/l0-misc.lisp: We don't want to use futexes (at least not instead

of spinlocks.)

level-0/X86/x86-misc.lisp: %ATOMIC-INCF-NODE needs to pause while spinning.

(Note that a locked ADD may be faster on x86, but wouldn't return a
meaningful value and some callers expect it to.)

level-1/l1-clos-boot.lisp: no more DESTRUCTURE-STATE.
level-1/l1-files.lisp: indentation change
level-1/l1-utils.lisp: no more DESTRUCTURE-STATE.
level-1/linux-files.lisp: UNSETENV

lib/hash.lisp: no need to %NORMALIZE-HASH-TABLE-COUNT.
lib/macros.lisp: no more DESTRUCTURE-STATE.

library/lispequ.lisp: no more DESTRUCTURE-STATE.

lisp-kernel/gc-common.c: decrement count when removing weak key from

hash vector; increment deleted-count if not lock-free.

lisp-kernel/x86-constants64.h: bump current, max image versions

lisp-kernel/linuxx8664/Makefile: don't define USE_FUTEX.

1 edited


  • trunk/source/level-0/l0-hash.lisp

    r15601 r15606  
    406406  (istruct-typep hash 'hash-table))
    408 (defun %normalize-hash-table-count (hash)
    409   (let* ((vector (nhash.vector hash))
    410          (weak-deletions-count (nhash.vector.weak-deletions-count vector)))
    411     (declare (fixnum weak-deletions-count))
    412     (unless (eql 0 weak-deletions-count)
    413       (setf (nhash.vector.weak-deletions-count vector) 0)
    414       ;; lock-free hash tables don't maintain deleted-count, since would need to
    415       ;; lock and it's not worth it.
    416       (unless (hash-lock-free-p hash)
    417         (let ((deleted-count (the fixnum
    418                                (+ (the fixnum (nhash.vector.deleted-count vector))
    419                                   weak-deletions-count)))
    420               (count (the fixnum (- (the fixnum (nhash.vector.count vector)) weak-deletions-count))))
    421           (setf (nhash.vector.deleted-count vector) deleted-count
    422                 (nhash.vector.count vector) count))))))
    599584    ;; We don't try to maintain a running total, so just count.
    600585    (return-from hash-table-count (lock-free-count-entries hash)))
    601   (%normalize-hash-table-count hash)
    602586  (the fixnum (nhash.vector.count (nhash.vector hash))))
    940924                 (atomic-decf (nhash.grow-threshold hash))
    941925                 (when (set-hash-key-conditional vector-index vector free-hash-marker key)
    942                    ;; %needs-rehashing-p is not equite enough in the track_keys case, since gc cannot
     926                   ;; %needs-rehashing-p is not quite enough in the track_keys case, since gc cannot
    943927                   ;; track this key until it's actually added to the table.  Check now.
    944928                   (if (and (%ilogbitp $nhash_track_keys_bit (nhash.vector.flags vector))
    10581042               (setf (%svref vector vidx) deleted-hash-key-marker)
    10591043               (setf (%svref vector (the fixnum (1+ vidx))) nil))
    1060              (incf (the fixnum (nhash.vector.deleted-count vector)))
    1061              (decf (the fixnum (nhash.vector.count vector)))
     1044             (atomic-incf (the fixnum (nhash.vector.deleted-count vector)))
     1045             (atomic-decf (the fixnum (nhash.vector.count vector)))
    10621046             (setq foundp t))
    10631047           (let* ((vector-index (funcall (nhash.find hash) hash key)))
    10701054                     (nhash.vector.cache-value vector) nil)
    10711055               ;; Update the count
    1072                (incf (the fixnum (nhash.vector.deleted-count vector)))
    1073                (decf (the fixnum (nhash.vector.count vector)))
     1056               (atomic-incf (the fixnum (nhash.vector.deleted-count vector)))
     1057               (atomic-decf (the fixnum (nhash.vector.count vector)))
    10741058               ;; Delete the value from the table.
    10751059               (setf (%svref vector vector-index) deleted-hash-key-marker
    11081092             (nhash.vector.finalization-alist vector) nil
    11091093             (nhash.vector.free-alist vector) nil
    1110              (nhash.vector.weak-deletions-count vector) 0
    11111094             (nhash.vector.deleted-count vector) 0
    11121095             (nhash.vector.flags vector) (logand $nhash_weak_flags_mask
    11491132                     (%set-hash-table-vector-key vector vector-index key)
    11501133                     (setf (%svref vector (the fixnum (1+ vector-index))) value)
    1151                      (incf (the fixnum (nhash.vector.count vector)))
     1134                     (atomic-incf (nhash.vector.count vector))
    11521135                     ;; Adjust deleted-count
    1153                      (when (> 0 (the fixnum
    1154                                   (decf (the fixnum
    1155                                           (nhash.vector.deleted-count vector)))))
    1156                        (%normalize-hash-table-count hash)))
     1136                     (atomic-decf (nhash.vector.deleted-count vector)))
    11571137                    ((eq old-value free-hash-marker)
    11581138                     (when (eql 0 (nhash.grow-threshold hash))
    11631143                     (setf (%svref vector (the fixnum (1+ vector-index))) value)
    11641144                     (decf (the fixnum (nhash.grow-threshold hash)))
    1165                      (incf (the fixnum (nhash.vector.count vector))))
     1145                     (atomic-incf (the fixnum (nhash.vector.count vector))))
    11661146                    (t
    11671147                     ;; Key was already there, update value.
    11881168          (return count))))))
    11961170(defun grow-hash-table (hash)
    11971171  (unless (typep hash 'hash-table)
    12111185(defun %grow-hash-table (hash)
    12121186  (block grow-hash-table
    1213     (%normalize-hash-table-count hash)
    12141187    (let* ((old-vector (nhash.vector hash))
    12151188           (old-size (nhash.vector.count old-vector))
    12361209                    weak-flags (logand flags $nhash_weak_flags_mask))
    12371210              (setf (nhash.vector.flags old-vector) flags-sans-weak)      ; disable GC weak stuff
    1238               (%normalize-hash-table-count hash)
    12391211              (when (%grow-hash-table-in-place-p hash)
    12401212                (setf (nhash.vector.flags old-vector) flags)
    15631535            (when (or deleted (eq key free-hash-marker))
    15641536              (if deleted  ; one less deleted entry
    1565                 (let ((count (1- (nhash.vector.deleted-count vector))))
    1566                   (declare (fixnum count))
    1567                   (setf (nhash.vector.deleted-count vector) count)
    1568                   (if (< count 0)
    1569                     (let ((wdc (nhash.vector.weak-deletions-count vector)))
    1570                       (setf (nhash.vector.weak-deletions-count vector) 0)
    1571                       (incf (nhash.vector.deleted-count vector) wdc)
    1572                       (decf (nhash.vector.count vector) wdc)))
     1537                (progn
     1538                  (atomic-decf  (nhash.vector.deleted-count vector))
    15731539                  (incf (nhash.grow-threshold hash))
    15741540                  ;; Change deleted to free
    15971563                                  (setq deleted (eq newkey deleted-hash-key-marker)))
    15981564                          (when deleted
    1599                             (let ((count (1- (nhash.vector.deleted-count vector))))
    1600                               (declare (fixnum count))
    1601                               (setf (nhash.vector.deleted-count vector) count)
    1602                               (if (< count 0)
    1603                                 (let ((wdc (nhash.vector.weak-deletions-count vector)))
    1604                                   (setf (nhash.vector.weak-deletions-count vector) 0)
    1605                                   (incf (nhash.vector.deleted-count vector) wdc)
    1606                                   (decf (nhash.vector.count vector) wdc)))
    1607                               (incf (nhash.grow-threshold hash))))
     1565                            (atomic-decf (nhash.vector.deleted-count vector))
     1566                            (incf (nhash.grow-threshold hash)))
    16081567                          (return))
    16091568                        (when (eq key newkey)
    16101569                          (cerror "Delete one of the entries." "Duplicate key: ~s in ~s ~s ~s ~s ~s"
    16111570                                  key hash value newvalue index found-index)                       
    1612                           (decf (nhash.vector.count vector))
     1571                          (atomic-decf (nhash.vector.count vector))
    16131572                          (incf (nhash.grow-threshold hash))
    16141573                          (return))
    19631922          (nhash.vector.free-alist vector) nil
    19641923          (nhash.vector.finalization-alist vector) nil
    1965           (nhash.vector.weak-deletions-count vector) 0
    19661924          (nhash.vector.hash vector) nil
    19671925          (nhash.vector.deleted-count vector) 0
Note: See TracChangeset for help on using the changeset viewer.