Przeglądaj źródła

* activated fastmove on win32

git-svn-id: trunk@2218 -
florian 19 lat temu
rodzic
commit
af9d6344b8
2 zmienionych plików z 47 dodań i 9 usunięć
  1. 12 7
      rtl/i386/i386.inc
  2. 35 2
      rtl/win32/system.pp

+ 12 - 7
rtl/i386/i386.inc

@@ -18,7 +18,7 @@
                                Primitives
 ****************************************************************************}
 var
-  has_sse_support,has_mmx_support : boolean;
+  has_sse_support,has_mmx_support,os_supports_sse : boolean;
 
 {$asmmode intel}
 
@@ -59,7 +59,7 @@ function sse_support : boolean;
           cpuid
           movl %edx,_edx
         end;
-        sse_support:=(_edx and $2000000)<>0;
+        sse_support:=((_edx and $2000000)<>0) and os_supports_sse;
      end
     else
      { a cpu with without cpuid instruction supports never sse }
@@ -88,14 +88,19 @@ function mmx_support : boolean;
        mmx_support:=false;
   end;
 
+{$define USE_FASTMOVE}
 {$i fastmove.inc}
 
 procedure fpc_cpuinit;
-begin
-  has_sse_support:=sse_support;
-  has_mmx_support:=mmx_support;
-  setup_fastmove;
-end;
+  begin
+    { because of the brain dead sse detection on x86, this test is post poned to fpc_cpucodeinit which
+      must be implemented OS dependend (FK)
+    has_sse_support:=sse_support;
+    has_mmx_support:=mmx_support;
+    setup_fastmove;
+    }
+    os_supports_sse:=false;
+  end;
 
 
 {$ifndef FPC_SYSTEM_HAS_MOVE}

+ 35 - 2
rtl/win32/system.pp

@@ -170,7 +170,7 @@ var
       { the arg. is still present!                     }
       sysreallocmem(argv[idx],len+1);
     end;
-    
+
 begin
   SetupProcVars;
   { create commandline, it starts with the executed filename which is argv[0] }
@@ -792,6 +792,10 @@ begin
         end;
 end;
 
+var
+  { this variable is set to true, if currently an sse check is executed and no sig ill should be generated }
+  sse_check : boolean;
+
 function syswin32_i386_exception_handler(excep : PExceptionPointers) : Longint;stdcall;
 var
   res: longint;
@@ -836,7 +840,16 @@ begin
           must_reset_fpu := false;
         end;
       STATUS_ILLEGAL_INSTRUCTION:
-        err := 216;
+        { if we're testing sse support, simply set the flag and continue }
+        if sse_check then
+          begin
+            os_supports_sse:=false;
+            { if yes, then retry }
+            excep^.ExceptionRecord^.ExceptionCode := 0;
+            res:=EXCEPTION_CONTINUE_EXECUTION;
+          end
+        else
+          err := 216;
       STATUS_ACCESS_VIOLATION:
         { Athlon prefetch bug? }
         if is_prefetch(pointer(excep^.ContextRecord^.Eip)) then
@@ -931,6 +944,24 @@ end;
 
 {$endif Set_i386_Exception_handler}
 
+{ because of the brain dead sse detection on x86, this test is post poned }
+procedure fpc_cpucodeinit;
+  begin
+    os_supports_sse:=true;
+    sse_check:=true;
+    asm
+      { force an sse exception if no sse is supported, the exception handler sets
+        os_supports_sse to false then }
+      movq %xmm0,%xmm0
+    end;
+    sse_check:=false;
+    has_sse_support:=sse_support;
+    has_mmx_support:=mmx_support;
+    setup_fastmove;
+  end;
+
+
+
 
 {****************************************************************************
                       OS dependend widestrings
@@ -1142,6 +1173,8 @@ begin
   { Setup heap }
   InitHeap;
   SysInitExceptions;
+  { setup fastmove stuff }
+  fpc_cpucodeinit;
   SysInitStdIO;
   { Arguments }
   setup_arguments;