source: release/1.4/source/level-0/X86/X8632/x8632-clos.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: 8.8 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
[9002]15(in-package "CCL")
16
17;;; This just maps a SLOT-ID to a SLOT-DEFINITION or NIL.
18;;; The map is a vector of (UNSIGNED-BYTE 8); this should
19;;; be used when there are fewer than 255 slots in the class.
20(defx8632lapfunction %small-map-slot-id-lookup ((slot-id arg_z))
21 (movl (@ 'map (% fn)) (% temp1))
22 (svref slot-id slot-id.index arg_y)
23 (vector-length temp1 temp0)
24 (xorl (%l imm0) (%l imm0))
25 (rcmpl (% arg_y) (% temp0))
26 (ja @have-table-index)
27 (movl (% arg_y) (% imm0))
28 (shrl ($ x8632::word-shift) (% imm0))
29 (movzbl (@ x8632::misc-data-offset (% temp1) (% imm0)) (%l imm0))
[10478]30 ;(shll ($ x8632::word-shift) (% imm0))
[9002]31 @have-table-index
32 (movl (@ 'table (% fn)) (% temp0))
33 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_z))
34 (single-value-return))
35
36;;; The same idea, only the map is a vector of (UNSIGNED-BYTE 32).
37(defx8632lapfunction %large-map-slot-id-lookup ((slot-id arg_z))
38 (movl (@ 'map (% fn)) (% temp1))
39 (svref slot-id slot-id.index arg_y)
40 (vector-length temp1 temp0)
41 (xorl (%l imm0) (%l imm0))
42 (rcmpl (% arg_y) (% temp0))
43 (ja @have-table-index)
44 (movl (% arg_y) (% imm0))
45 (movl (@ x8632::misc-data-offset (% temp1) (% imm0)) (%l imm0))
46 @have-table-index
47 (movl (@ 'table (% fn)) (% temp0))
48 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_z))
49 (single-value-return))
50
51(defx8632lapfunction %small-slot-id-value ((instance arg_y) (slot-id arg_z))
52 (movl (@ 'map (% fn)) (% temp1))
53 (svref slot-id slot-id.index temp0)
54 (vector-length temp1 imm0)
55 (rcmpl (% temp0) (% imm0))
56 (movl ($ 0) (% imm0)) ;don't disturb flags
57 (ja @missing)
58 (movl (% temp0) (% imm0))
59 (shrl ($ x8632::word-shift) (% imm0))
60 (movzbl (@ x8632::misc-data-offset (% temp1) (% imm0)) (% imm0))
61 (testl (% imm0) (% imm0))
62 (je @missing)
63 (movl (@ 'table (% fn)) (% temp0))
64 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_z))
65 (popl (% ra0))
66 (pushl ($ x8632::reserved-frame-marker))
67 (pushl ($ x8632::reserved-frame-marker))
68 (pushl (@ 'class (% fn)))
69 (set-nargs 3)
70 (pushl (% ra0))
[12788]71 (jmp (@ '%maybe-std-slot-value-using-class (% fn)))
[9002]72 @missing ; (%slot-id-ref-missing instance id)
73 (set-nargs 2)
74 (jmp (@'%slot-id-ref-missing (% fn))))
75
76(defx8632lapfunction %large-slot-id-value ((instance arg_y) (slot-id arg_z))
77 (movl (@ 'map (% fn)) (% temp1))
78 (svref slot-id slot-id.index temp0)
79 (vector-length temp1 imm0)
80 (rcmp (% temp0) (% imm0))
81 (movl ($ 0) (% imm0))
82 (ja @missing)
83 (movl (% temp0) (% imm0))
84 (movl (@ x8632::misc-data-offset (% temp1) (% imm0)) (% imm0))
85 (test (% imm0) (% imm0))
86 (je @missing)
87 (movl (@ 'table (% fn)) (% temp0))
88 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_z))
89 (popl (% ra0))
90 (pushl ($ x8632::reserved-frame-marker))
91 (pushl ($ x8632::reserved-frame-marker))
92 (pushl (@ 'class (% fn)))
93 (set-nargs 3)
94 (pushl (% ra0))
[12788]95 (jmp (@ '%maybe-std-slot-value-using-class (% fn)))
[9002]96 @missing ; (%slot-id-ref-missing instance id)
97 (set-nargs 2)
98 (jmp (@'%slot-id-ref-missing (% fn))))
99
100(defx86lapfunction %small-set-slot-id-value ((instance 4)
101 #|(ra 0)|#
102 (slot-id arg_y)
103 (new-value arg_z))
104 (movl (@ 'map (% fn)) (% temp1))
105 (svref slot-id slot-id.index imm0)
106 (vector-length temp1 temp0)
107 (rcmpl (% imm0) (% temp0))
108 (ja @missing)
109 (shrl ($ x8632::word-shift) (% imm0))
110 (movzbl (@ x8632::misc-data-offset (% temp1) (% imm0)) (% imm0))
111 (testl (% imm0) (% imm0))
112 (je @missing)
[9158]113 (movl (@ 'table (% fn)) (% temp0))
114 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_y))
[9002]115 (popl (% temp0)) ;return address
116 (popl (% temp1)) ;instance
[9158]117 ;; use existing frame
[9002]118 (pushl (@ 'class (% fn)))
119 (pushl (% temp1))
120 (pushl (% temp0))
121 (set-nargs 4)
122 ;; (%maybe-std-setf-slot-value-using-class class instance slotd new)
123 (jmp (@ '%maybe-std-setf-slot-value-using-class (% fn)))
124 @missing
125 (set-nargs 3)
126 ;; (%slot-id-set-missing instance id new)
127 (jmp (@ '%slot-id-set-missing (% fn))))
128
129(defx8632lapfunction %large-set-slot-id-value ((instance 4)
130 #|(ra 0)|#
131 (slot-id arg_y)
132 (new-value arg_z))
133 (movl (@ 'map (% fn)) (% temp1))
134 (svref slot-id slot-id.index imm0)
135 (vector-length temp1 temp0)
136 (rcmpl (% imm0) (% temp0))
137 (ja @missing)
[9638]138 (movl (@ x8632::misc-data-offset (% temp1) (% imm0)) (%l imm0))
[9002]139 (testl (%l imm0) (%l imm0))
140 (je @missing)
[9158]141 (movl (@ 'table (% fn)) (% temp0))
142 (movl (@ x8632::misc-data-offset (% temp0) (% imm0) 4) (% arg_y))
[9002]143 (popl (% temp0)) ;return addr
144 (popl (% temp1)) ;instance
145 (pushl (@ 'class (% fn)))
146 (pushl (% temp1))
147 (pushl (% temp0))
148 (set-nargs 4)
149 (jmp (@ '%maybe-std-setf-slot-value-using-class (% fn)))
150 @missing ; (%slot-id-set-missing instance id new-value)
151 (set-nargs 3)
152 (jmp (@'%slot-id-ref-missing (% fn))))
153
154;;; All of the generic function trampoline functions have to be
155;;; exactly the same size (x8632::gf-code-size) in words. The largest
156;;; of these - the general-case *GF-PROTO* - is currently about 27
157;;; words, so X8632::GF-CODE-SIZE is just a little bigger than that.
158;;; (Note that x8632::gf-code-size has to include space for the
159;;; self-reference table, which takes up another couple of words in
160;;; addition to the machine instructions.)
161(defparameter *gf-proto*
162 (nfunction
163 gag
164 (lambda (&lap &lexpr args)
165 (x86-lap-function
166 gag
167 ()
168 (:fixed-constants (class-wrapper slots dispatch-table dcode hash))
169 (:code-size x8632::gf-code-size)
170 (movl (@ (% esp)) (% ra0))
171 (save-frame-variable-arg-count)
172 (push-argregs)
173 (pushl (%l nargs))
174 (movl (% esp) (% arg_z))
175 (ref-global.l ret1valaddr imm0)
176 (cmpl (% ra0) (% imm0))
177 (je @multiple)
178 (ref-global.l lexpr-return1v ra0)
179 (jmp @call)
180 @multiple
[10959]181 (pushl (@ (+ (target-nil-value) (x8632::%kernel-global 'lexpr-return))))
[9002]182 (movl (% imm0) (% ra0))
183 @call
184 (push (% ra0))
185 (movl (@ 'dispatch-table (% fn)) (% arg_y))
186 (set-nargs 2)
187 (jmp (@ 'dcode (% fn))) ; dcode function
188 ))))
189
190(defx8632lapfunction gag-one-arg ((arg arg_z))
191 (:fixed-constants (class-wrapper slots dispatch-table dcode hash))
192 (:code-size x8632::gf-code-size)
193 (check-nargs 1)
194 (movl (@ 'dispatch-table (% fn)) (% arg_y))
195 (set-nargs 2)
196 (jmp (@ 'dcode (% fn))))
197
198(defx8632lapfunction gag-two-arg ((arg0 arg_y) (arg1 arg_z))
199 (:fixed-constants (class-wrapper slots dispatch-table dcode hash))
200 (:code-size x8632::gf-code-size)
201 (check-nargs 2)
202 (pop (% ra0))
203 (pushl ($ x8632::reserved-frame-marker))
204 (pushl ($ x8632::reserved-frame-marker))
205 (pushl (@ 'dispatch-table (% fn)))
206 (push (% ra0))
207 (set-nargs 3)
208 (jmp (@ 'dcode (% fn))))
209
210(defx8632lapfunction funcallable-trampoline ()
211 (:fixed-constants (class-wrapper slots dispatch-table dcode hash))
212 (:code-size x8632::gf-code-size)
213 (jmp (@ 'dcode (% fn))))
214
215;;; This is in LAP so that it can reference itself in the error message.
216;;; (It needs to be cloned, so %fn will be unique to each copy.)
217;;; It can't work for this to reference any of its own constants.
218(defx8632lapfunction unset-fin-trampoline ()
219 (:code-size x8632::gf-code-size)
220 (save-frame-variable-arg-count)
221 (call-subprim .SPheap-rest-arg)
222 (pop (% arg_z))
[9125]223 (pushl ($ x8632::reserved-frame-marker))
224 (pushl ($ x8632::reserved-frame-marker))
[9002]225 (pushl ($ '#.$XNOFINFUNCTION))
226 (movl (% fn) (% arg_y))
227 (set-nargs 3)
228 (call-subprim .SPksignalerr)
[10959]229 ;(movl ($ (target-nil-value)) (% arg_z))
[9002]230 (leave)
231 (single-value-return))
232
233(defparameter *cm-proto*
234 (nfunction
235 gag
236 (lambda (&lap &lexpr args)
237 (x86-lap-function
238 gag
239 ()
240 (:fixed-constants (thing dcode gf bits))
241 (movl (@ (% esp)) (% ra0))
242 (save-frame-variable-arg-count)
243 (push-argregs)
244 (pushl (% nargs))
245 (movl (% esp) (% arg_z))
246 (ref-global ret1valaddr imm0)
247 (cmpl (% ra0) (% imm0))
248 (je @multiple)
249 (ref-global lexpr-return1v ra0)
250 (jmp @call)
251 @multiple
[10959]252 (pushl (@ (+ (target-nil-value) (x8632::%kernel-global 'lexpr-return))))
[9002]253 (movl (% imm0) (% ra0))
254 @call
255 (push (% ra0))
256 (movl (@ 'thing (% fn)) (% arg_y))
257 (set-nargs 2)
258 (jmp (@ 'dcode (% fn)))))))
Note: See TracBrowser for help on using the repository browser.