From 04eeeb13f1b0423a4f341089a3552cc19e170c61 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 13 Nov 2013 18:24:27 -0500 Subject: [PATCH] Log hidden prng parameter dereferences. --- .../typed-racket/optimizer/hidden-costs.rkt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt index 220b245adc..6d1eb4ff53 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt @@ -11,6 +11,8 @@ ;; not an exhaustive list (define-literal-syntax-class hidden-port-parameter-function (display displayln newline write write-byte print printf)) +(define-literal-syntax-class hidden-random-parameter-function + (random)) ;; This syntax class does not perform optimization. ;; It only logs operations with hidden costs, for use by Optimization Coach. @@ -27,6 +29,12 @@ (not (subtypeof? arg -Output-Port))) #:do [(log-optimization-info "hidden parameter" #'op)] #:with opt #'(op args.opt ...)) + (pattern (#%plain-app op:hidden-random-parameter-function args:opt-expr ...) + ;; see above + #:when (for/and ([arg (in-syntax #'(args ...))]) + (not (subtypeof? arg -Pseudo-Random-Generator))) + #:do [(log-optimization-info "hidden parameter (random)" #'op)] + #:with opt #'(op args.opt ...)) ;; Log calls to struct constructors, so that OC can report those used in ;; hot loops. ;; Note: Sometimes constructors are wrapped in `#%expression', need to watch