Background:
In the course of debugging something, I encountered the following
instruction stream, apparently in rtl100:
51F23BCB 90 nop
rtl100.@System@@GetMem$qqri:
51F23BCC 85C0 test eax,eax
51F23BCE 7E13 jle $51f23be3
51F23BD0 FF1574C7F951 call dword ptr [$51f9c774]
51F23BD6 85C0 test eax,eax
51F23BD8 7402 jz $51f23bdc
51F23BDA F3C3 rep ret
51F23BDC B001 mov al,$01
51F23BDE E941020000 jmp $51f23e24
51F23BE3 31C0 xor eax,eax
51F23BE5 F3C3 rep ret
51F23BE7 90 nop
rtl100.@System@@FreeMem$qqrpv:
51F23BE8 85C0 test eax,eax
It appears that the instruction stream is intended, and generated from the
following source code segment from System.pas:
TEST EAX,EAX
JLE @@negativeorzerosize
CALL MemoryManager.GetMem
TEST EAX,EAX
JZ @@getmemerror
DB $F3
RET
@@getmemerror:
MOV AL,reOutOfMemory
JMP Error
@@negativeorzerosize:
XOR EAX, EAX
DB $F3
I believe it is a speed optimization that has to do with the pre-fetch cache.
--
Bruce
AMD's recommended solution is to either reorder instructions so that
this situation does not occur, or use the REP prefix on the RET
instruction.PS Before ask question try google first.