Don't futz with floenv if not in use.
authorTaylor R Campbell <campbell@mumble.net>
Fri, 30 Nov 2018 07:59:04 +0000 (07:59 +0000)
committerTaylor R Campbell <campbell@mumble.net>
Fri, 30 Nov 2018 08:19:40 +0000 (08:19 +0000)
Makes flo:raise-exceptions! kosher to use anywhere without incurring
cost in threads that don't care.

src/runtime/floenv.scm

index d4d478ee372a2f6062fc683f4c6401092e191cd0..37f8bab08ee7db6011df7eefd74f021a3f97db40 100644 (file)
@@ -102,7 +102,10 @@ USA.
           ((ucode-primitive float-environment 0))
           fp-env))))
 \f
-(define (use-floating-point-environment!)
+(define-integrable (using-floating-point-environment?)
+  (and (thread-float-environment (current-thread)) #t))
+
+(define-integrable (use-floating-point-environment!)
   (set-thread-float-environment! (current-thread) #t))
 
 (define (flo:environment)
@@ -243,12 +246,12 @@ USA.
   (flo:trappable-exceptions trappable-float-exceptions 0))
 
 (define (flo:clear-exceptions! exceptions)
-  (use-floating-point-environment!)
-  ((ucode-primitive clear-float-exceptions 1) exceptions))
+  (if (using-floating-point-environment?)
+      ((ucode-primitive clear-float-exceptions 1) exceptions)))
 
 (define (flo:raise-exceptions! exceptions)
-  (use-floating-point-environment!)
-  ((ucode-primitive raise-float-exceptions 1) exceptions))
+  (if (using-floating-point-environment?)
+      ((ucode-primitive raise-float-exceptions 1) exceptions)))
 
 (define (flo:restore-exception-flags! fexcept exceptions)
   (use-floating-point-environment!)