mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 15:09:19 +02:00
* only use init tables for threadvars
This commit is contained in:
parent
d91b687d35
commit
798289b1f3
@ -922,24 +922,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure initialize_threadvar(p : tnamedindexitem;arg:pointer);
|
|
||||||
var
|
|
||||||
href : treference;
|
|
||||||
list : taasmoutput;
|
|
||||||
begin
|
|
||||||
list:=taasmoutput(arg);
|
|
||||||
if (tsym(p).typ=varsym) and
|
|
||||||
(vo_is_thread_var in tvarsym(p).varoptions) then
|
|
||||||
begin
|
|
||||||
cg.a_param_const(list,OS_INT,tvarsym(p).getsize,paramanager.getintparaloc(2));
|
|
||||||
reference_reset_symbol(href,objectlibrary.newasmsymbol(tvarsym(p).mangledname),0);
|
|
||||||
cg.a_paramaddr_ref(list,href,paramanager.getintparaloc(1));
|
|
||||||
rg.saveregvars(list,all_registers);
|
|
||||||
cg.a_call_name(list,'FPC_INIT_THREADVAR');
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
{ generates the code for initialisation of local data }
|
{ generates the code for initialisation of local data }
|
||||||
procedure initialize_data(p : tnamedindexitem;arg:pointer);
|
procedure initialize_data(p : tnamedindexitem;arg:pointer);
|
||||||
var
|
var
|
||||||
@ -1378,19 +1360,6 @@ implementation
|
|||||||
(cs_profile in aktmoduleswitches) then
|
(cs_profile in aktmoduleswitches) then
|
||||||
cg.a_call_name(list,'__monstartup');
|
cg.a_call_name(list,'__monstartup');
|
||||||
|
|
||||||
{ add local threadvars in units (only if needed because not all platforms
|
|
||||||
have threadvar support) }
|
|
||||||
if have_local_threadvars then
|
|
||||||
cg.a_call_name(list,'FPC_INITIALIZELOCALTHREADVARS');
|
|
||||||
|
|
||||||
{ add global threadvars }
|
|
||||||
p:=symtablestack;
|
|
||||||
while assigned(p) do
|
|
||||||
begin
|
|
||||||
p.foreach_static({$ifndef TP}@{$endif}initialize_threadvar,list);
|
|
||||||
p:=p.next;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{ initialize units }
|
{ initialize units }
|
||||||
cg.a_call_name(list,'FPC_INITIALIZEUNITS');
|
cg.a_call_name(list,'FPC_INITIALIZEUNITS');
|
||||||
end;
|
end;
|
||||||
@ -1873,7 +1842,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.54 2002-10-06 19:41:30 peter
|
Revision 1.55 2002-10-14 19:42:33 peter
|
||||||
|
* only use init tables for threadvars
|
||||||
|
|
||||||
|
Revision 1.54 2002/10/06 19:41:30 peter
|
||||||
* Add finalization of typed consts
|
* Add finalization of typed consts
|
||||||
* Finalization of globals in the main program
|
* Finalization of globals in the main program
|
||||||
|
|
||||||
|
@ -176,6 +176,83 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure InsertThreadvarTablesTable;
|
||||||
|
var
|
||||||
|
hp : tused_unit;
|
||||||
|
ltvTables : taasmoutput;
|
||||||
|
count : longint;
|
||||||
|
begin
|
||||||
|
ltvTables:=TAAsmOutput.Create;
|
||||||
|
count:=0;
|
||||||
|
hp:=tused_unit(usedunits.first);
|
||||||
|
while assigned(hp) do
|
||||||
|
begin
|
||||||
|
If (hp.u.flags and uf_threadvars)=uf_threadvars then
|
||||||
|
begin
|
||||||
|
ltvTables.concat(Tai_const_symbol.Createname(hp.u.modulename^+'_$THREADVARLIST'));
|
||||||
|
inc(count);
|
||||||
|
end;
|
||||||
|
hp:=tused_unit(hp.next);
|
||||||
|
end;
|
||||||
|
{ Add program threadvars, if any }
|
||||||
|
If (current_module.flags and uf_threadvars)=uf_threadvars then
|
||||||
|
begin
|
||||||
|
ltvTables.concat(Tai_const_symbol.Createname(current_module.modulename^+'_$THREADVARLIST'));
|
||||||
|
inc(count);
|
||||||
|
end;
|
||||||
|
{ TableCount }
|
||||||
|
ltvTables.insert(Tai_const.Create_32bit(count));
|
||||||
|
ltvTables.insert(Tai_symbol.Createdataname_global('FPC_THREADVARTABLES',0));
|
||||||
|
ltvTables.concat(Tai_symbol_end.Createname('FPC_THREADVARTABLES'));
|
||||||
|
{ insert in data segment }
|
||||||
|
if (cs_create_smart in aktmoduleswitches) then
|
||||||
|
dataSegment.concat(Tai_cut.Create);
|
||||||
|
dataSegment.concatlist(ltvTables);
|
||||||
|
ltvTables.free;
|
||||||
|
if count > 0 then
|
||||||
|
have_local_threadvars := true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure AddToThreadvarList(p:tnamedindexitem;arg:pointer);
|
||||||
|
var
|
||||||
|
ltvTable : taasmoutput;
|
||||||
|
begin
|
||||||
|
ltvTable:=taasmoutput(arg);
|
||||||
|
if (tsym(p).typ=varsym) and
|
||||||
|
(vo_is_thread_var in tvarsym(p).varoptions) then
|
||||||
|
begin
|
||||||
|
{ address of threadvar }
|
||||||
|
ltvTable.concat(tai_const_symbol.createname(tvarsym(p).mangledname));
|
||||||
|
{ size of threadvar }
|
||||||
|
ltvTable.concat(tai_const.create_32bit(tvarsym(p).getsize));
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure InsertThreadvars;
|
||||||
|
var
|
||||||
|
ltvTable : TAAsmoutput;
|
||||||
|
begin
|
||||||
|
ltvTable:=TAAsmoutput.create;
|
||||||
|
if assigned(current_module.globalsymtable) then
|
||||||
|
current_module.globalsymtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}AddToThreadvarList,ltvTable);
|
||||||
|
current_module.localsymtable.foreach_static({$ifdef FPCPROCVAR}@{$endif}AddToThreadvarList,ltvTable);
|
||||||
|
if ltvTable.first<>nil then
|
||||||
|
begin
|
||||||
|
{ add begin and end of the list }
|
||||||
|
ltvTable.insert(tai_symbol.createdataname_global(current_module.modulename^+'_$THREADVARLIST',0));
|
||||||
|
ltvTable.concat(tai_const.create_32bit(0)); { end of list marker }
|
||||||
|
ltvTable.concat(tai_symbol_end.createname(current_module.modulename^+'_$THREADVARLIST'));
|
||||||
|
if (cs_create_smart in aktmoduleswitches) then
|
||||||
|
dataSegment.concat(Tai_cut.Create);
|
||||||
|
dataSegment.concatlist(ltvTable);
|
||||||
|
current_module.flags:=current_module.flags or uf_threadvars;
|
||||||
|
end;
|
||||||
|
ltvTable.Free;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure InsertResourceTablesTable;
|
Procedure InsertResourceTablesTable;
|
||||||
var
|
var
|
||||||
hp : tused_unit;
|
hp : tused_unit;
|
||||||
@ -356,6 +433,18 @@ implementation
|
|||||||
make_ref:=false;
|
make_ref:=false;
|
||||||
readconstdefs;
|
readconstdefs;
|
||||||
make_ref:=true;
|
make_ref:=true;
|
||||||
|
{ Thread support unit? }
|
||||||
|
if (cs_threading in aktmoduleswitches) then
|
||||||
|
begin
|
||||||
|
hp:=loadunit('Threads','');
|
||||||
|
tsymtable(hp.globalsymtable).next:=symtablestack;
|
||||||
|
symtablestack:=hp.globalsymtable;
|
||||||
|
{ add to the used units }
|
||||||
|
current_module.used_units.concat(tused_unit.create(hp,true));
|
||||||
|
unitsym:=tunitsym.create('Threads',hp.globalsymtable);
|
||||||
|
inc(unitsym.refs);
|
||||||
|
refsymtable.insert(unitsym);
|
||||||
|
end;
|
||||||
{ Objpas unit? }
|
{ Objpas unit? }
|
||||||
if m_objpas in aktmodeswitches then
|
if m_objpas in aktmodeswitches then
|
||||||
begin
|
begin
|
||||||
@ -653,54 +742,6 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure insertLocalThreadvarsTablesTable;
|
|
||||||
var
|
|
||||||
hp : tused_unit;
|
|
||||||
ltvTables : taasmoutput;
|
|
||||||
count : longint;
|
|
||||||
begin
|
|
||||||
ltvTables:=TAAsmOutput.Create;
|
|
||||||
count:=0;
|
|
||||||
hp:=tused_unit(usedunits.first);
|
|
||||||
while assigned(hp) do
|
|
||||||
begin
|
|
||||||
If (hp.u.flags and uf_local_threadvars)=uf_local_threadvars then
|
|
||||||
begin
|
|
||||||
ltvTables.concat(Tai_const_symbol.Createname(hp.u.modulename^+'_$LOCALTHREADVARLIST'));
|
|
||||||
inc(count);
|
|
||||||
end;
|
|
||||||
hp:=tused_unit(hp.next);
|
|
||||||
end;
|
|
||||||
{ TableCount }
|
|
||||||
ltvTables.insert(Tai_const.Create_32bit(count));
|
|
||||||
ltvTables.insert(Tai_symbol.Createdataname_global('FPC_LOCALTHREADVARTABLES',0));
|
|
||||||
ltvTables.concat(Tai_symbol_end.Createname('FPC_LOCALTHREADVARTABLES'));
|
|
||||||
{ insert in data segment }
|
|
||||||
if (cs_create_smart in aktmoduleswitches) then
|
|
||||||
dataSegment.concat(Tai_cut.Create);
|
|
||||||
dataSegment.concatlist(ltvTables);
|
|
||||||
ltvTables.free;
|
|
||||||
if count > 0 then
|
|
||||||
have_local_threadvars := true;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
procedure addToLocalThreadvarTab(p:tnamedindexitem;arg:pointer);
|
|
||||||
var
|
|
||||||
ltvTable : taasmoutput;
|
|
||||||
begin
|
|
||||||
ltvTable:=taasmoutput(arg);
|
|
||||||
if (tsym(p).typ=varsym) and
|
|
||||||
(vo_is_thread_var in tvarsym(p).varoptions) then
|
|
||||||
begin
|
|
||||||
{ address of threadvar }
|
|
||||||
ltvTable.concat(tai_const_symbol.createname(tvarsym(p).mangledname));
|
|
||||||
{ size of threadvar }
|
|
||||||
ltvTable.concat(tai_const.create_32bit(tvarsym(p).getsize));
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
procedure proc_unit;
|
procedure proc_unit;
|
||||||
|
|
||||||
@ -727,7 +768,6 @@ implementation
|
|||||||
store_crc,store_interface_crc : cardinal;
|
store_crc,store_interface_crc : cardinal;
|
||||||
s2 : ^string; {Saves stack space}
|
s2 : ^string; {Saves stack space}
|
||||||
force_init_final : boolean;
|
force_init_final : boolean;
|
||||||
ltvTable : taasmoutput;
|
|
||||||
begin
|
begin
|
||||||
consume(_UNIT);
|
consume(_UNIT);
|
||||||
if compile_level=1 then
|
if compile_level=1 then
|
||||||
@ -971,25 +1011,13 @@ implementation
|
|||||||
genimplicitunitfinal(codesegment);
|
genimplicitunitfinal(codesegment);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ generate a list of local threadvars }
|
|
||||||
ltvTable:=TAAsmoutput.create;
|
|
||||||
st.foreach_static({$ifdef FPCPROCVAR}@{$endif}addToLocalThreadvarTab,ltvTable);
|
|
||||||
if ltvTable.first<>nil then
|
|
||||||
begin
|
|
||||||
{ add begin and end of the list }
|
|
||||||
ltvTable.insert(tai_symbol.createdataname_global(current_module.modulename^+'_$LOCALTHREADVARLIST',0));
|
|
||||||
ltvTable.concat(tai_const.create_32bit(0)); { end of list marker }
|
|
||||||
ltvTable.concat(tai_symbol_end.createname(current_module.modulename^+'_$LOCALTHREADVARLIST'));
|
|
||||||
if (cs_create_smart in aktmoduleswitches) then
|
|
||||||
dataSegment.concat(Tai_cut.Create);
|
|
||||||
dataSegment.concatlist(ltvTable);
|
|
||||||
current_module.flags:=current_module.flags or uf_local_threadvars;
|
|
||||||
end;
|
|
||||||
ltvTable.Free;
|
|
||||||
|
|
||||||
{ the last char should always be a point }
|
{ the last char should always be a point }
|
||||||
consume(_POINT);
|
consume(_POINT);
|
||||||
|
|
||||||
|
{ generate a list of threadvars }
|
||||||
|
InsertThreadvars;
|
||||||
|
|
||||||
|
{ Generate resoucestrings }
|
||||||
If ResourceStrings.ResStrCount>0 then
|
If ResourceStrings.ResStrCount>0 then
|
||||||
begin
|
begin
|
||||||
ResourceStrings.CreateResourceStringList;
|
ResourceStrings.CreateResourceStringList;
|
||||||
@ -1261,7 +1289,6 @@ implementation
|
|||||||
aktprocdef.aliasnames.insert('PASCALMAIN');
|
aktprocdef.aliasnames.insert('PASCALMAIN');
|
||||||
aktprocdef.aliasnames.insert(target_info.cprefix+'main');
|
aktprocdef.aliasnames.insert(target_info.cprefix+'main');
|
||||||
end;
|
end;
|
||||||
insertLocalThreadvarsTablesTable;
|
|
||||||
compile_proc_body(true,false);
|
compile_proc_body(true,false);
|
||||||
|
|
||||||
{ should we force unit initialization? }
|
{ should we force unit initialization? }
|
||||||
@ -1341,19 +1368,21 @@ implementation
|
|||||||
tstoredsymtable(st).allprivatesused;
|
tstoredsymtable(st).allprivatesused;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ generate a list of threadvars }
|
||||||
|
InsertThreadvars;
|
||||||
|
|
||||||
{ generate imports }
|
{ generate imports }
|
||||||
if current_module.uses_imports then
|
if current_module.uses_imports then
|
||||||
importlib.generatelib;
|
importlib.generatelib;
|
||||||
|
|
||||||
if islibrary or
|
if islibrary or
|
||||||
(target_info.system in [system_i386_WIN32,system_i386_wdosx]) or
|
(target_info.system in [system_i386_WIN32,system_i386_wdosx]) or
|
||||||
(target_info.system=system_i386_NETWARE) then
|
(target_info.system=system_i386_NETWARE) then
|
||||||
exportlib.generatelib;
|
exportlib.generatelib;
|
||||||
|
|
||||||
|
{ insert Tables and Heap }
|
||||||
{ insert heap }
|
insertThreadVarTablesTable;
|
||||||
insertResourceTablesTable;
|
insertResourceTablesTable;
|
||||||
|
|
||||||
insertinitfinaltable;
|
insertinitfinaltable;
|
||||||
insertheap;
|
insertheap;
|
||||||
insertstacklength;
|
insertstacklength;
|
||||||
@ -1404,7 +1433,10 @@ implementation
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.80 2002-10-06 19:41:30 peter
|
Revision 1.81 2002-10-14 19:42:34 peter
|
||||||
|
* only use init tables for threadvars
|
||||||
|
|
||||||
|
Revision 1.80 2002/10/06 19:41:30 peter
|
||||||
* Add finalization of typed consts
|
* Add finalization of typed consts
|
||||||
* Finalization of globals in the main program
|
* Finalization of globals in the main program
|
||||||
|
|
||||||
|
@ -121,18 +121,18 @@ const
|
|||||||
uf_big_endian = $4;
|
uf_big_endian = $4;
|
||||||
uf_has_dbx = $8;
|
uf_has_dbx = $8;
|
||||||
uf_has_browser = $10;
|
uf_has_browser = $10;
|
||||||
uf_in_library = $20; { is the file in another file than <ppufile>.* ? }
|
uf_in_library = $20; { is the file in another file than <ppufile>.* ? }
|
||||||
uf_smart_linked = $40; { the ppu can be smartlinked }
|
uf_smart_linked = $40; { the ppu can be smartlinked }
|
||||||
uf_static_linked = $80; { the ppu can be linked static }
|
uf_static_linked = $80; { the ppu can be linked static }
|
||||||
uf_shared_linked = $100; { the ppu can be linked shared }
|
uf_shared_linked = $100; { the ppu can be linked shared }
|
||||||
uf_local_browser = $200;
|
uf_local_browser = $200;
|
||||||
uf_no_link = $400; { unit has no .o generated, but can still have
|
uf_no_link = $400; { unit has no .o generated, but can still have
|
||||||
external linking! }
|
external linking! }
|
||||||
uf_has_resources = $800; { unit has resource section }
|
uf_has_resources = $800; { unit has resource section }
|
||||||
uf_little_endian = $1000;
|
uf_little_endian = $1000;
|
||||||
uf_release = $2000;{ unit was compiled with -Ur option }
|
uf_release = $2000; { unit was compiled with -Ur option }
|
||||||
uf_local_threadvars = $4000; { unit has local threadvars }
|
uf_threadvars = $4000; { unit has threadvars }
|
||||||
uf_fpu_emulation = $8000; { this unit was compiled with fpu emulation on }
|
uf_fpu_emulation = $8000; { this unit was compiled with fpu emulation on }
|
||||||
|
|
||||||
type
|
type
|
||||||
ppureal=extended;
|
ppureal=extended;
|
||||||
@ -985,7 +985,10 @@ end;
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.26 2002-08-18 20:06:25 peter
|
Revision 1.27 2002-10-14 19:42:33 peter
|
||||||
|
* only use init tables for threadvars
|
||||||
|
|
||||||
|
Revision 1.26 2002/08/18 20:06:25 peter
|
||||||
* inlining is now also allowed in interface
|
* inlining is now also allowed in interface
|
||||||
* renamed write/load to ppuwrite/ppuload
|
* renamed write/load to ppuwrite/ppuload
|
||||||
* tnode storing in ppu
|
* tnode storing in ppu
|
||||||
|
Loading…
Reference in New Issue
Block a user