* revert r9557, the performance impact is to big for an academic corner

case optimziation

git-svn-id: trunk@9603 -
This commit is contained in:
peter 2007-12-31 13:36:16 +00:00
parent 621492c968
commit 5acb3649df
20 changed files with 52 additions and 45 deletions

View File

@ -385,6 +385,7 @@ begin
InOutRes:=0;
{ Arguments }
GenerateArgs;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
end.

View File

@ -411,6 +411,7 @@ begin
SysInitStdIO;
{ Reset IO Error }
InOutRes:=0;
InitSystemThreads;
{$ifdef HASVARIANT}
initvariantmanager;
{$endif HASVARIANT}

View File

@ -294,6 +294,8 @@ Begin
InOutRes:=0;
{ Arguments }
SetupCmdLine;
{ threading }
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
End.

View File

@ -298,6 +298,11 @@ begin
InOutRes:=0;
{$endif FPC_HAS_FEATURE_CONSOLEIO}
{$ifdef FPC_HAS_FEATURE_THREADING}
{ threading }
InitSystemThreads;
{$endif FPC_HAS_FEATURE_THREADING}
{$ifdef FPC_HAS_FEATURE_VARIANTS}
initvariantmanager;
{$endif FPC_HAS_FEATURE_VARIANTS}

View File

@ -577,6 +577,8 @@ begin
{ no I/O-Error }
inoutres:=0;
InitSystemThreads;
InitVariantManager;
{$ifdef HASWIDESTRING}

View File

@ -146,5 +146,7 @@ begin
SysInitStdIO;
{ Reset IO Error }
InOutRes:=0;
{ Arguments }
InitSystemThreads;
initvariantmanager;
end.

View File

@ -656,6 +656,9 @@ Begin
AllFilesMask := '*.*';
{ Reset IO Error }
InOutRes:=0;
{$ifdef FPC_HAS_FEATURE_THREADING}
InitSystemThreads;
{$endif}
{$ifdef EXCEPTIONS_IN_SYSTEM}
InitDPMIExcp;
InstallDefaultHandlers;

View File

