Преглед на файлове

+ adds mcount calls to syscall assembler helpers for i386 and x86-64, resolves #17140

git-svn-id: trunk@15812 -
florian преди 15 години
родител
ревизия
7dc4b6ecc1
променени са 3 файла, в които са добавени 224 реда и са изтрити 0 реда
  1. 81 0
      rtl/i386/i386.inc
  2. 61 0
      rtl/linux/i386/syscall.inc
  3. 82 0
      rtl/linux/x86_64/syscall.inc

+ 81 - 0
rtl/i386/i386.inc

@@ -634,6 +634,15 @@ end;
 function fpc_shortstr_to_shortstr(len:longint; const sstr: shortstring): shortstring; [public,alias: 'FPC_SHORTSTR_TO_SHORTSTR']; compilerproc;
 begin
   asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         cld
         movl    __RESULT,%edi
         movl    sstr,%esi
@@ -671,6 +680,15 @@ procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring)
   var
    saveesi,saveedi : longint;
   asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         movl    %edi,saveedi
         movl    %esi,saveesi
         cld
@@ -714,6 +732,15 @@ procedure fpc_shortstr_to_shortstr(out res:shortstring; const sstr: shortstring)
 procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN'];
 begin
   asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         pushl   %eax
         pushl   %ecx
         cld
@@ -759,6 +786,15 @@ end;
 function fpc_shortstr_concat(const s1,s2:shortstring):shortstring;compilerproc;
 begin
   asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         movl    __RESULT,%edi
         movl    %edi,%ebx
         movl    s1,%esi         { first string }
@@ -821,6 +857,15 @@ procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);
     [public,alias:'FPC_SHORTSTR_APPEND_SHORTSTR'];
 begin
   asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         movl    s1,%edi
         movl    s2,%esi
         movl    %edi,%ebx
@@ -866,6 +911,15 @@ function fpc_shortstr_compare(const left,right:shortstring): longint;assembler;
 var
   saveesi,saveedi,saveebx : longint;
 asm
+{$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+{$endif FPC_PROFILE}
         movl    %edi,saveedi
         movl    %esi,saveesi
         movl    %ebx,saveebx
@@ -930,6 +984,15 @@ procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public
 var
   saveres,saveebx,saveesi,saveedi : longint;
 asm
+{$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+{$endif FPC_PROFILE}
         movl    %ebx,saveebx
         movl    %esi,saveesi
         movl    %edi,saveedi
@@ -1031,6 +1094,15 @@ function fpc_pchar_length(p:pchar):longint;assembler;[public,alias:'FPC_PCHAR_LE
 var
   saveedi : longint;
 asm
+{$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+{$endif FPC_PROFILE}
         movl    %edi,saveedi
 {$ifdef REGCALL}
         movl    %eax,%edi
@@ -1123,6 +1195,15 @@ const digits:array[0..9] of cardinal=(0,10,100,1000,10000,
                                       100000000,1000000000);
 
 asm
+{$ifdef FPC_PROFILE}
+  push  %eax
+  push  %edx
+  push  %ecx
+  call  mcount
+  pop   %ecx
+  pop   %edx
+  pop   %eax
+{$endif FPC_PROFILE}
   push %esi
   push %edi
   push %ebx

+ 61 - 0
rtl/linux/i386/syscall.inc

@@ -77,9 +77,18 @@ end;
 
 Procedure fpc_geteipasebx;[external name 'fpc_geteipasebx'];
 
+{$ifdef FPC_PROFILE}
+procedure mcount; external name 'mcount';
+{$endif FPC_PROFILE}
+
 function FpSysCall(sysnr:TSysParam):TSysResult; assembler; register;  [public,alias:'FPC_SYSCALL0'];
 { Var sysnr located in register eax }
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        call  mcount
+        pop   %eax
+ {$endif FPC_PROFILE}
         push  %ebx
         push  %ecx
   {$ifdef FPC_PIC}
@@ -118,6 +127,13 @@ function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler; register; [p
 { Var sysnr located in register eax
   Var param1 located in register edx }
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        call  mcount
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
         push  %ecx
   {$ifdef FPC_PIC}
@@ -160,6 +176,15 @@ function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler; regis
   Var param1 located in register edx
   Var param2 located in register ecx }
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
         push  %edx
         push  %ecx
@@ -208,6 +233,15 @@ function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;
 var
   _psysinfo: LongWord;
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
         push  %edx
         push  %ecx
@@ -261,6 +295,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; asse
 var
   _psysinfo: LongWord;
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
         push  %esi
         push  %ecx
@@ -318,6 +361,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysRes
 var
   _psysinfo: LongWord;
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
         push  %edx
         push  %esi
@@ -383,6 +435,15 @@ function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6: TSysParam):T
 var
   _psysinfo: LongWord;
 asm
+  {$ifdef FPC_PROFILE}
+        push  %eax
+        push  %edx
+        push  %ecx
+        call  mcount
+        pop   %ecx
+        pop   %edx
+        pop   %eax
+  {$endif FPC_PROFILE}
         push  %ebx
 	push  %edx
         push  %esi

+ 82 - 0
rtl/linux/x86_64/syscall.inc

@@ -17,9 +17,18 @@
 
 {$ASMMODE GAS}
 
+{$ifdef FPC_PROFILE}
+procedure mcount; external name 'mcount';
+{$endif FPC_PROFILE}
+
 function FpSysCall(sysnr:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL0'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  call mcount
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   syscall                 { Do the system call. }
   cmpq $-4095, %rax       { Check %rax for error.  }
@@ -52,6 +61,13 @@ end;
 function FpSysCall(sysnr,param1 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL1'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  call mcount
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   syscall                 { Do the system call. }
@@ -85,6 +101,15 @@ end;
 function FpSysCall(sysnr,param1,param2 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL2'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  pushq param2
+  call mcount
+  popq param2
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   movq param2, %rsi
@@ -119,6 +144,17 @@ end;
 function FpSysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL3'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  pushq param2
+  pushq param3
+  call mcount
+  popq param3
+  popq param2
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   movq param2, %rsi
@@ -154,6 +190,19 @@ end;
 function FpSysCall(sysnr,param1,param2,param3,param4:TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL4'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  pushq param2
+  pushq param3
+  pushq param4
+  call mcount
+  popq param4
+  popq param3
+  popq param2
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   movq param2, %rsi
@@ -190,6 +239,21 @@ end;
 function FpSysCall(sysnr,param1,param2,param3,param4,param5 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL5'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  pushq param2
+  pushq param3
+  pushq param4
+  pushq param5
+  call mcount
+  popq param5
+  popq param4
+  popq param3
+  popq param2
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   movq param2, %rsi
@@ -228,6 +292,23 @@ end;
 function FpSysCall(sysnr,param1,param2,param3,param4,param5,param6 : TSysParam):TSysResult; assembler;[public,alias:'FPC_SYSCALL6'];
 
 asm
+{$ifdef FPC_PROFILE}
+  pushq sysnr
+  pushq param1
+  pushq param2
+  pushq param3
+  pushq param4
+  pushq param5
+  pushq param6
+  call mcount
+  popq param6
+  popq param5
+  popq param4
+  popq param3
+  popq param2
+  popq param1
+  popq sysnr
+{$endif FPC_PROFILE}
   movq sysnr, %rax        { Syscall number -> rax.  }
   movq param1, %rdi         { shift arg1 - arg5. }
   movq param2, %rsi
@@ -268,3 +349,4 @@ end;
 {$IFDEF SYS_LINUX}
   {$UNDEF SYSCALL_DEBUG}
 {$ENDIF SYS_LINUX}
+