Changeset 12904
- Timestamp:
- 08/29/10 17:30:04 (13 years ago)
- Location:
- branches/generic-class-file/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generic-class-file/abcl/src/org/armedbear/lisp/compiler-pass2.lisp
r12897 r12904 516 516 (emit-invokestatic +lisp+ "type_error" 517 517 (lisp-object-arg-types 2) +lisp-object+) 518 (emit ' pop) ; Needed for JVM stack consistency.518 (emit 'areturn) ; Needed for JVM stack consistency. 519 519 (label LABEL1)) 520 520 t) … … 911 911 912 912 913 (defun write-class-file (class stream) 913 (defun finish-class (class stream) 914 "Finalizes the `class' and writes the result to `stream'. 915 916 The compiler calls this function to indicate it doesn't want to 917 extend the class any further." 914 918 (class-add-method class (make-constructor (class-file-superclass class) 915 919 (abcl-class-file-lambda-name class) 916 920 (abcl-class-file-lambda-list class))) 917 921 (finalize-class-file class) 918 ( !write-class-file class stream))922 (write-class-file class stream)) 919 923 920 924 … … 3791 3795 (p2-compiland compiland) 3792 3796 ;; (finalize-class-file (compiland-class-file compiland)) 3793 ( write-class-file(compiland-class-file compiland) stream)))))3797 (finish-class (compiland-class-file compiland) stream))))) 3794 3798 3795 3799 (defun set-compiland-and-write-class (class-file compiland stream) … … 7086 7090 (*current-compiland* compiland)) 7087 7091 (with-saved-compiler-policy 7088 ;; Pass 1. 7089 (p1-compiland compiland) 7090 ;; *all-variables* doesn't contain variables which 7091 ;; are in an enclosing lexical environment (variable-environment) 7092 ;; so we don't need to filter them out 7093 (setf *closure-variables* 7094 (remove-if #'variable-special-p 7095 (remove-if-not #'variable-used-non-locally-p 7096 *all-variables*))) 7097 (let ((i 0)) 7098 (dolist (var (reverse *closure-variables*)) 7099 (setf (variable-closure-index var) i) 7100 (dformat t "var = ~S closure index = ~S~%" (variable-name var) 7101 (variable-closure-index var)) 7102 (incf i))) 7092 ;; Pass 1. 7093 (p1-compiland compiland)) 7094 7095 ;; *all-variables* doesn't contain variables which 7096 ;; are in an enclosing lexical environment (variable-environment) 7097 ;; so we don't need to filter them out 7098 (setf *closure-variables* 7099 (remove-if #'variable-special-p 7100 (remove-if-not #'variable-used-non-locally-p 7101 *all-variables*))) 7102 (let ((i 0)) 7103 (dolist (var (reverse *closure-variables*)) 7104 (setf (variable-closure-index var) i) 7105 (dformat t "var = ~S closure index = ~S~%" (variable-name var) 7106 (variable-closure-index var)) 7107 (incf i))) 7103 7108 7104 7109 ;; Assert that we're not refering to any variables 7105 7110 ;; we're not allowed to use 7106 (assert (= 0 7107 (length (remove-if (complement #'variable-references) 7108 (remove-if #'variable-references-allowed-p 7109 *visible-variables*))))) 7111 7112 (assert (= 0 7113 (length (remove-if (complement #'variable-references) 7114 (remove-if #'variable-references-allowed-p 7115 *visible-variables*))))) 7110 7116 7111 7117 ;; Pass 2. 7112 (with-class-file (compiland-class-file compiland) 7118 7119 (with-class-file (compiland-class-file compiland) 7120 (with-saved-compiler-policy 7113 7121 (p2-compiland compiland) 7114 ;; (finalize-class-file (compiland-class-file compiland))7115 ( write-class-file(compiland-class-file compiland) stream)))))7122 ;; (finalize-class-file (compiland-class-file compiland)) 7123 (finish-class (compiland-class-file compiland) stream))))) 7116 7124 7117 7125 (defvar *compiler-error-bailout*) -
branches/generic-class-file/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
r12896 r12904 533 533 (defun class-methods-by-name (class name) 534 534 "Returns all methods which have `name'." 535 (remove name(class-file-methods class)535 (remove (map-method-name name) (class-file-methods class) 536 536 :test-not #'string= :key #'method-name)) 537 537 538 538 (defun class-method (class name return &rest args) 539 539 "Return the method which is (uniquely) identified by its name AND descriptor." 540 (let ((return-and-args (cons return args))) 540 (let ((return-and-args (cons return args)) 541 (name (map-method-name name))) 541 542 (find-if #'(lambda (c) 542 543 (and (string= (method-name c) name) … … 662 663 663 664 664 (defun !write-class-file (class stream)665 (defun write-class-file (class stream) 665 666 "Serializes `class' to `stream', after it has been finalized." 666 667 … … 846 847 be one of two keyword identifiers to identify special methods: 847 848 848 * : class-constructor849 * :static-initializer 849 850 * :constructor 850 851 " 851 852 (cond 852 ((eq name : class-constructor)853 ((eq name :static-initializer) 853 854 "<clinit>") 854 855 ((eq name :constructor) … … 860 861 (%make-method :descriptor (cons return args) 861 862 :access-flags flags 862 :name name))863 :name (map-method-name name))) 863 864 864 865 (defun method-add-attribute (method attribute) … … 899 900 (pool-add-utf8 pool (apply #'descriptor (method-descriptor method))) 900 901 (method-name method) 901 (pool-add-utf8 pool (m ap-method-name (method-name method)))))902 (pool-add-utf8 pool (method-name method)))) 902 903 (finalize-attributes (method-attributes method) nil class)) 903 904 … … 993 994 (mapcar #'exception-handler-pc handlers)) 994 995 t))) 995 (setf (code-max-stack code) 996 (analyze-stack c (mapcar #'exception-handler-pc handlers))) 996 (unless (code-max-stack code) 997 (setf (code-max-stack code) 998 (analyze-stack c (mapcar #'exception-handler-pc handlers)))) 999 (unless (code-max-locals code) 1000 (setf (code-max-locals code) 1001 (analyze-locals code))) 997 1002 (multiple-value-bind 998 1003 (c labels) … … 1144 1149 *register* (code-current-local code))) 1145 1150 1146 (defmacro with-code-to-method ((class-file method &key (safe-nesting t))1147 1151 (defmacro with-code-to-method ((class-file method) 1152 &body body) 1148 1153 (let ((m (gensym)) 1149 1154 (c (gensym))) 1150 1155 `(progn 1151 ,@(when safe-nesting 1152 `((when *current-code-attribute* 1153 (save-code-specials *current-code-attribute*)))) 1156 (when *current-code-attribute* 1157 (save-code-specials *current-code-attribute*)) 1154 1158 (let* ((,m ,method) 1155 1159 (,c (method-ensure-code ,method)) … … 1161 1165 ,@body 1162 1166 (setf (code-code ,c) *code* 1163 (code-current-local ,c) *register* 1164 ;; (code-exception-handlers ,c) *handlers* 1167 (code-current-local ,c) *register* 1165 1168 (code-max-locals ,c) *registers-allocated*)) 1166 ,@(when safe-nesting 1167 `((when *current-code-attribute* 1168 (restore-code-specials *current-code-attribute*))))))) 1169 (when *current-code-attribute* 1170 (restore-code-specials *current-code-attribute*))))) 1169 1171 1170 1172
Note: See TracChangeset
for help on using the changeset viewer.