home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gccdist / gcc-src / vms / gcclib / prf.mar < prev    next >
Encoding:
Text File  |  1992-07-14  |  2.7 KB  |  87 lines

  1.     .title    prf 
  2.     .ident    /v1.0/
  3.     .sbttl    image section $code
  4.     .psect    $code,con,rel,novec,rd,nowrt,exe,pic,lcl,shr,long
  5. ; this entry point is never used.  It is here to give a name to the routine
  6. ; that the profiler will see
  7.     .entry __mcount_overhead,^M<R2>
  8. ;mcount::
  9. ;    pushl    16(fp)    ; the PC of the routine that called the routine we just
  10. ;            ;    came from.  (Whew!)
  11. ;    pushl    4(SP)    ; the PC of the routine we just came from
  12. ;            ;    the 4 offset is due to the fact that we just pushed
  13. ;    pushl    R0    ; and the addr of the count location 
  14. ;    calls    s^#3,_mcount
  15. ;    rsb
  16. ;
  17. ;
  18. ; This version is written to work as a jsb routine.  This is done for speed,
  19. ; since the calls overhead can be quite significant.  I do, however, inject a
  20. ; note of sanity here - if this is the first time through for this routine,
  21. ; we call the C version, which will set up R0 to point to the struct containing
  22. ; info for the function.
  23. ;
  24. ; We also check to see if the "called from" block has been allocated.  If this
  25. ; has not been done, we also call the C version
  26. mcount::
  27.     tstl (r0)
  28.     beql USE_C1
  29.     pushl r0
  30.     movl (r0),r0    ;get address of function block
  31.     movl 24(r0),r1    ; get where element of struct...
  32.     beql USE_C        ; is there a where block pointed to???
  33.     pushl r3    ; don't trash callers R3 -- ERD/EVL 13jul92
  34. L5:
  35.     movl 12(r1),r3
  36.     cmpl 16(r3),16(fp)    ; check start address
  37.     bgtru L4
  38.     cmpl 20(r3),16(fp)    ; and end address.
  39.     bgequ DO_LCL
  40. L4:
  41.     movl (r1),r1    ;Not this routine.  Try next one.
  42.     bneq L5        ;Is there another called from block in chain??
  43.     popl r3        ;restore callers R3 -- ERD/EVL 13jul92
  44. ;
  45. ; Go here if we use the C version.  This is required if one of the pointers
  46. ; to the structs is not set up, the C version can allocate the struct.
  47. ; Since this is only called once for each caller-called pair, efficiency is
  48. ; not quite as important.
  49. ;
  50. USE_C:
  51.     popl r0        ;Restore R0 - this will be used by C version.
  52. USE_C1:
  53.     pushl 16(fp)
  54.     pushl 4(sp)
  55.     pushl r0
  56.     calls s^#3,_mcount
  57.     rsb
  58.  
  59. ; Locally increment counters.  No calls are required.
  60. DO_LCL:
  61.     incl 4(r0)    ;increment count for routine
  62.     incl 4(r1)    ;and increment count for called from
  63. ;
  64. ;
  65. ;    movl #200,r0    ;test to add some more time to this routine
  66. ;test:    decl r0
  67. ;    bneq test    
  68. ;
  69.     popl r3        ;restore callers R3 -- ERD/EVL 13jul92
  70.     popl r0        ;restore stack
  71.     rsb
  72. ;
  73. ;
  74. ;
  75. ; this entry point is used by the timer.  This is called as an AST routine
  76. ; by VMS, and the PC is the fourth argument.  To find the PC of the routine
  77. ; that called the routine, we look at the FP to find the FP where that PC is
  78. ; saved.
  79. ;
  80.     .entry ___time_tick,^M<R2>
  81.     movl    12(fp),r0  ;get FP from AST handler (i.e. skip 1 call frame)
  82.     pushl    16(r0)       ;PC that called routine that was interrupted
  83.     pushl    16(ap)    ; PC that was interrupted (passed from AST handler)
  84.     calls    s^#1,___ast_routine
  85.     ret
  86.     .end
  87.