Calling COMPILE when *evaluator-mode* = :interpreter is less efficient than implicit compilation

Bug #1513458 reported by Douglas Katzman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
New
Undecided
Unassigned

Bug Description

ASSERT-GLOBAL-FUNCTION-DEFINITION-TYPE and ASSERT-DEFINITION-TYPE are each called one time too many.
It could be that the call in MAKE-FUNCTIONAL-FROM-TOPLEVEL-LAMBDA is extraneous.

Here are four compilations of the same function (one from a file, three from the REPL).
Compiling F1 is the questionable case. I would have thought F3 would have the same issue, but it doesn't.

* (set-pprint-dispatch 'sb-c::optional-dispatch (lambda (stream obj) (print-unreadable-object (obj stream :type t :identity t) (prin1 (sb-c::leaf-source-name obj) stream))))
NIL

* (trace sb-c::assert-definition-type)
(SB-C::ASSERT-DEFINITION-TYPE)

* (declaim (ftype (function (fixnum &optional fixnum) t) f1 f2 f3 f4))
(F1 F2 F3 F4)

* sb-ext:*evaluator-mode*
:INTERPRET

* (defun f1 (a &optional b) (+ a (or b 42)))
F1

* (values (compile 'f1))
  0: (SB-C::ASSERT-DEFINITION-TYPE #<SB-C::OPTIONAL-DISPATCH F1 {1002C2A3B3}>
                                   #<SB-KERNEL:FUN-TYPE (FUNCTION (FIXNUM &OPTIONAL FIXNUM) *)>
                                   :UNWINNAGE-FUN #<FUNCTION SB-C:COMPILER-NOTIFY>
                                   :WHERE "proclamation" :REALLY-ASSERT T)
  0: SB-C::ASSERT-DEFINITION-TYPE returned T
  0: (SB-C::ASSERT-DEFINITION-TYPE #<SB-C::OPTIONAL-DISPATCH F1 {1002C2A3B3}>
                                   #<SB-KERNEL:FUN-TYPE (FUNCTION (FIXNUM &OPTIONAL FIXNUM) *)>
                                   :UNWINNAGE-FUN #<FUNCTION SB-C:COMPILER-NOTIFY>
                                   :WHERE "proclamation" :REALLY-ASSERT T)
  0: SB-C::ASSERT-DEFINITION-TYPE returned T
F1

* (values (compile-file"/tmp/foo.lisp" :verbose nil))
; compiling (DEFUN F2 ...) 0: (SB-C::ASSERT-DEFINITION-TYPE #<SB-C::OPTIONAL-DISPATCH F2 {1002D28BC3}>
                                   #<SB-KERNEL:FUN-TYPE (FUNCTION (FIXNUM &OPTIONAL FIXNUM) *)>
                                   :UNWINNAGE-FUN #<FUNCTION SB-C:COMPILER-NOTIFY> :WHERE
                                   "proclamation" :REALLY-ASSERT T)
  0: SB-C::ASSERT-DEFINITION-TYPE returned T
#P"/private/tmp/foo.fasl"

* (values (compile 'f3 '(lambda (a &optional b) (+ a (or b 42)))))
  0: (SB-C::ASSERT-DEFINITION-TYPE #<SB-C::OPTIONAL-DISPATCH F3 {1002D20163}>
                                   #<SB-KERNEL:FUN-TYPE (FUNCTION (FIXNUM &OPTIONAL FIXNUM) *)>
                                   :UNWINNAGE-FUN #<FUNCTION SB-C:COMPILER-NOTIFY>
                                   :WHERE "proclamation" :REALLY-ASSERT T)
  0: SB-C::ASSERT-DEFINITION-TYPE returned T
F3

* (setq sb-ext:*evaluator-mode* :compile)
:COMPILE

* (defun f4 (a &optional b) (+ a (or b 42)))
  0: (SB-C::ASSERT-DEFINITION-TYPE #<SB-C::OPTIONAL-DISPATCH F4 {1002D77753}>
                                   #<SB-KERNEL:FUN-TYPE (FUNCTION (FIXNUM &OPTIONAL FIXNUM) *)>
                                   :UNWINNAGE-FUN #<FUNCTION SB-C:COMPILER-NOTIFY>
                                   :WHERE "proclamation" :REALLY-ASSERT T)
  0: SB-C::ASSERT-DEFINITION-TYPE returned T
F4

Revision history for this message
Charles (karlosz) wrote :

I don't understand what the issue here is.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.