From 0041e7d8dab2732d7e7bd08f2edf8e244486ac2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kochma=C5=84ski?= Date: Mon, 13 Nov 2023 13:12:26 +0100 Subject: [PATCH] cmp: use correctly with-exit-label Previusly we've duplicated some code with regard to this macro, most notably we've bound *exit* separately to label instead of passing it as a first arg. --- src/cmp/cmpbackend-cxx/cmpc-util.lsp | 1 + src/cmp/cmpbackend-cxx/cmppass2-call.lsp | 10 +++----- src/cmp/cmpbackend-cxx/cmppass2-cont.lsp | 5 ++-- src/cmp/cmpbackend-cxx/cmppass2-eval.lsp | 10 +++----- src/cmp/cmpbackend-cxx/cmppass2-top.lsp | 32 +++++++++--------------- 5 files changed, 23 insertions(+), 35 deletions(-) diff --git a/src/cmp/cmpbackend-cxx/cmpc-util.lsp b/src/cmp/cmpbackend-cxx/cmpc-util.lsp index 480075f92..24f6ae7fa 100644 --- a/src/cmp/cmpbackend-cxx/cmpc-util.lsp +++ b/src/cmp/cmpbackend-cxx/cmpc-util.lsp @@ -93,6 +93,7 @@ (*max-temp* 0) (*next-cfun* 0) (*last-label* 0) + (*unwind-exit* nil) (*inline-information* (ext:if-let ((r (machine-inline-information *machine*))) (si:copy-hash-table r) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-call.lsp b/src/cmp/cmpbackend-cxx/cmppass2-call.lsp index e444642c1..9298bc394 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-call.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-call.lsp @@ -101,12 +101,10 @@ (tail-recursion-possible) (inline-possible (fun-name fun)) (= (length args) (length (rest *tail-recursion-info*)))) - (let* ((*destination* 'TRASH) - (*exit* (next-label)) - (*unwind-exit* (cons *exit* *unwind-exit*))) - (c2psetq nil ;; We do not provide any C2FORM - (cdr *tail-recursion-info*) args) - (wt-label *exit*)) + (with-exit-label (*exit*) + (let ((*destination* 'TRASH)) + ;; We do not provide any C2FORM. + (c2psetq nil (cdr *tail-recursion-info*) args))) (unwind-no-exit 'TAIL-RECURSION-MARK) (wt-nl "goto TTL;") (cmpdebug "Tail-recursive call of ~s was replaced by iteration." diff --git a/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp b/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp index 2141be826..9f76b69d4 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-cont.lsp @@ -164,9 +164,8 @@ (wt-nl "if (__ecl_frs_push_result) {") (wt-comment "BEGIN CATCH ~A" code) (with-indentation - (with-exit-label (label) - (let ((*exit* label)) - (unwind-exit 'VALUES)))) + (with-exit-label (*exit*) + (unwind-exit 'VALUES))) (wt-nl "} else {") (with-indentation (c2expr* body))))) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp b/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp index 08b8d9c26..c9015e5dc 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-eval.lsp @@ -26,12 +26,10 @@ ;; other expressions will follow this one. We must thus create ;; a possible label so that the compiled forms exit right at ;; the point where the next form will be compiled. - (with-exit-label (label) - (let* ((*exit* label) - (*unwind-exit* (cons *exit* *unwind-exit*)) - ;;(*lex* *lex*) - (*lcl* *lcl*) - (*temp* *temp*)) + (with-exit-label (*exit*) + (let (;;(*lex* *lex*) + (*lcl* *lcl*) + (*temp* *temp*)) (c2expr form)))) (defun c2progn (c1form forms) diff --git a/src/cmp/cmpbackend-cxx/cmppass2-top.lsp b/src/cmp/cmpbackend-cxx/cmppass2-top.lsp index 7205f0ce6..dfdbe3594 100644 --- a/src/cmp/cmpbackend-cxx/cmppass2-top.lsp +++ b/src/cmp/cmpbackend-cxx/cmppass2-top.lsp @@ -245,35 +245,27 @@ (defun t2ordinary (c1form form) (declare (ignore c1form)) - (let* ((*exit* (next-label)) - (*unwind-exit* (list *exit*)) - (*destination* 'TRASH)) - (c2expr form) - (wt-label *exit*))) + (with-exit-label (*exit*) + (let ((*destination* 'TRASH)) + (c2expr form)))) (defun t2load-time-value (c1form vv-loc form) (declare (ignore c1form)) - (let* ((*exit* (next-label)) - (*unwind-exit* (list *exit*)) - (*destination* vv-loc)) - (c2expr form) - (wt-label *exit*))) + (with-exit-label (*exit*) + (let ((*destination* vv-loc)) + (c2expr form)))) (defun t2make-form (c1form vv-loc form) (declare (ignore c1form)) - (let* ((*exit* (next-label)) - (*unwind-exit* (list *exit*)) - (*destination* vv-loc)) - (c2expr form) - (wt-label *exit*))) + (with-exit-label (*exit*) + (let ((*destination* vv-loc)) + (c2expr form)))) (defun t2init-form (c1form vv-loc form) (declare (ignore c1form vv-loc)) - (let* ((*exit* (next-label)) - (*unwind-exit* (list *exit*)) - (*destination* 'TRASH)) - (c2expr form) - (wt-label *exit*))) + (with-exit-label (*exit*) + (let ((*destination* 'TRASH)) + (c2expr form)))) (defun locative-type-from-var-kind (kind) (cdr (assoc kind