View Issue Details

IDProjectCategoryView StatusLast Update
0029230PatchesPackagespublic2015-12-24 01:59
ReporterMaciej Izak Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.7 (SVN) 
Summary0029230: PascalScript: pass dyn. arrays
DescriptionPascalScript: pass dyn. arrays in registers when i386 register calling conventions are used (related to FPC r30870). Pass dyn. arrays in the same way as in Delphi for x64 (fix for long standing bug).

Patch and example demo attached.
TagsNo tags attached.
Fixed in Revisionr51018
LazTarget-
Widgetset
Attached Files

Activities

Maciej Izak

2015-12-21 19:16

developer   ~0088147

Fixed also in Sparta branch r50964

Maciej Izak

2015-12-21 19:18

developer  

testapp.zip (10,323 bytes)

Maciej Izak

2015-12-21 19:19

developer   ~0088148

testapp.zip is from related forum topic http://forum.lazarus.freepascal.org/index.php/topic,30815.0.html

Maciej Izak

2015-12-21 22:09

developer  

PascalScript.patch (1,525 bytes)   
Index: x64.inc
===================================================================
--- x64.inc	(revision 50967)
+++ x64.inc	(working copy)
@@ -542,11 +542,7 @@
               Result := True;
               exit;
             end else begin
-            {$IFDEF FPC}
-              StoreReg(IPointer(FVar.Dta));
-            {$ELSE}
               StoreReg(IPointer(FVar.Dta^));
-            {$ENDIF}
             end;
           end;
         btRecord:
Index: x86.inc
===================================================================
--- x86.inc	(revision 50967)
+++ x86.inc	(working copy)
@@ -1,7 +1,5 @@
 { implementation of x86         abi }
-{$ifdef FPC}
-{$define PS_ARRAY_ON_STACK}
-{$endif}
+
 function RealFloatCall_Register(p: Pointer;
   _EAX, _EDX, _ECX: Cardinal;
   StackData: Pointer;
@@ -390,9 +388,16 @@
             {$IFDEF PS_DYNARRAY}
               TempStr := StringOfChar(AnsiChar(#0),4);
               Pointer((@TempStr[1])^) := Pointer(fvar.Dta^);
-            {$IFDEF PS_ARRAY_ON_STACK}
-            UseReg := false;
+            {$IFDEF FPC}
+            {$IF FPC_FULLVERSION < 30101}
+              // pass dyn. array on stack
+              UseReg := false;
+            {$ELSE}
+              // pass dyn. arrays in registers when i386 register calling conventions are used
+              // more details -> FPC r30870
+              UseReg := CallingConv = cdRegister;
             {$ENDIF}
+            {$ENDIF ~FPC}
             {$ELSE}
               Exit;
             {$ENDIF}
PascalScript.patch (1,525 bytes)   

Maciej Izak

2015-12-21 22:13

developer   ~0088150

Last edited: 2015-12-21 22:14

View 2 revisions

New patch attached, little adjustments for FPC_FULLVERSION. Should be ok for Lazarus + FPC 2.6x, 3.0, 3.X and newer. Fixed also in Sparta Branch (r50964 + r50967).

Maciej Izak

2015-12-22 15:25

developer   ~0088173

More info related to patch:
http://wiki.freepascal.org/User_Changes_Trunk#Dynamic_array_parameters_are_passed_like_pointers

Juha Manninen

2015-12-24 01:59

developer   ~0088200

I applied the patch so it won't be ignored although I don't know PascalScript well.
Thanks.

Issue History

Date Modified Username Field Change
2015-12-21 19:15 Maciej Izak New Issue
2015-12-21 19:15 Maciej Izak File Added: PascalScript.patch
2015-12-21 19:16 Maciej Izak Note Added: 0088147
2015-12-21 19:18 Maciej Izak File Added: testapp.zip
2015-12-21 19:19 Maciej Izak Note Added: 0088148
2015-12-21 19:27 Maciej Izak Summary [Patch] PascalScript: pass dyn. arrays => PascalScript: pass dyn. arrays
2015-12-21 22:09 Maciej Izak File Deleted: PascalScript.patch
2015-12-21 22:09 Maciej Izak File Added: PascalScript.patch
2015-12-21 22:13 Maciej Izak Note Added: 0088150
2015-12-21 22:14 Maciej Izak Note Edited: 0088150 View Revisions
2015-12-22 15:25 Maciej Izak Note Added: 0088173
2015-12-24 01:59 Juha Manninen Fixed in Revision => r51018
2015-12-24 01:59 Juha Manninen Note Added: 0088200
2015-12-24 01:59 Juha Manninen Status new => resolved
2015-12-24 01:59 Juha Manninen Resolution open => fixed
2015-12-24 01:59 Juha Manninen Assigned To => Juha Manninen