diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-02-19 20:11:00 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-02-19 20:11:00 -0800 |
commit | c6fe7be22f1c77a6cbacd34e49ec9bf718d75553 (patch) | |
tree | e7157287b1ede65fab819388ac7fd4fed6f4ad1c | |
parent | 458cb61cedcd21d2eea0c8588a2050af2b678dac (diff) | |
download | txr-c6fe7be22f1c77a6cbacd34e49ec9bf718d75553.tar.gz txr-c6fe7be22f1c77a6cbacd34e49ec9bf718d75553.tar.bz2 txr-c6fe7be22f1c77a6cbacd34e49ec9bf718d75553.zip |
pprof: generate much smaller expansion.
* eval.c (me_pprof): Instead of emitting open code which
destructures the output of pprof and prints a diagnostic,
let's do that inside a run-time support function called
sys:rt-pprof, so (pprof x) now expands to (rt:pprof (prof x)).
(rt_pprof): New function.
(eval_init): Register sys:rt-pprof intrinsic.
-rw-r--r-- | eval.c | 38 |
1 files changed, 21 insertions, 17 deletions
@@ -3067,24 +3067,27 @@ static val me_delay(val form, val menv) static val me_pprof(val form, val menv) { - val retval = gensym(lit("retval-")); - val mbytes = gensym(lit("mal-bytes-")); - val gcbytes = gensym(lit("gc-bytes-")); - val msecs = gensym(lit("usecs-")); - (void) menv; - return list(tree_bind_s, - list(retval, mbytes, gcbytes, msecs, nao), - cons(prof_s, rest(form)), - list(format_s, t, lit("malloc bytes: ~12a\n" - "gc heap bytes: ~12a\n" - "total: ~12a\n" - "milliseconds: ~12a\n"), - mbytes, gcbytes, - list(plus_s, mbytes, gcbytes, nao), - msecs, nao), - retval, - nao); + return list(intern(lit("rt-pprof"), system_package), + cons(prof_s, rest(form)), nao); +} + +static val rt_pprof(val prof_list) +{ + val retval = pop(&prof_list); + val malloc_bytes = pop(&prof_list); + val gc_bytes = pop(&prof_list); + val msecs = pop(&prof_list); + + format(t, lit("malloc bytes: ~12a\n" + "gc heap bytes: ~12a\n" + "total: ~12a\n" + "milliseconds: ~12a\n"), + malloc_bytes, gc_bytes, + plus(malloc_bytes, gc_bytes), + msecs, nao); + + return retval; } static val me_when(val form, val menv) @@ -6866,6 +6869,7 @@ void eval_init(void) reg_fun(intern(lit("rt-defun"), system_package), func_n2(rt_defun)); reg_fun(intern(lit("rt-defmacro"), system_package), func_n3(rt_defmacro)); reg_fun(intern(lit("rt-defsymacro"), system_package), func_n2(rt_defsymacro)); + reg_fun(intern(lit("rt-pprof"), system_package), func_n1(rt_pprof)); eval_error_s = intern(lit("eval-error"), user_package); uw_register_subtype(eval_error_s, error_s); |