cs: compile FFI stubs in unsafe mode

Unsafe mode saves time compiling the stubs (which happens dynamically
for programs using `ffi/unsafe`) more than running them.
This commit is contained in:
Matthew Flatt 2019-10-05 07:10:23 -06:00
parent d3d0bffb88
commit f8bc4e8fa1

View File

@ -208,13 +208,19 @@
;; `compile`, `interpret`, etc. have `dynamic-wind`-based state ;; `compile`, `interpret`, etc. have `dynamic-wind`-based state
;; that need to be managed correctly when swapping Racket ;; that need to be managed correctly when swapping Racket
;; engines/threads. ;; engines/threads.
(define (compile* e) (define compile*
(case-lambda
[(e safe?)
(call-with-system-wind (lambda () (call-with-system-wind (lambda ()
(parameterize ([optimize-level (if safe?
(optimize-level)
3)])
(if assembly-on? (if assembly-on?
(parameterize ([#%$assembly-output (#%current-output-port)]) (parameterize ([#%$assembly-output (#%current-output-port)])
(printf ";; assembly ---------------------\n") (printf ";; assembly ---------------------\n")
(compile e)) (compile e))
(compile e))))) (compile e)))))]
[(e) (compile* e #t)]))
(define (interpret* e) (define (interpret* e)
(call-with-system-wind (lambda () (interpret e)))) (call-with-system-wind (lambda () (interpret e))))
(define (fasl-write* s o) (define (fasl-write* s o)
@ -225,7 +231,7 @@
(define (eval/foreign e mode) (define (eval/foreign e mode)
(performance-region (performance-region
mode mode
(compile* e))) (compile* e #f)))
(define primitives (make-hasheq)) ; hash of sym -> known (define primitives (make-hasheq)) ; hash of sym -> known
(define primitive-tables '()) ; list of (cons sym hash) (define primitive-tables '()) ; list of (cons sym hash)