@ -395,22 +395,6 @@ procedure finish_waitvarlist(loc_freelists: pfreelists); forward;
function try_finish_waitfixedlist(loc_freelists: pfreelists): boolean; forward;
procedure try_finish_waitvarlist(loc_freelists: pfreelists); forward;
var
fTM: TThreadManager; external name 'fCurrentTM';
procedure do_heap_lock;
begin
if Assigned(fTM.EnterCriticalSection) then
fTM.EnterCriticalSection(heap_lock);
end;
procedure do_heap_unlock;
begin
if Assigned(fTM.LeaveCriticalSection) then
fTM.LeaveCriticalSection(heap_lock);
end;
{*****************************************************************************
List adding/removal
*****************************************************************************}
@ -750,7 +734,7 @@ begin
if not assigned(poc) and (assigned(orphaned_freelists.waitfixed)
or assigned(orphaned_freelists.waitvar) or (orphaned_freelists.oscount > 0)) then
begin
do_heap_lock;
entercriticalsection(heap_lock);
finish_waitfixedlist(@orphaned_freelists);
finish_waitvarlist(@orphaned_freelists);
if orphaned_freelists.oscount > 0 then
@ -774,7 +758,7 @@ begin
loc_freelists^.oslist_all := poc;
end;
end;
do_heap_unlock;
leavecriticalsection(heap_lock);
end;
if poc = nil then
begin
@ -1035,18 +1019,18 @@ end;
procedure waitfree_fixed(pmc: pmemchunk_fixed; poc: poschunk);
begin
do_heap_lock;
entercriticalsection(heap_lock);
pmc^.next_fixed := poc^.freelists^.waitfixed;
poc^.freelists^.waitfixed := pmc;
do_heap_unlock;
leavecriticalsection(heap_lock);
end;
procedure waitfree_var(pmcv: pmemchunk_var);
begin
do_heap_lock;
entercriticalsection(heap_lock);
pmcv^.next_var := pmcv^.freelists^.waitvar;
pmcv^.freelists^.waitvar := pmcv;
do_heap_unlock;
leavecriticalsection(heap_lock);
end;
function SysFreeMem_Fixed(loc_freelists: pfreelists; pmc: pmemchunk_fixed): ptruint;
@ -1157,9 +1141,9 @@ function try_finish_waitfixedlist(loc_freelists: pfreelists): boolean;
begin
if loc_freelists^.waitfixed = nil then
exit(false);
do_heap_lock;
entercriticalsection(heap_lock);
finish_waitfixedlist(loc_freelists);
do_heap_unlock;
leavecriticalsection(heap_lock);
result := true;
end;
@ -1181,9 +1165,9 @@ procedure try_finish_waitvarlist(loc_freelists: pfreelists);
begin
if loc_freelists^.waitvar = nil then
exit;
do_heap_lock;
entercriticalsection(heap_lock);
finish_waitvarlist(loc_freelists);
do_heap_unlock;
leavecriticalsection(heap_lock);
end;
{*****************************************************************************
@ -1447,7 +1431,7 @@ begin
loc_freelists := @freelists;
if main_relo_freelists <> nil then
begin
do_heap_lock;
entercriticalsection(heap_lock);
finish_waitfixedlist(loc_freelists);
finish_waitvarlist(loc_freelists);
{$ifdef HAS_SYSOSFREE}
@ -1479,9 +1463,9 @@ begin
orphaned_freelists.oslist_all := loc_freelists^.oslist_all;
end;
end;
do_heap_unlock;
if (main_relo_freelists = loc_freelists) and Assigned(fTM.DoneCriticalSection) then
fTM.DoneCriticalSection(heap_lock);
leavecriticalsection(heap_lock);
if main_relo_freelists = loc_freelists then
donecriticalsection(heap_lock);
end;
{$ifdef SHOW_MEM_USAGE}
writeln('Max heap used/size: ', loc_freelists^.internal_status.maxheapused, '/',

View File

@ -15,16 +15,7 @@
Var
fCurrentTM : TThreadManager; public;
Procedure InitSystemThreads; forward;
function CurrentTM : TThreadManager;
begin
if not Assigned(fCurrentTM.BeginThread) then
InitSystemThreads;
Result:=fCurrentTM;
end;
CurrentTM : TThreadManager;
{*****************************************************************************
Threadvar initialization
@ -221,13 +212,13 @@ Function SetThreadManager(Const NewTM : TThreadManager) : Boolean;
begin
Result:=True;
If Assigned(fCurrentTM.DoneManager) then
Result:=fCurrentTM.DoneManager();
If Assigned(CurrentTM.DoneManager) then
Result:=CurrentTM.DoneManager();
If Result then
begin
fCurrentTM:=NewTM;
If Assigned(fCurrentTM.InitManager) then
Result:=fCurrentTM.InitManager();
CurrentTM:=NewTM;
If Assigned(CurrentTM.InitManager) then
Result:=CurrentTM.InitManager();
end;
end;

View File

@ -333,6 +333,8 @@ begin
SysInitExecPath;
{ Reset IO Error }
InOutRes:=0;
{ threading }
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
end.

View File

@ -553,6 +553,7 @@ begin
{ Reset IO Error }
InOutRes:=0;
errno:=0;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;

View File

@ -417,6 +417,7 @@ begin
InOutRes:=0;
{ Arguments }
GenerateArgs;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
end.

View File

@ -173,5 +173,7 @@ begin
SysInitStdIO;
{ Reset IO Error }
InOutRes:=0;
{ Arguments }
InitSystemThreads;
initvariantmanager;
end.

View File

@ -477,6 +477,7 @@ Begin
IsLibrary := FALSE;
IsConsole := TRUE;
ExitCode := 0;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
End.

View File

@ -547,6 +547,7 @@ Begin
{Delphi Compatible}
IsConsole := TRUE;
ExitCode := 0;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
End.

View File

@ -1190,6 +1190,7 @@ begin
DefaultCreator := '';
DefaultFileType := '';
InitSystemThreads;
InitVariantManager;
{$ifdef HASWIDESTRING}

View File

@ -229,6 +229,7 @@ Begin
InOutRes:=0;
{ Arguments }
SetupCmdLine;
InitSystemThreads;
initvariantmanager;
initwidestringmanager;
End.

View File

@ -1219,6 +1219,8 @@ begin
{ Reset IO Error }
InOutRes:=0;
ProcessID := GetCurrentProcessID;
{ threading }
InitSystemThreads;
{ Reset internal error variable }
errno:=0;
initvariantmanager;

View File

@ -1172,6 +1172,8 @@ begin
{ Reset IO Error }
InOutRes:=0;
ProcessID := GetCurrentProcessID;
{ threading }
InitSystemThreads;
{ Reset internal error variable }
errno:=0;
initvariantmanager;

View File

@ -1812,6 +1812,8 @@ initialization
{ Reset IO Error }
InOutRes:=0;
ProcessID := GetCurrentProcessID;
{ threading }
InitSystemThreads;
{ Reset internal error variable }
errno:=0;
initvariantmanager;