Commit Graph

73 Commits

Author SHA1 Message Date
svenbarth
7089677a22 * change RecInitTable into a direct reference to avoid an unnecessary indirection as both the full and init RTTI of a record always reside inside the same unit
git-svn-id: trunk@35128 -
2016-12-14 18:40:16 +00:00
svenbarth
12dba952f0 * integration of Part 2 patch of Mantis #30687 with a few adjustments:
- indentation in ncgrtti.pas
  - fewer ifdefs in rtti.inc
  - InitTable/Terminator field as first field to avoid padding on targets that require proper alignment and have SizeOf(Pointer) > 4

Original message by Maciej Izak:

Breaking change for rtti layout for record rtti. Init table
is always accessible from regular rtti. Rtti table contains indirect
reference to init table, additionally init table contains nil-terminator (for
rtl purposes - the only way to determine kind of info : init or rtti). Pros:

* will be possible to create more Delphi compatible code for RTTI, finally end-user can access to *real* managed fields of records (some work on TypInfo.pp is still required but is not necessary).
* important step forward for management operators (anyway this commit is not directly related to management operators)
* much more optimal memory allocation/initialization/finalization for records created/destroyed by InitializeArray/FinalizeArray, for example:

type
  TBar = record
    f1,f2,f3,f4,f5,f6,f7,f8,f9: byte;
    s: string;
  end;

previously:

  GetMem(PB, SizeOf(TBar));
  InitializeArray(PB, TypeInfo(TBar), 1); // FPC_INITIALIZE was executed 10 times

now:

  GetMem(PB, SizeOf(TBar));
  InitializeArray(PB, TypeInfo(TBar), 1); // FPC_INITIALIZE is executed just once

+ test attached

git-svn-id: trunk@35125 -
2016-12-13 23:03:11 +00:00
florian
c32e41b551 + add missing semicolon in fpc_initialize_array declaration, patch by Maciej Izak
git-svn-id: trunk@35000 -
2016-11-27 20:01:42 +00:00
svenbarth
345d83c3e3 Merge RTTI changes from packages branch (including adjustments that were required due to changes in trunk since then). These changes favor source backwards compatibility in contrast to Delphi compatibility. Binary compatiblity is however drastically broken due to the indirect references that are platform independant!
Merged revision(s) 28239-28289 from branches/svenbarth/packages:
Provide the possiblity to switch between the direct and indirect RTTI symbols.

ncgrtti.pas, TRTTIWriter:
  + get_rtti_label, get_rtti_label_ord2str & get_rtti_label_str2ord: add new "indirect" parameter and pass that along to rtti_mangledname
hlcgobj.pas, thlcgobj:
  * g_incrrefcount, g_initialize, g_finalize, g_array_rtti_helper: for now pass along False to get_rtti_label()
ncgvmt.pas, TVMTWriter:
  * writevmt: for now pass along False to get_rtti_label()
ncgld.pas, tcgrttinode:
  * pass_generate_code: for now pass along False to the get_rtti_label*() methods
........
Provide possibility to select between using a direct and an indirect RTTI reference. This way the references can be changed for selected cases.

ncgrtti, TRTTIWriter:
  * ref_rtti: new "indirect" parameter that's relayed to rtti_mangledname()
  * write_rtti_reference: new "indirect" paramater that's relayed to ref_rtti()
........
Switch properties to use the indirect type information without breaking backwards compatiblity. :)

compiler/ncgrtti.pas, TRTTIWriter:
  * published_properties_write_rtti_data: use the indirect reference, not the direct one
rtl/objpas/typinfo.pp:
  * to allow compilation with both 2.6.x and 2.7.1 and too avoid too many ifdefs at least in the declarations we define a macro TypeInfoPtr which is either PTypeInfo (2.6.x) or PPTypeInfo (2.7.1 and newer)
  * TPropInfo: rename PropType to PropTypeRef and change type to TypeInfoPtr
  + TPropInfo: add a new property PropType which returns a PTypeInfo out of the PropTypeRef depending on the compiler version
........
Switch further simple types (sets, enums, class references, pointers) to indirect type information (again without breaking backwards compatibility).

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * enumdef_rtti, setdef_rtti, classrefdef_rtti & pointerdef_rtti: write an indirect RTTI reference

