source: release/1.4/source/level-0/X86/X8632/x8632-hash.lisp

Last change on this file was 13075, checked in by R. Matthew Emerson, 15 years ago

Merge trunk changes r13066 through r13067.
(copyright notices)

File size: 4.3 KB
RevLine 
[13075]1;;; Copyright 2009 Clozure Associates
2;;; This file is part of Clozure CL.
3;;;
4;;; Clozure CL is licensed under the terms of the Lisp Lesser GNU
5;;; Public License , known as the LLGPL and distributed with Clozure
6;;; CL as the file "LICENSE". The LLGPL consists of a preamble and
7;;; the LGPL, which is distributed with Clozure CL as the file "LGPL".
8;;; Where these conflict, the preamble takes precedence.
9;;;
10;;; Clozure CL is referenced in the preamble as the "LIBRARY."
11;;;
12;;; The LLGPL is also available online at
13;;; http://opensource.franz.com/preamble.html
14
[7986]15(in-package "CCL")
16
17(eval-when (:compile-toplevel :execute)
18 (require "HASHENV" "ccl:xdump;hashenv"))
19
20;;; This should stay in LAP so that it's fast
21;;; Equivalent to cl:mod when both args are positive fixnums
22(defx8632lapfunction fast-mod ((number arg_y) (divisor arg_z))
[10815]23 (xorl (% edx) (% edx)) ;aka temp1
24 (mov (% number) (% imm0))
25 (div (% divisor)) ;boxed remainder goes into edx/temp1
26 (mov (% edx) (% arg_z))
[7986]27 (single-value-return))
28
[10265]29;; Faster mod based on Bruce Hoult's Dylan version, modified to use a
30;; branch-free max.
31(defx8632lapfunction fast-mod-3 ((number 4) #|(ra 0)|# (divisor arg_y) (recip arg_z))
32 (std) ;temp1 now unboxed
33 (let ((imm1 temp1)
34 (n temp0))
35 (movl (@ number (% esp)) (% n))
36 (movl (% n) (% imm0))
[10272]37 (shrl ($ target::fixnumshift) (% imm0)) ;logical shift is intentional
[10265]38 (mov (% recip) (% imm1))
39 (mul (% imm1)) ;; -> hi word in imm1 (unboxed)
40 (mov (% divisor) (% imm0))
41 (mul (% imm1)) ;; -> lo word in imm0 (boxed)
42 (subl (% imm0) (% n))
43 (subl (% divisor) (% n))
44 (mov (% n) (% arg_z))
45 (mov (% n) (% imm0))
46 (sar ($ (1- target::nbits-in-word)) (% imm0))
47 (andl (% imm0) (% divisor))
48 (addl (% divisor) (% arg_z)))
49 (xorl (% temp1) (% temp1))
50 (cld) ;temp1 now boxed
51 (single-value-return 3))
52
[7986]53(defx8632lapfunction %dfloat-hash ((key arg_z))
54 (movl (@ x8632::double-float.value (% key)) (% imm0))
55 (addl (@ x8632::double-float.val-high (% key)) (% imm0))
56 (box-fixnum imm0 arg_z)
57 (single-value-return))
58
59(defx8632lapfunction %sfloat-hash ((key arg_z))
60 (movl (@ x8632::single-float.value (% key)) (% imm0))
61 (box-fixnum imm0 arg_z)
62 (single-value-return))
63
64(defx8632lapfunction %macptr-hash ((key arg_z))
65 (movl (@ x8632::macptr.address (% key)) (% imm0))
66 (box-fixnum imm0 temp0)
67 (shll ($ (- 24 x8632::fixnumshift)) (% temp0))
68 (addl (% temp0) (% imm0))
69 (movl ($ (lognot x8632::fixnummask)) (% arg_z))
70 (andl (% imm0) (% arg_z))
71 (single-value-return))
72
73(defx8632lapfunction %bignum-hash ((key arg_z))
74 (mark-as-imm temp1)
75 (let ((header imm0)
76 (offset temp1)
77 (ndigits temp0))
78 (getvheader key header)
79 (header-length header ndigits)
80 (xorl (% offset) (% offset))
81 (let ((immhash header))
82 @loop
83 (roll ($ 13) (% immhash))
84 (addl (@ x8632::misc-data-offset (% key) (% offset)) (% immhash))
85 (addl ($ 4) (% offset))
86 (subl ($ '1) (% ndigits))
87 (jne @loop)
88 (box-fixnum immhash arg_z)))
89 (mark-as-node temp1)
90 (single-value-return))
91
92(defx8632lapfunction %get-fwdnum ()
93 (ref-global target::fwdnum arg_z)
94 (single-value-return))
95
96(defx8632lapfunction %get-gc-count ()
97 (ref-global target::gc-count arg_z)
98 (single-value-return))
99
100;;; Setting a key in a hash-table vector needs to
101;;; ensure that the vector header gets memoized as well
102(defx8632lapfunction %set-hash-table-vector-key ((vector 4) #|(ra 0)|# (index arg_y) (value arg_z))
103 (pop (% temp1)) ;return address
104 (pop (% temp0)) ;.SPset-hash-key wants arg in temp0
105 (discard-reserved-frame)
106 (push (% temp1))
107 (jmp-subprim .SPset-hash-key))
108
[10731]109;;; This needs to be done out-of-line, to handle EGC memoization.
110(defx8632lapfunction %set-hash-table-vector-key-conditional ((offset 8)
111 (vector 4)
112 #|(ra 0)|#
113 (old arg_y)
114 (new arg_z))
115 (movl (@ offset (% esp)) (% temp0))
116 (movl (@ vector (% esp)) (% temp1))
117 (save-simple-frame)
118 (call-subprim .SPset-hash-key-conditional)
119 (restore-simple-frame)
120 (single-value-return 4))
121
122
[7986]123;;; Strip the tag bits to turn x into a fixnum
124(defx8632lapfunction strip-tag-to-fixnum ((x arg_z))
125 (andb ($ (lognot x8632::fixnummask)) (%b x))
126 (single-value-return))
127
Note: See TracBrowser for help on using the repository browser.