Changeset 11847


Ignore:
Timestamp:
05/09/09 00:15:55 (12 years ago)
Author:
vvoutilainen
Message:

Clean up duplication for environment restoration and handlers.

File:
1 edited

Legend:

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

    r11846 r11847  
    39533953  (astore register))
    39543954
     3955(defun restore-environment-and-make-handler (register label-START)
     3956  (let ((label-END (gensym))
     3957  (label-EXIT (gensym)))
     3958    (emit 'goto label-EXIT)
     3959    (label label-END)
     3960    (restore-dynamic-environment register)
     3961    (emit 'athrow)
     3962    ;; Restore dynamic environment.
     3963    (label label-EXIT)
     3964    (restore-dynamic-environment register)
     3965    (push (make-handler :from label-START
     3966      :to label-END
     3967      :code label-END
     3968      :catch-type 0) *handlers*)))
     3969
    39553970(defun p2-m-v-b-node (block target)
    39563971  (let* ((*blocks* (cons block *blocks*))
     
    39613976         (bind-special-p nil)
    39623977         (variables (block-vars block))
    3963          (label-START (gensym))
    3964          (label-END (gensym))
    3965          (label-EXIT (gensym)))
     3978         (label-START (gensym)))
    39663979    (dolist (variable variables)
    39673980      (let ((special-p (variable-special-p variable)))
     
    40364049    (compile-progn-body (cdddr form) target)
    40374050    (when bind-special-p
    4038       (emit 'goto label-EXIT)
    4039       (label label-END)
    4040       (restore-dynamic-environment (block-environment-register block))
    4041       (emit 'athrow)
    4042 
    4043       ;; Restore dynamic environment.
    4044       (label label-EXIT)
    4045       (restore-dynamic-environment (block-environment-register block))
    4046       (push (make-handler :from label-START
    4047                           :to label-END
    4048                           :code label-END
    4049                           :catch-type 0) *handlers*))))
     4051      (restore-environment-and-make-handler (block-environment-register block)
     4052              label-START))))
    40504053
    40514054(defun propagate-vars (block)
     
    43594362         (*visible-variables* *visible-variables*)
    43604363         (specialp nil)
    4361          (label-START (gensym))
    4362          (label-END (gensym))
    4363          (label-EXIT (gensym)))
     4364         (label-START (gensym)))
    43644365    ;; Walk the variable list looking for special bindings and unused lexicals.
    43654366    (dolist (variable (block-vars block))
     
    43884389      (compile-progn-body (cddr form) target representation))
    43894390    (when specialp
    4390       (emit 'goto label-EXIT)
    4391       (label label-END)
    4392       ;; Restore dynamic environment.
    4393       (restore-dynamic-environment (block-environment-register block))
    4394       (emit 'athrow)
    4395 
    4396       (label label-EXIT)
    4397       (restore-dynamic-environment (block-environment-register block))
    4398       (push (make-handler :from label-START
    4399                           :to label-END
    4400                           :code label-END
    4401                           :catch-type 0) *handlers*))))
     4391      (restore-environment-and-make-handler (block-environment-register block)
     4392              label-START))))
    44024393
    44034394(defun p2-locally (form target representation)
     
    47734764
    47744765(defun p2-progv-node (block target representation)
     4766  (declare (ignore representation))
    47754767  (let* ((form (block-form block))
    47764768         (symbols-form (cadr form))
     
    47794771         (environment-register
    47804772          (setf (block-environment-register block) (allocate-register)))
    4781          (label-START (gensym))
    4782          (label-END (gensym))
    4783          (label-EXIT (gensym)))
     4773         (label-START (gensym)))
    47844774    (compile-form symbols-form 'stack nil)
    47854775    (compile-form values-form 'stack nil)
     
    47954785      ;; Implicit PROGN.
    47964786    (let ((*blocks* (cons block *blocks*)))
    4797       (compile-progn-body (cdddr form) target)
    4798       (emit 'goto label-EXIT)
    4799       (label label-END)
    4800       (restore-dynamic-environment environment-register)
    4801       (emit 'athrow))
    4802 
    4803     ;; Restore dynamic environment.
    4804     (label label-EXIT)
    4805     (restore-dynamic-environment environment-register)
    4806     (fix-boxing representation nil)
    4807     (push (make-handler :from label-START
    4808                           :to label-END
    4809                           :code label-END
    4810                           :catch-type 0) *handlers*)))
     4787      (compile-progn-body (cdddr form) target))
     4788    (restore-environment-and-make-handler environment-register label-START)))
    48114789
    48124790(defun p2-quote (form target representation)
     
    80878065         (*initialize-thread-var* nil)
    80888066         (super nil)
    8089          (label-START (gensym))
    8090          (label-END (gensym))
    8091          (label-EXIT (gensym)))
     8067         (label-START (gensym)))
    80928068
    80938069    (dolist (var (compiland-arg-vars compiland))
     
    82468222
    82478223    (when (compiland-environment-register compiland)
    8248       (emit 'goto label-EXIT)
    8249       (label label-END)
    8250       (restore-dynamic-environment (compiland-environment-register compiland))
    8251       (emit 'athrow)
    8252 
    8253       ;; Restore dynamic environment
    8254       (label label-EXIT)
    8255       (restore-dynamic-environment (compiland-environment-register compiland))
    8256       (push (make-handler :from label-START
    8257                           :to label-END
    8258                           :code label-END
    8259                           :catch-type 0) *handlers*))
     8224      (restore-environment-and-make-handler
     8225       (compiland-environment-register compiland) label-START))
    82608226
    82618227    (unless *code*
Note: See TracChangeset for help on using the changeset viewer.