From a8062fafe7bf38b896379ac85d4e61a94c8ae6b0 Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 28 May 2007 18:21:44 +0000 Subject: [PATCH] * valgrind safe primitive move implementation git-svn-id: trunk@7503 - --- rtl/i386/fastmove.inc | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/rtl/i386/fastmove.inc b/rtl/i386/fastmove.inc index f52365b8c7..60034585dc 100644 --- a/rtl/i386/fastmove.inc +++ b/rtl/i386/fastmove.inc @@ -367,6 +367,41 @@ asm @@Done: end; {SmallBackwardMove} + +{ at least valgrind up to 3.3 has a bug which prevents the default code to + work so we use a rather simple implementation here +} +procedure Forwards_Valgrind;assembler;nostackframe; +asm + push esi + push edi + mov esi,eax + mov edi,edx + rep movsb + pop edi + pop esi +end; + +{ at least valgrind up to 3.3 has a bug which prevents the default code to + work so we use a rather simple implementation here +} +procedure Backwards_Valgrind;assembler;nostackframe; +asm + push esi + push edi + lea esi,[eax+ecx-1] + lea edi,[edx+ecx-1] +@@repeat: + mov al,[esi] + mov [edi],al + dec esi + dec edi + dec ecx + jnz @@repeat + pop edi + pop esi +end; + {-------------------------------------------------------------------------} {Move ECX Bytes from EAX to EDX, where EAX > EDX and ECX > 36 (SMALLMOVESIZE)} procedure Forwards_IA32_3;assembler;nostackframe; @@ -840,7 +875,11 @@ procedure setup_fastmove;{$ifdef SYSTEMINLINE}inline;{$endif} {$ifdef FPC_HAS_VALGRINDBOOL} { workaround valgrind bug } if valgrind_used then - exit; + begin + fastmoveproc_forward:=@Forwards_Valgrind; + fastmoveproc_backward:=@Backwards_Valgrind; + end + else {$endif FPC_HAS_VALGRINDBOOL} if has_sse_support then