rtl/objpas/typinfo.pp, TTypeData:
  * rename BaseType to BaseTypeRef, CompType to CompTypeRef, InstanceType to InstanceTypeRef and RefType to RefTypeRef and change their type to TypeInfoPtr
  + add properties BaseType, CompType, InstanceType & RefType which return a PTypeInfo out of the corresponding *Ref field depending on the compiler version
........
Switch class and interface parent as well as extended type to indirect type information

compiler/ncgrtti.pas, TRTTIWriter:
  * write_rtti_data.objectdef_rtti.objectdef_rtti_class_full: use indirect reference for class parent and extended type
  * write_rtti_data.objectdef_rtti.objectdef_rtti_interface_full: use indirect reference for interface parent

rtl/objpas/typinfo.pp, TTypeData:
  + add new method DerefTypeInfoPtr which returns Nil if the indirect reference is Nil and otherwise returns the dereferences indirect reference (for 2.6.x the direct reference is returned as is)
  * rename ParentInfo to ParentInfoRef, HelperParent to HelperParentRef, ExtendedInfo to ExtendedInfoRef, IntfParent ot IntfParentRef and RawIntfParent to RawIntfParentRef and change their type to TypeInfoPtr
  + introduce ParentInfo, HelperParent, ExtendedInfo, IntfParent and RawIntfParent properties that return a PTypeInfo and use the new DerefTypeInfoPtr to return the correct type info value
  * change the other newly introduced properties of TTypeData to use DerefTypeInfoPtr as well to be on the safe side
........
Switch record/object fields to indirect type information references.

compiler/ncgrtti.pas, TRTTIWriter.fields_write_rtti_data:
  * use the indirect reference for the object parent type
  * use the indirect reference for the field type

rtl/inc/rtti.inc:
  * TRecordElement: change TypeInfo to PPointer for 2.7.1 and newer
  * RecordRTTI: correctly dereference the element type for 2.7.1 and newer
  * fpc_copy: correctly reference the element type for 2.7.1 and newer
........
Switch static arrays to indirect RTTI reference.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data:
  * arraydef_rtti: write the dimension types and the final field type as indirect references

rtl/inc/rtti.inc:
  * TArrayInfo: switch ElInfo to PPointer for 2.7.1+
  * ArrayRTTI & fpc_copy: correctly dereference ElInfo for 2.7.1+
rtl/objpas/typinfo.pp, TArrayTypeData:
  * switch ElType and Dims to PPTypeInfo; no backwards compatibility needed here as TArrayTypeData was added in 2.7.1 only

tests/test/trtti8.pp: fix test
........
Switch dynamic arrays to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.arraydef_rtti:
  * write indirect references for the two element entries

rtl/inc/dynarr.inc:
  * tdynarraytypedata: change elType2 to PPointer for 2.7.1+
  * fpc_dynarray_clear, fpc_dynarray_setlength & fpc_dynarray_copy: correctly dereference elType2 for 2.7.1+
rtl/objpas/typinfo.pp, TTypeData:
  * rename elType and elType2 to elTypeRef and elType2Ref respectively and change type to TypeInfoPtr
  * add properties elType and elType2 which return PTypeInfo by dereferencing elTypeRef and elType2Ref respecively correctly
  * remove a few stray "inline" directives in the implementation
........
Switch procedure parameters and result type to indirect RTTI references.

compiler/ncgrtti.pas, TRTTIWriter.write_rtti_data.procvardef_rtti:
  * write_procedure_param: use indirect RTTI reference
  * write result info for both methods and procvars as indirect RTTI reference
  * write parameters for procvars as indirect RTTI reference

rtl/objpas/typinfo.pp:
  * TProcedureParam: change type of ParamType to PPTypeInfo (no backwards compatiblity needed here; was added for 2.7.1)
  * TProcedureSignature: change type of RseultType to PPTypeInfo (no backwards compatibility needed here; was added for 2.7.1)
  * TTypeData: remark in the comments of tkMethod that ResultTypeRef and ParamTypeRefs are of type PPTypeInfo and not PTypeInfo

tests/test/trtti9.pp: 
  * fix test
........
Remove no longer needed "indirect" parameter for TRTTIWriter methods.

ncgrtti.pas, TRTTIWriter:
  - ref_rtti & write_rtti_reference: remove "indirect" parameter
  * ref_rtti: call rtti_mangledname with "indirect" always set to "true"
  - remove "true" parameter on callsites of write_rtti_reference & ref_rtti
........

