diff --git a/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp b/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp index 0b97063d4..22ad17d0c 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp @@ -79,10 +79,12 @@ (wt-nl "cl_object " tag-loc ";")) (bind "ECL_NEW_FRAME_ID(cl_env_copy)" tag-loc) (with-unwind-frame (tag-loc) - (do-tags (tag body (when (var-ref-ccb tag-loc) - (wt-nl "ecl_internal_error(\"GO found an inexistent tag\");"))) - (wt-nl "if (cl_env_copy->values[0]==ecl_make_fixnum(" (tag-index tag) "))") - (unwind-cond (tag-jump tag))) + (progn + (do-tags (tag body nil) + (unwind-cond (tag-jump tag) :jump-eq + 'VALUEZ (tag-index tag))) + (when (var-ref-ccb tag-loc) + (wt-nl "ecl_internal_error(\"GO found an inexistent tag\");"))) (c2tagbody-body body)) (close-inline-blocks))))) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp b/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp index 6933f1dd3..7b196d46d 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp @@ -137,8 +137,7 @@ (dolist (f butlast) (let ((*destination* 'VALUE0)) (c2expr* f)) - (wt-nl "if (" 'VALUE0 "!=ECL_NIL) ") - (unwind-cond normal-exit)) + (unwind-cond normal-exit :jump-t 'VALUE0)) (c2expr last)) (unwind-exit 'VALUE0))))) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-exit.lsp b/src/cmp/cmpbackend-cxx/cmppass2-exit.lsp index bbad802b5..e3957d497 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-exit.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-exit.lsp @@ -35,35 +35,18 @@ (t (baboon-exit-invalid *exit*))))) (defun unwind-jump (exit) - (multiple-value-bind (frs-bind bds-lcl bds-bind stack-frame ihs-p) - (compute-unwind (label-denv exit) *unwind-exit*) - (perform-unwind frs-bind bds-lcl bds-bind stack-frame ihs-p) - (wt-nl-go exit))) + (%unwind (label-denv exit) *unwind-exit*) + (%goto exit)) -;;; A conditional jump that is meant to be used as the IF statement body. -;;; FIXME we want UNWIND-JEQL and UNWIND-JNOT and open-code the test too. -(defun unwind-cond (exit) - (multiple-value-bind (frs-bind bds-lcl bds-bind stack-frame ihs-p) - (compute-unwind (label-denv exit) *unwind-exit*) - (with-lexical-scope () - (perform-unwind frs-bind bds-lcl bds-bind stack-frame ihs-p) - (wt-nl-go exit)))) +(defun unwind-cont (exit) + (%unwind (label-denv exit) *unwind-exit*) + (%goto exit)) (defun unwind-flee (exit kind) - ;; All these boil down to calling ecl_unwind which unwinds stacks dynamically. - ;; If we want to implement call/cc, then this is the place where we dispatch. - #+ (or) (wt-nl "ecl_unwind(cl_env_copy," frs-id ");") - (ecase kind - (:go - ;; The second argument is passed as a value (index for jump). - (wt-nl "cl_go(" (tag-var exit) ",ecl_make_fixnum(" (tag-index exit) "));")) - (:throw - ;; Unlike GO and RETURN-FROM, the destination is not known at compile time. - ;; TODO in some cases it is possible to prove the destination CATCH form. - (wt-nl "cl_throw(" exit ");")) - (:return-from - ;; The second argument is used only to signal the error. - (wt-nl "cl_return_from(" (blk-var exit) "," (get-object (blk-name exit)) ");")))) + (%escape exit kind)) + +(defun unwind-cond (exit kind &rest args) + (%branch exit *unwind-exit* kind args)) ;;; @@ -100,24 +83,6 @@ ;;; LEAVE -> outermost location ;;; #