1
;;;-*-Mode:LISP; Package:(PCL LISP 1000); Base:10; Syntax:Common-lisp -*-
3
;;; *************************************************************************
4
;;; Copyright (c) 1985, 1986, 1987, 1988, 1989, 1990 Xerox Corporation.
5
;;; All rights reserved.
7
;;; Use and copying of this software and preparation of derivative works
8
;;; based upon this software are permitted. Any distribution of this
9
;;; software or derivative works must comply with all applicable United
10
;;; States export control laws.
12
;;; This software is made available AS IS, and Xerox Corporation makes no
13
;;; warranty about the software, its performance or its conformity to any
16
;;; Any person obtaining a copy of this software is requested to send their
17
;;; name and post office or electronic mail address to:
18
;;; CommonLoops Coordinator
20
;;; 3333 Coyote Hill Rd.
21
;;; Palo Alto, CA 94304
22
;;; (or send Arpanet mail to CommonLoops-Coordinator.pa@Xerox.arpa)
24
;;; Suggestions, comments and requests for improvements are also welcome.
25
;;; *************************************************************************
29
(in-package "COMPILER")
31
;; do evaluation of top level forms at compile time.
32
(eval-when (compile eval load)
33
(setq *EVAL-WHEN-COMPILE* t)
36
(pushnew :turbo-closure *features*)
37
(pushnew :turbo-closure-env-size *features*)
38
;; patch around compiler bug.
41
(let ((rset "int Rset;
43
(unless (search rset compiler::*cmpinclude-string*)
44
(setq compiler::*cmpinclude-string*
45
(concatenate 'string rset compiler::*cmpinclude-string*))))
47
(when (get 'si::basic-wrapper 'si::s-data)
48
(pushnew :new-kcl-wrapper *features*)
49
(pushnew :structure-wrapper *features*))
57
(unless (fboundp 'real-c2lambda-expr-with-key)
58
(setf (symbol-function 'real-c2lambda-expr-with-key)
59
(symbol-function 'c2lambda-expr-with-key)))
61
(defun c2lambda-expr-with-key (lambda-list body)
62
(declare (special *sup-used*))
64
(real-c2lambda-expr-with-key lambda-list body))
67
;There is a bug in the implementation of *print-circle* that
68
;causes some akcl debugging commands (including :bt and :bl)
69
;to cause the following error when PCL is being used:
70
;Unrecoverable error: value stack overflow.
72
;When a CLOS object is printed, travel_push_object ends up
73
;traversing almost the whole class structure, thereby overflowing
77
;*print-circle* is badly implemented in kcl.
78
;it has two separate problems that should be fixed:
79
; 1. it traverses the printed object putting all objects found
80
; on the value stack (rather than in a hash table or some
81
; other structure; this is a problem because the size of the value stack
82
; is fixed, and a potentially unbounded number of objects
83
; need to be traversed), and
84
; 2. it blindly traverses all slots of any
85
; kind of structure including std-object structures.
86
; This is safe, but not always necessary, and is very time-consuming
87
; for CLOS objects (because it will always traverse every class).
89
;For now, avoid using *print-circle* T when it will cause problems.
93
(eval-when (compile eval )
94
(defmacro si::f (op &rest args)
95
`(the fixnum (,op ,@ (mapcar #'(lambda (x) `(the fixnum ,x)) args) )))
97
(defmacro si::fb (op &rest args)
98
`(,op ,@ (mapcar #'(lambda (x) `(the fixnum ,x)) args) ))
101
(defun si::display-env (n env)
102
(do ((v (reverse env) (cdr v)))
103
((or (not (consp v)) (si::fb > (fill-pointer si::*display-string*) n)))
104
(or (and (consp (car v))
107
(let ((*print-circle* (can-use-print-circle-p (cadar v))))
108
(format si::*display-string* "~s=~s~@[,~]" (caar v) (cadar v) (cdr v)))))
110
(defun si::display-compiled-env ( plength ihs &aux
111
(base (si::ihs-vs ihs))
112
(end (min (si::ihs-vs (1+ ihs)) (si::vs-top))))
113
(format si::*display-string* "")
115
(v (get (si::ihs-fname ihs) 'si::debug) (cdr v)))
116
((or (si::fb >= i end)(si::fb > (fill-pointer si::*display-string*) plength)))
117
(let ((*print-circle* (can-use-print-circle-p (si::vs i))))
118
(format si::*display-string* "~a~@[~d~]=~s~@[,~]"
119
(or (car v) 'si::loc) (if (not (car v)) (si::f - i base)) (si::vs i)
120
(si::fb < (setq i (si::f + i 1)) end)))))
122
(clines "#define objnull_p(x) ((x==OBJNULL)?Ct:Cnil)")
123
(defentry objnull-p (object) (object "objnull_p"))
125
(defun can-use-print-circle-p (x)
126
(catch 'can-use-print-circle-p
127
(can-use-print-circle-p1 x nil)))
129
(defun can-use-print-circle-p1 (x so-far)
130
(and (not (objnull-p x)) ; because of deficiencies in the compiler, maybe?
131
(if (member x so-far)
132
(throw 'can-use-print-circle-p t)
133
(let ((so-far (cons x so-far)))
134
(flet ((can-use-print-circle-p (x)
135
(can-use-print-circle-p1 x so-far)))
137
(vector (or (not (eq 't (array-element-type x)))
138
(every #'can-use-print-circle-p x)))
139
(cons (and (can-use-print-circle-p (car x))
140
(can-use-print-circle-p (cdr x))))
141
(array (or (not (eq 't (array-element-type x)))
142
(let* ((rank (array-rank x))
143
(dimensions (make-list rank)))
145
(setf (nth i dimensions) (array-dimension x i)))
146
(or (member 0 dimensions)
147
(do ((cursor (make-list rank :initial-element 0)))
149
(declare (:dynamic-extent cursor))
150
(unless (can-use-print-circle-p
151
(apply #'aref x cursor))
153
(when (si::increment-cursor cursor dimensions)
155
(t (or (not (si:structurep x))
156
(let* ((def (si:structure-def x))
157
(name (si::s-data-name def))
158
(len (si::s-data-length def))
159
(pfun (si::s-data-print-function def)))
162
(unless (can-use-print-circle-p
163
(si:structure-ref x name i))
164
(return nil)))))))))))))
166
(defun si::apply-display-fun (display-fun n lis)
167
(let ((*print-length* si::*debug-print-level*)
168
(*print-level* si::*debug-print-level*)
170
(*PRINT-CASE* :downcase)
173
(setf (fill-pointer si::*display-string*) 0)
174
(format si::*display-string* "{")
175
(funcall display-fun n lis)
176
(when (si::fb > (fill-pointer si::*display-string*) n)
177
(setf (fill-pointer si::*display-string*) n)
178
(format si::*display-string* "..."))
180
(format si::*display-string* "}")
185
;The old definition of this had a bug:
186
;sometimes it returned without calling mv-values.
187
(defun si::next-stack-frame (ihs &aux line-info li i k na)
188
(cond ((si::fb < ihs si::*ihs-base*)
189
(si::mv-values nil nil nil nil nil))
191
;; next lower visible ihs
192
(si::mv-setq (fun i) (si::get-next-visible-fun ihs))
194
(cond ((and (setq line-info (get fun 'si::line-info))
195
(do ((j (si::f + ihs 1) (si::f - j 1))
198
(setq form (si::ihs-fun j))
199
(cond ((setq li (si::get-line-of-form form line-info))
200
(return-from si::next-stack-frame
204
(car (aref line-info 0))
206
(list (si::vs (setq k (si::ihs-vs j)))
208
(si::vs (+ k 2)))))))))))))
209
((and (not (special-form-p na))
210
(not (get na 'si::dbl-invisible))
212
(si::mv-values i na nil nil
213
(if (si::ihs-not-interpreted-env i)
215
(let ((i (si::ihs-vs i)))
216
(list (si::vs i) (si::vs (1+ i)) (si::vs (si::f + i 2)))))))
217
(t (si::mv-values nil nil nil nil nil))))