[gambit-list] Profiling of expanded code?

William Cook wcook at cs.utexas.edu
Sat Nov 15 12:38:28 EST 2008


Why doesn't the Gambit define-macro (and syntax-case) just do the right thing? This 
is very annoying. And it seems that the transformation you are applying below is very 
straightforward, and could be applied to all macros created with define-macro. I know 
there are complex cases where it might not work, but at least  pointing the source at 
the macro source (as you do below) would be nice. Can you access the sub-source of a 
source object, rather than getting the sexpr?

William

  Guillaume Cartier wrote:
> For statprof to work with your code, you will have to rewrite your 
> macros using Gambit's ##define-syntax.
>  
> When you use define-macro, Gambit strips all source information before 
> passing the sexpr to expand to your macro. With ##define-syntax, you 
> will receive a source object containing source positioning information 
> for every sexpr in the form to expand. You can then insert those source 
> objects into the expansion of your macro. Doing that, every Gambit tool 
> that needs source information like statprof will now work with your macros.
>  
> Here's a 'when' macro defined using ##define-syntax :
>  
> (##define-syntax when
>   (lambda (form-src)
>     (let ((test (cadr (##source-code form-src)))
>           (body (cddr (##source-code form-src))))
>       (##sourcify
>         `(if ,test
>              (begin
>                , at body)
>            #f)
>         form-src))))
>  
> A partial list of primitives you will need :
> 
>     * (##source? expr) : guess what it does :)
>     * (##source-code source) : returns the sepxr that was sourcified by
>       'source'
>     * (##desourcify source) : full recursive desourcification of 'source'
>     * (##sourcify expr source) : creates a source object for 'expr' that
>       has the same source info as 'source'
> 
>   
> On Thu, Nov 6, 2008 at 8:21 AM, David St-Hilaire 
> <sthilaid at iro.umontreal.ca <mailto:sthilaid at iro.umontreal.ca>> wrote:
> 
>     Hi all!
> 
>     I often use Guillaume Germain's profiler for gambit
>     (http://www.iro.umontreal.ca/~germaing/statprof.html) and I would
>     like to know
>     if its possible to get a profiling result on the marco expanded
>     code, and not
>     the source code.
> 
>     I ask this because I wrote several macro which define multiple
>     functions. It
>     seems that lots of the work is done within these functions but the
>     profiler only
>     tells me that it is my macro call who does all the work (but its in
>     fact the
>     code generated by that macro). So having access to a profiling
>     report of the
>     macro expanded code could be usefull :)
> 
>     Thanks!
> 
>     David
>     _______________________________________________
>     Gambit-list mailing list
>     Gambit-list at iro.umontreal.ca <mailto:Gambit-list at iro.umontreal.ca>
>     https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list

-- 
William Cook
http://www.cs.utexas.edu/users/wcook



More information about the Gambit-list mailing list