From 60ad22f29f55a38f1ea09e71a5e25ce0cad7ec32 Mon Sep 17 00:00:00 2001 From: Evan Hanson
Date: Sat, 27 Sep 2014 13:37:53 +1200 Subject: [PATCH] Include debug info on ##core#direct_call nodes. Signed-off-by: Peter Bex --- NEWS | 1 + c-backend.scm | 26 ++++++++++++++++++++------ compiler.scm | 15 ++++++++++++--- optimizer.scm | 9 ++++++--- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index fcdeabc..6a34708 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ - Compiler: - Fixed incorrect argvector restoration after GC in directly recursive functions (#1317). + - "Direct" procedure invocations now also maintain debug info (#894). - Runtime system: - "time" macro now shows peak memory usage (#1318, thanks to Kooda). diff --git a/c-backend.scm b/c-backend.scm index 2479986..b006ed0 100644 --- a/c-backend.scm +++ b/c-backend.scm @@ -356,14 +356,27 @@ ((##core#direct_call) (let* ((args (cdr subs)) (n (length args)) - (nf (add1 n)) - ;;(name (second params)) - (call-id (third params)) - (demand (fourth params)) + (nf (add1 n)) + (dbi (first params)) + ;; (safe-to-call (second params)) + (name (third params)) + (name-str (source-info->string name)) + (call-id (fourth params)) + (demand (fifth params)) (allocating (not (zero? demand))) (empty-closure (zero? (lambda-literal-closure-size (find-lambda call-id)))) (fn (car subs)) ) - (gen call-id #\() + (gen #\() + (when name + (cond (emit-debug-info + (when dbi + (gen #t " C_debugger(&(C_debug_info[" dbi "])," + (if non-av-proc "0,NULL" "c,av") "),"))) + (emit-trace-info + (gen #t " C_trace(\"" (backslashify name-str) "\"),")) + (else + (gen #t " /* " (uncommentify name-str) " */") ) ) ) + (gen #t " " call-id #\() (when allocating (gen "C_a_i(&a," demand #\)) (when (or (not empty-closure) (pair? args)) (gen #\,)) ) @@ -371,7 +384,8 @@ (expr fn i) (when (pair? args) (gen #\,)) ) (when (pair? args) (expr-args args i)) - (gen #\)) ) ) + (gen #\)) ; function call + (gen #t #\)) ) ) ; complete expression ((##core#callunit) ;; The code generated here does not use the extra temporary needed for standard calls, so we have diff --git a/compiler.scm b/compiler.scm index db1b0b2..be605f2 100644 --- a/compiler.scm +++ b/compiler.scm @@ -218,7 +218,7 @@ ; [##core#proc {