Changeset 15580


Ignore:
Timestamp:
05/23/22 06:23:39 (10 months ago)
Author:
Mark Evenson
Message:

Compiler falls back to interpreted forms greater than 65535 bytes

This allows loading the FSET library by adding the too large sexps as
interpreted forms to loader, macroexpanding all forms before writing
the form to the loader to try follow the CL standard.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compile-file.lisp

    r15569 r15580  
    7474        (setf (char name i) #\_)))
    7575    name))
    76  
     76
    7777
    7878(declaim (ftype (function () t) next-classfile))
     
    107107    (return-from verify-load nil))
    108108  (with-open-file (cf classfile :direction :input)
    109     (when 
     109    (when
    110110        (= 0 (file-length cf))
    111111;;; TODO hook into a real ABCL compiler condition hierarchy
     
    205205;; TODO        (annotate form toplevel-form classfile compiled-function fasl-class-number)
    206206        ;;; ??? define an API by perhaps exporting these symbols?
    207         (setf (getf form 'form-source) 
     207        (setf (getf form 'form-source)
    208208              toplevel-form
    209              
    210               (getf form 'classfile) 
     209
     210              (getf form 'classfile)
    211211              classfile
    212                    
    213               (getf form 'compiled-function) 
     212
     213              (getf form 'compiled-function)
    214214              compiled-function
    215                  
    216               (getf form 'class-number) 
     215
     216              (getf form 'class-number)
    217217              saved-class-number))
    218218      (setf form
     
    323323                         (cl:get ',sym  'sys::source nil))))))
    324324
    325          
     325
    326326(declaim (ftype (function (t t t) t) process-toplevel-mop.ensure-method))
    327327(defun process-toplevel-mop.ensure-method (form stream compile-time-too)
     
    393393              :element-type ',(array-element-type initial-value)
    394394              :initial-contents ',(coerce initial-value 'list))))
    395     `(progn 
     395    `(progn
    396396       (sys:put ',name 'sys::source
    397397                (cl:cons
     
    497497                 when (eq (car method-form) :method)
    498498                   collect
    499                    (multiple-value-bind (function-name qualifiers lambda-list specializers documentation declarations body) 
     499                   (multiple-value-bind (function-name qualifiers lambda-list specializers documentation declarations body)
    500500                       (mop::parse-defmethod `(,(second form) ,@(rest method-form)))
    501501                     ;;; FIXME: style points for refactoring double backquote to "normal" form
     
    604604                                   (cl:cons '((:function ,name)
    605605                                              ,(namestring *source*) ,*source-position*)
    606                                             (cl:get ',sym  'sys::source nil)))                 
     606                                            (cl:get ',sym  'sys::source nil)))
    607607                          (sys:fset ',name
    608608                                    (sys::get-fasl-function *fasl-loader*
     
    640640    (push name *toplevel-functions*)
    641641    (when (and (consp name)
    642                (or 
     642               (or
    643643                (eq 'setf (first name))
    644644                (eq 'cl:setf (first name))))
     
    700700      (when (and (symbolp operator)
    701701                 (macro-function operator *compile-file-environment*))
    702         (when (eq operator 'define-setf-expander) 
     702        (when (eq operator 'define-setf-expander)
    703703          (push (second form) *toplevel-setf-expanders*))
    704         (when (and (eq operator 'defsetf) 
     704        (when (and (eq operator 'defsetf)
    705705                   (consp (third form))) ;; long form of DEFSETF
    706706          (push (second form) *toplevel-setf-expanders*))
     
    742742                          (translate-logical-pathname output-file)
    743743                          output-file))
    744          (zipfile 
     744         (zipfile
    745745          (if (find :windows *features*)
    746746              (make-pathname :defaults output-file :type type)
     
    783783
    784784(defun write-fasl-prologue (stream in-package)
    785   "Write the forms that form the fasl to STREAM. 
    786 
    787 The last form will use IN-PACKAGE to set the *package* to its value when 
     785  "Write the forms that form the fasl to STREAM.
     786
     787The last form will use IN-PACKAGE to set the *package* to its value when
    788788COMPILE-FILE was invoked."
    789789  (let ((out stream)
     
    824824(defun compile-from-stream (in output-file temp-file temp-file2
    825825                            extract-toplevel-funcs-and-macros
    826                             functions-file macros-file exports-file 
     826                            functions-file macros-file exports-file
    827827                            setf-functions-file setf-expanders-file)
    828828  (let* ((*compile-file-pathname* (make-pathname :defaults (pathname in)
     
    855855            (jvm::with-file-compilation
    856856              (handler-bind
    857                   ((style-warning 
     857                  ((style-warning
    858858                    #'(lambda (c)
    859859                        (setf warnings-p t)
     
    876876                     (when (eq form in)
    877877                       (return))
    878                      (process-toplevel-form form out nil))))
     878                     (if (>= (length (format nil "~a" form)) 65536)
     879                         ;; Following the solution propose here:
     880                         ;; see https://github.com/armedbear/abcl/issues/246#issuecomment-698854437
     881                         ;; just include the offending interpreted form in the loader
     882                         ;; using it instead of the compiled representation
     883                         (write (ext:macroexpand-all form *compile-file-environment*)
     884                                :stream out)
     885                         (process-toplevel-form form out nil))
     886                     )))
    879887                    (finalize-fasl-output)
    880888                    (dolist (name *fbound-names*)
     
    10421050            (compile-from-stream in output-file temp-file temp-file2
    10431051                                 extract-toplevel-funcs-and-macros
    1044                                  functions-file macros-file exports-file 
     1052                                 functions-file macros-file exports-file
    10451053                                 setf-functions-file setf-expanders-file)
    10461054          (values (truename output-file) warnings-p failure-p))))))
Note: See TracChangeset for help on using the changeset viewer.