Skip to content

Commit 5a11349

Browse files
committed
Simplify $reset-protect in the same way
1 parent 5748a74 commit 5a11349

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

s/7.ss

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
;;; 7.ss
22
;;; Copyright 1984-2017 Cisco Systems, Inc.
3-
;;;
3+
;;;
44
;;; Licensed under the Apache License, Version 2.0 (the "License");
55
;;; you may not use this file except in compliance with the License.
66
;;; You may obtain a copy of the License at
7-
;;;
7+
;;;
88
;;; http://www.apache.org/licenses/LICENSE-2.0
9-
;;;
9+
;;;
1010
;;; Unless required by applicable law or agreed to in writing, software
1111
;;; distributed under the License is distributed on an "AS IS" BASIS,
1212
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -466,7 +466,7 @@
466466
(define-record-type (sstats make-sstats sstats?)
467467
(nongenerative #{sstats pfwch3jd8ts96giujpitoverj-0})
468468
(sealed #t)
469-
(fields
469+
(fields
470470
(mutable cpu sstats-cpu set-sstats-cpu!)
471471
(mutable real sstats-real set-sstats-real!)
472472
(mutable bytes sstats-bytes set-sstats-bytes!)
@@ -479,7 +479,7 @@
479479
(lambda (cpu real bytes gc-count gc-cpu gc-real gc-bytes)
480480
(new cpu real bytes gc-count gc-cpu gc-real gc-bytes))))))
481481
(define exact-integer? (lambda (x) (and (integer? x) (exact? x))))
482-
(set-who! make-sstats
482+
(set-who! make-sstats
483483
(lambda (cpu real bytes gc-count gc-cpu gc-real gc-bytes)
484484
(define verify-time
485485
(lambda (name x)
@@ -616,29 +616,26 @@
616616
(unless (and (real? v) (not (negative? v)))
617617
($oops 'collect-maximum-generation-threshold-factor "~s is not a nonnegative real" v))
618618
v)))
619-
619+
620620
(define $reset-protect
621621
(lambda (body out)
622-
((call/cc
623-
(lambda (k)
624-
(parameterize ([reset-handler
622+
(call/cc
623+
(lambda (k)
624+
(parameterize ([reset-handler
625625
(lambda ()
626-
(k (lambda ()
627-
(out)
628-
((reset-handler)))))])
629-
(with-exception-handler
630-
(lambda (c)
631-
; would prefer not to burn bridges even for serious condition
632-
; if the exception is continuable, but we have no way to know
633-
; short of grubbing through the continuation
634-
(if (serious-condition? c)
635-
(k (lambda () (out) (raise c)))
636-
(raise-continuable c)))
637-
(lambda ()
638-
(call-with-values body
639-
(case-lambda
640-
[(v) (lambda () v)]
641-
[v* (lambda () (apply values v*))]))))))))))
626+
(call-in-continuation k
627+
(lambda ()
628+
(out)
629+
((reset-handler)))))])
630+
(with-exception-handler
631+
(lambda (c)
632+
; would prefer not to burn bridges even for serious condition
633+
; if the exception is continuable, but we have no way to know
634+
; short of grubbing through the continuation
635+
(if (serious-condition? c)
636+
(call-in-continuation k (lambda () (out) (raise c)))
637+
(raise-continuable c)))
638+
body))))))
642639

643640
(define exit-handler)
644641
(define reset-handler)
@@ -890,7 +887,7 @@
890887
(docollect
891888
(lambda (gct prev-allocated-after-max)
892889
(let ([max-gen? (fx= g (collect-maximum-generation))])
893-
(values
890+
(values
894891
; make gc-trip to look like we've just collected generation g
895892
; w/o also having collected generation g+1
896893
(if max-gen?
@@ -1288,7 +1285,7 @@
12881285
(condition-wait $collect-cond $tc-mutex)
12891286
(f)]))))
12901287
(critical-section
1291-
(dynamic-wind
1288+
(dynamic-wind
12921289
once
12931290
(collect-request-handler)
12941291
(lambda () (set! $collect-request-pending #f))))))))
@@ -1467,7 +1464,7 @@
14671464
(define-record-type pass-stats
14681465
(nongenerative)
14691466
(sealed #t)
1470-
(fields
1467+
(fields
14711468
(mutable calls)
14721469
(mutable cpu)
14731470
(mutable gc-cpu)
@@ -1489,7 +1486,7 @@
14891486
(set! stats-ht (make-eq-hashtable))))
14901487

14911488
(set! $enable-pass-timing (make-parameter #f))
1492-
1489+
14931490
(set-who! $pass-time
14941491
(lambda (name thunk)
14951492
(unless (symbol? name) ($oops who "~s is not a symbol" name))
@@ -1539,8 +1536,8 @@
15391536
(define (build-result namev psv)
15401537
(vector->list
15411538
(vector-map
1542-
(lambda (name ps)
1543-
(list name
1539+
(lambda (name ps)
1540+
(list name
15441541
(pass-stats-calls ps)
15451542
(pass-stats-cpu ps)
15461543
(pass-stats-gc-cpu ps)

0 commit comments

Comments
 (0)