* memory optimization with tconstsym (1.5%)

This commit is contained in:
carl 2002-11-22 22:48:10 +00:00
parent e15d019b58
commit 05d86bbef8
7 changed files with 126 additions and 110 deletions

View File

@ -307,16 +307,16 @@ implementation
constbool,
constchar,
constord :
equal_constsym:=(sym1.valueord=sym2.valueord);
equal_constsym:=(sym1.value.valueord=sym2.value.valueord);
constpointer :
equal_constsym:=(sym1.valueordptr=sym2.valueordptr);
equal_constsym:=(sym1.value.valueordptr=sym2.value.valueordptr);
conststring,constresourcestring :
begin
if sym1.len=sym2.len then
if sym1.value.len=sym2.value.len then
begin
p1:=pchar(sym1.valueptr);
p2:=pchar(sym2.valueptr);
pend:=p1+sym1.len;
p1:=pchar(sym1.value.valueptr);
p2:=pchar(sym2.value.valueptr);
pend:=p1+sym1.value.len;
while (p1<pend) do
begin
if p1^<>p2^ then
@ -329,9 +329,9 @@ implementation
end;
end;
constreal :
equal_constsym:=(pbestreal(sym1.valueptr)^=pbestreal(sym2.valueptr)^);
equal_constsym:=(pbestreal(sym1.value.valueptr)^=pbestreal(sym2.value.valueptr)^);
constset :
equal_constsym:=(pnormalset(sym1.valueptr)^=pnormalset(sym2.valueptr)^);
equal_constsym:=(pnormalset(sym1.value.valueptr)^=pnormalset(sym2.value.valueptr)^);
constnil :
equal_constsym:=true;
end;
@ -2040,7 +2040,10 @@ implementation
end.
{
$Log$
Revision 1.26 2002-11-17 16:31:55 carl
Revision 1.27 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.26 2002/11/17 16:31:55 carl
* memory optimization (3-4%) : cleanup of tai fields,
cleanup of tdef and tsym fields.
* make it work for m68k

View File

@ -305,29 +305,29 @@ implementation
p1:=nil;
case p.consttyp of
constint :
p1:=genintconstnode(p.valueord);
p1:=genintconstnode(p.value.valueord);
conststring :
begin
len:=p.len;
len:=p.value.len;
if not(cs_ansistrings in aktlocalswitches) and (len>255) then
len:=255;
getmem(pc,len+1);
move(pchar(p.valueptr)^,pc^,len);
move(pchar(p.value.valueptr)^,pc^,len);
pc[len]:=#0;
p1:=cstringconstnode.createpchar(pc,len);
end;
constchar :
p1:=cordconstnode.create(p.valueord,cchartype,true);
p1:=cordconstnode.create(p.value.valueord,cchartype,true);
constreal :
p1:=crealconstnode.create(pbestreal(p.valueptr)^,pbestrealtype^);
p1:=crealconstnode.create(pbestreal(p.value.valueptr)^,pbestrealtype^);
constbool :
p1:=cordconstnode.create(p.valueord,booltype,true);
p1:=cordconstnode.create(p.value.valueord,booltype,true);
constset :
p1:=csetconstnode.create(pconstset(p.valueptr),p.consttype);
p1:=csetconstnode.create(pconstset(p.value.valueptr),p.consttype);
constord :
p1:=cordconstnode.create(p.valueord,p.consttype,true);
p1:=cordconstnode.create(p.value.valueord,p.consttype,true);
constpointer :
p1:=cpointerconstnode.create(p.valueordptr,p.consttype);
p1:=cpointerconstnode.create(p.value.valueordptr,p.consttype);
constnil :
p1:=cnilnode.create;
else
@ -924,7 +924,10 @@ begin
end.
{
$Log$
Revision 1.43 2002-10-05 12:43:25 carl
Revision 1.44 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.43 2002/10/05 12:43:25 carl
* fixes for Delphi 6 compilation
(warning : Some features do not work under Delphi)

View File

@ -1188,37 +1188,37 @@ implementation
constint :
begin
{ do a very dirty trick to bootstrap this code }
if (tconstsym(srsym).valueord>=-(int64(2147483647)+int64(1))) and
(tconstsym(srsym).valueord<=2147483647) then
p1:=cordconstnode.create(tconstsym(srsym).valueord,s32bittype,true)
else if (tconstsym(srsym).valueord > maxlongint) and
(tconstsym(srsym).valueord <= int64(maxlongint)+int64(maxlongint)+1) then
p1:=cordconstnode.create(tconstsym(srsym).valueord,u32bittype,true)
if (tconstsym(srsym).value.valueord>=-(int64(2147483647)+int64(1))) and
(tconstsym(srsym).value.valueord<=2147483647) then
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,s32bittype,true)
else if (tconstsym(srsym).value.valueord > maxlongint) and
(tconstsym(srsym).value.valueord <= int64(maxlongint)+int64(maxlongint)+1) then
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,u32bittype,true)
else
p1:=cordconstnode.create(tconstsym(srsym).valueord,cs64bittype,true);
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,cs64bittype,true);
end;
conststring :
begin
len:=tconstsym(srsym).len;
len:=tconstsym(srsym).value.len;
if not(cs_ansistrings in aktlocalswitches) and (len>255) then
len:=255;
getmem(pc,len+1);
move(pchar(tconstsym(srsym).valueptr)^,pc^,len);
move(pchar(tconstsym(srsym).value.valueptr)^,pc^,len);
pc[len]:=#0;
p1:=cstringconstnode.createpchar(pc,len);
end;
constchar :
p1:=cordconstnode.create(tconstsym(srsym).valueord,cchartype,true);
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,cchartype,true);
constreal :
p1:=crealconstnode.create(pbestreal(tconstsym(srsym).valueptr)^,pbestrealtype^);
p1:=crealconstnode.create(pbestreal(tconstsym(srsym).value.valueptr)^,pbestrealtype^);
constbool :
p1:=cordconstnode.create(tconstsym(srsym).valueord,booltype,true);
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,booltype,true);
constset :
p1:=csetconstnode.create(pconstset(tconstsym(srsym).valueptr),tconstsym(srsym).consttype);
p1:=csetconstnode.create(pconstset(tconstsym(srsym).value.valueptr),tconstsym(srsym).consttype);
constord :
p1:=cordconstnode.create(tconstsym(srsym).valueord,tconstsym(srsym).consttype,true);
p1:=cordconstnode.create(tconstsym(srsym).value.valueord,tconstsym(srsym).consttype,true);
constpointer :
p1:=cpointerconstnode.create(tconstsym(srsym).valueordptr,tconstsym(srsym).consttype);
p1:=cpointerconstnode.create(tconstsym(srsym).value.valueordptr,tconstsym(srsym).consttype);
constnil :
p1:=cnilnode.create;
constresourcestring:
@ -1228,7 +1228,7 @@ implementation
p1.resulttype:=cansistringtype;
end;
constguid :
p1:=cguidconstnode.create(pguid(tconstsym(srsym).valueptr)^);
p1:=cguidconstnode.create(pguid(tconstsym(srsym).value.valueptr)^);
end;
end;
@ -2266,7 +2266,10 @@ implementation
end.
{
$Log$
Revision 1.90 2002-11-20 22:49:55 pierre
Revision 1.91 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.90 2002/11/20 22:49:55 pierre
* commented check code tht was invalid in 1.1
Revision 1.89 2002/11/18 18:34:41 peter

View File

@ -515,8 +515,8 @@ implementation
end
else if is_constresourcestringnode(p) then
begin
strval:=pchar(tconstsym(tloadnode(p).symtableentry).valueptr);
strlength:=tconstsym(tloadnode(p).symtableentry).len;
strval:=pchar(tconstsym(tloadnode(p).symtableentry).value.valueptr);
strlength:=tconstsym(tloadnode(p).symtableentry).value.len;
end
else
begin
@ -985,7 +985,10 @@ implementation
end.
{
$Log$
Revision 1.58 2002-11-09 15:31:57 carl
Revision 1.59 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.58 2002/11/09 15:31:57 carl
+ align ansi/wide string constants
Revision 1.57 2002/09/06 19:58:31 carl

View File

@ -968,7 +968,7 @@ Begin
if tconstsym(sym).consttyp in [constint,constchar,constbool] then
begin
opr.typ:=OPR_CONSTANT;
opr.val:=tconstsym(sym).valueord;
opr.val:=tconstsym(sym).value.valueord;
SetupVar:=true;
Exit;
end;
@ -1278,7 +1278,7 @@ Begin
begin
if (tconstsym(srsym).consttyp in [constord,constint,constchar,constbool]) then
Begin
l:=tconstsym(srsym).valueord;
l:=tconstsym(srsym).value.valueord;
SearchIConstant:=TRUE;
exit;
end;
@ -1592,7 +1592,10 @@ end;
end.
{
$Log$
Revision 1.48 2002-11-18 17:31:59 peter
Revision 1.49 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.48 2002/11/18 17:31:59 peter
* pass proccalloption to ret_in_xxx and push_xxx functions
Revision 1.47 2002/11/15 16:29:31 peter

View File

@ -3227,16 +3227,16 @@ implementation
case hpc.consttyp of
conststring,
constresourcestring :
hs:=strpas(pchar(hpc.valueptr));
hs:=strpas(pchar(hpc.value.valueptr));
constreal :
str(pbestreal(hpc.valueptr)^,hs);
str(pbestreal(hpc.value.valueptr)^,hs);
constord :
hs:=tostr(hpc.valueord);
hs:=tostr(hpc.value.valueord);
constpointer :
hs:=tostr(hpc.valueordptr);
hs:=tostr(hpc.value.valueordptr);
constbool :
begin
if hpc.valueord<>0 then
if hpc.value.valueord<>0 then
hs:='TRUE'
else
hs:='FALSE';
@ -3244,7 +3244,7 @@ implementation
constnil :
hs:='nil';
constchar :
hs:=chr(hpc.valueord);
hs:=chr(hpc.value.valueord);
constset :
hs:='<set>';
end;
@ -5537,7 +5537,10 @@ implementation
end.
{
$Log$
Revision 1.107 2002-11-19 16:21:29 pierre
Revision 1.108 2002-11-22 22:48:10 carl
* memory optimization with tconstsym (1.5%)
Revision 1.107 2002/11/19 16:21:29 pierre
* correct several stabs generation problems
Revision 1.106 2002/11/18 17:31:59 peter

View File

@ -273,14 +273,22 @@ interface
{$endif GDB}
end;
tconstvalue = record
case integer of
0: (valueord : tconstexprint);
1: (valueordptr : tconstptruint);
2: (valueptr : pointer; len : longint);
end;
tconstsym = class(tstoredsym)
consttype : ttype;
consttyp : tconsttyp;
resstrindex, { needed for resource strings }
valueord : tconstexprint; { used for ordinal values }
value : tconstvalue;
resstrindex : longint; { needed for resource strings }
(* valueord : tconstexprint; { used for ordinal values }
valueordptr : TConstPtrUInt; { used for pointer values }
valueptr : pointer; { used for string, set, real values }
len : longint; { len is needed for string length }
len : longint; { len is needed for string length }*)
constructor create_ord(const n : string;t : tconsttyp;v : tconstexprint);
constructor create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
constructor create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
@ -1877,85 +1885,74 @@ implementation
constructor tconstsym.create_ord(const n : string;t : tconsttyp;v : TConstExprInt);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=v;
valueordptr:=0;
valueptr:=nil;
value.valueord:=v;
ResStrIndex:=0;
consttype.reset;
len:=0;
end;
constructor tconstsym.create_ord_typed(const n : string;t : tconsttyp;v : tconstexprint;const tt:ttype);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=v;
valueordptr:=0;
valueptr:=nil;
value.valueord:=v;
ResStrIndex:=0;
consttype:=tt;
len:=0;
end;
constructor tconstsym.create_ordptr_typed(const n : string;t : tconsttyp;v : tconstptruint;const tt:ttype);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=v;
valueptr:=nil;
value.valueordptr:=v;
ResStrIndex:=0;
consttype:=tt;
len:=0;
end;
constructor tconstsym.create_ptr(const n : string;t : tconsttyp;v : pointer);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=0;
valueptr:=v;
value.valueptr:=v;
ResStrIndex:=0;
consttype.reset;
len:=0;
end;
constructor tconstsym.create_ptr_typed(const n : string;t : tconsttyp;v : pointer;const tt:ttype);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=0;
valueptr:=v;
value.valueptr:=v;
ResStrIndex:=0;
consttype:=tt;
len:=0;
end;
constructor tconstsym.create_string(const n : string;t : tconsttyp;str:pchar;l:longint);
begin
inherited create(n);
fillchar(value, sizeof(value), #0);
typ:=constsym;
consttyp:=t;
valueord:=0;
valueordptr:=0;
valueptr:=str;
value.valueptr:=str;
consttype.reset;
len:=l;
value.len:=l;
if t=constresourcestring then
ResStrIndex:=ResourceStrings.Register(name,pchar(valueptr),len);
ResStrIndex:=ResourceStrings.Register(name,pchar(value.valueptr),value.len);
end;
@ -1969,53 +1966,51 @@ implementation
typ:=constsym;
consttype.reset;
consttyp:=tconsttyp(ppufile.getbyte);
valueord:=0;
valueordptr:=0;
valueptr:=nil;
fillchar(value, sizeof(value), #0);
case consttyp of
constint:
valueord:=ppufile.getexprint;
value.valueord:=ppufile.getexprint;
constwchar,
constbool,
constchar :
valueord:=ppufile.getlongint;
value.valueord:=ppufile.getlongint;
constord :
begin
ppufile.gettype(consttype);
valueord:=ppufile.getexprint;
value.valueord:=ppufile.getexprint;
end;
constpointer :
begin
ppufile.gettype(consttype);
valueordptr:=ppufile.getptruint;
value.valueordptr:=ppufile.getptruint;
end;
conststring,
constresourcestring :
begin
len:=ppufile.getlongint;
getmem(pc,len+1);
ppufile.getdata(pc^,len);
value.len:=ppufile.getlongint;
getmem(pc,value.len+1);
ppufile.getdata(pc^,value.len);
if consttyp=constresourcestring then
ResStrIndex:=ppufile.getlongint;
valueptr:=pc;
value.valueptr:=pc;
end;
constreal :
begin
new(pd);
pd^:=ppufile.getreal;
valueptr:=pd;
value.valueptr:=pd;
end;
constset :
begin
ppufile.gettype(consttype);
new(ps);
ppufile.getnormalset(ps^);
valueptr:=ps;
value.valueptr:=ps;
end;
constguid :
begin
new(pguid(valueptr));
ppufile.getdata(valueptr^,sizeof(tguid));
new(pguid(value.valueptr));
ppufile.getdata(value.valueptr^,sizeof(tguid));
end;
constnil : ;
else
@ -2029,13 +2024,13 @@ implementation
case consttyp of
conststring,
constresourcestring :
freemem(pchar(valueptr),len+1);
freemem(pchar(value.valueptr),value.len+1);
constreal :
dispose(pbestreal(valueptr));
dispose(pbestreal(value.valueptr));
constset :
dispose(pnormalset(valueptr));
dispose(pnormalset(value.valueptr));
constguid :
dispose(pguid(valueptr));
dispose(pguid(value.valueptr));
end;
inherited destroy;
end;
@ -2061,37 +2056,37 @@ implementation
case consttyp of
constnil : ;
constint:
ppufile.putexprint(valueord);
ppufile.putexprint(value.valueord);
constbool,
constchar :
ppufile.putlongint(valueord);
ppufile.putlongint(value.valueord);
constord :
begin
ppufile.puttype(consttype);
ppufile.putexprint(valueord);
ppufile.putexprint(value.valueord);
end;
constpointer :
begin
ppufile.puttype(consttype);
ppufile.putptruint(valueordptr);
ppufile.putptruint(value.valueordptr);
end;
conststring,
constresourcestring :
begin
ppufile.putlongint(len);
ppufile.putdata(pchar(valueptr)^,len);
ppufile.putlongint(value.len);
ppufile.putdata(pchar(value.valueptr)^,value.len);
if consttyp=constresourcestring then
ppufile.putlongint(ResStrIndex);
end;
constreal :
ppufile.putreal(pbestreal(valueptr)^);
ppufile.putreal(pbestreal(value.valueptr)^);
constset :
begin
ppufile.puttype(consttype);
ppufile.putnormalset(valueptr^);
ppufile.putnormalset(value.valueptr^);
end;
constguid :
ppufile.putdata(valueptr^,sizeof(tguid));
ppufile.putdata(value.valueptr^,sizeof(tguid));
else
internalerror(13);
end;
@ -2105,16 +2100,16 @@ implementation
{even GDB v4.16 only now 'i' 'r' and 'e' !!!}
case consttyp of
conststring : begin
st := 's'''+strpas(pchar(valueptr))+'''';
st := 's'''+strpas(pchar(value.valueptr))+'''';
end;
constbool,
constint,
constord,
constchar : st := 'i'+int64tostr(valueord);
constchar : st := 'i'+int64tostr(value.valueord);
constpointer :
st := 'i'+int64tostr(valueordptr);
st := 'i'+int64tostr(value.valueordptr);
constreal : begin
system.str(pbestreal(valueptr)^,st);
system.str(pbestreal(value.valueptr)^,st);
st := 'r'+st;
end;
{ if we don't know just put zero !! }
@ -2504,7 +2499,10 @@ implementation
end.
{
$Log$
Revision 1.73 2002-11-18 17:31:59 peter
Revision 1.74 2002-11-22 22:48:11 carl
* memory optimization with tconstsym (1.5%)
Revision 1.73 2002/11/18 17:31:59 peter
* pass proccalloption to ret_in_xxx and push_xxx functions
Revision 1.72 2002/11/17 16:31:57 carl