Diff for /gforth/prof-inline.fs between versions 1.6 and 1.7

version 1.6, 2004/09/07 18:14:46 version 1.7, 2004/09/13 07:32:37
Line 56  struct Line 56  struct
 end-struct list%  end-struct list%
   
 list%  list%
     cell% 2* field profile-count      cell% 2* field profile-count \ how often this profile point is performed
     cell% 2* field profile-sourcepos      cell% 2* field profile-sourcepos
     cell% field profile-char \ character position in line      cell% field profile-char \ character position in line
     cell% field profile-bblen \ number of primitives in BB      cell% field profile-bblen \ number of primitives in BB
       cell% field profile-bblenpi \ bblen after partial inlining
       cell% field profile-callee-postlude \ 0 or (for calls) callee postlude len
       cell% field profile-tailof \ 0 or (for tail bbs) pointer to coldef bb
     cell% field profile-colondef? \ is this a colon definition start      cell% field profile-colondef? \ is this a colon definition start
     cell% field profile-calls \ static calls to the colon def (calls%)      cell% field profile-calls \ static calls to the colon def (calls%)
     cell% field profile-straight-line \ may contain calls, but no other CF      cell% field profile-straight-line \ may contain calls, but no other CF
     cell% field profile-calls-from \ static calls in the colon def      cell% field profile-calls-from \ static calls in the colon def
 end-struct profile% \ profile point      cell% field profile-exits \ number of exits in this colon def
       cell% 2* field profile-execs \ number of EXECUTEs etc. of this colon def
       cell% field profile-prelude \ first BB-len of colon def (incl. callee)
       cell% field profile-postlude \ last BB-len of colon def (incl. callee)
   end-struct profile% \ profile point 
   
 list%  list%
     cell% field calls-call \ ptr to profile point of bb containing the call      cell% field calls-call \ ptr to profile point of bb containing the call
Line 118  variable all-bbs 0 all-bbs ! \ list of a Line 125  variable all-bbs 0 all-bbs ! \ list of a
     0. r@ profile-count 2!      0. r@ profile-count 2!
     current-sourcepos r@ profile-sourcepos 2!      current-sourcepos r@ profile-sourcepos 2!
     >in @ r@ profile-char !      >in @ r@ profile-char !
       0 r@ profile-callee-postlude !
       0 r@ profile-tailof !
     r@ profile-colondef? off      r@ profile-colondef? off
     0 r@ profile-bblen !      0 r@ profile-bblen !
       -100000000 r@ profile-bblenpi !
       current-profile-point @ profile-bblenpi @ -100000000 = if
           current-profile-point @ dup profile-bblen @ swap profile-bblenpi !
       endif
     0 r@ profile-calls !      0 r@ profile-calls !
     r@ profile-straight-line on      r@ profile-straight-line on
     0 r@ profile-calls-from !      0 r@ profile-calls-from !
       0 r@ profile-exits !
       0. r@ profile-execs 2!
       0 r@ profile-prelude !
       0 r@ profile-postlude !
     r@ next-profile-point-p insert-list-end      r@ next-profile-point-p insert-list-end
     r@ current-profile-point !      r@ current-profile-point !
     r@ new-call all-bbs insert-list      r@ new-call all-bbs insert-list
Line 291  Defer before-word-profile ( -- ) Line 308  Defer before-word-profile ( -- )
     r> ! ; \ change hook behaviour      r> ! ; \ change hook behaviour
   
 : note-execute ( -- )  : note-execute ( -- )
     \ end of BB due to execute      \ end of BB due to execute, dodefer, perform
       profile-this \ should actually happen after the word, but the
                    \ error is probably small
 ;  ;
   
 : note-call ( addr -- )  : note-call ( addr -- )
