瀏覽代碼

* valgrind safe primitive move implementation

git-svn-id: trunk@7503 -
florian 18 年之前
父節點
當前提交
a8062fafe7
共有 1 個文件被更改,包括 40 次插入1 次删除
  1. 40 1
      rtl/i386/fastmove.inc

+ 40 - 1
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