Commit Graph

93 Commits

Author SHA1 Message Date
florian
449cc8f152 * make use of AllocMem in fpc_dynarray_setlength
git-svn-id: trunk@46900 -
2020-09-19 21:06:11 +00:00
svenbarth
15141124f4 * restore ability to cycle with 3.0.4 (at least until 3.2.2 is released) after r46890
git-svn-id: trunk@46895 -
2020-09-19 13:54:25 +00:00
svenbarth
d3e18ccb5e * fix for Mantis #37221: apply adjusted patch by Ondrej Pokorny to allow the use of Copy() on open array parameters (the result will be a dynamic array)
+ added test

git-svn-id: trunk@46890 -
2020-09-18 15:00:10 +00:00
florian
ed688aceee * remove packed from tdynarray, it is not needed and especially 64 bit CPUs which require proper aligment, suffer from it
git-svn-id: trunk@42920 -
2019-09-04 20:45:23 +00:00
florian
217ae6e4bb * more fixes to rtti after attribute branch merging
git-svn-id: trunk@42476 -
2019-07-21 08:28:29 +00:00
svenbarth
3ad24c9db8 * as attributes can be part of any type they are best suited in a common part of TTypeData
git-svn-id: trunk@42375 -
2019-07-12 22:06:09 +00:00
pierre
e4346b264f Add missing alignment in DynArrayIndex function
git-svn-id: trunk@39586 -
2018-08-07 16:34:57 +00:00
svenbarth
8536abce8a * as the management operator feature is not platform specific using a specific define for it aside from a
version check is unnecessary, thus remove the FPC_HAS_MANAGEMENT_OPERATOR define and instead check for VER3_0

git-svn-id: trunk@39257 -
2018-06-20 19:00:24 +00:00
svenbarth
8606293028 * assume that dynamic arrays with a negative reference count are immutable (at least regarding their metadata)
git-svn-id: trunk@39037 -
2018-05-20 11:50:06 +00:00
florian
c230f81719 + support for <dyn. array>+<dyn. array>, resolves #30463
git-svn-id: trunk@38406 -
2018-03-04 16:12:43 +00:00
svenbarth
c87cee09fd * use the type information *parameter* not the unitialized parameter
git-svn-id: trunk@38234 -
2018-02-13 19:26:21 +00:00
svenbarth
916ff0b92c + extend Concat() with support for dynamic arrays
+ added test

git-svn-id: trunk@37723 -
2017-12-12 19:54:08 +00:00
svenbarth
c45f738081 * fix DynArrayIndex(): as the last typeinfo entry is no longer a dynamic array the elSize needs to be remembered
git-svn-id: trunk@36942 -
2017-08-20 15:15:25 +00:00
svenbarth
8b5461367b * move TTypeKind from TypInfo unit to System unit as it's necessary for the future GetTypeKind() intrinsic
* also adjust (P)Byte usages to (P/T)TypeKind where necessary/approbiate

git-svn-id: trunk@36873 -
2017-08-11 20:37:36 +00:00
svenbarth
72c595eefe + implement support for Insert() for dynamic arrays; the parameter that is inserted can be a dynamic or static array of the same type, an array constructor or a single element of the arrays type; all that is determined based on the second type
+ added test

git-svn-id: trunk@36307 -
2017-05-23 19:11:49 +00:00
maciej-izak
0cff9fe83c * Call management operator (Initialize) for records when SetLength for dynamic arrays is used.
git-svn-id: trunk@35450 -
2017-02-19 12:47:31 +00:00
florian
0b82f71e8d * take care of the fact that there are 32 bit abis (e.g. ARMHF) which align qword on 8 byte boundaries, resolves issue #31132
git-svn-id: trunk@35218 -
2016-12-30 15:32:56 +00:00
florian
3faff7946d * fix typo for endif VER3_0_0, patch by Maciej Izak
git-svn-id: trunk@34999 -
2016-11-27 20:01:41 +00:00
svenbarth
f889891466 * fix Delete() for dynamic arrays
git-svn-id: trunk@34457 -
2016-09-08 17:42:50 +00:00
svenbarth
26a2ddd3d6 + extend Delete() intrinsics with Delphi compatible support for dynamic arrays. Also fixes Mantis #30306
git-svn-id: trunk@34455 -
2016-09-08 17:15:10 +00:00
pierre
97c2067832 Fix compiler cycling starting from 3.0.0 powerpc64 release compiler
git-svn-id: trunk@34431 -
2016-09-05 09:36:43 +00:00
svenbarth
d9d2789375 * fix DynArrayDim() and DynArrayIndex() after the RTTI changes in r33944
git-svn-id: trunk@34180 -
2016-07-22 13:48:12 +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
svenbarth
e15816e35b Fix for Mantis #30110. Speed up finalization of array of primitive/simple records (aka records not containing managed types).
rtl/inc/dynarr.inc:
  + add elType field to tdynarraytypedata (this tells us whether a finalization is needed)
  * fpc_dynarray_clear: don't finalize the array elements if elType is Nil
  * fpc_dynarray_setlength: only call int_addref() and int_finalizearray() if elType is set
  * fpc_dynarray_copy: don't check for tkManagedTypes, but instead check whether elType is assigned

