mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-11 15:29:43 +01:00
* also save/restore the size of the padding of record/objectsymtables
* when creating a child class, ignore the padding added to the parent
in case of objcclasses (gcc/clang also do that; maybe the same
has to be done for cppclass as well)
-> objcclass layouts seem to finally completely match the gcc ones
git-svn-id: trunk@18119 -
This commit is contained in:
parent
1c11f6c8b7
commit
0398ff6bf5
@ -43,7 +43,7 @@ type
|
|||||||
{$endif Test_Double_checksum}
|
{$endif Test_Double_checksum}
|
||||||
|
|
||||||
const
|
const
|
||||||
CurrentPPUVersion = 132;
|
CurrentPPUVersion = 133;
|
||||||
|
|
||||||
{ buffer sizes }
|
{ buffer sizes }
|
||||||
maxentrysize = 1024;
|
maxentrysize = 1024;
|
||||||
|
|||||||
@ -3002,6 +3002,7 @@ implementation
|
|||||||
trecordsymtable(symtable).padalignment:=shortint(ppufile.getbyte);
|
trecordsymtable(symtable).padalignment:=shortint(ppufile.getbyte);
|
||||||
trecordsymtable(symtable).usefieldalignment:=shortint(ppufile.getbyte);
|
trecordsymtable(symtable).usefieldalignment:=shortint(ppufile.getbyte);
|
||||||
trecordsymtable(symtable).datasize:=ppufile.getasizeint;
|
trecordsymtable(symtable).datasize:=ppufile.getasizeint;
|
||||||
|
trecordsymtable(symtable).paddingsize:=ppufile.getword;
|
||||||
trecordsymtable(symtable).ppuload(ppufile);
|
trecordsymtable(symtable).ppuload(ppufile);
|
||||||
{ requires usefieldalignment to be set }
|
{ requires usefieldalignment to be set }
|
||||||
symtable.defowner:=self;
|
symtable.defowner:=self;
|
||||||
@ -3087,6 +3088,7 @@ implementation
|
|||||||
ppufile.putbyte(byte(trecordsymtable(symtable).padalignment));
|
ppufile.putbyte(byte(trecordsymtable(symtable).padalignment));
|
||||||
ppufile.putbyte(byte(trecordsymtable(symtable).usefieldalignment));
|
ppufile.putbyte(byte(trecordsymtable(symtable).usefieldalignment));
|
||||||
ppufile.putasizeint(trecordsymtable(symtable).datasize);
|
ppufile.putasizeint(trecordsymtable(symtable).datasize);
|
||||||
|
ppufile.putword(trecordsymtable(symtable).paddingsize);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ppufile.writeentry(ibrecorddef);
|
ppufile.writeentry(ibrecorddef);
|
||||||
@ -4385,6 +4387,7 @@ implementation
|
|||||||
stringdispose(import_lib);
|
stringdispose(import_lib);
|
||||||
symtable:=tObjectSymtable.create(self,objrealname^,0);
|
symtable:=tObjectSymtable.create(self,objrealname^,0);
|
||||||
tObjectSymtable(symtable).datasize:=ppufile.getasizeint;
|
tObjectSymtable(symtable).datasize:=ppufile.getasizeint;
|
||||||
|
tObjectSymtable(symtable).paddingsize:=ppufile.getword;
|
||||||
tObjectSymtable(symtable).fieldalignment:=shortint(ppufile.getbyte);
|
tObjectSymtable(symtable).fieldalignment:=shortint(ppufile.getbyte);
|
||||||
tObjectSymtable(symtable).recordalignment:=shortint(ppufile.getbyte);
|
tObjectSymtable(symtable).recordalignment:=shortint(ppufile.getbyte);
|
||||||
vmt_offset:=ppufile.getlongint;
|
vmt_offset:=ppufile.getlongint;
|
||||||
@ -4555,6 +4558,7 @@ implementation
|
|||||||
else
|
else
|
||||||
ppufile.putstring('');
|
ppufile.putstring('');
|
||||||
ppufile.putasizeint(tObjectSymtable(symtable).datasize);
|
ppufile.putasizeint(tObjectSymtable(symtable).datasize);
|
||||||
|
ppufile.putword(tObjectSymtable(symtable).paddingsize);
|
||||||
ppufile.putbyte(byte(tObjectSymtable(symtable).fieldalignment));
|
ppufile.putbyte(byte(tObjectSymtable(symtable).fieldalignment));
|
||||||
ppufile.putbyte(byte(tObjectSymtable(symtable).recordalignment));
|
ppufile.putbyte(byte(tObjectSymtable(symtable).recordalignment));
|
||||||
ppufile.putlongint(vmt_offset);
|
ppufile.putlongint(vmt_offset);
|
||||||
@ -4804,6 +4808,10 @@ implementation
|
|||||||
if (tObjectSymtable(c.symtable).usefieldalignment=C_alignment) and
|
if (tObjectSymtable(c.symtable).usefieldalignment=C_alignment) and
|
||||||
(tObjectSymtable(symtable).usefieldalignment=C_alignment) then
|
(tObjectSymtable(symtable).usefieldalignment=C_alignment) then
|
||||||
tObjectSymtable(symtable).fieldalignment:=tObjectSymtable(c.symtable).fieldalignment;
|
tObjectSymtable(symtable).fieldalignment:=tObjectSymtable(c.symtable).fieldalignment;
|
||||||
|
{ the padding is not inherited for Objective-C classes (maybe not
|
||||||
|
for cppclass either?) }
|
||||||
|
if objecttype=odt_objcclass then
|
||||||
|
tObjectSymtable(symtable).datasize:=tObjectSymtable(symtable).datasize-tObjectSymtable(c.symtable).paddingsize;
|
||||||
if (oo_has_vmt in objectoptions) and
|
if (oo_has_vmt in objectoptions) and
|
||||||
(oo_has_vmt in c.objectoptions) then
|
(oo_has_vmt in c.objectoptions) then
|
||||||
tObjectSymtable(symtable).datasize:=tObjectSymtable(symtable).datasize-sizeof(pint);
|
tObjectSymtable(symtable).datasize:=tObjectSymtable(symtable).datasize-sizeof(pint);
|
||||||
|
|||||||
@ -92,14 +92,18 @@ interface
|
|||||||
function has_single_field(out sym:tfieldvarsym): boolean;
|
function has_single_field(out sym:tfieldvarsym): boolean;
|
||||||
function get_unit_symtable: tsymtable;
|
function get_unit_symtable: tsymtable;
|
||||||
protected
|
protected
|
||||||
_datasize : asizeint;
|
{ size in bytes including padding }
|
||||||
|
_datasize : asizeint;
|
||||||
{ size in bits of the data in case of bitpacked record. Only important during construction, }
|
{ size in bits of the data in case of bitpacked record. Only important during construction, }
|
||||||
{ no need to save in/restore from ppu file. datasize is always (databitsize+7) div 8. }
|
{ no need to save in/restore from ppu file. datasize is always (databitsize+7) div 8. }
|
||||||
databitsize : asizeint;
|
databitsize : asizeint;
|
||||||
|
{ size in bytes of padding }
|
||||||
|
_paddingsize : word;
|
||||||
procedure setdatasize(val: asizeint);
|
procedure setdatasize(val: asizeint);
|
||||||
public
|
public
|
||||||
function iscurrentunit: boolean; override;
|
function iscurrentunit: boolean; override;
|
||||||
property datasize : asizeint read _datasize write setdatasize;
|
property datasize : asizeint read _datasize write setdatasize;
|
||||||
|
property paddingsize: word read _paddingsize write _paddingsize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
trecordsymtable = class(tabstractrecordsymtable)
|
trecordsymtable = class(tabstractrecordsymtable)
|
||||||
@ -1021,6 +1025,8 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
procedure tabstractrecordsymtable.addalignmentpadding;
|
procedure tabstractrecordsymtable.addalignmentpadding;
|
||||||
|
var
|
||||||
|
padded_datasize: asizeint;
|
||||||
begin
|
begin
|
||||||
{ make the record size aligned correctly so it can be
|
{ make the record size aligned correctly so it can be
|
||||||
used as elements in an array. For C records we
|
used as elements in an array. For C records we
|
||||||
@ -1043,7 +1049,9 @@ implementation
|
|||||||
else
|
else
|
||||||
padalignment:=min(recordalignment,usefieldalignment);
|
padalignment:=min(recordalignment,usefieldalignment);
|
||||||
end;
|
end;
|
||||||
_datasize:=align(_datasize,padalignment);
|
padded_datasize:=align(_datasize,padalignment);
|
||||||
|
_paddingsize:=padded_datasize-_datasize;
|
||||||
|
_datasize:=padded_datasize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1975,11 +1975,12 @@ begin
|
|||||||
writeln(space,' Name of Record : ',getstring);
|
writeln(space,' Name of Record : ',getstring);
|
||||||
write (space,' Options : ');
|
write (space,' Options : ');
|
||||||
readobjectdefoptions;
|
readobjectdefoptions;
|
||||||
writeln(space,' FieldAlign : ',getbyte);
|
writeln(space,' FieldAlign : ',shortint(getbyte));
|
||||||
writeln(space,' RecordAlign : ',getbyte);
|
writeln(space,' RecordAlign : ',shortint(getbyte));
|
||||||
writeln(space,' PadAlign : ',getbyte);
|
writeln(space,' PadAlign : ',shortint(getbyte));
|
||||||
writeln(space,'UseFieldAlignment : ',getbyte);
|
writeln(space,'UseFieldAlignment : ',shortint(getbyte));
|
||||||
writeln(space,' DataSize : ',getaint);
|
writeln(space,' DataSize : ',getasizeint);
|
||||||
|
writeln(space,' PaddingSize : ',getword);
|
||||||
if not EndOfEntry then
|
if not EndOfEntry then
|
||||||
HasMoreInfos;
|
HasMoreInfos;
|
||||||
{read the record definitions and symbols}
|
{read the record definitions and symbols}
|
||||||
@ -2013,9 +2014,10 @@ begin
|
|||||||
end;
|
end;
|
||||||
writeln(space,' External name : ',getstring);
|
writeln(space,' External name : ',getstring);
|
||||||
writeln(space,' Import lib : ',getstring);
|
writeln(space,' Import lib : ',getstring);
|
||||||
writeln(space,' DataSize : ',getaint);
|
writeln(space,' DataSize : ',getasizeint);
|
||||||
writeln(space,' FieldAlign : ',getbyte);
|
writeln(space,' PaddingSize : ',getword);
|
||||||
writeln(space,' RecordAlign : ',getbyte);
|
writeln(space,' FieldAlign : ',shortint(getbyte));
|
||||||
|
writeln(space,' RecordAlign : ',shortint(getbyte));
|
||||||
writeln(space,' Vmt offset : ',getlongint);
|
writeln(space,' Vmt offset : ',getlongint);
|
||||||
write (space, ' Ancestor Class : ');
|
write (space, ' Ancestor Class : ');
|
||||||
readderef('');
|
readderef('');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user