From 4c8bf080b8a201ec919b7264879311d3dd3d4e24 Mon Sep 17 00:00:00 2001 From: "resyntax-ci[bot]" <181813515+resyntax-ci[bot]@users.noreply.github.com> Date: Sat, 5 Oct 2024 22:24:56 +0000 Subject: [PATCH 1/2] Automated Resyntax fixes This is an automated change generated by Resyntax. #### Pass 1 Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/optimizer.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/optimizer.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 92, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/pair.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/pair.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 77, `datum->syntax-migration`: The fifth argument to `datum->syntax` is ignored. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/vector.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/vector.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/fixnum.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/fixnum.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 127, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/float.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/float.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 139, `or-in-for/and-to-filter-clause`: The `or` expression in this `for` loop can be replaced by a filtering clause. Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/float-complex.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/float-complex.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 85, `if-let-to-cond`: `cond` with internal definitions is preferred over `if` with `let`, to reduce nesting Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/struct.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/struct.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/list.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/list.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/number.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/number.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/box.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/box.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 3 fixes to [`typed-racket-lib/typed-racket/optimizer/logging.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/logging.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 93, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. * Line 104, `map-to-for`: This `map` operation can be replaced with a `for/list` loop. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/dead-code.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/dead-code.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/apply.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/apply.rkt) * Line 2, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/extflonum.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/extflonum.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 2 fixes to [`typed-racket-lib/typed-racket/optimizer/utils.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/utils.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. * Line 53, `let-to-define`: Internal definitions are recommended instead of `let` expressions, to reduce nesting. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/string.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/string.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. Applied 1 fix to [`typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt`](../blob/HEAD/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt) * Line 3, `tidy-require`: Keep imports in `require` sorted and grouped by phase, with collections before files. ## Summary Fixed 28 issues in 20 files. * Fixed 20 occurrences of `tidy-require` * Fixed 4 occurrences of `let-to-define` * Fixed 1 occurrence of `datum->syntax-migration` * Fixed 1 occurrence of `or-in-for/and-to-filter-clause` * Fixed 1 occurrence of `if-let-to-cond` * Fixed 1 occurrence of `map-to-for` --- .../typed-racket/optimizer/apply.rkt | 11 +++-- .../typed-racket/optimizer/box.rkt | 9 ++-- .../typed-racket/optimizer/dead-code.rkt | 12 +++-- .../typed-racket/optimizer/extflonum.rkt | 13 +++-- .../typed-racket/optimizer/fixnum.rkt | 24 ++++++---- .../typed-racket/optimizer/float-complex.rkt | 48 +++++++++++-------- .../typed-racket/optimizer/float.rkt | 30 +++++++----- .../typed-racket/optimizer/hidden-costs.rkt | 13 ++--- .../typed-racket/optimizer/list.rkt | 12 +++-- .../typed-racket/optimizer/logging.rkt | 29 +++++------ .../typed-racket/optimizer/number.rkt | 10 ++-- .../typed-racket/optimizer/numeric-utils.rkt | 10 ++-- .../typed-racket/optimizer/optimizer.rkt | 33 ++++++------- .../typed-racket/optimizer/pair.rkt | 30 +++++++----- .../typed-racket/optimizer/string.rkt | 9 ++-- .../typed-racket/optimizer/struct.rkt | 13 ++--- .../typed-racket/optimizer/unboxed-let.rkt | 25 +++++----- .../typed-racket/optimizer/unboxed-tables.rkt | 7 +-- .../typed-racket/optimizer/utils.rkt | 30 +++++++----- .../typed-racket/optimizer/vector.rkt | 21 ++++---- 20 files changed, 221 insertions(+), 168 deletions(-) diff --git a/typed-racket-lib/typed-racket/optimizer/apply.rkt b/typed-racket-lib/typed-racket/optimizer/apply.rkt index ccf6f63fe..2085d26ea 100644 --- a/typed-racket-lib/typed-racket/optimizer/apply.rkt +++ b/typed-racket-lib/typed-racket/optimizer/apply.rkt @@ -1,9 +1,12 @@ #lang racket/base -(require syntax/parse racket/syntax - (for-template racket/unsafe/ops racket/base (prefix-in k- '#%kernel)) +(require (for-template racket/base + racket/unsafe/ops + (prefix-in k- '#%kernel)) + racket/syntax + syntax/parse "../utils/utils.rkt" - "utils.rkt" - "logging.rkt") + "logging.rkt" + "utils.rkt") (provide apply-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/box.rkt b/typed-racket-lib/typed-racket/optimizer/box.rkt index b026880ad..10c0d41b6 100644 --- a/typed-racket-lib/typed-racket/optimizer/box.rkt +++ b/typed-racket-lib/typed-racket/optimizer/box.rkt @@ -1,10 +1,11 @@ #lang racket/base -(require syntax/parse +(require (for-template racket/base + racket/unsafe/ops) + syntax/parse "../utils/utils.rkt" - (for-template racket/base racket/unsafe/ops) - "utils.rkt" - "logging.rkt") + "logging.rkt" + "utils.rkt") (provide box-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/dead-code.rkt b/typed-racket-lib/typed-racket/optimizer/dead-code.rkt index e285f03be..99074ecaa 100644 --- a/typed-racket-lib/typed-racket/optimizer/dead-code.rkt +++ b/typed-racket-lib/typed-racket/optimizer/dead-code.rkt @@ -1,13 +1,15 @@ #lang racket/base -(require syntax/parse syntax/stx racket/sequence +(require (for-template racket/base) + racket/sequence racket/syntax - (for-template racket/base) - "../utils/utils.rkt" + syntax/parse + syntax/stx (only-in "../utils/tc-utils.rkt" current-type-enforcement-mode deep) "../types/type-table.rkt" - "utils.rkt" - "logging.rkt") + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide dead-code-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/extflonum.rkt b/typed-racket-lib/typed-racket/optimizer/extflonum.rkt index c9dc5aa2f..999f809cc 100644 --- a/typed-racket-lib/typed-racket/optimizer/extflonum.rkt +++ b/typed-racket-lib/typed-racket/optimizer/extflonum.rkt @@ -1,13 +1,16 @@ #lang racket/base -(require syntax/parse racket/extflonum +(require (for-template racket/base + racket/extflonum + racket/unsafe/ops) + racket/extflonum + syntax/parse syntax/parse/experimental/specialize - (for-template racket/base racket/extflonum racket/unsafe/ops) "../utils/utils.rkt" - "utils.rkt" - "logging.rkt" + "fixnum.rkt" "float.rkt" - "fixnum.rkt") + "logging.rkt" + "utils.rkt") (provide extflonum-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/fixnum.rkt b/typed-racket-lib/typed-racket/optimizer/fixnum.rkt index 6f4a6584a..db92ae71d 100644 --- a/typed-racket-lib/typed-racket/optimizer/fixnum.rkt +++ b/typed-racket-lib/typed-racket/optimizer/fixnum.rkt @@ -1,14 +1,18 @@ #lang racket/base -(require syntax/parse +(require (for-syntax racket/base + racket/syntax + syntax/parse) + (for-template racket/base + racket/fixnum + racket/unsafe/ops) + syntax/parse syntax/parse/experimental/specialize - "../utils/utils.rkt" - (for-template racket/base racket/fixnum racket/unsafe/ops) - (for-syntax racket/base syntax/parse racket/syntax) "../rep/type-rep.rkt" "../types/numeric-tower.rkt" - "utils.rkt" - "logging.rkt") + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide fixnum-expr fixnum-opt-expr) @@ -124,10 +128,10 @@ ;; if we make it this far, an optimization is likely to be expected by the ;; user, so we report a missed opt if the check fails (define (check-if-safe stx) - (let ([safe-to-opt? (subtypeof? stx -Fixnum)]) - (unless safe-to-opt? - (log-fixnum-missed-opt stx)) - safe-to-opt?)) + (define safe-to-opt? (subtypeof? stx -Fixnum)) + (unless safe-to-opt? + (log-fixnum-missed-opt stx)) + safe-to-opt?) (define-syntax-class fixnum-opt-expr #:literal-sets (kernel-literals) diff --git a/typed-racket-lib/typed-racket/optimizer/float-complex.rkt b/typed-racket-lib/typed-racket/optimizer/float-complex.rkt index ce8ee36eb..e1168ac87 100644 --- a/typed-racket-lib/typed-racket/optimizer/float-complex.rkt +++ b/typed-racket-lib/typed-racket/optimizer/float-complex.rkt @@ -1,19 +1,29 @@ #lang racket/base -(require syntax/parse syntax/stx syntax/id-table racket/promise - racket/syntax racket/match syntax/parse/experimental/specialize - "../utils/utils.rkt" racket/unsafe/ops racket/sequence - (for-template racket/base racket/math racket/flonum racket/unsafe/ops) +(require (for-template racket/base + racket/flonum + racket/math + racket/unsafe/ops) + racket/match + racket/promise + racket/sequence + racket/syntax + racket/unsafe/ops + syntax/id-table + syntax/parse + syntax/parse/experimental/specialize + syntax/stx "../types/numeric-tower.rkt" "../types/subtype.rkt" "../types/type-table.rkt" "../types/utils.rkt" - "utils.rkt" - "numeric-utils.rkt" - "logging.rkt" + "../utils/tc-utils.rkt" + "../utils/utils.rkt" "float.rkt" + "logging.rkt" + "numeric-utils.rkt" "unboxed-tables.rkt" - "../utils/tc-utils.rkt") + "utils.rkt") (provide float-complex-opt-expr float-complex-expr @@ -82,18 +92,16 @@ (define c1 (stx-car cs)) (define o-nf (as-non-float o)) (define c1-nf (as-non-float c1)) - (if (or o-nf c1-nf) - ;; can't convert those to floats just yet, or may change - ;; the result - (let ([new-o (mark-as-non-float - (quasisyntax/loc this-syntax - (#,op #,(or o-nf o) #,(or c1-nf c1))))]) - (if (stx-null? (stx-cdr cs)) - new-o - (loop new-o - (stx-cdr cs)))) - ;; we've hit floats, can start coercing - (n-ary->binary this-syntax unsafe (cons #`(real->double-flonum #,(or o-nf o)) cs))))) + (cond + [(or o-nf c1-nf) + ;; can't convert those to floats just yet, or may change + ;; the result + (define new-o + (mark-as-non-float (quasisyntax/loc this-syntax + (#,op #,(or o-nf o) #,(or c1-nf c1))))) + (if (stx-null? (stx-cdr cs)) new-o (loop new-o (stx-cdr cs)))] + ;; we've hit floats, can start coercing + [else (n-ary->binary this-syntax unsafe (cons #`(real->double-flonum #,(or o-nf o)) cs))]))) diff --git a/typed-racket-lib/typed-racket/optimizer/float.rkt b/typed-racket-lib/typed-racket/optimizer/float.rkt index c62a57fd1..873197332 100644 --- a/typed-racket-lib/typed-racket/optimizer/float.rkt +++ b/typed-racket-lib/typed-racket/optimizer/float.rkt @@ -1,17 +1,23 @@ #lang racket/base -(require syntax/parse racket/sequence racket/flonum racket/promise - syntax/parse/experimental/specialize +(require (for-template racket/base + racket/flonum + racket/math + racket/unsafe/ops) + racket/flonum + racket/promise + racket/sequence syntax/id-table - (for-template racket/base racket/flonum racket/unsafe/ops racket/math) - "../utils/utils.rkt" - "../utils/tc-utils.rkt" - "../types/numeric-tower.rkt" + syntax/parse + syntax/parse/experimental/specialize "../types/abbrev.rkt" - "utils.rkt" - "numeric-utils.rkt" + "../types/numeric-tower.rkt" + "../utils/tc-utils.rkt" + "../utils/utils.rkt" + "fixnum.rkt" "logging.rkt" - "fixnum.rkt") + "numeric-utils.rkt" + "utils.rkt") (provide float-opt-expr float-arg-expr int-expr float-op) @@ -136,10 +142,10 @@ ;; (Note: could allow for more args, if not next to each other, but ;; probably not worth the trouble (most ops have 2 args anyway)) (and (subtypeof? this-syntax -Flonum) - (for/and ([a (in-syntax #'(fs ...))]) + (for/and ([a (in-syntax #'(fs ...))] + #:unless (subtypeof? a -Flonum)) ;; flonum or provably non-zero - (or (subtypeof? a -Flonum) - (subtypeof? a (Un -PosReal -NegReal)))) + (subtypeof? a (Un -PosReal -NegReal))) (>= 1 (for/sum ([a (in-syntax #'(fs ...))] #:when (not (subtypeof? a -Flonum))) diff --git a/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt b/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt index 7d0caf005..3a8e2b544 100644 --- a/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt +++ b/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt @@ -1,13 +1,14 @@ #lang racket/base -(require syntax/parse racket/sequence - (for-template racket/base) - "../utils/utils.rkt" - "utils.rkt" - "logging.rkt" +(require (for-template racket/base) + racket/sequence + syntax/parse "../types/abbrev.rkt" "../types/numeric-tower.rkt" - "../types/struct-table.rkt") + "../types/struct-table.rkt" + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide hidden-cost-log-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/list.rkt b/typed-racket-lib/typed-racket/optimizer/list.rkt index a9abd7e47..e3b9a2dfd 100644 --- a/typed-racket-lib/typed-racket/optimizer/list.rkt +++ b/typed-racket-lib/typed-racket/optimizer/list.rkt @@ -1,13 +1,15 @@ #lang racket/base -(require syntax/parse racket/match - "../utils/utils.rkt" +(require (for-template racket/base + racket/unsafe/ops) + racket/match + syntax/parse "../types/abbrev.rkt" - "../types/utils.rkt" "../types/type-table.rkt" - "utils.rkt" + "../types/utils.rkt" + "../utils/utils.rkt" "logging.rkt" - (for-template racket/base racket/unsafe/ops)) + "utils.rkt") (provide list-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/logging.rkt b/typed-racket-lib/typed-racket/optimizer/logging.rkt index e17cb4a75..84ced580b 100644 --- a/typed-racket-lib/typed-racket/optimizer/logging.rkt +++ b/typed-racket-lib/typed-racket/optimizer/logging.rkt @@ -1,8 +1,10 @@ #lang racket/base -(require racket/string - syntax/location racket/logging syntax/parse - data/queue +(require data/queue + racket/logging + racket/string + syntax/location + syntax/parse "../utils/tc-utils.rkt") (provide log-optimization log-missed-optimization log-optimization-info @@ -90,25 +92,20 @@ ;;-------------------------------------------------------------------- (define (line+col->string stx) - (let ([line (syntax-line stx)] - [col (syntax-column stx)]) - (if (and line col) - (format "~a:~a" line col) - "(no location)"))) + (define line (syntax-line stx)) + (define col (syntax-column stx)) + (if (and line col) (format "~a:~a" line col) "(no location)")) (define (format-irritants irritants) (if (null? irritants) "" (format " -- caused by: ~a" (string-join - (map (lambda (irritant) - (let ([irritant (locate-stx irritant)]) - (format "~a ~s" - (line+col->string irritant) - (syntax->datum irritant)))) - (sort irritants < - #:key (lambda (x) - (or (syntax-position x) 0)))) + (for/list ([irritant (in-list (sort irritants + < + #:key (lambda (x) (or (syntax-position x) 0))))]) + (let ([irritant (locate-stx irritant)]) + (format "~a ~s" (line+col->string irritant) (syntax->datum irritant)))) ", ")))) ;; For command-line printing purposes. diff --git a/typed-racket-lib/typed-racket/optimizer/number.rkt b/typed-racket-lib/typed-racket/optimizer/number.rkt index 2563a7e68..63be89ff3 100644 --- a/typed-racket-lib/typed-racket/optimizer/number.rkt +++ b/typed-racket-lib/typed-racket/optimizer/number.rkt @@ -1,13 +1,13 @@ #lang racket/base -(require syntax/parse +(require (for-template racket/base) + syntax/parse syntax/parse/experimental/specialize - (for-template racket/base) - "../utils/utils.rkt" "../types/abbrev.rkt" "../types/numeric-tower.rkt" - "utils.rkt" - "logging.rkt") + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide number-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt b/typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt index e5e04e44b..eff7ac688 100644 --- a/typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt +++ b/typed-racket-lib/typed-racket/optimizer/numeric-utils.rkt @@ -1,9 +1,13 @@ #lang racket/base -(require syntax/parse syntax/id-table - (for-template racket/base racket/flonum racket/fixnum racket/unsafe/ops) - "../utils/utils.rkt" +(require (for-template racket/base + racket/fixnum + racket/flonum + racket/unsafe/ops) + syntax/id-table + syntax/parse "../types/numeric-tower.rkt" + "../utils/utils.rkt" "utils.rkt") (provide (all-defined-out)) diff --git a/typed-racket-lib/typed-racket/optimizer/optimizer.rkt b/typed-racket-lib/typed-racket/optimizer/optimizer.rkt index ded7be3de..9f5832304 100644 --- a/typed-racket-lib/typed-racket/optimizer/optimizer.rkt +++ b/typed-racket-lib/typed-racket/optimizer/optimizer.rkt @@ -1,27 +1,28 @@ #lang racket/base -(require syntax/parse racket/pretty - "../utils/utils.rkt" +(require racket/pretty + syntax/parse (only-in "../utils/tc-utils.rkt" optional current-type-enforcement-mode) "../private/syntax-properties.rkt" "../types/type-table.rkt" - "utils.rkt" - "number.rkt" - "fixnum.rkt" - "float.rkt" + "../utils/utils.rkt" + "apply.rkt" + "box.rkt" + "dead-code.rkt" "extflonum.rkt" + "fixnum.rkt" "float-complex.rkt" - "vector.rkt" - "string.rkt" + "float.rkt" + "hidden-costs.rkt" "list.rkt" + "number.rkt" "pair.rkt" "sequence.rkt" - "box.rkt" + "string.rkt" "struct.rkt" - "dead-code.rkt" - "apply.rkt" "unboxed-let.rkt" - "hidden-costs.rkt") + "utils.rkt" + "vector.rkt") (provide optimize-top) @@ -89,7 +90,7 @@ (when (eq? te-mode optional) (raise-optimizer-context-error te-mode))) (parameterize ([optimize (syntax-parser [e:opt-expr* #'e.opt])]) - (let ((result ((optimize) stx))) - (when *show-optimized-code* - (pretty-print (syntax->datum result))) - result))) + (define result ((optimize) stx)) + (when *show-optimized-code* + (pretty-print (syntax->datum result))) + result)) diff --git a/typed-racket-lib/typed-racket/optimizer/pair.rkt b/typed-racket-lib/typed-racket/optimizer/pair.rkt index 4c9470501..3fee7adae 100644 --- a/typed-racket-lib/typed-racket/optimizer/pair.rkt +++ b/typed-racket-lib/typed-racket/optimizer/pair.rkt @@ -1,23 +1,27 @@ #lang racket/base -(require syntax/parse +(require (for-syntax racket/base + racket/syntax + syntax/parse) + (for-template racket/base + racket/list + racket/unsafe/ops) racket/match - (for-template racket/base racket/unsafe/ops racket/list) - (for-syntax racket/base syntax/parse racket/syntax) + syntax/parse (only-in "../utils/tc-utils.rkt" current-type-enforcement-mode) - "../utils/utils.rkt" + (only-in "../types/match-expanders.rkt" Listof:) + "../optimizer/logging.rkt" + "../optimizer/utils.rkt" "../rep/type-rep.rkt" - "../types/type-table.rkt" - "../types/utils.rkt" + "../typecheck/typechecker.rkt" "../types/base-abbrev.rkt" - (only-in "../types/match-expanders.rkt" Listof:) "../types/resolve.rkt" "../types/subtype.rkt" - "../typecheck/typechecker.rkt" - "../optimizer/utils.rkt" - "../optimizer/logging.rkt" - "utils.rkt" - "logging.rkt") + "../types/type-table.rkt" + "../types/utils.rkt" + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide pair-opt-expr) @@ -74,7 +78,7 @@ ;; change the source location of a given syntax object (define ((relocate loc-stx) stx) - (datum->syntax stx (syntax->datum stx) loc-stx stx stx)) + (datum->syntax stx (syntax->datum stx) loc-stx stx)) ;; if the equivalent sequence of cars and cdrs is guaranteed not to fail, ;; we can optimize diff --git a/typed-racket-lib/typed-racket/optimizer/string.rkt b/typed-racket-lib/typed-racket/optimizer/string.rkt index dd8a07b2f..c0eb8c634 100644 --- a/typed-racket-lib/typed-racket/optimizer/string.rkt +++ b/typed-racket-lib/typed-racket/optimizer/string.rkt @@ -1,10 +1,11 @@ #lang racket/base -(require syntax/parse - (for-template racket/base racket/unsafe/ops) +(require (for-template racket/base + racket/unsafe/ops) + syntax/parse "../utils/utils.rkt" - "utils.rkt" - "logging.rkt") + "logging.rkt" + "utils.rkt") (provide string-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/struct.rkt b/typed-racket-lib/typed-racket/optimizer/struct.rkt index b0762ad6b..8d82e946e 100644 --- a/typed-racket-lib/typed-racket/optimizer/struct.rkt +++ b/typed-racket-lib/typed-racket/optimizer/struct.rkt @@ -1,12 +1,13 @@ #lang racket/base -(require syntax/parse - (for-template racket/base racket/unsafe/ops) - "../utils/utils.rkt" - "../utils/tc-utils.rkt" +(require (for-template racket/base + racket/unsafe/ops) + syntax/parse "../types/struct-table.rkt" - "utils.rkt" - "logging.rkt") + "../utils/tc-utils.rkt" + "../utils/utils.rkt" + "logging.rkt" + "utils.rkt") (provide struct-opt-expr) diff --git a/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt b/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt index b73340a24..e5ec570d5 100644 --- a/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt +++ b/typed-racket-lib/typed-racket/optimizer/unboxed-let.rkt @@ -1,20 +1,23 @@ #lang racket/base -(require syntax/parse syntax/stx racket/sequence - syntax/parse/experimental/template - racket/match racket/syntax +(require (for-template racket/base) + racket/match racket/promise - "../utils/utils.rkt" - (for-template racket/base) + racket/sequence + racket/syntax + syntax/parse + syntax/parse/experimental/template + syntax/stx + "../env/mvar-env.rkt" + "../rep/type-rep.rkt" "../types/numeric-tower.rkt" - "../types/utils.rkt" "../types/type-table.rkt" - "../rep/type-rep.rkt" - "../env/mvar-env.rkt" - "utils.rkt" - "logging.rkt" + "../types/utils.rkt" + "../utils/utils.rkt" "float-complex.rkt" - "unboxed-tables.rkt") + "logging.rkt" + "unboxed-tables.rkt" + "utils.rkt") (provide unboxed-let-opt-expr escapes?) diff --git a/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt b/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt index 8c0f917d6..6874c0d06 100644 --- a/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt +++ b/typed-racket-lib/typed-racket/optimizer/unboxed-tables.rkt @@ -1,8 +1,9 @@ #lang racket/base -(require syntax/id-table syntax/parse - "../utils/utils.rkt" - "../utils/tc-utils.rkt") +(require syntax/id-table + syntax/parse + "../utils/tc-utils.rkt" + "../utils/utils.rkt") (provide add-unboxed-fun! diff --git a/typed-racket-lib/typed-racket/optimizer/utils.rkt b/typed-racket-lib/typed-racket/optimizer/utils.rkt index 57c3c3585..c23a34b11 100644 --- a/typed-racket-lib/typed-racket/optimizer/utils.rkt +++ b/typed-racket-lib/typed-racket/optimizer/utils.rkt @@ -1,20 +1,25 @@ #lang racket/base -(require racket/match racket/sequence - syntax/id-table racket/syntax syntax/stx +(require (for-syntax racket/base + racket/syntax + syntax/parse) + (for-template racket/base) + racket/match + racket/promise + racket/sequence + racket/syntax + syntax/id-table syntax/parse syntax/parse/experimental/specialize - racket/promise - (for-syntax racket/base syntax/parse racket/syntax) - "../utils/utils.rkt" + syntax/stx (only-in "../utils/literal-syntax-class.rkt" - [define-literal-syntax-class define-literal-syntax-class*]) - (for-template racket/base) + [define-literal-syntax-class define-literal-syntax-class*]) + "../rep/type-rep.rkt" + "../types/match-expanders.rkt" + "../types/subtype.rkt" "../types/type-table.rkt" "../types/utils.rkt" - "../types/subtype.rkt" - "../types/match-expanders.rkt" - "../rep/type-rep.rkt") + "../utils/utils.rkt") (provide *show-optimized-code* subtypeof? isoftype? @@ -50,8 +55,9 @@ ;; generates a table matching safe to unsafe promitives (define (mk-unsafe-tbl generic safe-pattern unsafe-pattern) (for/fold ([h (make-immutable-free-id-table)]) ([g (in-list generic)]) - (let ([f (format-id g safe-pattern g)] [u (format-id g unsafe-pattern g)]) - (free-id-table-set (free-id-table-set h g u) f u)))) + (define f (format-id g safe-pattern g)) + (define u (format-id g unsafe-pattern g)) + (free-id-table-set (free-id-table-set h g u) f u))) ;; unlike their safe counterparts, unsafe binary operators can only take 2 arguments ;; this works on operations that are (A A -> A) diff --git a/typed-racket-lib/typed-racket/optimizer/vector.rkt b/typed-racket-lib/typed-racket/optimizer/vector.rkt index 23cbf1cc9..7a6065519 100644 --- a/typed-racket-lib/typed-racket/optimizer/vector.rkt +++ b/typed-racket-lib/typed-racket/optimizer/vector.rkt @@ -1,17 +1,22 @@ #lang racket/base -(require syntax/parse - racket/match racket/flonum racket/extflonum - (for-template racket/base racket/flonum racket/extflonum racket/unsafe/ops) - "../utils/utils.rkt" +(require (for-template racket/base + racket/extflonum + racket/flonum + racket/unsafe/ops) + racket/extflonum + racket/flonum + racket/match + syntax/parse "../rep/type-rep.rkt" + "../types/abbrev.rkt" + "../types/numeric-tower.rkt" "../types/type-table.rkt" "../types/utils.rkt" - "../types/numeric-tower.rkt" - "../types/abbrev.rkt" - "utils.rkt" + "../utils/utils.rkt" + "fixnum.rkt" "logging.rkt" - "fixnum.rkt") + "utils.rkt") (provide vector-opt-expr) From ffa028445a48e2bc2e1c80c0f0f8ca1219cda67a Mon Sep 17 00:00:00 2001 From: Jacqueline Firth Date: Mon, 7 Oct 2024 16:18:17 -0700 Subject: [PATCH 2/2] Revert `or-in-for/and-to-filter-clause` resyntax rule application --- typed-racket-lib/typed-racket/optimizer/float.rkt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/typed-racket-lib/typed-racket/optimizer/float.rkt b/typed-racket-lib/typed-racket/optimizer/float.rkt index 873197332..867b1f0b1 100644 --- a/typed-racket-lib/typed-racket/optimizer/float.rkt +++ b/typed-racket-lib/typed-racket/optimizer/float.rkt @@ -142,10 +142,10 @@ ;; (Note: could allow for more args, if not next to each other, but ;; probably not worth the trouble (most ops have 2 args anyway)) (and (subtypeof? this-syntax -Flonum) - (for/and ([a (in-syntax #'(fs ...))] - #:unless (subtypeof? a -Flonum)) + (for/and ([a (in-syntax #'(fs ...))]) ;; flonum or provably non-zero - (subtypeof? a (Un -PosReal -NegReal))) + (or (subtypeof? a -Flonum) + (subtypeof? a (Un -PosReal -NegReal)))) (>= 1 (for/sum ([a (in-syntax #'(fs ...))] #:when (not (subtypeof? a -Flonum)))