Line 299  Defer before-word-profile ( -- ) Line 318  Defer before-word-profile ( -- )
     dup ['] (does>2) >body = if \ adjust does handler address      dup ['] (does>2) >body = if \ adjust does handler address
         4 cells here 1 cells - +!          4 cells here 1 cells - +!
     endif      endif
     profile-this current-profile-point @ new-call      { addr }
     over 3 cells + @ ['] dinc >body = if ( addr call-prof-point )      current-profile-point @ { lastbb }
       profile-this
       current-profile-point @ { thisbb }
       thisbb new-call { call-node }
       over 3 cells + @ ['] dinc >body = if
         \ non-library call          \ non-library call
          swap cell+ @ profile-calls insert-list      !! update profile-bblenpi of last and current pp
           addr cell+ @ { callee-pp }
           callee-pp profile-postlude @ thisbb profile-callee-postlude !
           call-node callee-pp profile-calls insert-list
     else ( addr call-prof-point )      else ( addr call-prof-point )
         library-calls insert-list drop          call-node library-calls insert-list
     endif ;      endif ;
   
 : prof-compile, ( xt -- )  : prof-compile, ( xt -- )
Line 312  Defer before-word-profile ( -- ) Line 338  Defer before-word-profile ( -- )
         DEFERS compile, EXIT          DEFERS compile, EXIT
     endif      endif
     1 current-profile-point @ profile-bblen +!      1 current-profile-point @ profile-bblen +!
     dup >does-code if      dup CASE
         dup >does-code note-call          ['] execute of note-execute endof
     then          ['] perform of note-execute endof
     dup >code-address CASE          dup >does-code if
         docol:   OF dup >body note-call ENDOF              dup >does-code note-call
         dodefer: OF note-execute ENDOF          then
         \ dofield: OF >body @ POSTPONE literal ['] + peephole-compile, EXIT ENDOF          dup >code-address CASE
         \ code words and ;code-defined words (code words could be optimized):              docol:   OF dup >body note-call ENDOF
               dodefer: OF note-execute ENDOF
               \ dofield: OF >body @ POSTPONE literal ['] + peephole-compile, EXIT ENDOF
               \ code words and ;code-defined words (code words could be optimized):
           ENDCASE
     ENDCASE      ENDCASE
     DEFERS compile, ;      DEFERS compile, ;
   
Line 327  Defer before-word-profile ( -- ) Line 357  Defer before-word-profile ( -- )
     defers :-hook      defers :-hook
     next-profile-point-p @      next-profile-point-p @
     profile-this      profile-this
     @ dup last-colondef-profile !      @ dup last-colondef-profile ! ( current-profile-point )
       1 over profile-bblenpi !
     profile-colondef? on ;      profile-colondef? on ;
   
   : exit-hook-profile ( -- )
       defers exit-hook
       1 last-colondef-profile @ profile-exits +! ;
   
   : ;-hook-profile ( -- )
       \ ;-hook is called before the POSTPONE EXIT
       defers ;-hook
       last-colondef-profile @ { col }
       current-profile-point @ { bb }
       col profile-bblen @ col profile-prelude +!
       col profile-exits @ 0= if
           col bb profile-tailof !
           bb profile-bblen @ bb profile-callee-postlude @ +
           col profile-postlude !
           1 bb profile-bblenpi !
           \ not counting the EXIT
       endif ;
   
 hook-profiling-into then-like  hook-profiling-into then-like
 \ hook-profiling-into if-like    \ subsumed by other-control-flow  \ hook-profiling-into if-like    \ subsumed by other-control-flow
 \ hook-profiling-into ahead-like \ subsumed by other-control-flow  \ hook-profiling-into ahead-like \ subsumed by other-control-flow
Line 339  hook-profiling-into again-like Line 388  hook-profiling-into again-like
 hook-profiling-into until-like  hook-profiling-into until-like
 ' :-hook-profile IS :-hook  ' :-hook-profile IS :-hook
 ' prof-compile, IS compile,  ' prof-compile, IS compile,
   ' exit-hook-profile IS exit-hook
   ' ;-hook-profile IS ;-hook

Removed from v.1.6  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>