source: trunk/source/level-0/X86/x86-hash.lisp @ 15264

Last change on this file since 15264 was 15264, checked in by gb, 8 years ago

lib/compile-ccl.lisp: Define some "optional features" for testing
hashing algorithms. :EQ-HASH-MONITOR causes EQ-hashing routines to
record the number of calls/probes involved. (The INCFs here aren't
thread-safe.) :MIXUP-HASH-CODE-NOP makes the function
CCL::MIXUP-HASH-CODE return its argument.

Implement WITH-GLOBAL-OPTIMIZATION-SETTINGS a little differently;
use it in TEST-CCL.

level-0/X86/x86-hash.lisp: in STRIP-TAG-TO-FIXNUM, shift by an
extra bit (so that results aren't always odd/even depending on
tag bits of arg.) This seems to be the right thing and should
likely be implemented on all architectures.

level-0/l0-hash.lisp: conditionally implement the new optional
features.

NEED-USE-EQL: can use EQ if arg is a fixnum or #+64-bit-target
a SINGLE-FLOAT.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1;;; -*- Mode: Lisp; Package: CCL -*-
2;;;
3;;;   Copyright (C) 2006-2009 Clozure Associates and contributors
4;;;   This file is part of Clozure CL. 
5;;;
6;;;   Clozure CL is licensed under the terms of the Lisp Lesser GNU Public
7;;;   License , known as the LLGPL and distributed with Clozure CL as the
8;;;   file "LICENSE".  The LLGPL consists of a preamble and the LGPL,
9;;;   which is distributed with Clozure CL as the file "LGPL".  Where these
10;;;   conflict, the preamble takes precedence. 
11;;;
12;;;   Clozure CL is referenced in the preamble as the "LIBRARY."
13;;;
14;;;   The LLGPL is also available online at
15;;;   http://opensource.franz.com/preamble.html
16
17;;; level-0;ppc;ppc-hash.lisp
18
19
20(in-package "CCL")
21#+x8664-target
22(progn
23
24(eval-when (:compile-toplevel :execute)
25  (require "HASHENV" "ccl:xdump;hashenv"))
26
27
28
29
30;;; This should stay in LAP so that it's fast
31;;; Equivalent to cl:mod when both args are positive fixnums
32
33
34(defx86lapfunction fast-mod ((number arg_y) (divisor arg_z))
35  (xorq (% imm1) (% imm1))
36  (mov (% number) (% imm0))
37  (div (% divisor))
38  (mov (% imm1) (% arg_z))
39  (single-value-return))
40
41
42;; Faster mod based on Bruce Hoult's Dylan version, modified to use a branch-free max.
43(defx86lapfunction fast-mod-3 ((number arg_x) (divisor arg_y) (recip arg_z))
44  (mov (% number) (% imm0))
45  (shrq ($ target::fixnumshift) (% imm0))
46  (mov (% recip) (% imm1))
47  (mul (% imm1)) ;; -> hi word in imm1 (unboxed)
48  (mov (% divisor) (% imm0))
49  (mul (% imm1)) ;; -> lo word in imm0 (boxed)
50  (subq (% imm0) (% number))
51  (subq (% divisor) (% number))
52  (mov (% number) (% arg_z))
53  (mov (% number) (% imm0))
54  (sar ($ (1- target::nbits-in-word)) (% imm0))
55  (andq (% imm0) (% divisor))
56  (addq (% divisor) (% arg_z))
57  (single-value-return))
58
59(defx86lapfunction %dfloat-hash ((key arg_z))
60  (movq (@ x8664::double-float.value (% key)) (% imm0))
61  (box-fixnum imm0 arg_z)
62  (single-value-return))
63
64(defx86lapfunction %sfloat-hash ((key arg_z))
65  (mov (% key) (% imm1))
66  (movl ($ #x-80000000) (%l imm0))
67  (shr ($ 32) (% imm1))
68  (xorq (% arg_y) (% arg_y))
69  (shr ($ (- 32 x8664::fixnumshift)) (% key))
70  (rcmp (%l imm0) (%l imm1))
71  (cmoveq (% arg_y) (% arg_z))
72  (single-value-return))
73
74(defx86lapfunction %macptr-hash ((key arg_z))
75  (movq (@ target::macptr.address (% key)) (% imm0))
76  (movq (% imm0) (% imm1))
77  (shlq ($ 24) (% imm1))
78  (addq (% imm1) (% imm0))
79  (movq ($ (lognot target::fixnummask)) (% arg_z))
80  (andq (% imm0) (% arg_z))
81  (single-value-return))
82
83
84(defx86lapfunction %bignum-hash ((key arg_z))
85  (let ((header imm0)
86        (offset imm1)
87        (ndigits temp0))
88    (getvheader key header)
89    (header-length header ndigits)
90    (xorq (% offset) (% offset))
91    (let ((immhash header))
92      @loop
93      (rolq ($ 13) (% immhash))
94      (addl (@ x8664::misc-data-offset (% key) (% offset)) (%l immhash))
95      (addq ($ 4) (% offset))
96      (subq ($ '1) (% ndigits))
97      (jne  @loop)
98      (box-fixnum immhash arg_z))
99    (single-value-return)))
100
101
102(defx86lapfunction %get-fwdnum ()
103  (ref-global target::fwdnum arg_z)
104  (single-value-return))
105
106
107(defx86lapfunction %get-gc-count ()
108  (ref-global target::gc-count arg_z)
109  (single-value-return))
110
111
112;;; Setting a key in a hash-table vector needs to
113;;; ensure that the vector header gets memoized as well
114(defx86lapfunction %set-hash-table-vector-key ((vector arg_x) (index arg_y) (value arg_z))
115  (jmp-subprim .SPset-hash-key))
116
117;;; This needs to be done out-of-line, to handle EGC memoization.
118(defx86lapfunction %set-hash-table-vector-key-conditional ((offset 8) #|(ra 0)|# (vector arg_x) (old arg_y) (new arg_z))
119  (movq (@ offset (% rsp)) (% temp0))
120  (save-simple-frame)
121  (call-subprim .SPset-hash-key-conditional)
122  (restore-simple-frame)
123  (single-value-return 3))
124
125;;; Strip the tag bits to turn x into a fixnum
126(defx86lapfunction strip-tag-to-fixnum ((x arg_z))
127  (movq (% x) (% imm0))
128  (shlq ($ x8664::ntagbits) (% imm0))
129  (box-fixnum imm0 arg_z)
130  (single-value-return))
131
132;;; end of x86-hash.lisp
133) ; #+x8664-target
Note: See TracBrowser for help on using the repository browser.