Changeset 3592 for trunk/kStuff/kProfiler2/prfamd64msc.asm
- Timestamp:
- Sep 23, 2007, 9:50:24 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kStuff/kProfiler2/prfamd64msc.asm
r3586 r3592 83 83 push r10 84 84 push r11 85 sub rsp, 30h ; rsp is aligned at this point (7pushes).85 sub rsp, 28h ; rsp is unaligned at this point (8 pushes). 86 86 ; reserve 20h for spill, and 8 bytes for ts. 87 87 … … 91 91 or r8, rax ; param 3 - the timestamp 92 92 mov [rsp + 20h], r8 ; save the tsc for later use. 93 lea rdx, [rsp + 7*8 + 30h] ; Param 2 - frame pointer (pointer to the return address of the function calling us)93 lea rdx, [rsp + 8*8 + 28h] ; Param 2 - frame pointer (pointer to the return address of the function calling us) 94 94 mov rcx, [rdx] ; Param 1 - The function address 95 95 call KPRF_ENTER … … 127 127 push r10 128 128 push r11 129 sub rsp, 30h ; rsp is aligned at this point (7pushes).129 sub rsp, 28h ; rsp is unaligned at this point (8 pushes). 130 130 ; reserve 20h for spill, and 8 bytes for ts. 131 131 132 ; setting up the leave call frame.132 ; setting up the enter call frame 133 133 mov r8d, edx 134 134 shl r8, 32 135 135 or r8, rax ; param 3 - the timestamp 136 136 mov [rsp + 20h], r8 ; save the tsc for later use. 137 lea rdx, [rsp + 7*8 + 30h] ; Param 2 - frame pointer (pointer to the return address of the function calling us)137 lea rdx, [rsp + 8*8 + 28h] ; Param 2 - frame pointer (pointer to the return address of the function calling us) 138 138 mov rcx, [rdx] ; Param 1 - The function address 139 139 call KPRF_LEAVE … … 148 148 common_return_path: 149 149 ; Update overhead 150 test eax, eax150 test rax, rax 151 151 jz common_no_overhead 152 152 cmp byte [g_fCalibrated wrt rip], 0 … … 166 166 167 167 ; restore volatile registers. 168 add rsp, 30h168 add rsp, 28h 169 169 pop r11 170 170 pop r10 … … 180 180 ; Data rsi points to while we're calibrating. 181 181 struc CALIBDATA 182 .OverheadLo resd 1 183 .OverheadHi resd 1 184 .ProfiledLo resd 1 185 .ProfiledHi resd 1 186 .EnterTSLo resd 1 187 .EnterTSHi resd 1 188 .MinLo resd 1 189 .MinHi resd 1 182 .Overhead resq 1 183 .Profiled resq 1 184 .EnterTS resq 1 185 .Min resq 1 190 186 endstruc 191 187 … … 219 215 mov rsi, rsp ; rsi points to the CALIBDATA 220 216 221 and rsp, -1 5217 and rsp, -16 222 218 223 219 ; … … 238 234 ; 239 235 mov ecx, 200h 240 mov dword [rsi + CALIBDATA.Min Lo], 0ffffffffh241 mov dword [rsi + CALIBDATA.Min Hi], 07fffffffh236 mov dword [rsi + CALIBDATA.Min], 0ffffffffh 237 mov dword [rsi + CALIBDATA.Min + 4], 07fffffffh 242 238 calib_inner_loop: 243 239 244 240 ; zero the overhead and profiled times. 245 241 xor eax, eax 246 mov [rsi + CALIBDATA.Overhead Lo], rax247 mov [rsi + CALIBDATA.Profiled Lo], rax242 mov [rsi + CALIBDATA.Overhead], rax 243 mov [rsi + CALIBDATA.Profiled], rax 248 244 call calib_nullproc 249 245 250 246 ; subtract the overhead 251 mov rax, [rsi + CALIBDATA.Profiled Lo]252 sub rax, [rsi + CALIBDATA.Overhead Lo]247 mov rax, [rsi + CALIBDATA.Profiled] 248 sub rax, [rsi + CALIBDATA.Overhead] 253 249 254 250 ; update the minimum value. 255 251 bt rax, 63 256 252 jc near calib_outer_dec ; if negative, just simplify and shortcut 257 cmp rax, [rsi + CALIBDATA.Min Hi]253 cmp rax, [rsi + CALIBDATA.Min] 258 254 jge calib_inner_next 259 255 calib_inner_update_minimum: 260 mov [rsi + CALIBDATA.Min Lo], rax256 mov [rsi + CALIBDATA.Min], rax 261 257 calib_inner_next: 262 258 loop calib_inner_loop 263 259 264 260 ; Is the minimum value acceptable? 265 test dword [rsi + CALIBDATA.Min Lo+ 4], 80000000h261 test dword [rsi + CALIBDATA.Min + 4], 80000000h 266 262 jnz calib_outer_dec ; simplify if negative. 267 cmp dword [rsi + CALIBDATA.Min Hi+ 4], 0263 cmp dword [rsi + CALIBDATA.Min + 4], 0 268 264 jnz calib_outer_inc ; this shouldn't be possible 269 cmp dword [rsi + CALIBDATA.Min Lo], 1fh265 cmp dword [rsi + CALIBDATA.Min], 1fh 270 266 jbe calib_outer_dec ; too low - 2 ticks per pair is the minimum! 271 cmp dword [rsi + CALIBDATA.MinLo], 30h 272 jbe calib_done ; this is fine! 267 ;cmp dword [rsi + CALIBDATA.Min], 30h 268 ;jbe calib_done ; this is fine! 269 cmp dword [rsi + CALIBDATA.Min], 70h ; - a bit weird... 270 jbe calib_outer_next ; do the full 200h*200h iteration 273 271 calib_outer_inc: 274 272 inc dword [g_OverheadAdj wrt rip] … … 284 282 285 283 ; epilog - restore it all. 286 leave284 mov rsp, rbp 287 285 pop r15 288 286 pop r14 … … 300 298 pop rax 301 299 popfq 300 pop rbp 302 301 ret 303 302 … … 319 318 push r10 320 319 push r11 321 sub rsp, 30h ; rsp is aligned at this point (7pushes).320 sub rsp, 28h ; rsp is unaligned at this point (8 pushes). 322 321 ; reserve 20h for spill, and 8 bytes for ts. 323 322 … … 328 327 mov [rsp + 20h], r8 329 328 330 mov [rsi + CALIBDATA.EnterTS Lo], r8331 332 lea rax, [rsi + CALIBDATA.Overhead Lo]329 mov [rsi + CALIBDATA.EnterTS], r8 330 331 lea rax, [rsi + CALIBDATA.Overhead] 333 332 jmp common_overhead 334 333 … … 348 347 push r10 349 348 push r11 350 sub rsp, 30h ; rsp is aligned at this point (7pushes).349 sub rsp, 28h ; rsp is unaligned at this point (8 pushes). 351 350 ; reserve 20h for spill, and 8 bytes for ts. 352 351 … … 357 356 mov [rsp + 20h], r8 358 357 359 sub r8, [rsi + CALIBDATA.EnterTS Lo]360 add [rsi + CALIBDATA.Profiled Lo], r8361 362 lea rax, [rsi + CALIBDATA.EnterTS Lo]358 sub r8, [rsi + CALIBDATA.EnterTS] 359 add [rsi + CALIBDATA.Profiled], r8 360 361 lea rax, [rsi + CALIBDATA.EnterTS] 363 362 jmp common_overhead 364 363
Note:
See TracChangeset
for help on using the changeset viewer.