From f8bc4e8fa1d37d90a66e0e975dcbc244cd3c9796 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 5 Oct 2019 07:10:23 -0600 Subject: [PATCH] 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. --- racket/src/cs/linklet.sls | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/racket/src/cs/linklet.sls b/racket/src/cs/linklet.sls index 654b859831..901f76d32a 100644 --- a/racket/src/cs/linklet.sls +++ b/racket/src/cs/linklet.sls @@ -208,13 +208,19 @@ ;; `compile`, `interpret`, etc. have `dynamic-wind`-based state ;; that need to be managed correctly when swapping Racket ;; engines/threads. - (define (compile* e) - (call-with-system-wind (lambda () - (if assembly-on? - (parameterize ([#%$assembly-output (#%current-output-port)]) - (printf ";; assembly ---------------------\n") - (compile e)) - (compile e))))) + (define compile* + (case-lambda + [(e safe?) + (call-with-system-wind (lambda () + (parameterize ([optimize-level (if safe? + (optimize-level) + 3)]) + (if assembly-on? + (parameterize ([#%$assembly-output (#%current-output-port)]) + (printf ";; assembly ---------------------\n") + (compile e)) + (compile e)))))] + [(e) (compile* e #t)])) (define (interpret* e) (call-with-system-wind (lambda () (interpret e)))) (define (fasl-write* s o) @@ -225,7 +231,7 @@ (define (eval/foreign e mode) (performance-region mode - (compile* e))) + (compile* e #f))) (define primitives (make-hasheq)) ; hash of sym -> known (define primitive-tables '()) ; list of (cons sym hash)