Changeset 12174


Ignore:
Timestamp:
10/04/09 20:18:15 (12 years ago)
Author:
ehuelsmann
Message:

Rewrite RETURN-FROM to fix MISC.293A, MISC.293B and MISC.293C.

Add documentation as to why this type of rewriting is necessary.

File:
1 edited

Legend:

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

    r12173 r12174  
    363363(defknown p1-return-from (t) t)
    364364(defun p1-return-from (form)
     365  (let ((new-form (rewrite-return-from form)))
     366    (when (neq form new-form)
     367      (return-from p1-return-from (p1 new-form))))
    365368  (let* ((name (second form))
    366369         (block (find-block name)))
     
    890893(defknown unsafe-p (t) t)
    891894(defun unsafe-p (args)
     895  "Determines whether the args can cause 'stack unsafe situations'.
     896Returns T if this is the case.
     897
     898When a 'stack unsafe situation' is encountered, the stack cannot
     899be used for temporary storage of intermediary results. This happens
     900because one of the forms in ARGS causes a local transfer of control
     901- local GO instruction - which assumes an empty stack, or if one of
     902the args causes a Java exception handler to be installed, which
     903- when triggered - clears out the stack.
     904"
    892905  (cond ((node-p args)
    893906         (unsafe-p (node-form args)))
     
    906919              (when (unsafe-p arg)
    907920                (return t))))))))
     921
     922(defknown rewrite-return-from (t) t)
     923(defun rewrite-return-from (form)
     924  (let* ((args (cdr form))
     925         (result-form (second args))
     926         (var (gensym)))
     927    (if (unsafe-p (cdr args))
     928        (if (single-valued-p result-form)
     929            `(let ((,var ,result-form))
     930               (return-from ,(first args) ,var))
     931            `(let ((,var (multiple-value-list ,result-form)))
     932               (return-from ,(first args) (values-list ,var))))
     933        form)))
     934
    908935
    909936(defknown rewrite-throw (t) t)
Note: See TracChangeset for help on using the changeset viewer.