Skip to content

Commit

Permalink
Fix byte code verification error in edge case.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferada committed Jun 2, 2017
1 parent 4b6cbb1 commit 4630bfd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/org/armedbear/lisp/compiler-pass2.lisp
Expand Up @@ -6846,8 +6846,6 @@ We need more thought here.
t)

(defun p2-throw (form target representation)
;; FIXME What if we're called with a non-NIL representation?
(declare (ignore representation))
(with-operand-accumulation
((emit-thread-operand)
(compile-operand (second form) nil) ; Tag.
Expand All @@ -6857,7 +6855,11 @@ We need more thought here.
(lisp-object-arg-types 2) nil))
;; Following code will not be reached.
(when target
(emit-push-nil)
(ecase representation
((:int :boolean :char)
(emit 'iconst_0))
((nil)
(emit-push-nil)))
(emit-move-from-stack target)))

(defun p2-unwind-protect-node (block target)
Expand Down
13 changes: 13 additions & 0 deletions test/lisp/abcl/misc-tests.lisp
Expand Up @@ -135,3 +135,16 @@
(deftest nth.inlined.1
(prog1 T (compile NIL (lambda (list) (nth (lambda ()) list))))
T)

;; these used to fail during byte code verification
(deftest throw.representation.1
(prog1 T (compile NIL (lambda () (eql (the fixnum (throw 'foo 42)) 2))))
T)

(deftest throw.representation.2
(prog1 T (compile NIL (lambda () (char-code (the character (throw 'foo 42))))))
T)

(deftest throw.representation.3
(prog1 T (compile NIL (lambda () (if (the boolean (throw 'foo 42)) 1 2))))
T)

0 comments on commit 4630bfd

Please sign in to comment.