git-svn-id: trunk@33719 -
2016-05-20 16:04:14 +00:00
florian
a7f1ce2e98 * patch by Dmitry Boyarintsev: initialize dyn. arrays more cleverly in a setlength call with ref. count>1, resolves issue #29250
git-svn-id: trunk@32721 -
2015-12-26 08:53:56 +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
nickysn
a10c200090 * tdynarraytypedata.elSize changed from PtrUInt to SizeUInt; this fixes e.g.
setlength on dynarrays in the i8086 far data memory models

git-svn-id: trunk@28710 -
2014-09-22 20:18:07 +00:00
sergei
f42c1b3720 * Return dynamic arrays in parameter, this was the only managed type still returned in register. Returning managed types in registers requires catching and re-raising exceptions at callee side in order to finalize result and avoid memory leaks. While such behavior makes little difference with generic setjmp-based exception handling, it becomes very inefficient as SEH-styled exception handling is being introduced.
The new behavior is also Delphi-compatible.

git-svn-id: trunk@26180 -
2013-12-04 13:43:22 +00:00
pierre
a311c53167 Replace HandleErrorFrame calls by HandleErrorAddrFrameInd where possible in common code (to allow correct backtrace for mips cpu)
git-svn-id: trunk@21900 -
2012-07-12 11:53:59 +00:00
sergei
92f927976e * Rewrote fpc_dynarray_copy to trim out-of-range arguments instead of raising range error. Makes behavior Delphi-compatible and resolves #21396.
* Changed copying the entire array to use range 0..high(sizeint) instead of -1..-2.

git-svn-id: trunk@20468 -
2012-03-04 04:41:52 +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
a8fe9601de * Get rid of using pdynarraytypeinfo, instead treat rtti as distinct 'header' and 'data' parts. In variants unit, use rtti declarations from typinfo directly. In system unit, declare private tdynarraytypedata record which (like typinfo.TTypeData) is not packed on alignment-sensitive targets. This simplifies code and removes scary pointer manipulations, should also yield better code on aligned targets.
git-svn-id: trunk@20106 -
2012-01-18 19:28:08 +00:00
sergei
5658c30328 * Partially reverted r20041 to prevent IE200606085 on ARM platforms.
It appears that a function which is present in interface part and aliased to another function using "external name 'foo'" directive cannot be placed immediately before the function to which it is aliased. The body of first function consists of a single jump which fails to be correctly relocated.

git-svn-id: trunk@20053 -
2012-01-11 18:22:43 +00:00
sergei
40f29ffd7a * Generate direct order of indexes passed to fpc_dynarray_setlength at compile time, eliminates the need of reversing them at runtime (in DynArraySetLength).
* 'dimcount' parameter is now of type sizeint everywhere (was dword in fpc_dynarray_setlength and  longint generated by compiler).
Since multi-dimensional dynarrays are not used in compiler code, this change does not break cycling.

git-svn-id: trunk@20041 -
2012-01-10 18:58:20 +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
mazen
b127fc154a * Fixed spell error revealed by lintian.
git-svn-id: trunk@16094 -
2010-10-06 20:33:57 +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
Jonas Maebe
65f217ed02 * only set dynarray pointer to nil in decref in case the last reference
has been destroyed (mantis #12000)

git-svn-id: trunk@11672 -
2008-08-31 10:07:53 +00:00
peter
923aac0390 * give range error if setlength value < 0 and the array is not filled
git-svn-id: trunk@9758 -
2008-01-14 18:05:48 +00:00
florian
fd2032dab2 + start of embedded rtl
+ feature support in the compiler

git-svn-id: trunk@5628 -
2006-12-17 18:40:36 +00:00
micha
d704af7216 fix compilation for {$T+} linux/win
git-svn-id: trunk@4794 -
2006-10-04 20:43:55 +00:00
peter
16f121a8bc * reuse generic align()
git-svn-id: trunk@4382 -
2006-08-07 07:03:25 +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
tom_at_work
9d7ac02696 * fixed tb0488 on unix platforms (missing cwstring uses)
* 64bit big-endian fix of dynamic array handling
* added qword support for %x format specifier of format() functions

git-svn-id: trunk@1773 -
2005-11-16 20:50:38 +00:00
florian
8b3c634573 * fixed DynArraySetLength
git-svn-id: trunk@1678 -
2005-11-06 17:16:55 +00:00
florian
c5f82ba6de + (ole)variant<->error type conversion
+ DynArraySetLength
+ DynArrayFromVariant

git-svn-id: trunk@1608 -
2005-10-30 23:12:08 +00:00
florian
8dd52941d5 * tdynarraytypeinfo moved to interface
* made aligntoptr inlined

git-svn-id: trunk@630 -
2005-07-15 21:09:45 +00:00
michael
198b2104be + Removed HASFUNCTIONCOPYDYNARR define
git-svn-id: trunk@313 -
2005-06-09 18:06:35 +00:00
michael
5cafc069b5 + Removed NOSAVEREGISTERS define
git-svn-id: trunk@307 -
2005-06-09 17:58:20 +00:00