Changeset 11855


Ignore:
Timestamp:
05/11/09 20:32:22 (14 years ago)
Author:
ehuelsmann
Message:

Further simplification of the little

planet that's called P2-COMPILAND.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11854 r11855  
    80318031         (*this-class* (class-file-class class-file))
    80328032         (args (cadr p1-result))
     8033         (closure-args (intersection *closure-variables*
     8034                                     (compiland-arg-vars compiland)))
    80338035         (body (cddr p1-result))
    80348036         (*using-arg-array* nil)
    80358037         (*hairy-arglist-p* nil)
     8038         ;; *hairy-arglist-p* != NIL --> *using-arglist-array* != NIL
    80368039
    80378040         (*child-p* (not (null (compiland-parent compiland))))
     
    80698072               (compiland-closure-register compiland)))
    80708073
    8071 
    8072     (let ((register *register*)
    8073           (index 0))
     8074    (when *using-arg-array*
     8075      (setf (compiland-argument-register compiland) (allocate-register)))
     8076
     8077    ;; Assign indices or registers, depending on where the args are
     8078    ;; located: the arg-array or the call-stack
     8079    (let ((index 0))
    80748080      (dolist (variable (compiland-arg-vars compiland))
    80758081        (aver (null (variable-register variable)))
    80768082        (aver (null (variable-index variable)))
    8077         (cond
    8078           (*hairy-arglist-p*
    8079            (setf (variable-index variable) index))
    8080           (*using-arg-array*
    8081            (setf (variable-index variable) index))
    8082           (t
    8083            (setf (variable-register variable) register)))
    8084         (incf register)
     8083        (if *using-arg-array*
     8084            (setf (variable-index variable) index)
     8085            (setf (variable-register variable) (allocate-register)))
    80858086        (incf index)))
    80868087
    8087     (cond (*using-arg-array*
    8088            ;; One slot for arg array.
    8089            (setf (compiland-argument-register compiland) (allocate-register))
    8090 
    8091            (unless (or *closure-variables* *child-p*)
    8092              ;; Reserve a register for each parameter.
    8093              (dolist (variable (compiland-arg-vars compiland))
    8094                (aver (null (variable-register variable)))
    8095                (aver (null (variable-reserved-register variable)))
    8096                (unless (variable-special-p variable)
    8097                  (setf (variable-reserved-register variable)
    8098                        (allocate-register))))))
    8099           (t
    8100            ;; Otherwise, one register for each argument.
    8101            (dolist (variable (compiland-arg-vars compiland))
    8102              (declare (ignore variable))
    8103              (allocate-register))))
     8088    (when (and *using-arg-array*
     8089               (not (or *closure-variables* *child-p*)))
     8090      ;; Reserve a register for each parameter.
     8091      (dolist (variable (compiland-arg-vars compiland))
     8092        (aver (null (variable-register variable)))
     8093        (aver (null (variable-reserved-register variable)))
     8094        (unless (variable-special-p variable)
     8095          (setf (variable-reserved-register variable)
     8096                (allocate-register)))))
    81048097
    81058098    (p2-compiland-process-type-declarations body)
     
    81208113      (cond (*child-p*
    81218114             (aver (eql (compiland-closure-register compiland) 1))
    8122              (when (some #'variable-closure-index
    8123                          (compiland-arg-vars compiland))
     8115             (when closure-args
    81248116               (aload (compiland-closure-register compiland))))
    81258117            (t
     
    81278119             (dformat t "p2-compiland ~S anewarray 1~%" (compiland-name compiland))
    81288120             (emit 'anewarray "org/armedbear/lisp/LispObject")))
    8129       (dolist (variable (compiland-arg-vars compiland))
     8121      (dolist (variable closure-args)
    81308122        (dformat t "considering ~S ...~%" (variable-name variable))
    8131         (when (variable-closure-index variable)
    8132           (dformat t "moving variable ~S~%" (variable-name variable))
    8133           (cond ((variable-register variable)
    8134                  (when (eql (variable-register variable)
    8135                             (compiland-closure-register compiland))
    8136                    (error "ERROR! compiland closure register = ~S var ~S register = ~S~%"
    8137                           (compiland-closure-register compiland)
    8138                           (variable-name variable)
    8139                           (variable-register variable)))
    8140                  (emit 'dup) ; array
    8141                  (emit-push-constant-int (variable-closure-index variable))
    8142                  (aload (variable-register variable))
    8143                  (emit 'aastore)
    8144                  (setf (variable-register variable) nil)) ; The variable has moved.
    8145                 ((variable-index variable)
    8146                  (emit 'dup) ; array
    8147                  (emit-push-constant-int (variable-closure-index variable))
    8148                  (aload (compiland-argument-register compiland))
    8149                  (emit-push-constant-int (variable-index variable))
    8150                  (emit 'aaload)
    8151                  (emit 'aastore)
    8152                  (setf (variable-index variable) nil))))) ; The variable has moved.
     8123        (dformat t "moving variable ~S~%" (variable-name variable))
     8124        (cond ((variable-register variable)
     8125               (when (eql (variable-register variable)
     8126                          (compiland-closure-register compiland))
     8127                 (error "ERROR! compiland closure register = ~S var ~S register = ~S~%"
     8128                        (compiland-closure-register compiland)
     8129                        (variable-name variable)
     8130                        (variable-register variable)))
     8131               (emit 'dup) ; array
     8132               (emit-push-constant-int (variable-closure-index variable))
     8133               (aload (variable-register variable))
     8134               (emit 'aastore)
     8135               (setf (variable-register variable) nil))
     8136              ;; The variable has moved.
     8137              ((variable-index variable)
     8138               (emit 'dup) ; array
     8139               (emit-push-constant-int (variable-closure-index variable))
     8140               (aload (compiland-argument-register compiland))
     8141               (emit-push-constant-int (variable-index variable))
     8142               (emit 'aaload)
     8143               (emit 'aastore)
     8144               (setf (variable-index variable) nil))))
     8145      ;; The variable has moved.
     8146
    81538147      (aver (not (null (compiland-closure-register compiland))))
    81548148      (cond (*child-p*
    8155              (when (some #'variable-closure-index
    8156                          (compiland-arg-vars compiland))
     8149             (when closure-args
    81578150               (emit 'pop)))
    81588151            (t
Note: See TracChangeset for help on using the changeset viewer.