From 74c388909431debbca4a7fcd38ce68091c27cde6 Mon Sep 17 00:00:00 2001 From: Douglas Katzman Date: Mon, 4 Mar 2024 10:35:50 -0500 Subject: [PATCH] Enable #+salted-symbol-hash for 64-bit riscv --- crossbuild-runner/backends/ppc64/features | 1 - crossbuild-runner/backends/x86-64/features | 1 - src/cold/shared.lisp | 6 ++++++ src/compiler/riscv/cell.lisp | 22 ++++++++++------------ 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/crossbuild-runner/backends/ppc64/features b/crossbuild-runner/backends/ppc64/features index 5836013d5..6742c14b0 100644 --- a/crossbuild-runner/backends/ppc64/features +++ b/crossbuild-runner/backends/ppc64/features @@ -3,4 +3,3 @@ :64-bit :untagged-fdefns :sb-thread :soft-card-marks :gencgc :compare-and-swap-vops :alien-callbacks -:salted-symbol-hash diff --git a/crossbuild-runner/backends/x86-64/features b/crossbuild-runner/backends/x86-64/features index 5cc6ff7fb..2409d99e8 100644 --- a/crossbuild-runner/backends/x86-64/features +++ b/crossbuild-runner/backends/x86-64/features @@ -15,4 +15,3 @@ :executable-funinstances :unbind-in-unwind :no-continue-unwind -:salted-symbol-hash diff --git a/src/cold/shared.lisp b/src/cold/shared.lisp index 2ab1574ea..39ee46fd4 100644 --- a/src/cold/shared.lisp +++ b/src/cold/shared.lisp @@ -319,6 +319,12 @@ (pushnew :immobile-code sb-xc:*features*)) (when (target-featurep :64-bit) (push :compact-symbol sb-xc:*features*)) + (when (target-featurep :64-bit) + ;; Considering that a single config file governs rv32 and rv64, I don't + ;; know how to make this properly configurable. In theory, 32-bit builds could + ;; have a salted hash (gaining 3 bits by making the hash slot raw), but + ;; they don't, so in light of things, this is a valid criterion. + (push :salted-symbol-hash sb-xc:*features*)) (when (target-featurep '(:and :sb-thread (:or (:and :darwin (:not (:or :ppc :x86))) :openbsd))) (push :os-thread-stack sb-xc:*features*)) (when (target-featurep '(:and :x86 :int4-breakpoints)) diff --git a/src/compiler/riscv/cell.lisp b/src/compiler/riscv/cell.lisp index acb837ea4..91950c54e 100644 --- a/src/compiler/riscv/cell.lisp +++ b/src/compiler/riscv/cell.lisp @@ -198,23 +198,21 @@ (:translate symbol-global-value)) #+64-bit +(progn (define-vop (symbol-hash) (:policy :fast-safe) (:translate symbol-hash) (:args (symbol :scs (descriptor-reg))) - (:temporary (:scs (non-descriptor-reg)) temp) - (:results (res :scs (any-reg))) + (:results (res :scs (unsigned-reg))) (:result-types positive-fixnum) (:generator 2 - ;; The symbol-hash slot of NIL holds NIL because it is also the - ;; cdr slot, so we have to strip off the two low bits to make - ;; sure it is a fixnum. The lowtag selection magic that is - ;; required to ensure this is explained in the comment in - ;; objdef.lisp - (loadw temp symbol symbol-hash-slot other-pointer-lowtag) - (inst andi res temp (lognot fixnum-tag-mask)))) - -#+64-bit + (loadw res symbol symbol-hash-slot other-pointer-lowtag) + (inst srli res res 24))) ; shift out 3 bytes +(define-vop (symbol-name-hash symbol-hash) + (:translate symbol-name-hash) + (:generator 1 + (inst lwu res symbol ; little-endian + (- (+ 4 (ash symbol-hash-slot word-shift)) other-pointer-lowtag)))) (define-vop () (:args (symbol :scs (descriptor-reg))) (:results (result :scs (unsigned-reg))) @@ -225,7 +223,6 @@ (inst lhu result symbol (+ (ash symbol-name-slot word-shift) (- other-pointer-lowtag) 6)))) ; little-endian -#+64-bit (define-vop () (:policy :fast-safe) (:translate symbol-name) @@ -237,6 +234,7 @@ (loadw result symbol symbol-name-slot other-pointer-lowtag) (inst slli result result sb-impl::package-id-bits) (inst srli result result sb-impl::package-id-bits)))) +) ; end PROGN ;;;; Fdefinition (fdefn) objects.