Browse Source

- removed register lists after pure assembler procedures
- removed {$ifdef FPC_HAS_RIP_RELATIVE}, it is obsolete because rip-releative referencing is supported in at least two releases by now.
+ added nostackframe to simple assembler procedures
* Inclocked, Declocked: do not duplicate entire procedures, Win64 and Linux versions differ in a single instruction.

git-svn-id: trunk@19162 -

sergei 14 years ago
parent
commit
c73b6cfbd4
1 changed files with 46 additions and 113 deletions
  1. 46 113
      rtl/x86_64/x86_64.inc

+ 46 - 113
rtl/x86_64/x86_64.inc

@@ -28,14 +28,14 @@
 Function Sptr : Pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 Function Sptr : Pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
 asm
         movq    %rsp,%rax
         movq    %rsp,%rax
-end ['RAX'];
+end;
 
 
 {$IFNDEF INTERNAL_BACKTRACE}
 {$IFNDEF INTERNAL_BACKTRACE}
 {$define FPC_SYSTEM_HAS_GET_FRAME}
 {$define FPC_SYSTEM_HAS_GET_FRAME}
 function get_frame:pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 function get_frame:pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
 asm
 asm
         movq    %rbp,%rax
         movq    %rbp,%rax
-end ['RAX'];
+end;
 {$ENDIF not INTERNAL_BACKTRACE}
 {$ENDIF not INTERNAL_BACKTRACE}
 
 
 
 
@@ -53,7 +53,7 @@ asm
         movq    8(%rdi),%rax
         movq    8(%rdi),%rax
 {$endif win64}
 {$endif win64}
 .Lg_a_null:
 .Lg_a_null:
