From 570c5ef0f4294a7569db7d791a3ddf7e240d5fb9 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Thu, 20 Oct 2011 14:30:01 -0400 Subject: [PATCH] Log fuel and closure size. That way, we can detect close calls post facto. --- collects/typed-racket/optimizer/tool/mzc.rkt | 15 +++++++++++---- src/racket/src/optimize.c | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/collects/typed-racket/optimizer/tool/mzc.rkt b/collects/typed-racket/optimizer/tool/mzc.rkt index 60e52b94a5..f2029a01a0 100644 --- a/collects/typed-racket/optimizer/tool/mzc.rkt +++ b/collects/typed-racket/optimizer/tool/mzc.rkt @@ -75,6 +75,7 @@ "( in: (([^ :]+):([^ :]+):([^ :]+): )?([^ ]+))?" ;; module info, useless to us (at least for now) " in module: [^ ]+") + " size: ([^ ]+) threshold: ([^ ]+)" "$")) (struct inlining-event (kind ; success, miss, out of fuel, ... @@ -82,13 +83,17 @@ loc ; (U #f (List path line col pos span)) where-name ; _where_ it gets inlined (enclosing fun) where-loc ; (U #f (Line path line col)) + size ; size of the closure being inlined + threshold ; how big of a closure can we inline + ;; the last two use the same units )) (define (parse-inlining-event l) (match (regexp-match inlining-event-regexp l) [`(,all ,kind ,what ,name ,path ,line ,col ,pos ,span ,only-name - ,where ,where-loc ,where-path ,where-line ,where-col ,where-name) + ,where ,where-loc ,where-path ,where-line ,where-col ,where-name + ,size ,threshold) (inlining-event kind (string->symbol (or name only-name)) (if only-name @@ -103,13 +108,15 @@ (list where-path (string->number where-line) (string->number where-col)) - #f))] ; no source location + #f) ; no source location + (string->number size) + (string->number threshold))] [_ (error "ill-formed inlining log entry" l)])) ;; f gets inlined in f (or tried to) (define (self-inline-evt? evt) (match evt - [(inlining-event kind name loc where-name where-loc) + [(inlining-event kind name loc where-name where-loc size threshold) (match* (loc where-loc) [((list path line col pos span) (list where-path where-line where-col)) @@ -121,7 +128,7 @@ (define (inlining-event->forged-stx evt) (match evt - [(inlining-event kind name loc where-name where-loc) + [(inlining-event kind name loc where-name where-loc size threshold) (datum->syntax #'here name loc)])) diff --git a/src/racket/src/optimize.c b/src/racket/src/optimize.c index 69f5358fb9..ff776c0beb 100644 --- a/src/racket/src/optimize.c +++ b/src/racket/src/optimize.c @@ -1092,9 +1092,11 @@ Scheme_Object *optimize_for_inline(Optimize_Info *info, Scheme_Object *le, int a scheme_log(NULL, SCHEME_LOG_WARNING, 0, - "mzc optimizer: inlining: involving: %s%s", + "mzc optimizer: inlining: involving: %s%s size: %d threshold: %d", scheme_write_to_string(data->name ? data->name : scheme_false, NULL), - scheme_optimize_context_to_string(info->context)); + scheme_optimize_context_to_string(info->context), + sz, + threshold); le = apply_inlined(le, data, sub_info, argc, app, app2, app3, context, nested_count, orig_le, prev, prev_offset); if (nested_count) @@ -1105,9 +1107,11 @@ Scheme_Object *optimize_for_inline(Optimize_Info *info, Scheme_Object *le, int a scheme_log(NULL, SCHEME_LOG_WARNING, 0, - "mzc optimizer: no inlining: involving: %s%s", + "mzc optimizer: no inlining: involving: %s%s size: %d threshold: %d", scheme_write_to_string(data->name ? data->name : scheme_false, NULL), - scheme_optimize_context_to_string(info->context)); + scheme_optimize_context_to_string(info->context), + sz, + threshold); } } else { LOG_INLINE(fprintf(stderr, "No fuel %s %d[%d]>%d@%d %d\n", scheme_write_to_string(data->name ? data->name : scheme_false, NULL), @@ -1116,9 +1120,11 @@ Scheme_Object *optimize_for_inline(Optimize_Info *info, Scheme_Object *le, int a scheme_log(NULL, SCHEME_LOG_WARNING, 0, - "mzc optimizer: no inlining, out of fuel: involving: %s%s", + "mzc optimizer: no inlining, out of fuel: involving: %s%s size: %d threshold: %d", scheme_write_to_string(data->name ? data->name : scheme_false, NULL), - scheme_optimize_context_to_string(info->context)); + scheme_optimize_context_to_string(info->context), + sz, + threshold); } } else { /* Issue warning below */