- movl 4(%esp),%eax /* pc */
- movl 8(%esp),%ecx /* up */
-
- /* does sampled pc fall within bottom of profiling window? */
- subl PR_OFF(%ecx),%eax /* pc -= up->pr_off; */
- jl 1f /* if (pc < 0) return; */
-
- /* construct scaled index */
- shrl $1,%eax /* reduce pc to a short index */
- mull PR_SCALE(%ecx) /* pc*up->pr_scale */
- shrdl $15,%edx,%eax /* praddr >> 15 */
- cmpl $0,%edx /* if overflow, ignore */
- jne 1f
- andb $0xfe,%al /* praddr &= ~1 */
-
- /* within profiling buffer? if so, compute address */
- cmpl %eax,PR_SIZE(%ecx) /* if (praddr > up->pr_size) return; */
- jg 1f
- addl PR_BASE(%ecx),%eax /* praddr += up->pr_base; */
-
- /* tally ticks to selected counter */
- movl _curpcb,%ecx
- movl $proffault,PCB_ONFAULT(%ecx) #in case we page/protection violate
- movl 12(%esp),%edx /* ticks */
- addw %dx,(%eax)
- movl $0,PCB_ONFAULT(%ecx)
-1: ret
+ pushl %ebp
+ movl %esp,%ebp
+ movl 12(%ebp),%edx /* up */
+ movl 8(%ebp),%eax /* pc */
+
+ subl PR_OFF(%edx),%eax /* pc -= up->pr_off */
+ jl L1 /* if (pc < 0) return */
+
+ shrl $1,%eax /* praddr = pc >> 1 */
+ imull PR_SCALE(%edx),%eax /* praddr *= up->pr_scale */
+ shrl $15,%eax /* praddr = praddr << 15 */
+ andl $-2,%eax /* praddr &= ~1 */
+
+ cmpl PR_SIZE(%edx),%eax /* if (praddr > up->pr_size) return */
+ ja L1
+
+/* addl %eax,%eax /* praddr -> word offset */
+ addl PR_BASE(%edx),%eax /* praddr += up-> pr_base */
+ movl 16(%ebp),%ecx /* ticks */
+
+ movl _curpcb,%edx
+ movl $proffault,PCB_ONFAULT(%edx)
+ addl %ecx,(%eax) /* storage location += ticks */
+ movl $0,PCB_ONFAULT(%edx)
+L1:
+ leave
+ ret