Faster TlsAlloc() or zero_bit_scan
Dietrich Teickner
dietrich_teickner at arcor.de
Thu Feb 10 11:59:21 CST 2005
Hi,
I have a suggestion for a faster implementation of the zero_bit_scan in
RtlFindClearBits [NTDLL.@]
(rlbitmap.c) for e.g. TlsAlloc()
The main is the usage of the instruction 'bsf eax, eax'
This I have implemented in the new experimental odinxp-tree for finding
the first zero_bit in the first 'bytecount' bytes of the bitmap addr.
Dietrich
public _search_zero_bit
;int CDECL search_zero_bit(int bytecount, void *addr);
_search_zero_bit proc near
push esi
push edx
mov esi, [esp+16]
mov edx, [esp+12]
inc edx
loop:
add esi, 4
mov eax, -1
dec edx
;not found
jz short found
xor eax, dword ptr [esi - 4]
jz loop
bsf eax, eax
jz short loop
sub esi, 4
sub esi, [esp+16]
shl esi, 5-2
add eax, esi
found:
pop edx
pop esi
ret
_search_zero_bit endp
More information about the wine-devel
mailing list