source: release/1.11/source/level-0/X86/X8632/x8632-clos.lisp

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

Merge copyright/license header changes to 1.11 release branch.

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