Commit Graph

124 Commits

Author SHA1 Message Date
svenbarth
7023a6f95b * have the remaining 7 Boolean types also use tkBool as typekind instead of tkInteger
git-svn-id: trunk@35186 -
2016-12-23 16:05:14 +00:00
svenbarth
dbbb6dca32 * correctly treat Boolean64 as otUQword and QWordBool as otSQWord (the former having QWord range 0..1, the latter Low(Int64)..High(Int64))
git-svn-id: trunk@35185 -
2016-12-23 16:04:12 +00:00
svenbarth
26e7d005aa * use Low(LongInt) and Max(LongInt) as min/max values for the RTTI of the ByteBool, WordBool and LongBool types to be Delphi compatible; the range of the defs is not changed to avoid the application of range checks
git-svn-id: trunk@35184 -
2016-12-23 16:01:59 +00:00
Jonas Maebe
d8c4980b2e * don't reuse the same type with the typed const builder for
differently-sized types

git-svn-id: trunk@35153 -
2016-12-18 13:57:15 +00:00
Jonas Maebe
691c2d655e * put multiple statements of the else-part of case between begin..end
git-svn-id: trunk@35152 -
2016-12-18 13:57:12 +00:00
Jonas Maebe
fe6b662c37 * fixed range error
git-svn-id: trunk@35151 -
2016-12-18 13:57:09 +00:00
Jonas Maebe
bcb7fedb3c * fixed indentation
git-svn-id: trunk@35150 -
2016-12-18 13:57:06 +00:00
svenbarth
86207c9b55 - remove no longer valid {otNone} comment
git-svn-id: trunk@35136 -
2016-12-16 14:23:14 +00:00
svenbarth
a9d14fe30b * extend TOrdType by entries for 64-bit values
* have tkInt64 and tkQWord entries also contain the OrdType field (basically the compiler can now use the same function to generate them only with different type kinds)

+ added test

