2
(export '(%structure-name
3
%compiled-function-name
4
%set-compiled-function-name))
6
(eval-when (compile eval load)
7
(setq *EVAL-WHEN-COMPILE* t)
10
(defmacro memq (item list) `(member ,item ,list :test #'eq))
11
(defmacro assq (item list) `(assoc ,item ,list :test #'eq))
12
(defmacro posq (item list) `(position ,item ,list :test #'eq))
14
(defmacro dotimes ((var form &optional (val nil)) &rest body &environment env)
15
(multiple-value-bind (doc decls bod)
16
(extract-declarations body env)
17
(declare (ignore doc))
18
(let ((limit (gensym))
22
(declare (fixnum ,limit ,var))
27
(when (>= ,var ,limit) (return-from nil ,val))
29
(setq ,var (the fixnum (1+ ,var)))
32
(defun printing-random-thing-internal (thing stream)
33
(format stream "~O" (si:address thing)))
35
(eval-when (compile load eval)
36
(pushnew :turbo-closure *features*)
37
(pushnew :turbo-closure-env-size *features*))
40
(defmacro %svref (vector index)
41
`(svref (the simple-vector ,vector) (the fixnum ,index)))
43
(defsetf %svref (vector index) (new-value)
44
`(setf (svref (the simple-vector ,vector) (the fixnum ,index))
47
(si::freeze-defstruct 'pcl::std-instance)
49
(si::freeze-defstruct 'method-call)
50
(si::freeze-defstruct 'fast-method-call)
52
(defvar *pcl-funcall* `(lambda (loc)
54
"{object _funobj = " loc ";"
55
"if(type_of(_funobj)==t_cclosure && (_funobj->cc.cc_turbo))
56
(*(_funobj->cc.cc_self))(_funobj->cc.cc_turbo);
57
else if (type_of(_funobj)==t_cfun) (*(_funobj->cc.cc_self))();
58
else super_funcall_no_event(_funobj);}")))
60
(setq compiler::*super-funcall* *pcl-funcall*)
62
(defmacro fmc-funcall (fn pv-cell next-method-call &rest args)
63
`(funcall ,fn ,pv-cell ,next-method-call ,@args))
65
(defun pcl::proclaim-defmethod (x y) y
67
(setf (get x 'compiler::proclaimed-closure ) t)))
71
;#+turbo-closure-env-size
74
object cclosure_env_nthcdr (n,cc)
78
if(type_of(cc)!=t_cclosure)return Cnil;
79
if((turbo=cc->cc.cc_turbo)==NULL)
82
{if(type_of(env)!=t_cons)return Cnil;
86
{if(n>=fix(*(turbo-1)))return Cnil;
90
(defentry cclosure-env-nthcdr (int object) (object cclosure_env_nthcdr))
91
;; This is the unsafe but fast version.
92
(defentry %cclosure-env-nthcdr (int object) (object cclosure_env_nthcdr))
94
(eval-when (compile eval load)
95
(defparameter *gcl-function-inlines*
96
'( (%fboundp (t) compiler::boolean nil nil "(#0)->s.s_gfdef!=OBJNULL")
97
(%symbol-function (t) t nil nil "(#0)->s.s_gfdef")
98
(si:%structure-name (t) t nil nil "(#0)->str.str_def->str.str_self[0]")
99
(si:%compiled-function-name (t) t nil nil "(#0)->cf.cf_name")
100
(si:%set-compiled-function-name (t t) t t nil "((#0)->cf.cf_name)=(#1)")
101
(cclosurep (t) compiler::boolean nil nil "type_of(#0)==t_cclosure")
102
(sfun-p (t) compiler::boolean nil nil "type_of(#0)==t_sfun")
103
(%cclosure-env (t) t nil nil "(#0)->cc.cc_env")
104
(%set-cclosure-env (t t) t t nil "((#0)->cc.cc_env)=(#1)")
106
(%cclosure-env-nthcdr (fixnum t) t nil nil "(#1)->cc.cc_turbo[#0]")
108
(logxor (fixnum fixnum) fixnum nil nil "((#0) ^ (#1))")))
110
(defun make-function-inline (inline)
111
(setf (get (car inline) 'compiler::inline-always)
112
(list (if (fboundp 'compiler::flags)
113
(let ((opt (cdr inline)))
114
(list (first opt) (second opt)
115
(logior (if (fourth opt) 1 0) ; allocates-new-storage
116
(if (third opt) 2 0) ; side-effect
117
(if nil 4 0) ; constantp
118
(if (eq (car inline) 'logxor)
119
8 0)) ;result type from args
125
(defmacro define-inlines ()
127
,@(mapcan #'(lambda (inline)
128
(let ((name (intern (format nil "~S inline" (car inline))))
129
(vars (mapcar #'(lambda (type)
130
(declare (ignore type))
133
`((eval-when (compile eval load)
134
(make-function-inline
135
',(cons name (cdr inline))))
136
,@(when (or (every #'(lambda (type) (eq type 't))
138
(char= #\% (aref (symbol-name (car inline)) 0)))
139
`((defun ,(car inline) ,vars
140
,@(mapcan #'(lambda (var var-type)
141
(unless (eq var-type 't)
142
`((declare (type ,var-type ,var)))))
144
(the ,(caddr inline) (,name ,@vars)))
145
(make-function-inline ',inline))))))
146
*gcl-function-inlines*)))
150
(defsetf si:%compiled-function-name si:%set-compiled-function-name)
151
(defsetf %cclosure-env %set-cclosure-env)
153
(defun set-function-name-1 (fn new-name ignore)
154
(declare (ignore ignore))
155
(cond ((compiled-function-p fn)
156
(si::turbo-closure fn)
157
(when (symbolp new-name) (pcl::proclaim-defmethod new-name nil))
158
(setf (si:%compiled-function-name fn) new-name))
160
(eq (car fn) 'lambda-block))
161
(setf (cadr fn) new-name))
163
(eq (car fn) 'lambda))
164
(setf (car fn) 'lambda-block
165
(cdr fn) (cons new-name (cdr fn)))))
173
object fSuse_fast_links();
175
object set_cclosure (result_cc,value_cc,available_size)
176
object result_cc,value_cc; int available_size;
178
object result_env_tail,value_env_tail; int i;
180
/* If we are currently using fast linking, */
181
/* make sure to remove the link for result_cc. */
182
(VFUN_NARGS=2,fSuse_fast_links(sLnil,result_cc));
184
/* use_fast_links(3,Cnil,result_cc); */
186
result_env_tail=result_cc->cc.cc_env;
187
value_env_tail=value_cc->cc.cc_env;
188
for(i=available_size;
189
result_env_tail!=Cnil && i>0;
190
result_env_tail=CMPcdr(result_env_tail), value_env_tail=CMPcdr(value_env_tail))
191
CMPcar(result_env_tail)=CMPcar(value_env_tail), i--;
192
result_cc->cc.cc_self=value_cc->cc.cc_self;
193
result_cc->cc.cc_data=value_cc->cc.cc_data;
199
(defentry %set-cclosure (object object int) (object set_cclosure))
202
(defun structure-functions-exist-p ()
205
(si:define-compiler-macro structure-instance-p (x)
207
`(and (si:structurep ,x)
208
(not (eq (si:%structure-name ,x) 'std-instance)))))
210
(defun structure-type (x)
211
(and (si:structurep x)
212
(si:%structure-name x)))
214
(si:define-compiler-macro structure-type (x)
216
`(and (si:structurep ,x)
217
(si:%structure-name ,x))))
219
(defun structure-type-p (type)
220
(or (not (null (gethash type *structure-table*)))
221
(let (#+akcl(s-data nil))
223
(setq s-data (get type 'si::s-data))
225
(null (si::s-data-type s-data)
229
(defun structure-type-included-type-name (type)
230
(or (car (gethash type *structure-table*))
231
(let ((includes (si::s-data-includes (get type 'si::s-data))))
233
(si::s-data-name includes)))))
235
(defun structure-type-internal-slotds (type)
236
(si::s-data-slot-descriptions (get type 'si::s-data))
239
(defun structure-type-slot-description-list (type)
240
(or (cdr (gethash type *structure-table*))
241
(mapcan #'(lambda (slotd)
242
(when (and slotd (car slotd))
243
(let ((offset (fifth slotd)))
244
(let ((reader #'(lambda (x)
245
(si:structure-ref1 x offset)
247
(writer #'(lambda (v x)
248
(si:structure-set x type offset v))))
249
#+turbo-closure (si:turbo-closure reader)
250
#+turbo-closure (si:turbo-closure writer)
252
(let ((*package* *the-pcl-package*))
253
(intern (format nil "~s SLOT~D" type offset))))
254
(writer-sym (get-setf-function-name reader-sym))
255
(slot-name (first slotd))
256
(read-only-p (fourth slotd)))
257
(setf (symbol-function reader-sym) reader)
258
(setf (symbol-function writer-sym) writer)
259
(do-standard-defsetf-1 reader-sym)
260
(list (list slot-name
262
(and (not read-only-p) writer))))))))
263
(let ((slotds (structure-type-internal-slotds type))
264
(inc (structure-type-included-type-name type)))
266
(nthcdr (length (structure-type-internal-slotds inc))
270
(defun structure-slotd-name (slotd)
273
(defun structure-slotd-accessor-symbol (slotd)
276
;(defun structure-slotd-writer-function (slotd)
279
(defun structure-slotd-reader-function (slotd)
282
(defun structure-slotd-writer-function (slotd)
285
(defun renew-sys-files()
287
(compiler::get-packages "sys-package.lisp")
288
(with-open-file (st "sys-package.lisp"
291
(format st "(lisp::in-package \"SI\")
292
(export '(%structure-name
293
%compiled-function-name
294
%set-compiled-function-name))
299
(compiler::make-all-proclaims "*.fn")
300
(with-open-file (st "sys-proclaim.lisp"
303
(format st "~%(IN-PACKAGE \"PCL\")~%")
307
(sloop::sloop for v in-package "PCL"
308
when (get v 'compiler::proclaimed-closure)
310
(setf (get v 'compiler::proclaimed-closure) t))