(define (assemble&link info-output-pathname)
(phase/assemble)
- (if info-output-pathname
- (phase/info-generation-2 info-output-pathname))
- (phase/link)
- *result*)
+ (let ((file-wrapper
+ (and info-output-pathname
+ (phase/info-generation-2 info-output-pathname))))
+ (phase/link)
+ (values *result* file-wrapper)))
(define (wrap-lap entry-label some-lap)
(LAP ,@(if *procedure-result?*
(define (info-generation-2 pathname set-debugging-info!)
(compiler-phase "Debugging Information Generation"
(lambda ()
- (set-debugging-info!
- *code-vector*
- (let ((info
- (info-generation-phase-3
- (last-reference *dbg-expression*)
- (last-reference *dbg-procedures*)
- (last-reference *dbg-continuations*)
- *label-bindings*
- (last-reference *external-labels*))))
- (cond ((eq? pathname 'KEEP) ; for dynamic execution
- (vector 'DEBUGGING-INFO-WRAPPER
- 2
- #f
- #f
- #f
- info))
- ((eq? pathname 'RECURSIVE) ; recursive compilation
- (set! *recursive-compilation-results*
- (cons (vector *recursive-compilation-number*
- info
- *code-vector*
- *tl-bound*
- *tl-free*
- *tl-metadata*)
- *recursive-compilation-results*))
- (vector 'DEBUGGING-INFO-WRAPPER
- 2
- *debugging-key*
- (if (pathname? *info-output-filename*)
- (->namestring *info-output-filename*)
- *info-output-filename*)
- *recursive-compilation-number*
- #f))
- (else
- (compiler:dump-info-file
- (vector 'DEBUGGING-FILE-WRAPPER
- 2
- *debugging-key*
- (list->vector
- (cons info
- (map (lambda (other) (vector-ref other 1))
- (recursive-compilation-results)))))
- pathname)
- (vector 'DEBUGGING-INFO-WRAPPER
- 2
- *debugging-key*
- (if (pathname? *info-output-filename*)
- (->namestring *info-output-filename*)
- *info-output-filename*)
- 0
- #f))))))))
+ (receive (debug-info file-wrapper)
+ (let ((info
+ (info-generation-phase-3
+ (last-reference *dbg-expression*)
+ (last-reference *dbg-procedures*)
+ (last-reference *dbg-continuations*)
+ *label-bindings*
+ (last-reference *external-labels*))))
+ (cond ((eq? pathname 'KEEP) ; for dynamic execution
+ (values (vector 'DEBUGGING-INFO-WRAPPER
+ 2
+ #f
+ #f
+ #f
+ info)
+ #f))
+ ((eq? pathname 'RECURSIVE) ; recursive compilation
+ (set! *recursive-compilation-results*
+ (cons (vector *recursive-compilation-number*
+ info
+ *code-vector*
+ *tl-bound*
+ *tl-free*
+ *tl-metadata*)
+ *recursive-compilation-results*))
+ (values (vector 'DEBUGGING-INFO-WRAPPER
+ 2
+ *debugging-key*
+ (if (pathname? *info-output-filename*)
+ (->namestring *info-output-filename*)
+ *info-output-filename*)
+ *recursive-compilation-number*
+ #f)
+ #f))
+ (else
+ (values (vector 'DEBUGGING-INFO-WRAPPER
+ 2
+ *debugging-key*
+ (if (pathname? *info-output-filename*)
+ (->namestring *info-output-filename*)
+ *info-output-filename*)
+ 0
+ #f)
+ (vector 'DEBUGGING-FILE-WRAPPER
+ 2
+ *debugging-key*
+ (list->vector
+ (cons info
+ (map (lambda (other)
+ (vector-ref other 1))
+ (recursive-compilation-results))
+ )))))))
+ (set-debugging-info! *code-vector* debug-info)
+ file-wrapper))))
(define (recursive-compilation-results)
(sort *recursive-compilation-results*
(set! *block-label* (generate-label))
(set! *external-labels* '())
(set! *ic-procedure-headers* '())
- (phase/assemble)
- (phase/link)
- *result*)))
+ (assemble&link #f))))
(define (canonicalize-label-name name)
;; The Scheme assembler allows any Scheme symbol as a label
(define (cross-assemble&link info-output-pathname)
(phase/assemble)
- (if info-output-pathname
- (cross-compiler-phase/info-generation-2 info-output-pathname))
- (cross-compiler-phase/link)
- *result*)
+ (let ((file-wrapper
+ (and info-output-pathname
+ (cross-compiler-phase/info-generation-2 info-output-pathname))))
+ (cross-compiler-phase/link)
+ (values *result* file-wrapper)))
(define (cross-compiler-phase/info-generation-2 pathname)
(info-generation-2 pathname set-cc-code-block/debugging-info!))
input-pathname
output-pathname
(lambda ()
- (compile-scode/internal
+ (compile-bin-file-1
scode
(pathname-new-type
output-pathname
lap-output-port)))))))))))))
unspecific)
+(define (compile-bin-file-1 scode info-output-pathname rtl-output-port
+ lap-output-port)
+ (receive (result file-wrapper)
+ (compile-scode/internal scode info-output-pathname rtl-output-port
+ lap-output-port)
+ (if file-wrapper
+ (compiler:dump-info-file file-wrapper
+ info-output-pathname))
+ result))
+
(define *debugging-key*)
(define *compiler-input-pathname*)
(define *compiler-output-pathname*)
(*info-output-filename* keep-debugging-info?))
(compile-scode/no-file/hook
(lambda ()
- (compile-scode/internal scode keep-debugging-info?)))))
+ (receive (result file-wrapper)
+ (compile-scode/internal scode keep-debugging-info?)
+ (declare (ignore file-wrapper))
+ result)))))
(define (compiler:batch-compile input #!optional output)
(fluid-let ((compiler:batch-mode? #t))
(*procedure-result?* procedure-result?))
(compile-scode/recursive/hook
(lambda ()
- (compile-scode/internal
- scode
- (and *info-output-filename*
- (if (eq? *info-output-filename* 'KEEP)
- 'KEEP
- 'RECURSIVE))
- *rtl-output-port*
- *lap-output-port*
- bind-compiler-variables)))))))
+ (receive (result file-wrapper)
+ (compile-scode/internal
+ scode
+ (and *info-output-filename*
+ (if (eq? *info-output-filename* 'KEEP)
+ 'KEEP
+ 'RECURSIVE))
+ *rtl-output-port*
+ *lap-output-port*
+ bind-compiler-variables)
+ (declare (ignore file-wrapper))
+ result)))))))
(if procedure-result?
(let ((do-it
(lambda ()
(define (in-compiler thunk)
(let ((run-compiler
(lambda ()
- (let ((value
- (let ((expression (thunk)))
+ (receive (scode file-marker) (thunk)
+ (let ((result
(let ((others (recursive-compilation-results)))
- (if (compiled-code-address? expression)
+ (if (compiled-code-address? scode)
(scode/make-comment
;; Keep in sync with "crsend.scm" and with
;; "runtime/infstr.scm".
(if compiler:compile-by-procedures?
'compiled-by-procedures
'compiled-as-unit)
- (compiled-code-address->block expression)
+ (compiled-code-address->block scode)
(list->vector
(map (lambda (other)
(vector-ref other 2))
others))
(lambda (elt1 elt2)
(eq? (car elt1) (car elt2)))))
- expression)
+ scode)
(vector compiler:compile-by-procedures?
- expression
+ scode
(map (lambda (other)
(vector-ref other 2))
- others)))))))
- (if compiler:show-time-reports?
- (compiler-time-report "Total compilation time"
- *process-time*
- *real-time*))
- value))))
+ others))))))
+ (if compiler:show-time-reports?
+ (compiler-time-report "Total compilation time"
+ *process-time*
+ *real-time*))
+ (values result file-marker))))))
(if compiler:preserve-data-structures?
(begin
(compiler:reset!)
(begin
(write-char #\page)
(newline)))
- (output-port/flush-output port))))))
+ (output-port/flush-output port))))))
\ No newline at end of file
(define (assemble&link info-output-pathname)
(phase/assemble info-output-pathname)
- (if info-output-pathname
- (phase/info-generation-2 *labels* info-output-pathname))
- (phase/output-generation)
- *result*)
+ (let ((file-wrapper
+ (and info-output-pathname
+ (phase/info-generation-2 *labels* info-output-pathname))))
+ (phase/output-generation)
+ (values *result* file-wrapper)))
(define (wrap-lap entry-label some-lap)
(set! *start-label* entry-label)
(last-reference *external-labels*))))
(cond ((eq? pathname 'KEEP) ; for dynamic execution
;; (warn "C back end cannot keep debugging info in memory")
- unspecific)
+ #f)
((eq? pathname 'RECURSIVE) ; recursive compilation
(set! *recursive-compilation-results*
(cons (vector *recursive-compilation-number*
info
#f)
*recursive-compilation-results*))
- unspecific)
+ #f)
(else
- (compiler:dump-info-file
- (let ((others (recursive-compilation-results)))
- (if (null? others)
- info
- (list->vector
- (cons info
- (map (lambda (other) (vector-ref other 1))
- others)))))
- pathname)))))))
+ (let ((others (recursive-compilation-results)))
+ (if (null? others)
+ info
+ (list->vector
+ (cons info
+ (map (lambda (other) (vector-ref other 1))
+ others)))))))))))
(define (compiler:dump-bci-file binf pathname)
(let ((bci-path (pathname-new-type pathname "bci")))