git-svn-id: trunk@35135 -
2016-12-16 14:22:04 +00:00
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
e580e22576 * extend ref_rtti() with the possibility to use a direct reference if really desired
git-svn-id: trunk@35127 -
2016-12-14 18:38:54 +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
Jonas Maebe
5efb32285a * fixed alignment for interface RTTI (patch by Alfred, mantis #30182)
git-svn-id: trunk@34695 -
2016-10-09 12:34:01 +00:00
Jonas Maebe
4c9903455e - don't apply const_align() to alignments passed to high level typed
constant builder, it will do so itself if necessary

git-svn-id: trunk@34632 -
2016-10-06 06:25:02 +00:00
nickysn
8672d25e9a * use tai_const.create_nil_dataptr instead of .create_pint(0) when writing the
leading nils in the enum rtti in lookup mode

git-svn-id: trunk@34626 -
2016-10-04 21:15:36 +00:00
nickysn
4dc35b0996 * use sizeint when writing the element size and count for the array rtti
git-svn-id: trunk@34624 -
2016-10-04 17:38:18 +00:00
Jonas Maebe
ae51adac18 * give names to the types of the fields of the enumdef rtti, so that we can
refer to these type names when writing the s2o and o2s arrays in the LLVM
    assembler writer (otherwise we have to write out the entire definition
    of those fields and their subtypes for every access, resulting in a 139MB
    cpubase.ll instead of a more reasonable 1.5MB one now)

git-svn-id: trunk@34386 -
2016-08-28 22:07:47 +00:00
svenbarth
f50671fe44 * reference the RTTI assembler symbols if they're queried from a different unit than the own they're declared in
git-svn-id: trunk@34347 -
2016-08-19 14:54:28 +00:00
svenbarth
50865158a4 Fix for Mantis #30410.
* ncgrtti.pas, TRTTIWriter.ref_rtti: don't require the indirect symbol as an external assembler symbol, but the direct one

git-svn-id: trunk@34221 -
2016-07-29 13:49:42 +00:00
svenbarth
f69b365b77 * declare various symbols as external assembler symbols: RTTI references, parent VMT, FPC_EMPTYMETHOD (all three only if it's used from a different unit), threadvar lists and symbols declared as "external"
git-svn-id: trunk@34176 -
2016-07-22 13:34:38 +00:00
svenbarth
bb72c1c4df * declare various assembler symbols (VMT, RTTI, threadvars) as public assembler symbols
* declare public function alias as public assembler symbols

git-svn-id: trunk@34175 -
2016-07-22 13:11:24 +00:00
Jonas Maebe
a0efde8167 * automatically generate necessary indirect symbols when a new assembler
symbol is defined
   o removed all places where AB_INDIRECT symbols were explicitly generated
   o only generate AB_INDIRECT symbols for AT_DATA on systems_indirect_var_imports
   o for some symbols an indirect symbol is always required (because they are
     dereferenced by code in RTL units) -> use new AT_DATA_FORCEINDIRECT type

git-svn-id: trunk@34165 -
2016-07-20 20:53:03 +00:00
Jonas Maebe
1cb8c0d00c * specify the def of assembler level symbols defined via
tasmdata.DefineAsmSymbol() and all routines that call it
   o will be used to automatically generate AB_INDIRECT sybols when
     necessary

git-svn-id: trunk@34164 -
2016-07-20 20:52:59 +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
140f5b5f94 Write indirect symbols for the RTTI (basically a merge of r28238, but using the typed constant builder and the new indirect asmbinds)
ncgrtti.pas, TRTTIWriter:
  * write_rtti & write_rtti_extrasyms: generate an indirect symbol for each of the RTTI symbols (they are not used yet, but soon will be)
  * write_rtti: reorder operations a bit: first free the tcb (we don't need it anymore), then write the indirect symbol and only then write any extra symbols that might be needed (this way the RTTI data and the indirect symbol will be next to each other)
  

git-svn-id: trunk@33447 -
2016-04-08 13:39:04 +00:00
florian
cb4773432b + hardfloat directive (arm only): use hard float calling conventions regardless of the abi, resolves #29715
git-svn-id: trunk@33196 -
2016-03-06 15:47:31 +00:00
svenbarth
8152d1185c Only write the IIDStr for Corba interfaces (it's completely redundant for COM ones)
ncgrtti.pas, TRTTIWriter.write_rtti_data.objectdef_rtti.objectdef_rtti_interface_full:
  * only set the ifHasStrGUID flag for Corba interfaces and if the IIDStr is not '' (which it is by default)
  * only write the IIDStr for Corba interfaces

git-svn-id: trunk@33105 -
2016-02-19 15:22:46 +00:00
Jonas Maebe
5aadb149ed * ensure the types of all elements emitted in all paths through
writeaccessproc() are the same, so the reuse of existing defs doesn't
    result in the generation of typecasts for llvm

git-svn-id: trunk@32903 -
2016-01-10 14:01:43 +00:00
Jonas Maebe
5201547043 * don't reuse defs when writing RTTI for stored properties, as their layout
depends on how exactly they are stored

git-svn-id: trunk@32757 -
2015-12-27 11:14:41 +00:00
Jonas Maebe
9258b5d76b + non-functional 128 bit integer types (inaccessible from Pascal), for use
in the LLVM high level code generator to implement overflow checking

git-svn-id: trunk@32735 -
2015-12-26 20:00:33 +00:00
Jonas Maebe
94a6ef3103 * use codeptruinttype/codeptrsinttype when emiting ordinal constants that
have the same size as voidcodepointertype

git-svn-id: trunk@32473 -
2015-11-22 11:49:43 +00:00
Jonas Maebe
c2caa6641c * free typedconstbuilder after generating rtti
git-svn-id: trunk@32201 -
2015-10-30 14:17:13 +00:00
Jonas Maebe
8c90941d89 * use the enymsym's name rather converting its symid to a string when creating
the rtti record's fields

git-svn-id: trunk@32150 -
2015-10-25 19:21:51 +00:00
svenbarth
3afc18f277 Fix for Mantis #28766.
ncgrtti.pas, write_persistent_type_info:
  * do not generate RTTI information for generics

git-svn-id: trunk@31911 -
2015-10-02 13:06:51 +00:00
yury
432248cbf1 * Removed lot of unused vars.
git-svn-id: trunk@31732 -
2015-09-17 12:48:58 +00:00
Jonas Maebe
be2ec5be59 * write full/init rtti and VMTs separately instead of at the same time
o this allows us to write the VMTs earlier (before the synthetic method
     implementations are generated), which means we can create new synthetic
     methods while generating the VMTs (for interface trampolines)

git-svn-id: trunk@31635 -
2015-09-12 23:32:38 +00:00
Jonas Maebe
4c0807c596 * simplified enum lookup table management by using tfplist instead of
an ad hoc dynamic array implementation

git-svn-id: trunk@31295 -
2015-08-06 18:34:31 +00:00
Jonas Maebe
d7f6744f7b * converted ncgrtti to the high level typed constant builder
o the result is still not very clean due to the fact that this data
     is almost completely unstructured due to variable-length strings
     everywhere, which means that
    a) we cannot just load recorddefs from the system or typeinfo unit
       and use those as templates
    b) we cannot easily reuse the recorddefs we create ourselves (except
       if the strings have the same length -- this is the reason for all
       of the names specified to begin_anonymous_record: to reuse defs
       as much as possible rather than creating new ones all the time)
    c) we have to add explicitly aligned subrecords everywhere to insert
       explicit alignment on platforms that need it

git-svn-id: trunk@31255 -
2015-07-30 16:58:17 +00:00
nickysn
d1ac1bf1e0 * fixed writing rtti published property getter/setter/stored proc info in the
i8086 far code/data memory models

git-svn-id: trunk@28726 -
2014-09-30 01:47:17 +00:00
nickysn
2e0707f465 * fixed writing of dynarray rtti in the i8086 far data memory models
git-svn-id: trunk@28707 -
2014-09-22 16:12:11 +00:00
sergei
7e1c370c17 * Write RTTI for function arguments as children of function RTTI, resolves #24540,#25002,#25128 (bugs are basically duplicate, so adding only first of them to the testsuite).
git-svn-id: trunk@27797 -
2014-05-16 20:09:32 +00:00
florian
4d5119bf1c * fixes several issues which cause warnings by the dfa code when using it to detect uninitialized variables
git-svn-id: trunk@26161 -
2013-12-01 17:02:08 +00:00
nickysn
088c06d308 * fixed class VMT generation for the i8086 medium memory model (near code, far data) by setting correctly the Tasmsymtype to each symbol according to whether it points to code or data
git-svn-id: trunk@25276 -
2013-08-18 00:03:55 +00:00
nickysn
875e676441 * use Create_nil_dataptr in objectdef_rtti_class_full() when writing the current vmt address for objects that have no vmt
git-svn-id: trunk@25200 -
2013-07-31 15:10:46 +00:00
nickysn
f7d3f7cd33 * use create_nil_dataptr instead of create_sym(nil) in TRTTIWriter.write_rtti_reference; among other things, this fixes writeln(enum) in the i8086 medium memory model
git-svn-id: trunk@24977 -
2013-06-25 21:02:55 +00:00
paul
5ff7bb884e compiler: don't skip objc class/protocols in case of initrtti, fixed crash of dynamic array/record which contains a objc class/protocol and requires an initialization
git-svn-id: trunk@24723 -
2013-06-01 14:45:10 +00:00
sergei
23cb216435 * RTTI fix for alignment-sensitive targets:
* typinfo.pp: the newly introduced records were added into {$PACKRECORDS 1} area of effect, which  effectively made all records packed, entirely defeating FPC_REQUIRES_PROPER_ALIGNMENT purpose. 
  * added alignment between TProcedureParam records, adjusted TProcedureSignature.GetParam() appropriately.
   * ncgrtti.pas: added two missing alignments and removed a redundant one.
   * tests/test/trtti9.pp: modified to use TProcedureSignature.GetParam() and endian-independent check for parameter flags.

git-svn-id: trunk@24562 -
2013-05-23 16:03:42 +00:00
paul
b333ef582b compiler: don't treat array[..] of dynamic array as a 2 dimension array
git-svn-id: trunk@24522 -
2013-05-17 01:08:27 +00:00
paul
980bc634b4 compiler:
- add write_rtti_reference method, 
  - minor refactoring, 
  - always write nil as RTTI reference for objc types and void types

git-svn-id: trunk@24471 -
2013-05-08 05:47:48 +00:00
paul
fceb6c3cc5 compiler: skip objc types in ProcVar rtti arguments and result type
git-svn-id: trunk@24470 -
2013-05-08 03:40:01 +00:00