* use helper call to retrieve address of input/output to reduce

code that is generated in the main program for loading the
    threadvar
This commit is contained in:
peter 2004-11-09 23:10:22 +00:00
parent 6c9c4c686c
commit 95e0ed26f8
5 changed files with 63 additions and 19 deletions

View File

@ -72,8 +72,8 @@ implementation
uses
verbose,globals,systems,
globtype, cutils,
symbase,symconst,symdef,symsym,symtable,paramgr,defutil,defcmp,
pass_1,tgobj,
symbase,symconst,symdef,symsym,symtable,paramgr,defutil,
pass_1,
ncal,ncon,ncnv,nadd,nld,nbas,nflw,nmem,nmat,nutils,
cgbase,procinfo
;
@ -305,7 +305,7 @@ implementation
temp : ttempcreatenode;
procprefix,
name : string[31];
srsym : tglobalvarsym;
textsym : ttypesym;
tempowner : tsymtable;
readfunctype : ttype;
is_typed,
@ -364,14 +364,6 @@ implementation
{ if we don't have a filepara, create one containing the default }
if not assigned(filepara) then
begin
{ retrieve the symbols for standard input/output handle }
if do_read then
name := 'INPUT'
else
name := 'OUTPUT';
if not searchsysvar(name,srsym,tempowner) then
internalerror(200108141);
{ since the input/output variables are threadvars loading them into
a temp once is faster. Create a temp which will hold a pointer to the file }
filetemp := ctempcreatenode.create_reg(voidpointertype,voidpointertype.def.size,tt_persistent);
@ -385,15 +377,21 @@ implementation
resulttypepass(tnode(filetemp));
{ assign the address of the file to the temp }
if do_read then
name := 'input'
else
name := 'output';
addstatement(newstatement,
cassignmentnode.create(ctemprefnode.create(filetemp),
caddrnode.create(cloadnode.create(srsym,tempowner))));
ccallnode.createintern('fpc_get_'+name,nil)));
{ create a new fileparameter as follows: file_type(temp^) }
{ (so that we pass the value and not the address of the temp }
{ to the read/write routine) }
if not searchsystype('TEXT',textsym) then
internalerror(200108313);
filepara := ccallparanode.create(ctypeconvnode.create_internal(
cderefnode.create(ctemprefnode.create(filetemp)),srsym.vartype),nil);
cderefnode.create(ctemprefnode.create(filetemp)),textsym.restype),nil);
end
else
{ remove filepara from the parameter chain }
@ -1387,7 +1385,7 @@ implementation
end;
end;
if hp=nil then
hp:=tnode.create(errorn);
hp:=terrornode.create;
result:=hp;
goto myexit;
end
@ -2442,7 +2440,12 @@ begin
end.
{
$Log$
Revision 1.150 2004-11-08 22:09:59 peter
Revision 1.151 2004-11-09 23:10:22 peter
* use helper call to retrieve address of input/output to reduce
code that is generated in the main program for loading the
threadvar
Revision 1.150 2004/11/08 22:09:59 peter
* tvarsym splitted
Revision 1.149 2004/11/02 12:55:16 peter

View File

@ -203,7 +203,9 @@ interface
function searchsym_in_class_by_msgint(classh:tobjectdef;i:longint):tsym;
function searchsym_in_class_by_msgstr(classh:tobjectdef;const s:string):tsym;
function searchsystype(const s: stringid; var srsym: ttypesym): boolean;
{$ifdef notused}
function searchsysvar(const s: stringid; var srsym: tsym; var symowner: tsymtable): boolean;
{$endif notused}
function search_class_member(pd : tobjectdef;const s : string):tsym;
function search_assignment_operator(from_def,to_def:Tdef):Tprocdef;
@ -2036,6 +2038,7 @@ implementation
end;
{$ifdef notused}
function searchsysvar(const s: stringid; var srsym: tsym; var symowner: tsymtable): boolean;
begin
if not(cs_compilesystem in aktmoduleswitches) then
@ -2049,6 +2052,7 @@ implementation
assigned(srsym) and
(srsym.typ = globalvarsym);
end;
{$endif notused}
function search_class_member(pd : tobjectdef;const s : string):tsym;
@ -2303,7 +2307,12 @@ implementation
end.
{
$Log$
Revision 1.162 2004-11-08 22:09:59 peter
Revision 1.163 2004-11-09 23:10:22 peter
* use helper call to retrieve address of input/output to reduce
code that is generated in the main program for loading the
threadvar
Revision 1.162 2004/11/08 22:09:59 peter
* tvarsym splitted
Revision 1.161 2004/11/05 21:16:55 peter

View File

@ -173,6 +173,8 @@ Function fpc_PWideChar_To_ShortStr(const p : pwidechar): shortstring; compilerpr
{$endif HASWIDECHAR}
{ from text.inc }
Function fpc_get_input:PText;{$ifdef hascompilerproc}compilerproc;{$endif}
Function fpc_get_output:PText;{$ifdef hascompilerproc}compilerproc;{$endif}
Procedure fpc_Write_End(var f:Text); compilerproc;
Procedure fpc_Writeln_End(var f:Text); compilerproc;
Procedure fpc_Write_Text_ShortStr(Len : Longint;var f : Text;const s : String); compilerproc;
@ -330,7 +332,12 @@ function fpc_qword_to_double(q: qword): double; compilerproc;
{
$Log$
Revision 1.58 2004-09-29 14:55:49 mazen
Revision 1.59 2004-11-09 23:10:22 peter
* use helper call to retrieve address of input/output to reduce
code that is generated in the main program for loading the
threadvar
Revision 1.58 2004/09/29 14:55:49 mazen
* widestring conversion routines takes a widechar so no
information is lost

View File

@ -278,6 +278,9 @@ Type
PWideString = ^WideString;
{$endif HASWIDESTRING}
{ Needed for fpc_get_output }
PText = ^Text;
TTextLineBreakStyle = (tlbsLF,tlbsCRLF,tlbsCR);
{ procedure type }
@ -770,7 +773,12 @@ const
{
$Log$
Revision 1.106 2004-11-04 09:32:31 peter
Revision 1.107 2004-11-09 23:10:22 peter
* use helper call to retrieve address of input/output to reduce
code that is generated in the main program for loading the
threadvar
Revision 1.106 2004/11/04 09:32:31 peter
ErrOutput added
Revision 1.105 2004/10/30 20:49:10 marco

View File

@ -442,6 +442,18 @@ Begin
End;
Function fpc_get_input:PText;{$ifdef hascompilerproc}compilerproc;{$endif}
begin
fpc_get_input:=@Input;
end;
Function fpc_get_output:PText;{$ifdef hascompilerproc}compilerproc;{$endif}
begin
fpc_get_output:=@Output;
end;
{*****************************************************************************
Write(Ln)
*****************************************************************************}
@ -1277,7 +1289,12 @@ end;
{
$Log$
Revision 1.26 2004-09-21 23:36:51 hajny
Revision 1.27 2004-11-09 23:10:22 peter
* use helper call to retrieve address of input/output to reduce
code that is generated in the main program for loading the
threadvar
Revision 1.26 2004/09/21 23:36:51 hajny
* SetTextLineEnding implemented, FileRec.Name position alignment for CPU64
Revision 1.25 2004/08/20 10:04:39 olle