* new temporary ansistring handling

This commit is contained in:
florian 1999-05-17 21:56:57 +00:00
parent e905aeea04
commit 8706cd801f
15 changed files with 121 additions and 148 deletions

View File

@ -45,4 +45,10 @@ Changes in the syntax or semantic of FPC:
13/05/99 Classes are now only allowed in the ObjFpc or Delphi mode. Use
{$mode objfpc} or {$mode delphi}. Or from commandline -S2 or -Sd
16/05/99 Remove options -Up (use now -Fu) and -Fg (use now -Fl)
17/05/99 Redesign of ansistring temporary handling, please report
any problems
17/05/99 Most stuff of the objpas unit is now in the system unit
because the new temporary ansistring handling support
exceptions and exceptions need the class OOP model

View File

@ -146,9 +146,7 @@ implementation
href : treference;
pushed,
cmpop : boolean;
savedunused : tregisterset;
hr : treference;
oldrl : plinkedlist;
begin
{ string operations are not commutative }
@ -160,8 +158,6 @@ implementation
case p^.treetype of
addn:
begin
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
cmpop:=false;
secondpass(p^.left);
@ -184,41 +180,24 @@ implementation
ungetregister32(p^.left^.location.register);
end;
savedunused:=unused;
{ push the still used registers }
pushusedregisters(pushedregs,$ff);
{ push data }
clear_location(p^.location);
p^.location.loc:=LOC_MEM;
gettempansistringreference(p^.location.reference);
emitpushreferenceaddr(exprasmlist,p^.location.reference);
emit_push_loc(p^.right^.location);
emit_push_loc(p^.left^.location);
emitcall('FPC_ANSISTR_CONCAT',true);
unused:=savedunused;
clear_location(p^.location);
p^.location.register:=getexplicitregister32(R_EAX);
p^.location.loc:=LOC_REGISTER;
emit_reg_reg(A_MOV,S_L,R_EAX,p^.location.register);
{ unused:=unused-[R_EAX]; }
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
{ unused:=unused+[R_EAX]; }
popusedregisters(pushedregs);
maybe_loadesi;
{ done with temptoremove !! (PM)
ungetiftemp(p^.left^.location.reference);
ungetiftemp(p^.right^.location.reference); }
reset_reference(hr);
gettempansistringreference(hr);
addtemptodestroy(p^.resulttype,hr);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
newreference(hr))));
ungetiftempansi(p^.left^.location.reference);
ungetiftempansi(p^.right^.location.reference);
end;
ltn,lten,gtn,gten,
equaln,unequaln:
begin
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
secondpass(p^.left);
pushed:=maybe_push(p^.right^.registers32,p);
secondpass(p^.right);
@ -252,11 +231,6 @@ implementation
exprasmlist^.concat(new(pai386,op_reg(A_PUSH,S_L,p^.left^.location.register)));
end;
emitcall('FPC_ANSISTR_COMPARE',true);
unused:=unused-[R_EAX];
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
unused:=unused+[R_EAX];
emit_reg_reg(A_OR,S_L,R_EAX,R_EAX);
popusedregisters(pushedregs);
maybe_loadesi;
@ -2056,7 +2030,10 @@ implementation
end.
{
$Log$
Revision 1.55 1999-05-10 14:37:49 pierre
Revision 1.56 1999-05-17 21:56:58 florian
* new temporary ansistring handling
Revision 1.55 1999/05/10 14:37:49 pierre
problem with EAX being overwritten before used in A_MULL code fixed
Revision 1.54 1999/05/09 17:58:42 jonas

View File

@ -228,7 +228,6 @@ implementation
{ we must pop this size also after !! }
{ must_pop : boolean; }
pop_size : longint;
oldrl : plinkedlist;
label
dont_call;
@ -243,10 +242,6 @@ implementation
no_virtual_call:=false;
unusedregisters:=unused;
{ save old ansi string release list }
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
if not assigned(p^.procdefinition) then
exit;
if (p^.procdefinition^.options and poinline)<>0 then
@ -1017,6 +1012,37 @@ implementation
else
p^.location.loc:=LOC_FPU;
end
else if is_ansistring(p^.resulttype) or
is_widestring(p^.resulttype) then
begin
gettempansistringreference(hr);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,R_EAX,
newreference(hr))));
p^.location.loc:=LOC_REFERENCE;
p^.location.reference:=hr;
{ unnessary ansi/wide strings are imm. disposed }
if not(p^.return_value_used) then
begin
pushusedregisters(pushedregs,$ff);
emitpushreferenceaddr(exprasmlist,hr);
if is_ansistring(p^.resulttype) then
begin
exprasmlist^.concat(new(pai386,
op_sym(A_CALL,S_NO,newasmsymbol('FPC_ANSISTR_DECR_REF'))));
if not (cs_compilesystem in aktmoduleswitches) then
concat_external('FPC_ANSISTR_DECR_REF',EXT_NEAR);
end
else
begin
exprasmlist^.concat(new(pai386,
op_sym(A_CALL,S_NO,newasmsymbol('FPC_WIDESTR_DECR_REF'))));
if not (cs_compilesystem in aktmoduleswitches) then
concat_external('FPC_WIDESTR_DECR_REF',EXT_NEAR);
end;
ungetiftemp(hr);
popusedregisters(pushedregs);
end;
end
else
begin
p^.location.loc:=LOC_REGISTER;
@ -1029,42 +1055,6 @@ implementation
hregister:=getexplicitregister32(R_EAX);
emit_reg_reg(A_MOV,S_L,R_EAX,hregister);
p^.location.register:=hregister;
if is_ansistring(p^.resulttype) or
is_widestring(p^.resulttype) then
begin
gettempansistringreference(hr);
exprasmlist^.concat(new(pai386,op_reg_ref(A_MOV,S_L,p^.location.register,
newreference(hr))));
{$ifdef AnsiStrRef}
ungetregister(hregister);
p^.location.loc:=LOC_REFERENCE;
p^.location.reference:=hr;
{$endif}
{ unnessary ansi/wide strings are imm. disposed }
if not(p^.return_value_used) then
begin
pushusedregisters(pushedregs,$ff);
emitpushreferenceaddr(exprasmlist,hr);
if is_ansistring(p^.resulttype) then
begin
exprasmlist^.concat(new(pai386,
op_sym(A_CALL,S_NO,newasmsymbol('FPC_ANSISTR_DECR_REF'))));
if not (cs_compilesystem in aktmoduleswitches) then
concat_external('FPC_ANSISTR_DECR_REF',EXT_NEAR);
end
else
begin
exprasmlist^.concat(new(pai386,
op_sym(A_CALL,S_NO,newasmsymbol('FPC_WIDESTR_DECR_REF'))));
if not (cs_compilesystem in aktmoduleswitches) then
concat_external('FPC_WIDESTR_DECR_REF',EXT_NEAR);
end;
ungetiftemp(hr);
popusedregisters(pushedregs);
end
else
oldrl^.concat(new(ptemptodestroy,init(hr,p^.resulttype)));
end;
end;
end;
end;
@ -1079,11 +1069,6 @@ implementation
if pop_size>0 then
exprasmlist^.concat(new(pai386,op_const_reg(A_ADD,S_L,pop_size,R_ESP)));
{ release temp. ansi strings }
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
{ restore registers }
popusedregisters(pushed);
@ -1215,7 +1200,10 @@ implementation
end.
{
$Log$
Revision 1.78 1999-05-01 13:24:02 peter
Revision 1.79 1999-05-17 21:56:59 florian
* new temporary ansistring handling
Revision 1.78 1999/05/01 13:24:02 peter
* merged nasm compiler
* old asm moved to oldasm/

View File

@ -250,9 +250,6 @@ implementation
end;
end;
var
ltemptoremove : plinkedlist;
procedure second_string_to_string(pto,pfrom : ptree;convtyp : tconverttype);
var
@ -320,8 +317,6 @@ implementation
clear_location(pto^.location);
pto^.location.loc:=LOC_REFERENCE;
gettempansistringreference(pto^.location.reference);
ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
pushusedregisters(pushed,$ff);
emit_push_lea_loc(pfrom^.location);
emit_push_lea_loc(pto^.location);
@ -499,8 +494,6 @@ implementation
st_ansistring :
begin
gettempansistringreference(pto^.location.reference);
ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
release_loc(pfrom^.location);
pushusedregisters(pushed,$ff);
push_int(l);
@ -546,8 +539,6 @@ implementation
st_ansistring :
begin
gettempansistringreference(pto^.location.reference);
ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
release_loc(pfrom^.location);
pushusedregisters(pushed,$ff);
emit_pushw_loc(pfrom^.location);
@ -1066,8 +1057,6 @@ implementation
begin
pto^.location.loc:=LOC_REFERENCE;
gettempansistringreference(pto^.location.reference);
ltemptoremove^.concat(new(ptemptodestroy,init(pto^.location.reference,pto^.resulttype)));
exprasmlist^.concat(new(pai386,op_const_ref(A_MOV,S_L,0,newreference(pto^.location.reference))));
case pfrom^.location.loc of
LOC_REFERENCE,LOC_MEM:
begin
@ -1146,26 +1135,16 @@ implementation
second_nothing, {arrayconstructor_to_set}
second_load_smallset
);
var
oldrl,oldlrl : plinkedlist;
{$ifdef TESTOBJEXT2}
var
r : preference;
nillabel : plabel;
{$endif TESTOBJEXT2}
begin
{ the ansi string disposing is a little bit hairy: }
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
{ this isn't good coding, I think tc_bool_2_int, shouldn't be }
{ type conversion (FK) }
{ this is necessary, because second_bool_2_int, have to change }
{ true- and false label before calling secondpass }
{ the helper routines need access to the release list }
oldlrl:=ltemptoremove;
ltemptoremove:=oldrl;
if not(p^.convtyp in [tc_bool_2_int,tc_bool_2_bool]) then
begin
secondpass(p^.left);
@ -1213,11 +1192,6 @@ implementation
exprasmlist^.concat(new(pai_label,init(nillabel)));
end;
{$endif TESTOBJEXT2}
{ clean up all temp. objects (ansi/widestrings) }
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
ltemptoremove:=oldlrl;
end;
@ -1331,7 +1305,10 @@ implementation
end.
{
$Log$
Revision 1.71 1999-05-12 00:19:40 peter
Revision 1.72 1999-05-17 21:57:00 florian
* new temporary ansistring handling
Revision 1.71 1999/05/12 00:19:40 peter
* removed R_DEFAULT_SEG
* uniform float names

View File

@ -717,6 +717,10 @@ do_jmp:
if assigned(p^.right) then
secondpass(p^.right);
exprasmlist^.concat(new(pai386,op_ref(A_PUSH,S_L,
newreference(ref))));
emitcall('FPC_DESTROYEXCEPTION',true);
{ clear some stuff }
ungetiftemp(ref);
emitjmp(C_None,endexceptlabel);
@ -733,7 +737,7 @@ do_jmp:
procedure secondtryfinally(var p : ptree);
var
finallylabel,noreraiselabel,endfinallylabel : plabel;
finallylabel,noreraiselabel : plabel;
begin
{ we modify EAX }
@ -741,7 +745,6 @@ do_jmp:
getlabel(finallylabel);
getlabel(noreraiselabel);
getlabel(endfinallylabel);
push_int(1); { Type of stack-frame must be pushed}
emitcall('FPC_PUSHEXCEPTADDR',true);
exprasmlist^.concat(new(pai386,
@ -772,7 +775,6 @@ do_jmp:
emitcall('FPC_RERAISE',true);
emitlab(noreraiselabel);
emitcall('FPC_POPADDRSTACK',true);
emitlab(endfinallylabel);
end;
@ -798,7 +800,10 @@ do_jmp:
end.
{
$Log$
Revision 1.36 1999-05-13 21:59:21 peter
Revision 1.37 1999-05-17 21:57:01 florian
* new temporary ansistring handling
Revision 1.36 1999/05/13 21:59:21 peter
* removed oldppu code
* warning if objpas is loaded from uses
* first things for new deref writing

View File

@ -1231,9 +1231,6 @@ implementation
end;
else internalerror(9);
end;
{ remove temp. objects, we don't generate them here }
removetemps(exprasmlist,temptoremove);
temptoremove^.clear;
{ reset pushedparasize }
pushedparasize:=oldpushedparasize;
end;
@ -1241,7 +1238,10 @@ implementation
end.
{
$Log$
Revision 1.49 1999-05-12 15:46:26 pierre
Revision 1.50 1999-05-17 21:57:03 florian
* new temporary ansistring handling
Revision 1.49 1999/05/12 15:46:26 pierre
* handle_str disposetree was badly placed
Revision 1.48 1999/05/12 00:19:42 peter

View File

@ -356,13 +356,10 @@ implementation
hregister : tregister;
loc : tloc;
r : preference;
oldrl : plinkedlist;
{$ifndef OLDASM}
ai : pai386;
{$endif}
begin
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
otlabel:=truelabel;
oflabel:=falselabel;
getlabel(truelabel);
@ -672,9 +669,6 @@ implementation
{$EndIf regallocfix}
end;
end;
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
freelabel(truelabel);
freelabel(falselabel);
truelabel:=otlabel;
@ -851,7 +845,10 @@ implementation
end.
{
$Log$
Revision 1.54 1999-05-12 00:19:43 peter
Revision 1.55 1999-05-17 21:57:04 florian
* new temporary ansistring handling
Revision 1.54 1999/05/12 00:19:43 peter
* removed R_DEFAULT_SEG
* uniform float names

View File

@ -787,9 +787,6 @@ implementation
reset_reference(p^.location.reference);
p^.location.loc:=LOC_REGISTER;
p^.location.register:=hr;
{ we can remove all temps }
removetemps(exprasmlist,temptoremove);
temptoremove^.clear;
end;
st_widestring:
begin
@ -799,9 +796,6 @@ implementation
newreference(p^.location.reference),hr))); reset_reference(p^.location.reference);
p^.location.loc:=LOC_REGISTER;
p^.location.register:=hr;
{ we can remove all temps }
removetemps(exprasmlist,temptoremove);
temptoremove^.clear;
end;
end;
end;
@ -890,7 +884,10 @@ implementation
end.
{
$Log$
Revision 1.37 1999-05-17 14:14:14 pierre
Revision 1.38 1999-05-17 21:57:05 florian
* new temporary ansistring handling
Revision 1.37 1999/05/17 14:14:14 pierre
+ -gc for check pointer with heaptrc
Revision 1.36 1999/05/12 00:19:44 peter

View File

@ -169,7 +169,7 @@ implementation
procedure writenames(p : pprocdeftree);
begin
getlabel(p^.nl);
getdatalabel(p^.nl);
if assigned(p^.l) then
writenames(p^.l);
datasegment^.concat(new(pai_label,init(p^.nl)));
@ -211,7 +211,7 @@ implementation
writenames(root);
{ now start writing of the message string table }
getlabel(r);
getdatalabel(r);
datasegment^.concat(new(pai_label,init(r)));
genstrmsgtab:=r;
datasegment^.concat(new(pai_const,init_32bit(count)));
@ -250,7 +250,7 @@ implementation
_class^.publicsyms^.foreach(insertmsgint);
{ now start writing of the message string table }
getlabel(r);
getdatalabel(r);
datasegment^.concat(new(pai_label,init(r)));
genintmsgtab:=r;
datasegment^.concat(new(pai_const,init_32bit(count)));
@ -566,7 +566,10 @@ implementation
end.
{
$Log$
Revision 1.4 1999-05-13 21:59:27 peter
Revision 1.5 1999-05-17 21:57:07 florian
* new temporary ansistring handling
Revision 1.4 1999/05/13 21:59:27 peter
* removed oldppu code
* warning if objpas is loaded from uses
* first things for new deref writing

View File

@ -50,6 +50,8 @@ unit hcodegen;
{ no register variables }
pi_is_assembler = $40; { set if the procedure is declared as ASSEMBLER
=> don't optimize}
pi_needs_implicit_finally = $80; { set, if the procedure contains data which }
{ needs to be finalized }
type
pprocinfo = ^tprocinfo;
tprocinfo = record
@ -142,7 +144,6 @@ unit hcodegen;
pushedparasize : longint;
make_const_global : boolean;
temptoremove : plinkedlist;
{ message calls with codegenerror support }
procedure cgmessage(const t : tmsgconst);
@ -321,7 +322,10 @@ end.
{
$Log$
Revision 1.30 1999-05-01 13:24:22 peter
Revision 1.31 1999-05-17 21:57:08 florian
* new temporary ansistring handling
Revision 1.30 1999/05/01 13:24:22 peter
* merged nasm compiler
* old asm moved to oldasm/

View File

@ -305,6 +305,7 @@ uses
opcode:=op;
opsize:=_size;
ops:=0;
condition:=c_none;
fillchar(oper,sizeof(oper),0);
{$ifndef NOAG386BIN}
insentry:=nil;
@ -1573,7 +1574,10 @@ end;
end.
{
$Log$
Revision 1.7 1999-05-16 17:00:45 peter
Revision 1.8 1999-05-17 21:57:09 florian
* new temporary ansistring handling
Revision 1.7 1999/05/16 17:00:45 peter
* fixed sym_ofs_ref op loading
Revision 1.6 1999/05/12 00:19:50 peter

View File

@ -98,13 +98,17 @@ implementation
if assigned(hp^.right) then
begin
cleartempgen;
{!!!!!!
oldrl:=temptoremove;
temptoremove:=new(plinkedlist,init);
}
secondpass(hp^.right);
{ release temp. ansi strings }
{ !!!!!!!
some temporary data which can't be released elsewhere
removetemps(exprasmlist,temptoremove);
dispose(temptoremove,done);
temptoremove:=oldrl;
}
end;
hp:=hp^.left;
end;
@ -359,7 +363,7 @@ implementation
label
nextreg;
begin
temptoremove:=nil;
{!!!!!!!! temptoremove:=nil; }
cleartempgen;
{ when size optimization only count occurrence }
if cs_littlesize in aktglobalswitches then
@ -553,7 +557,10 @@ implementation
end.
{
$Log$
Revision 1.20 1999-05-02 21:33:54 florian
Revision 1.21 1999-05-17 21:57:11 florian
* new temporary ansistring handling
Revision 1.20 1999/05/02 21:33:54 florian
* several bugs regarding -Or fixed
Revision 1.19 1999/05/01 13:24:28 peter

View File

@ -1527,7 +1527,7 @@ unit pdecl;
if (aktclass^.options and oo_can_have_published)<>0 then
aktclass^.generate_rtti;
{ write class name }
getlabel(classnamelabel);
getdatalabel(classnamelabel);
datasegment^.concat(new(pai_label,init(classnamelabel)));
datasegment^.concat(new(pai_const,init_8bit(length(aktclass^.objname^))));
datasegment^.concat(new(pai_string,init(aktclass^.objname^)));
@ -2230,7 +2230,10 @@ unit pdecl;
end.
{
$Log$
Revision 1.116 1999-05-13 21:59:34 peter
Revision 1.117 1999-05-17 21:57:12 florian
* new temporary ansistring handling
Revision 1.116 1999/05/13 21:59:34 peter
* removed oldppu code
* warning if objpas is loaded from uses
* first things for new deref writing

View File

@ -372,7 +372,7 @@
procedure tdef.generate_rtti;
begin
has_rtti:=true;
getlabel(rtti_label);
getdatalabel(rtti_label);
write_child_rtti_data;
rttilist^.concat(new(pai_label,init(rtti_label)));
write_rtti_data;
@ -397,7 +397,7 @@
procedure tdef.generate_inittable;
begin
has_inittable:=true;
getlabel(inittable_label);
getdatalabel(inittable_label);
write_child_init_data;
rttilist^.concat(new(pai_label,init(inittable_label)));
write_init_data;
@ -3271,7 +3271,7 @@ Const local_symtable_index : longint = $8001;
procedure tobjectdef.generate_rtti;
begin
has_rtti:=true;
getlabel(rtti_label);
getdatalabel(rtti_label);
write_child_rtti_data;
rttilist^.concat(new(pai_symbol,init_global(rtti_name)));
rttilist^.concat(new(pai_label,init(rtti_label)));
@ -3380,7 +3380,10 @@ Const local_symtable_index : longint = $8001;
{
$Log$
Revision 1.116 1999-05-16 02:26:51 peter
Revision 1.117 1999-05-17 21:57:15 florian
* new temporary ansistring handling
Revision 1.116 1999/05/16 02:26:51 peter
* fixed loading of classrefdef
Revision 1.115 1999/05/14 17:52:26 peter

View File

@ -81,7 +81,6 @@ unit temp_gen;
function ungetiftempansi(const ref : treference) : boolean;
procedure gettempansistringreference(var ref : treference);
implementation
uses
@ -359,8 +358,8 @@ unit temp_gen;
end;
end;
function istemp(const ref : treference) : boolean;
begin
{ ref.index = R_NO was missing
led to problems with local arrays
@ -498,7 +497,10 @@ begin
end.
{
$Log$
Revision 1.23 1999-05-17 12:49:16 pierre
Revision 1.24 1999-05-17 21:57:17 florian
* new temporary ansistring handling
Revision 1.23 1999/05/17 12:49:16 pierre
* several problems with EXTDEBUG fixed
Revision 1.22 1999/05/15 21:33:21 peter