aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2016-03-15 07:43:53 +0100
committerTristan Gingold <tgingold@free.fr>2016-03-15 07:43:53 +0100
commitc14f26236d1d3cbdf6d0503f19d0a6a69907d35a (patch)
tree489467daed506425aa8f53dae5587d1a11a5d8a8
parent309014dcb97559210e561399757ccee01601a140 (diff)
downloadghdl-c14f26236d1d3cbdf6d0503f19d0a6a69907d35a.tar.gz
ghdl-c14f26236d1d3cbdf6d0503f19d0a6a69907d35a.tar.bz2
ghdl-c14f26236d1d3cbdf6d0503f19d0a6a69907d35a.zip
Improve behaviour of secondary stack.
Fix speed issue of bug040.
-rw-r--r--src/grt/grt-stack2.adb14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/grt/grt-stack2.adb b/src/grt/grt-stack2.adb
index 0ac25f5b7..00698d51c 100644
--- a/src/grt/grt-stack2.adb
+++ b/src/grt/grt-stack2.adb
@@ -57,26 +57,24 @@ package body Grt.Stack2 is
function Mark (S : Stack2_Ptr) return Mark_Id
is
- S2 : Stack2_Acc;
+ S2 : constant Stack2_Acc := To_Acc (S);
begin
- S2 := To_Acc (S);
return S2.Top;
end Mark;
procedure Release (S : Stack2_Ptr; Mark : Mark_Id)
is
- S2 : Stack2_Acc;
+ S2 : constant Stack2_Acc := To_Acc (S);
begin
- S2 := To_Acc (S);
S2.Top := Mark;
end Release;
function Allocate (S : Stack2_Ptr; Size : Ghdl_Index_Type)
- return System.Address
+ return System.Address
is
pragma Suppress (All_Checks);
- S2 : Stack2_Acc;
+ S2 : constant Stack2_Acc := To_Acc (S);
Chunk : Chunk_Acc;
N_Chunk : Chunk_Acc;
@@ -86,8 +84,6 @@ package body Grt.Stack2 is
Res : System.Address;
begin
- S2 := To_Acc (S);
-
-- Find the chunk to which S2.TOP belong.
Chunk := S2.First_Chunk;
loop
@@ -98,7 +94,7 @@ package body Grt.Stack2 is
if Chunk /= null then
-- If there is enough place in it, allocate from the chunk.
- if S2.Top + Max_Size <= Chunk.Last then
+ if Max_Size <= Chunk.Last - S2.Top + 1 then
Res := Chunk.Mem (S2.Top)'Address;
S2.Top := S2.Top + Max_Size;
return Res;