-end ['RAX'];
+end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
 {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
@@ -70,7 +70,7 @@ asm
         movq    (%rdi),%rax
         movq    (%rdi),%rax
 {$endif win64}
 {$endif win64}
 .Lg_a_null:
 .Lg_a_null:
-end ['RAX'];
+end;
 
 
 // The following assembler procedures are disabled for FreeBSD due to
 // The following assembler procedures are disabled for FreeBSD due to
 // multiple issues with its old GNU assembler (Mantis #19188).
 // multiple issues with its old GNU assembler (Mantis #19188).
@@ -635,175 +635,108 @@ end;
 
 
 {$endif freebsd}
 {$endif freebsd}
 
 
-{$asmmode att}
 {$define FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
 {$define FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
 { does a thread save inc/dec }
 { does a thread save inc/dec }
-function declocked(var l : longint) : boolean;assembler;
+function declocked(var l : longint) : boolean;assembler; nostackframe;
   asm
   asm
-{$ifdef win64}
-     {
-       l: %rcx
-     }
-     { this check should be done because a lock takes a lot }
-     { of time!                                             }
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
-     jz         .Ldeclockednolock
-     lock
-     decl       (%rcx)
-     jmp        .Ldeclockedend
-.Ldeclockednolock:
-     decl       (%rcx)
-.Ldeclockedend:
-     setzb      %al
-{$else win64}
-     {
-       l: %rdi
-     }
      { this check should be done because a lock takes a lot }
      { this check should be done because a lock takes a lot }
      { of time!                                             }
      { of time!                                             }
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
      movq       IsMultithread@GOTPCREL(%rip),%rax
      movq       IsMultithread@GOTPCREL(%rip),%rax
      cmpb       $0,(%rax)
      cmpb       $0,(%rax)
 {$else FPC_PIC}
 {$else FPC_PIC}
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+     cmpb       $0,IsMultithread(%rip)
 {$endif FPC_PIC}
 {$endif FPC_PIC}
+{$ifndef win64}
+     mov        %rdi, %rcx
+{$endif win64}
      jz         .Ldeclockednolock
      jz         .Ldeclockednolock
      lock
      lock
-     decl       (%rdi)
+     decl       (%rcx)
      jmp        .Ldeclockedend
      jmp        .Ldeclockedend
 .Ldeclockednolock:
 .Ldeclockednolock:
-     decl       (%rdi)
+     decl       (%rcx)
 .Ldeclockedend:
 .Ldeclockedend:
      setzb      %al
      setzb      %al
-{$endif win64}
   end;
   end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_DECLOCKED_INT64}
 {$define FPC_SYSTEM_HAS_DECLOCKED_INT64}
-function declocked(var l : int64) : boolean;assembler;
+function declocked(var l : int64) : boolean;assembler; nostackframe;
   asm
   asm
-{$ifdef win64}
-     {
-       l: %rcx
-     }
-     { this check should be done because a lock takes a lot }
-     { of time!                                             }
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
-     jz         .Ldeclockednolock
-     lock
-     decq       (%rcx)
-     jmp        .Ldeclockedend
-.Ldeclockednolock:
-     decq       (%rcx)
-.Ldeclockedend:
-     setzb      %al
-{$else win64}
-     {
-       l: %rdi
-     }
      { this check should be done because a lock takes a lot }
      { this check should be done because a lock takes a lot }
      { of time!                                             }
      { of time!                                             }
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
      movq       IsMultithread@GOTPCREL(%rip),%rax
      movq       IsMultithread@GOTPCREL(%rip),%rax
      cmpb       $0,(%rax)
      cmpb       $0,(%rax)
 {$else FPC_PIC}
 {$else FPC_PIC}
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+     cmpb       $0,IsMultithread(%rip)
 {$endif FPC_PIC}
 {$endif FPC_PIC}
+{$ifndef win64}
+     mov        %rdi, %rcx
+{$endif win64}
      jz         .Ldeclockednolock
      jz         .Ldeclockednolock
      lock
      lock
-     decq       (%rdi)
+     decq       (%rcx)
      jmp        .Ldeclockedend
      jmp        .Ldeclockedend
 .Ldeclockednolock:
 .Ldeclockednolock:
-     decq       (%rdi)
+     decq       (%rcx)
 .Ldeclockedend:
 .Ldeclockedend:
      setzb      %al
      setzb      %al
-{$endif win64}
   end;
   end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
 {$define FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
-procedure inclocked(var l : longint);assembler;
+procedure inclocked(var l : longint);assembler; nostackframe;
 
 
   asm
   asm
-{$ifdef win64}
-     {
-       l: %rcx
-     }
-     { this check should be done because a lock takes a lot }
-     { of time!                                             }
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
-     jz         .Linclockednolock
-     lock
-     incl       (%rcx)
-     jmp        .Linclockedend
-.Linclockednolock:
-     incl       (%rcx)
-.Linclockedend:
-{$else win64}
-     {
-       l: %rdi
-     }
      { this check should be done because a lock takes a lot }
      { this check should be done because a lock takes a lot }
      { of time!                                             }
      { of time!                                             }
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
      movq       IsMultithread@GOTPCREL(%rip),%rax
      movq       IsMultithread@GOTPCREL(%rip),%rax
      cmpb       $0,(%rax)
      cmpb       $0,(%rax)
 {$else FPC_PIC}
 {$else FPC_PIC}
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+     cmpb       $0,IsMultithread(%rip)
 {$endif FPC_PIC}
 {$endif FPC_PIC}
+{$ifndef win64}
+     mov        %rdi, %rcx
+{$endif win64}
      jz         .Linclockednolock
      jz         .Linclockednolock
      lock
      lock
-     incl       (%rdi)
+     incl       (%rcx)
      jmp        .Linclockedend
      jmp        .Linclockedend
 .Linclockednolock:
 .Linclockednolock:
-     incl       (%rdi)
+     incl       (%rcx)
 .Linclockedend:
 .Linclockedend:
-{$endif win64}
   end;
   end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_INCLOCKED_INT64}
 {$define FPC_SYSTEM_HAS_INCLOCKED_INT64}
-procedure inclocked(var l : int64);assembler;
+procedure inclocked(var l : int64);assembler; nostackframe;
 
 
   asm
   asm
-{$ifdef win64}
-     {
-       l: %rcx
-     }
-     { this check should be done because a lock takes a lot }
-     { of time!                                             }
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
-     jz         .Linclockednolock
-     lock
-     incq       (%rcx)
-     jmp        .Linclockedend
-.Linclockednolock:
-     incq       (%rcx)
-.Linclockedend:
-{$else win64}
-     {
-       l: %rdi
-     }
      { this check should be done because a lock takes a lot }
      { this check should be done because a lock takes a lot }
      { of time!                                             }
      { of time!                                             }
 {$ifdef FPC_PIC}
 {$ifdef FPC_PIC}
      movq       IsMultithread@GOTPCREL(%rip),%rax
      movq       IsMultithread@GOTPCREL(%rip),%rax
      cmpb       $0,(%rax)
      cmpb       $0,(%rax)
 {$else FPC_PIC}
 {$else FPC_PIC}
-     cmpb       $0,IsMultithread{$ifdef FPC_HAS_RIP_RELATIVE}(%rip){$endif}
+     cmpb       $0,IsMultithread(%rip)
 {$endif FPC_PIC}
 {$endif FPC_PIC}
+{$ifndef win64}
+     mov        %rdi, %rcx
+{$endif win64}
      jz         .Linclockednolock
      jz         .Linclockednolock
      lock
      lock
-     incq       (%rdi)
+     incq       (%rcx)
      jmp        .Linclockedend
      jmp        .Linclockedend
 .Linclockednolock:
 .Linclockednolock:
-     incq       (%rdi)
+     incq       (%rcx)
 .Linclockedend:
 .Linclockedend:
-{$endif win64}
   end;
   end;
 
 
 
 
-function InterLockedDecrement (var Target: longint) : longint; assembler;
+function InterLockedDecrement (var Target: longint) : longint; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movq    %rcx,%rax
         movq    %rcx,%rax
@@ -818,7 +751,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedIncrement (var Target: longint) : longint; assembler;
+function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movq    %rcx,%rax
         movq    %rcx,%rax
@@ -833,7 +766,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
+function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         xchgl   (%rcx),%edx
         xchgl   (%rcx),%edx
@@ -845,7 +778,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
+function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         xchgq   %rcx,%rdx
         xchgq   %rcx,%rdx
@@ -861,7 +794,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedCompareExchange(var Target: longint; NewValue, Comperand : longint): longint; assembler;
+function InterLockedCompareExchange(var Target: longint; NewValue, Comperand : longint): longint; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movl            %r8d,%eax
         movl            %r8d,%eax
@@ -875,7 +808,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedDecrement64 (var Target: int64) : int64; assembler;
+function InterLockedDecrement64 (var Target: int64) : int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movq    %rcx,%rax
         movq    %rcx,%rax
@@ -890,7 +823,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedIncrement64 (var Target: int64) : int64; assembler;
+function InterLockedIncrement64 (var Target: int64) : int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movq    %rcx,%rax
         movq    %rcx,%rax
@@ -905,7 +838,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedExchange64 (var Target: int64;Source : int64) : int64; assembler;
+function InterLockedExchange64 (var Target: int64;Source : int64) : int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         xchgq   (%rcx),%rdx
         xchgq   (%rcx),%rdx
@@ -917,7 +850,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedExchangeAdd64 (var Target: int64;Source : int64) : int64; assembler;
+function InterLockedExchangeAdd64 (var Target: int64;Source : int64) : int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         xchgq   %rcx,%rdx
         xchgq   %rcx,%rdx
@@ -933,7 +866,7 @@ asm
 end;
 end;
 
 
 
 
-function InterLockedCompareExchange64(var Target: int64; NewValue, Comperand : int64): int64; assembler;
+function InterLockedCompareExchange64(var Target: int64; NewValue, Comperand : int64): int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
         movq            %r8,%rax
         movq            %r8,%rax
@@ -1074,7 +1007,7 @@ function SwapEndian(const AValue: Word): Word;{$ifdef SYSTEMINLINE}inline;{$endi
   end;
   end;
 
 
 
 
-function SwapEndian(const AValue: LongInt): LongInt; assembler;
+function SwapEndian(const AValue: LongInt): LongInt; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
   movl %ecx, %eax
   movl %ecx, %eax
@@ -1085,7 +1018,7 @@ asm
 end;
 end;
 
 
 
 
-function SwapEndian(const AValue: DWord): DWord; assembler;
+function SwapEndian(const AValue: DWord): DWord; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
   movl %ecx, %eax
   movl %ecx, %eax
@@ -1096,7 +1029,7 @@ asm
 end;
 end;
 
 
 
 
-function SwapEndian(const AValue: Int64): Int64; assembler;
+function SwapEndian(const AValue: Int64): Int64; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
   movq %rcx, %rax
   movq %rcx, %rax
@@ -1107,7 +1040,7 @@ asm
 end;
 end;
 
 
 
 
-function SwapEndian(const AValue: QWord): QWord; assembler;
+function SwapEndian(const AValue: QWord): QWord; assembler; nostackframe;
 asm
 asm
 {$ifdef win64}
 {$ifdef win64}
   movq %rcx, %rax
   movq %rcx, %rax