* Change InternalTinyAlign procedure:
Change variable ASize to be VAR parameter type
so that possible size reduction required by alignment
is propagated correctly to calling function.
git-svn-id: trunk@36297 -
be used (TBD in a future commit) for optimizing x:=-x and x:=not x on CPUs
that support performing these operations directly in memory (such as x86)
git-svn-id: trunk@35749 -
op=and/or/xor). They generate more optimal code on certain architectures
(including x86). The new inline nodes aren't generated by the compiler yet,
but will be used in the future, at certain optimization levels, whenever the
pattern x:=x op y is detected by the compiler.
git-svn-id: trunk@35666 -
* fpc_Initialize: Initialize operator is called after recordrtti(data,typeinfo,@int_initialize);
* fpc_Finalize: Finalize operator is called before recordrtti(data,typeinfo,@int_finalize);
* fpc_Addref: AddRef operator is called after recordrtti(data,typeinfo,@int_addref);
* fpc_Copy: Copy operator (if exists) is called instead of default copy behavior
* replace RTTIRecordRttiInfoToInitInfo function (which was introduced only to speed-up InitializeArray/FinalizeArray) with a more advanced RTTIRecordOp function. Result of RTTIRecordRttiInfoToInitInfo is now returned in initrtti parameter. Additionally as new result is returned PRecordInfoInit which is usefully in basic RTL functions: fpc_Initialize, fpc_Finalize, fpc_Addref, fpc_Copy
git-svn-id: trunk@35446 -
compiler/ncgrtti.pas
+ write_record_operators procedure which fills simple VMT like table for MO.
* recorddef_rtti save MO (if exists)
* objectdef_rtti_fields save nil pointer/entry for objects rtti (have same RTL parts like for records)
compiler/options.pas
+ new define FPC_HAS_MANAGEMENT_OPERATORS
compiler/symconst.pas
+ new item itp_init_record_operators for tinternaltypeprefix enum
+ new entry '$init_record_operators$' in internaltypeprefixName
rtl/inc/rtti.inc
+ new field RecordOp (pointer to MO VMT table) in TRecordInfoInit
+ new types to handle MO VMT: TRTTIRecordOpVMT, PRTTIRecordOpVMT, TRTTIRecCopyOp, TRTTIRecVarOp
rtl/objpas/typinfo.pp
+ RecordOp field for TRecInitData record
git-svn-id: trunk@35445 -
- 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 -
top of the IOffset: SizeUInt field, because it is sometimes used as a
CodePointer (for etStaticMethodResult and etStaticMethodClass) and sometimes
as a SizeInt and these two types can be of different size in certain i8086
memory models
git-svn-id: trunk@34645 -
* Correct computation of CRC for if add_tail is true:
tail is before extra_info, not after.
Use tail_size variable to cacluate CRC use the whole tail memory area.
+ New function released_modified. Checks if released memory
was modified after it release (used if keep_released is true).
* TraceGetMem,TraceFreeMem TraceReallocMem: adapt to new tail_size variable.
* TraceInit: Store previous memory manager in local variable,
to be able to restore it in TracExit call.
* LoadEnvironment: Add parsing of tail_size=XXX, where XXX is a decimal value,
rounded up to next multiple of sizeof(ptruint).
git-svn-id: trunk@34385 -
The problem was in the source of random related functions,
which are used in this test by several thread in parallel,
while this code is known and advertised as non-thread safe.
The access by multiple threads led to multiple increments of the
mt_index static variable, which was then never reset to zero and
led to all successive calls to random function to return zero.
This fix simply insures that the mt_state array is never
accessed past its end, and that mt_index is reset correctly even
if multiple increments do happen.
It does not make the random function thread-safe.
* Use local variable l_index to avoid accessing mt_state array past last element.
* Change mt_index=MTWIST_N+1 into l_index>=MTWIST_N+1
to insure that mt_init will be called again if index is past end.
git-svn-id: trunk@34320 -
+ AllocateSig and ReleaseSig for theap_mem_info.sig field.
+ CheckSig for theap_extra_info.check field.
+ CRC32Seed and CRC32Pattern in CRC related functions.
* if sig is equal ReleaseSig, always assume already released (even if usecrc ius true).
git-svn-id: trunk@34260 -
Previously we had the following approach:
- classes that implemented interfaces had an interface table
- classes that didn't implement an interface, but inherited from a class that did had a Nil entry
- classes that didn't implement any interface (including their parents) had a reference to FPC_EMPTYINTF (this was to optimize lookups)
Now the approach is as follows:
- classes that implement an interface or have a parent that implements an interface have an interface table; if the class itself doesn't implement an interface then the count will be 0
- classes that don't implement an interface at all (neither them nor their parents) have a Nil interface table
This way FPC_EMPTYINTF can be removed without sacrificing at least the optimization for classes without any interface. For classes that have parents with interfaces there will be a small speed penalty due to an additional lookup for the counter.
git-svn-id: trunk@34087 -
compiler/ngenutil.pas, tnodeutils:
* InsertThreadvarTablesTable: reference a unit's (and the program's) threadvar table using a indirect symbol
* InsertThreadvars: generate an indirect symbol for the threadvar table
rtl/inc/threadvr.inc:
* TltvInitTablesTable: add an additional indirection for the tables field
git-svn-id: trunk@34043 -
- MSDOS heap in tinyheap.inc modified to use usual
SysGetMem and similar names.
- Use HAS_MEMORYMANAGER (used previously in wince source code,
to specify that a memory manager is defined elsewhere than inside
heap.inc include file.
- Use
- Remove TinyHeapMemoryManager Structure variable completely
heaptrc.pp: remove unneeded macro code after name changes of tinyheap.inc
msdos/system.pp now only defines HAS_MEMORYMANAGER macro
win16/system.pp defines HAS_MEMORYMANAGER and FPC_NO_DEFAULT_HEAP
as it still uses a different memory manager.
__stkbottom variable added for win16 system.pp as it is required
by i8086 specific stack check code.
git-svn-id: trunk@33983 -
rtl/inc/system.inc:
+ ResHeader variable that provides the public _FPC_ResLocation symbol used by intres.inc; this variable will always be available and without indirect entry information it will simply hook up to FPC_RESLOCATION itself
* SetupEntryInformation: setup FPCResLocation
rtl/inc/intres.inc:
* no need to cater for indirect entry or not anymore
git-svn-id: trunk@33964 -
Adjust non-Windows resources to work with indirect main information as well.
rtl/inc/systemh.inc, TEntryInformation:
+ new cross platform field ResLocation which stores the pointer to the resources
rtl/inc/intres.inc:
* change the type of ResHeader from PResHdr to PPResHdr (and adjust code that uses it accordingly; Note: the first dereferencing is assumed to be always valid!)
* adjust declaration of ResHeader depending on whether indirect main information is used or not
rtl/darwin/sysinit.pas & rtl/linux/si_impl.inc:
* pass the location of the resources through SysInitEntryInformation
rtl/bsd/system.pp & rtl/linux/system.pp:
+ new public variable FPCResLocation which is setup by SysEntry
rtl/win32/sysinit.inc:
* initialize ResLocation of SysInitEntryInformation as Nil
rtl/win32/system.pp:
* initialize ResLocation of EntryInformation as Nil
........
For systems that support both internal and external resources (in this case only Darwin ones) we need to generate the FPC_RESLOCATION symbol always, because the SysInit unit is resource type agnostic.
ngenutil.pas, tnodeutils:
* InsertResourceInfo: generate FPC_RESLOCATION symbol pointing to 0 in case the program is compiled on Darwin with resources set to external ones (-We)
git-svn-id: trunk@33952 -
Switch Mac OS X to indirect entry information.
compiler/systems/t_bsd.pas, TLinkerBSD:
+ implement InitSysInitUnitName
compiler/system.pas:
* systems_internal_sysinit: add Darwin systems
compiler/hlcgobj.pas, thlcgobj:
* gen_proc_symbol_end: for Darwin systems don't directly call PascalMain for libraries, but FPC_LIBMAIN instead
rtl/darwin:
+ add sysinit.pas unit which contains the executable and library entry points for Darwin
rtl/darwin/Makefile.fpc:
* add sysinit unit
rtl/bsd/sysosh.inc:
+ add a Darwin specific TPlatformEntryInformation (could probably be used for all Unix systems...)
rtl/bsd/system.pp:
* define FPC_HAS_INDIRECT_MAIN_INFORMATION for Darwin systems once we're no longer bootstrapping with 2.6.x
+ add EntryInformation variable (this could maybe moved to system.inc...)
+ add new procedure SysEntry that is called from the entrypoint and which sets up necessary information required by other parts of the RTL
* the old FPC_SYSTEMMAIN is still in place for bootstrapping
rtl/inc/systemh.inc, TEntryInformation:
* PascalMain is cdecl on non-Windows systems (ToDo: really?)
rtl/inc/system.inc:
* initialstklen is provided by the indirect entry information, so no external here
........
Fix bootstrapping.
rtl/darwin/sysinit.pas:
* enable the code only when no longer bootstrapping with 2.6.x
........
Fix bootstrapping.
rtl/objpas/objpas.pp:
* define FPC_HAS_INDIRECT_MAIN_INFORMATION for Darwin only while not bootstrapping with 2.6.x
........
rtl/darwin/sysinit.pas:
* reference PASCALMAIN correctly (I wonder how this even worked previously :/ )
git-svn-id: trunk@33949 -
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 -
+ add constants for the Delete and Insert intrinsics
compproc.inc:
* use the new constants instead of magic values to denote the relationship of the compilerprocs to the intrinsics
git-svn-id: trunk@33901 -
Since overloading compilerprocs does not work each procedure got its own unique name, but they are using the new compilerproc extension to map them to the Insert and Delete symbol so that error messages can be shown with the respective name for the procedure declarations instead of fpc_shortstr_delete for example.
git-svn-id: trunk@33895 -
pasbool8type for this results in too much trouble (we mustn't use i1
for parameters, because then LLVM will try to apply the ABI convention
for passing "1 bit" values, or in records because then this may
result in unwanted bitpacking). Downside: the new LLVMBool1 type is
also exposed in the system unit, because we need it to define LLVM
intrinsics...
git-svn-id: trunk@33726 -
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 -
rtl/inc/systemh.inc & rtl/java/jsystemh_types.inc:
- TEntryInformation: remove WideInitTables
rtl/win/sysosh.inc:
+ TEntyrInformationOS: add WideInitTables
rtl/win/syswin.inc:
* adjust WStrInitTablesTable, so that it is now a pointer and can be used both with direct and indirect main entry
* InitWin32Widestrings: WStrInitTablesTable is now a pointer
rtl/win32/sysinit.inc:
* WideInitTables has moved to the OS specific part of the entry information
rtl/win32/system.pp:
* OsSetupEntryinformation: setup WStrInitTablesTable
git-svn-id: trunk@33571 -
especially when exeinfo unit is implicitly loaded when -gl compilation option
is used.
+ LocalError, new ExitProc procedure, used to catch any error that could happen
inside GetExeInMemoryBaseAddr procedure.
* Use SetJmp/LongJmp instead of Try/except in GetExeInMemoryBaseAddr function,
together with local change and restoration of ExitProc.
git-svn-id: trunk@33561 -
routine gets called multiple times with the same buffer as parameter and
then updates it (fixes errors when compiled with -gt)
git-svn-id: trunk@33203 -
o removed utf8string overload
o always ignore any code page information from the input, and interpret the
contents of the input directly as utf8-encoded bytes
* made utf8tostring() compatible with the JVM backend (mantis #29497)
git-svn-id: trunk@33159 -
rtl/inc/system.inc:
* SetupEntryInformation: call new, optional function OSSetupEntryInformation to handle platform specific entry information initialization
rtl/win/sysosh.inc, TEntryInformationOS:
+ new field TlsKeyAddr which will hold the address to the main binary's TlsKey variable
win32/sysinit.inc:
+ provide the variable holding the TlsKey and pass that on to the entry information record
win32/system.pp:
+ new OS specific entry information initialization (currently only the TlsKey)
win/systhrd.inc:
* declare TlsKey as a pointer to a DWord value instead of a DWord; on non-indirect entry platforms this is initialized with the address of new variable TlsKeyVar, on indirect entry platforms it will be initialized by the entry information initialization
* adjust usages of TlsKey from DWord to PDWord
win/systlsdir.inc:
* TlsKey is now a PDWord and (in sysinit) points to TlsKeyVar
win/syswin.inc:
* adjust TlsKey usage
inc/heaptrc.pp:
* TlsKey is now a PDWord, thus adjust the import and the usage
git-svn-id: trunk@33091 -
rtl/inc/system.inc:
* provide a public alias for SetupEntryInformation so that it can be used in SysInit as well without globally exporting it
rtl/win/systlsdir.inc:
* Exec_tls_callback: call SetupEntryInformation before initalizing the heap and multithreading so that the threadvar tables can be referenced correctly
git-svn-id: trunk@33035 -
rtl/inc/system.inc:
+ new variables that hold pointers to the tables
+ new procedure SetupEntryInformation() that should be used in the entry points of indirect entry targets to setup cross target fields
+ for direct entry targets the two resource string tables are imported here and supplied as initialization to the table pointers
objpas/objpas.pp:
* adjust table declarations so that the pointers provided from the System unit are used
* adjust usages of the tables as they are now pointers
win32/system.pp:
* Exe_Entry: use SetupEntryInformation()
win/syswin.inc:
* Dll_Entry: use SetupEntryInformation()
git-svn-id: trunk@33028 -
rtl/inc/systemh.inc:
+ TEntryInformation: add Pointer fields ResourceStringTables, ResStrInitTables, WideInitTables (for targets with separate WideString type) and ResLocation (not used on Windows, but since most other targets don't have Windows' resource system it's not part of OS)
rtl/java/jsystemh_types.inc:
+ TEntryInformation: adjust for consistency reasons
rtl/win32/sysinit.inc:
* SysInitEntryInformation: initialize with pointers to the correct tables
git-svn-id: trunk@33027 -
+ add (uninitialized) global variable EntryInformation for systems that use indirect main information
win32/system.pp:
- remove initialized EntryInformation and instead rely on the one passed by the sysinit* units
git-svn-id: trunk@33026 -
rtl/inc/systemh.inc:
+ add field OS of type TEntryInformationOS if the target specifies HAS_ENTRYINFORMATION_OS
rtl/java/jsystemh_types.inc:
+ same adjustments as above for consistency reasons despite it being not used there anyway
git-svn-id: trunk@33024 -
so that we can still find the type definitions in it once we don't store
the entire implementation symtable to the ppu anymore
git-svn-id: trunk@32151 -
* Obtain a real processaddress for ELF images by OpenExeFile() instead of hard-coded 0.
* It fixes line info information for Position Independent Executables (PIE).
git-svn-id: trunk@32052 -
- removed the envp variable from the msdos system unit, because it's not
compatible with ppchar in all memory models (we use ppfarchar to avoid copying
the environment in the program's data segment in near data memory models)
git-svn-id: trunk@32017 -