From ce59724778ce9410a8141e00d9f122ee857f2392 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Mon, 13 May 2013 16:47:47 -0400 Subject: [PATCH] Log sequence specialization failures in `for' loops. Using this logging, Optimization Coach can recommend adding `in-list' and co. to `for' loops in hot code. --- collects/racket/private/for.rkt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/collects/racket/private/for.rkt b/collects/racket/private/for.rkt index aab1489e3c..43bcce8d53 100644 --- a/collects/racket/private/for.rkt +++ b/collects/racket/private/for.rkt @@ -171,6 +171,9 @@ ;; taints down to all the relevant identifiers and expressions: (arm-for-clause clause syntax-arm)) + (define sequence-specialization-logger + (make-logger 'sequence-specialization (current-logger))) + (define (expand-clause orig-stx clause) (define (unpack stx) (syntax-case stx () @@ -294,7 +297,17 @@ (and post-guard (not (pred id ...))) (loop-arg ...)))] [[(id ...) rhs] + #t (let ([introducer (make-syntax-introducer)]) + ;; log non-specialized clauses, for performance tuning + (when (log-level? sequence-specialization-logger 'debug) + (log-message sequence-specialization-logger + 'debug + (format "non-specialized for clause: ~a:~a:~a" + (syntax-source #'rhs) + (syntax-line #'rhs) + (syntax-column #'rhs)) + #'rhs)) (with-syntax ([[(id ...) rhs] (introducer (syntax-local-introduce clause))]) (arm-for-clause (syntax-local-introduce