git-svn-id: trunk@33944 -
2016-06-10 17:01:51 +00:00
marco
4733e50de5 * system unit additions from mantis #27206. Exports some dynarray related RTTI functions.
git-svn-id: trunk@29364 -
2015-01-01 00:21:40 +00:00
pierre
034c440d84 Fix big mistake in previous commit, packed must be disabled if FPC_REQUIRES_PROPER_AIGNMENT is set
git-svn-id: trunk@27614 -
2014-04-20 17:36:24 +00:00
pierre
8193aff81d Fix cycle starting for 2.6.4 release for powerpc64-linux
git-svn-id: trunk@27610 -
2014-04-20 16:28:52 +00:00
sergei
ae81e0889b * Updated internal declarations of RTTI structures to match their counterparts in typinfo unit and actual data generated by compiler. It went unnoticed this far because fields whose location differ with and without 'packed' record attribute are not used by internal routines, and tests use declarations from typinfo unit (the declarations in question are not in interface, so tests cannot be done against them).
This eliminates a lot of unaligned code on SPARC and ARM. 

git-svn-id: trunk@26845 -
2014-02-22 19:26:25 +00:00
paul
72fd58d62e rtl: fix possible division by zero
git-svn-id: trunk@24472 -
2013-05-08 06:00:44 +00:00
paul
fe04dedbab compiler: change RTTI size of record field offset from fixed 32bit to platform dependent integer (sizeint) since it is stored this way in the compiler. This is also Delphi compatible, rtl: adopt rtl appropriately
git-svn-id: trunk@24460 -
2013-05-07 11:25:41 +00:00
paul
dce960c97b compiler: write Delphi compatible tkArray RTTI:
- TotalSize of all array dimensions instead of first dimension size
  - Element type of last array dimension
  - dimension information
rtl:
  - adopt array initialization/finalization/copy for the new tkArray RTTI
  - add Delphi compatible TArrayTypeData member for typinfo.TTypeData structure
tests:
  - add a test which checks RTTI information for 2 dimension array

git-svn-id: trunk@24458 -
2013-05-07 09:12:18 +00:00
paul
d18f273f67 compier, rtl: revert 24424 since it fails on some platforms
git-svn-id: trunk@24425 -
2013-05-04 16:16:30 +00:00
paul
e23534eec4 compiler, rtl: some rtti related changes:
- write pint instead of 32 bit for record field offset (compiler uses aintsize = pint in TRecordDef), use PtrInt in RTL for record reading
  - add tkRecord to TTypeData (field and type names are taken from Delphi help)
  - add tkProcedure as alias to tkProcVar

git-svn-id: trunk@24424 -
2013-05-04 16:05:04 +00:00
sergei
27c626245b * Reuse RecordRTTI to finalize class instances. This is possible because RTTI for classes is the same as for records (except different value of tkKind field), and RecordRTTI ignores tkKind (assuming that required checks are done by its caller).
git-svn-id: trunk@23213 -
2012-12-23 12:10:11 +00:00
sergei
f136e44b6b - RTL: cleaned up remaining 'decr_ref' routines (not removed completely due to bootstrapping needs, but aliased to 'finalize' ones).
git-svn-id: trunk@20130 -
2012-01-20 19:19:08 +00:00
sergei
568ef396fb * Added fpc_dynarray_assign (a helper for dynamic array assignments), added local access to fpc_intf_assign, and switched fpc_copy to use assignment helpers instead of incr_ref/decr_ref combinations.
git-svn-id: trunk@20114 -
2012-01-19 17:43:37 +00:00
sergei
0d3fa2d2db - Cleaned out VER2_2 defines
git-svn-id: trunk@19479 -
2011-10-13 10:19:13 +00:00
sergei
c2ea372682 * Declared types describing RTTI data of arrays and records, and rewrote main RTTI routines using these types. Shorter by about 60 lines, functionality isn't changed.
git-svn-id: trunk@17141 -
2011-03-16 18:53:53 +00:00
sergei
1fcd40ee64 Continue fixing open array handling:
* Unified fpc_initialize_array,fpc_finalize_array with fpc_decref_array and fpc_addref_array by removing 'size' parameter from the former two. Element size is easily calculated from RTTI, so omitting it simplifies code generation. All four helpers are now callable by tcg.g_array_rtti_helper().
* ncgutil.pas: initialization of open array out-parameters is now done properly (using fpc_initialize_array).
+ Test

