Changeset 13488 for trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
- Timestamp:
- 08/13/11 20:26:01 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r13487 r13488 1076 1076 (defknown declare-field (t t t) t) 1077 1077 (defun declare-field (name descriptor) 1078 (let ((field (make-field name descriptor 1079 :flags '(:final :static :private)))) 1078 (let ((field (make-field name descriptor :flags '(:final :static)))) 1080 1079 (class-add-field *class-file* field))) 1081 1080 … … 1349 1348 (defknown declare-local-function (local-function) string) 1350 1349 (defun declare-local-function (local-function) 1351 (declare-with-hashtable 1352 local-function *declared-functions* ht g 1353 (setf g (symbol-name (gensym "LFUN"))) 1354 (let ((class-name (abcl-class-file-class-name 1355 (compiland-class-file 1356 (local-function-compiland local-function))))) 1357 (with-code-to-method 1358 (*class-file* (abcl-class-file-constructor *class-file*)) 1359 ;; fixme *declare-inline* 1360 (declare-field g +lisp-object+) 1361 (emit-new class-name) 1362 (emit 'dup) 1363 (emit-invokespecial-init class-name '()) 1364 (emit-putstatic *this-class* g +lisp-object+) 1365 (setf (gethash local-function ht) g))))) 1350 (let ((class-name (abcl-class-file-class-name 1351 (compiland-class-file 1352 (local-function-compiland local-function)))) 1353 (field-name (local-function-field local-function))) 1354 (with-code-to-method 1355 (*class-file* (abcl-class-file-constructor *class-file*)) 1356 ;; fixme *declare-inline* 1357 (declare-field field-name +lisp-object+) 1358 (emit-new class-name) 1359 (emit 'dup) 1360 (emit-invokespecial-init class-name '()) 1361 (emit-putstatic *this-class* field-name +lisp-object+)))) 1366 1362 1367 1363 … … 2196 2192 (local-function (find-local-function op)) 2197 2193 (*register* *register*)) 2198 (cond ((local-function-variable local-function) 2199 ;; LABELS 2200 (dformat t "compile-local-function-call LABELS case variable = ~S~%" 2201 (variable-name (local-function-variable local-function))) 2202 (compile-var-ref (make-var-ref 2203 (local-function-variable local-function)) 2204 'stack nil)) 2194 (cond 2205 2195 ((local-function-environment local-function) 2206 2196 (assert (local-function-references-allowed-p local-function)) … … 4041 4031 "Creates a class file associated with `compiland`, writing it 4042 4032 either to stream or the pathname of the class file if `stream' is NIL." 4043 (let* ((class-file (compiland-class-file compiland)) 4044 (pathname (abcl-class-file-pathname class-file))) 4033 (let* ((pathname (funcall *pathnames-generator*)) 4034 (class-file (make-abcl-class-file :pathname pathname))) 4035 (setf (compiland-class-file compiland) class-file) 4045 4036 (with-open-stream (f (or stream 4046 4037 (open pathname :direction :output … … 4068 4059 bytes))))))) 4069 4060 4070 (defun emit-make-compiled-closure-for-labels (local-function)4071 (let ((parent (compiland-parent (local-function-compiland local-function))))4072 (multiple-value-bind4073 (class field)4074 (local-function-class-and-field local-function)4075 (emit-getstatic class field +lisp-object+))4076 (when (compiland-closure-register parent)4077 (dformat t "(compiland-closure-register parent) = ~S~%"4078 (compiland-closure-register parent))4079 (emit-checkcast +lisp-compiled-closure+)4080 (duplicate-closure-array parent)4081 (emit-invokestatic +lisp+ "makeCompiledClosure"4082 (list +lisp-object+ +closure-binding-array+)4083 +lisp-object+)))4084 (emit-move-to-variable (local-function-variable local-function)))4085 4086 4061 (defknown p2-labels-process-compiland (t) t) 4087 4062 (defun p2-labels-process-compiland (local-function) … … 4089 4064 (cond 4090 4065 (*file-compilation* 4091 (compile-and-write-to-stream compiland) 4092 (emit-make-compiled-closure-for-labels local-function)) 4066 (compile-and-write-to-stream compiland)) 4093 4067 (t 4094 4068 (with-open-stream (stream (sys::%make-byte-array-output-stream)) … … 4099 4073 (abcl-class-file-class-name 4100 4074 (compiland-class-file compiland))) 4101 bytes) 4102 (emit-make-compiled-closure-for-labels local-function))))))) 4075 bytes))))))) 4103 4076 4104 4077 (defknown p2-flet-node (t t t) t) … … 4126 4099 (body (cddr form))) 4127 4100 (dolist (local-function local-functions) 4128 (push local-function *local-functions*) 4129 (push (local-function-variable local-function) *visible-variables*)) 4130 (dolist (local-function local-functions) 4131 (let ((variable (local-function-variable local-function))) 4132 (aver (null (variable-register variable))) 4133 (unless (variable-closure-index variable) 4134 (setf (variable-register variable) (allocate-register nil))))) 4101 (push local-function *local-functions*)) 4135 4102 (dolist (local-function local-functions) 4136 4103 (p2-labels-process-compiland local-function)) … … 4142 4109 (defun p2-lambda (local-function target) 4143 4110 (let ((compiland (local-function-compiland local-function))) 4144 (aver (not (null (compiland-class-file compiland))))4145 4111 (cond (*file-compilation* 4146 4112 (compile-and-write-to-stream compiland) … … 4186 4152 ((setf local-function (find-local-function name)) 4187 4153 (dformat t "p2-function 1~%") 4188 (cond 4189 ((local-function-variable local-function) 4190 (dformat t "p2-function 2 emitting var-ref~%") 4191 (compile-var-ref (make-var-ref 4192 (local-function-variable local-function)) 4193 'stack nil)) 4194 (t 4195 (multiple-value-bind 4196 (class field) 4197 (local-function-class-and-field local-function) 4198 (emit-getstatic class field +lisp-object+)) 4199 (when (compiland-closure-register *current-compiland*) 4200 (emit-checkcast +lisp-compiled-closure+) 4201 (duplicate-closure-array *current-compiland*) 4202 (emit-invokestatic +lisp+ "makeCompiledClosure" 4203 (list +lisp-object+ +closure-binding-array+) 4204 +lisp-object+)))) 4154 (multiple-value-bind 4155 (class field) 4156 (local-function-class-and-field local-function) 4157 (emit-getstatic class field +lisp-object+)) 4158 (when (compiland-closure-register *current-compiland*) 4159 (emit-checkcast +lisp-compiled-closure+) 4160 (duplicate-closure-array *current-compiland*) 4161 (emit-invokestatic +lisp+ "makeCompiledClosure" 4162 (list +lisp-object+ +closure-binding-array+) 4163 +lisp-object+)) 4205 4164 (emit-move-from-stack target)) 4206 4165 ((inline-ok name) … … 4224 4183 (emit-move-from-stack target) 4225 4184 (return-from p2-function)) 4226 (cond 4227 ((local-function-variable local-function) 4228 (dformat t "p2-function 2~%") 4229 (compile-var-ref (make-var-ref 4230 (local-function-variable local-function)) 4231 'stack nil)) 4232 (t 4233 (multiple-value-bind 4234 (class field) 4235 (local-function-class-and-field) 4236 ; Stack: template-function 4237 (emit-getstatic class field +lisp-object+))))) 4185 (multiple-value-bind 4186 (class field) 4187 (local-function-class-and-field local-function) 4188 ; Stack: template-function 4189 (emit-getstatic class field +lisp-object+))) 4238 4190 ((and (member name *functions-defined-in-current-file* :test #'equal) 4239 4191 (not (notinline-p name))) … … 7102 7054 7103 7055 7104 (defun assign-field-and-class-name (local-function) 7105 (let* ((pathname (funcall *pathnames-generator*)) 7106 (class-file (make-abcl-class-file :pathname pathname)) 7107 (compiland (local-function-compiland local-function))) 7108 (setf (compiland-class-file compiland) class-file)) 7056 (defun assign-field-name (local-function) 7109 7057 (setf (local-function-field local-function) 7110 ( declare-local-function local-function)))7058 (symbol-name (gensym "LFUN")))) 7111 7059 7112 7060 (defknown p2-compiland (t) t) … … 7162 7110 7163 7111 (dolist (local-function (compiland-children compiland)) 7164 (assign-field- and-class-name local-function))7112 (assign-field-name local-function)) 7165 7113 7166 7114 (dolist (var (compiland-arg-vars compiland)) … … 7308 7256 ;; Warn if any unused args. (Is this the right place?) 7309 7257 (check-for-unused-variables (compiland-arg-vars compiland)) 7258 7259 (dolist (local-function (compiland-children compiland)) 7260 (when (compiland-class-file (local-function-compiland local-function)) 7261 (declare-local-function local-function))) 7310 7262 7311 7263 ;; Go back and fill in prologue.
Note: See TracChangeset
for help on using the changeset viewer.