Skip to content

Commit

Permalink
1.0.31.20: smaller code for failing ECASE/ETYPECASE
Browse files Browse the repository at this point in the history
(ERROR 'CASE-FAILURE ...) generates a lot of code.  Commonize the code in
a CASE-FAILURE function and have the macros call that function instead.
This change results in fewer entries in the constant vector and smaller
code since fewer arguments have to be loaded.  This makes the error case
slightly slower, but that's not a problem.

Shrinks core size by ~160K on x86-64.
  • Loading branch information
Nathan Froyd committed Sep 26, 2009
1 parent 305c519 commit 8380b5e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
6 changes: 1 addition & 5 deletions src/code/macros.lisp
Expand Up @@ -303,11 +303,7 @@ invoked. In that case it will store into PLACE and start over."
(cond
,@(nreverse clauses)
,@(if errorp
`((t (error 'case-failure
:name ',name
:datum ,keyform-value
:expected-type ',expected-type
:possibilities ',keys))))))))
`((t (case-failure ',name ,keyform-value ',keys))))))))
) ; EVAL-WHEN

(defmacro-mundanely case (keyform &body cases)
Expand Down
9 changes: 9 additions & 0 deletions src/code/target-error.lisp
Expand Up @@ -176,6 +176,15 @@ with that condition (or with no condition) will be returned."
:interactive read-evaluated-form
value))))

(defun case-failure (name value keys)
(error 'case-failure
:name name
:datum value
:expected-type (if (eq name 'ecase)
`(member ,@keys)
`(or ,@keys))
:possibilities keys))

(defun case-body-error (name keyform keyform-value expected-type keys)
(restart-case
(error 'case-failure
Expand Down
1 change: 1 addition & 0 deletions src/compiler/fndb.lisp
Expand Up @@ -1427,6 +1427,7 @@
;; FIXME: This function does not return, but due to the implementation
;; of FILTER-LVAR we cannot write it here.
(defknown %compile-time-type-error (t t t) *)
(defknown sb!kernel::case-failure (t t t) nil)

(defknown %odd-key-args-error () nil)
(defknown %unknown-key-arg-error (t) nil)
Expand Down
2 changes: 1 addition & 1 deletion version.lisp-expr
Expand Up @@ -17,4 +17,4 @@
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
"1.0.31.19"
"1.0.31.20"

0 comments on commit 8380b5e

Please sign in to comment.