git-svn-id: trunk@17081 -
2011-03-05 18:45:44 +00:00
sergei
54bc8efa0b * Fixed reference counting of open array parameters passed by value. RTTI of the array itself is useless in this case, as it does not provide correct element count. Now using dedicated helpers which take RTTI of array element and the element count. Resolves #18859.
git-svn-id: trunk@17068 -
2011-03-03 18:38:46 +00:00
Jonas Maebe
749991ec02 + support extra parameter for initialize() that indicates how many elements
should be initialised, similar to how this was already allowed for
    finalize() (mantis #17998)

git-svn-id: trunk@16407 -
2010-11-23 15:14:40 +00:00
florian
e01e4e5719 * optimized copy(<dyn. array> ...) by checking if the elements are really ref. counted
git-svn-id: trunk@15228 -
2010-05-05 13:49:06 +00:00
marco
4104d9f481 * More pluggability of the RTL. Mantis 15124
git-svn-id: trunk@14212 -
2009-11-18 21:16:12 +00:00
yury
e82e4ae806 * Fixed WideString on wince. WideString=UnicodeString on wince. Bug #14304.
git-svn-id: trunk@13510 -
2009-08-10 11:32:08 +00:00
Jonas Maebe
f9b4d58e98 * set finalized dynarrays to nil (mantis #12048)
git-svn-id: trunk@11773 -
2008-09-13 20:01:47 +00:00
florian
b178b08ba7 Merged revisions 11665-11738 via svnmerge from
http://svn.freepascal.org/svn/fpc/branches/unicodestring

........
  r11665 | florian | 2008-08-30 13:30:17 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * continued to work on unicodestring type support
........
  r11666 | florian | 2008-08-30 19:02:26 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * expectloc for wide/ansi/unicode strings is LOC_CONSTANT or LOC_REGISTER now
........
  r11667 | florian | 2008-08-30 20:42:37 +0200 (Sat, 30 Aug 2008) | 1 line
  
  * more unicodestring stuff fixed, test results on win32 are already good
........
  r11670 | florian | 2008-08-30 23:21:48 +0200 (Sat, 30 Aug 2008) | 2 lines
  
  * first fixes for unix bootstrapping
........
  r11683 | ivost | 2008-09-01 12:46:39 +0200 (Mon, 01 Sep 2008) | 2 lines
  
      * fixed 64bit bug in iconvenc.pas
........
  r11689 | florian | 2008-09-01 23:12:34 +0200 (Mon, 01 Sep 2008) | 1 line
  
  * fixed several errors when building on unix
........
  r11694 | florian | 2008-09-03 20:32:43 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * fixed unix compilation
........
  r11695 | florian | 2008-09-03 21:01:04 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * bootstrapping fix
........
  r11696 | florian | 2008-09-03 21:07:18 +0200 (Wed, 03 Sep 2008) | 1 line
  
  * more bootstrapping fixed
........
  r11698 | florian | 2008-09-03 22:47:54 +0200 (Wed, 03 Sep 2008) | 1 line
  
  + two missing compiler procs exported
........
  r11701 | florian | 2008-09-04 16:42:34 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + lazarus project for the linux rtl
........
  r11702 | florian | 2008-09-04 16:43:27 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  + set unicode string procedures
........
  r11707 | florian | 2008-09-04 23:23:02 +0200 (Thu, 04 Sep 2008) | 2 lines
  
  * fixed several type casting stuff
........
  r11712 | florian | 2008-09-05 22:46:03 +0200 (Fri, 05 Sep 2008) | 1 line
  
  * fixed unicodestring compilation on windows after recent unix changes
........
  r11713 | florian | 2008-09-05 23:35:12 +0200 (Fri, 05 Sep 2008) | 1 line
  
  + UnicodeString support for Variants
........
  r11715 | florian | 2008-09-06 20:59:54 +0200 (Sat, 06 Sep 2008) | 1 line
  
  * patch by Martin Schreiber for UnicodeString streaming
........
  r11716 | florian | 2008-09-06 22:22:55 +0200 (Sat, 06 Sep 2008) | 2 lines
  
  * fixed test
........
  r11717 | florian | 2008-09-07 10:25:51 +0200 (Sun, 07 Sep 2008) | 1 line
  
  * fixed typo when converting tunicodestring to punicodechar
........
  r11718 | florian | 2008-09-07 11:29:52 +0200 (Sun, 07 Sep 2008) | 3 lines
  
  * fixed writing of UnicodeString properties
  * moved some helper routines to unicode headers
........
  r11734 | florian | 2008-09-09 22:38:55 +0200 (Tue, 09 Sep 2008) | 1 line
  
  * fixed bootstrapping
........
  r11735 | florian | 2008-09-10 11:25:28 +0200 (Wed, 10 Sep 2008) | 2 lines
  
  * first fixes for persisten unicodestrings
........
  r11736 | florian | 2008-09-10 14:31:00 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  Initialized merge tracking via "svnmerge" with revisions "1-11663" from 
  http://svn.freepascal.org/svn/fpc/trunk
........
  r11737 | florian | 2008-09-10 21:06:57 +0200 (Wed, 10 Sep 2008) | 3 lines
  
  * fixed unicodestring <-> variant handling
  * fixed unicodestring property reading
........

git-svn-id: trunk@11739 -
2008-09-10 20:14:31 +00:00
florian
f56b741948 * quicker finalization of dyn. arrays, thanks to the hint of Volker Zipfel
git-svn-id: trunk@11357 -
2008-07-10 16:44:45 +00:00
Jonas Maebe
dc71827e2e * procedure version of fpc_copy to avoid errors with {$x-} (mantis #9918)
git-svn-id: trunk@8790 -
2007-10-14 10:55:40 +00:00
florian
657ef819e0 * comment fixed
git-svn-id: trunk@7779 -
2007-06-23 09:16:21 +00:00
Jonas Maebe
d9284963b3 * fix for fpc_copy on 64 bit systems from Florian
git-svn-id: trunk@7713 -
2007-06-17 15:07:52 +00:00
florian
ea97b8b137 * fixed copying of remaining elements
git-svn-id: trunk@7699 -
2007-06-17 09:47:05 +00:00
florian
2c4aeefbf4 * fixed copying of automated records
git-svn-id: trunk@7696 -
2007-06-16 21:44:55 +00:00
florian
37bd49692e * proper fix for 8481 et. al.
git-svn-id: trunk@7691 -
2007-06-16 19:03:53 +00:00
yury
11576fd24b * fixed warnings and notes while compiling system unit for wince.
git-svn-id: trunk@4250 -
2006-07-18 15:00:09 +00:00
florian
7bff61ce29 * patch from Ales Katona to add a stack size parameter to tthread functions
git-svn-id: trunk@1621 -
2005-11-01 22:01:48 +00:00
michael
5cafc069b5 + Removed NOSAVEREGISTERS define
git-svn-id: trunk@307 -
2005-06-09 17:58:20 +00:00
michael
93ba0409be + Removed HASCOMPILERPROC define
git-svn-id: trunk@265 -
2005-06-07 21:41:02 +00:00
michael
21425e303c + Removed HASVARIANT define
git-svn-id: trunk@244 -
2005-06-07 20:48:31 +00:00
michael
8a226bba52 + Removed HASWIDESTRING/HASWIDECHAR defines
git-svn-id: trunk@241 -
2005-06-07 20:42:22 +00:00
michael
23ad0ae1ec + Removed HASINTF and VER1_0 defines
git-svn-id: trunk@239 -
2005-06-07 20:30:03 +00:00
peter
4ace790492 * remove $Log
git-svn-id: trunk@231 -
2005-06-07 09:47:55 +00:00
fpc
790a4fe2d3 * log and id tags removed
git-svn-id: trunk@42 -
2005-05-21 09:42:41 +00:00
fpc
50778076c3 initial import
git-svn-id: trunk@1 -
2005-05-16 18:37:41 +00:00
peter
e417e34496 * truncate log 2005-02-14 17:13:06 +00:00
florian
99ebd46010 * several variant init./final. stuff fixed 2005-01-15 18:47:26 +00:00
florian
bd211ce900 + init/cleaning code for variants added 2005-01-08 20:43:44 +00:00
florian
6c739fa996 * fixed rtti reading of arrays for 64 bit 2004-11-02 15:52:04 +00:00
peter
35e7518475 * rtti is always aligned, remove move() workarounds 2004-10-26 15:02:51 +00:00
peter
6214bb294b * record and array parsing moved to procedure and handle like
a data stream instead of using records
2004-10-24 21:39:42 +00:00
peter
fd759e521f * saveregisters calling convention is obsolete 2004-10-24 20:01:41 +00:00