Florian Klaempfl wrote:
Bernd Mueller schrieb:
Hello,

the ARMv5 runtime detection in rtl/arm/arm.inc fails, because the used
pld instruction does not raise SIGILL on ARM architectures ARMv4 and
below. If you would use an instruction which raises a SIGILL, it would
still fail, because SignalToRunerror in rtl/linux/arm/sighnd.inc does
not recover correct from the SIGILL.

The problem is now, that the wrong move procedure Move_pld is used
instead of Move_blended for ARMv4 which leads to a huge speed penalty
(about 25 %) for this architecture.

Not using pld gives a speed penalty of 500-1000% (!) for ARMv5 :)
no question.

I would suggest to use conditional compilation to separate between the
different ARM architectures.

At least this is no good solution because it would require that we build
two completly different releases.

I attached a patch, which solves the problem. To be honest: I am not totally sure if this is the right way. I am a newbie concerning Linux and ARM. At least the patch should not break ARMv5 ;-)

Regards, Bernd.

Index: rtl/arm/arm.inc
===================================================================
--- rtl/arm/arm.inc    (Revision 10376)
+++ rtl/arm/arm.inc    (Arbeitskopie)
@@ -589,7 +589,7 @@
   cpu_has_edsp:=true;
   in_edsp_test:=true;
   asm
-    pld [r0]
+     clz r0, r1
   end;
   in_edsp_test:=false;
   if cpu_has_edsp then
@@ -601,4 +601,3 @@

 {include hand-optimized assembler division code}
 {$i divide.inc}
-
Index: rtl/linux/arm/sighnd.inc
===================================================================
--- rtl/linux/arm/sighnd.inc    (Revision 10376)
+++ rtl/linux/arm/sighnd.inc    (Arbeitskopie)
@@ -20,6 +20,7 @@

 var
   res,fpustate : word;
+  dwReturn: dword;
 begin
   res:=0;
   case sig of
@@ -33,6 +34,16 @@
           begin
             res:=0;
             cpu_has_edsp:=false;
+            {
+               adjust return address to point behind the instruction which
+               caused the forced SIGILL.
+            }
+            dwReturn:= uContext^.uc_mcontext.arm_pc;
+            asm
+               ldr r0, dwReturn
+               add r0, r0, #4
+               str r0, [r11, #-0x4]
+            end;
           end
         else
           res:=216;
@@ -47,4 +58,3 @@
     
HandleErrorAddrFrame(res,pointer(uContext^.uc_mcontext.arm_ip),pointer(uContext^.uc_mcontext.arm_fp));
 end;
_______________________________________________
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply via email to