Commit d4731b80 by Bob Duff Committed by Arnaud Charlet

sem_case.adb, [...]: Replace use of Heap_Sort_A (passing'Unrestricted_Access of…

sem_case.adb, [...]: Replace use of Heap_Sort_A (passing'Unrestricted_Access of nested subprograms...

2007-10-15  Bob Duff  <duff@adacore.com>

	* sem_case.adb, sem_ch13.adb, lib-sort.adb: Replace use of Heap_Sort_A
	(passing'Unrestricted_Access of nested subprograms to Sort) with use of
	the generic Heap_Sort_G, in order to avoid trampolines.

From-SVN: r129327
parent 28eba57c
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
-- -- -- --
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A; with GNAT.Heap_Sort_G;
separate (Lib) separate (Lib)
procedure Sort (Tbl : in out Unit_Ref_Table) is procedure Sort (Tbl : in out Unit_Ref_Table) is
...@@ -48,6 +48,8 @@ procedure Sort (Tbl : in out Unit_Ref_Table) is ...@@ -48,6 +48,8 @@ procedure Sort (Tbl : in out Unit_Ref_Table) is
procedure Move_Uname (From : Natural; To : Natural); procedure Move_Uname (From : Natural; To : Natural);
-- Move routine needed by the sorting routine below -- Move routine needed by the sorting routine below
package Sorting is new GNAT.Heap_Sort_G (Move_Uname, Lt_Uname);
-------------- --------------
-- Lt_Uname -- -- Lt_Uname --
-------------- --------------
...@@ -88,8 +90,7 @@ begin ...@@ -88,8 +90,7 @@ begin
T (I) := Tbl (Int (I) - 1 + Tbl'First); T (I) := Tbl (Int (I) - 1 + Tbl'First);
end loop; end loop;
Sort (T'Last, Sorting.Sort (T'Last);
Move_Uname'Unrestricted_Access, Lt_Uname'Unrestricted_Access);
-- Sort is complete, copy result back into place -- Sort is complete, copy result back into place
......
...@@ -41,7 +41,7 @@ with Sinfo; use Sinfo; ...@@ -41,7 +41,7 @@ with Sinfo; use Sinfo;
with Tbuild; use Tbuild; with Tbuild; use Tbuild;
with Uintp; use Uintp; with Uintp; use Uintp;
with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A; with GNAT.Heap_Sort_G;
package body Sem_Case is package body Sem_Case is
...@@ -104,6 +104,8 @@ package body Sem_Case is ...@@ -104,6 +104,8 @@ package body Sem_Case is
procedure Move_Choice (From : Natural; To : Natural); procedure Move_Choice (From : Natural; To : Natural);
-- Move routine for sorting the Choice_Table -- Move routine for sorting the Choice_Table
package Sorting is new GNAT.Heap_Sort_G (Move_Choice, Lt_Choice);
procedure Issue_Msg (Value1 : Node_Id; Value2 : Node_Id); procedure Issue_Msg (Value1 : Node_Id; Value2 : Node_Id);
procedure Issue_Msg (Value1 : Node_Id; Value2 : Uint); procedure Issue_Msg (Value1 : Node_Id; Value2 : Uint);
procedure Issue_Msg (Value1 : Uint; Value2 : Node_Id); procedure Issue_Msg (Value1 : Uint; Value2 : Node_Id);
...@@ -215,10 +217,7 @@ package body Sem_Case is ...@@ -215,10 +217,7 @@ package body Sem_Case is
return; return;
end if; end if;
Sort Sorting.Sort (Positive (Choice_Table'Last));
(Positive (Choice_Table'Last),
Move_Choice'Unrestricted_Access,
Lt_Choice'Unrestricted_Access);
Lo := Expr_Value (Choice_Table (1).Lo); Lo := Expr_Value (Choice_Table (1).Lo);
Hi := Expr_Value (Choice_Table (1).Hi); Hi := Expr_Value (Choice_Table (1).Hi);
......
...@@ -54,7 +54,7 @@ with Ttypes; use Ttypes; ...@@ -54,7 +54,7 @@ with Ttypes; use Ttypes;
with Tbuild; use Tbuild; with Tbuild; use Tbuild;
with Urealp; use Urealp; with Urealp; use Urealp;
with GNAT.Heap_Sort_A; use GNAT.Heap_Sort_A; with GNAT.Heap_Sort_G;
package body Sem_Ch13 is package body Sem_Ch13 is
...@@ -296,13 +296,15 @@ package body Sem_Ch13 is ...@@ -296,13 +296,15 @@ package body Sem_Ch13 is
declare declare
Comps : array (0 .. Num_CC) of Entity_Id; Comps : array (0 .. Num_CC) of Entity_Id;
-- Array to collect component and discrimninant entities. The data -- Array to collect component and discrimninant entities. The data
-- starts at index 1, the 0'th entry is for GNAT.Heap_Sort_A. -- starts at index 1, the 0'th entry is for the sort routine.
function CP_Lt (Op1, Op2 : Natural) return Boolean; function CP_Lt (Op1, Op2 : Natural) return Boolean;
-- Compare routine for Sort (See GNAT.Heap_Sort_A) -- Compare routine for Sort
procedure CP_Move (From : Natural; To : Natural); procedure CP_Move (From : Natural; To : Natural);
-- Move routine for Sort (see GNAT.Heap_Sort_A) -- Move routine for Sort
package Sorting is new GNAT.Heap_Sort_G (CP_Move, CP_Lt);
Start : Natural; Start : Natural;
Stop : Natural; Stop : Natural;
...@@ -353,7 +355,7 @@ package body Sem_Ch13 is ...@@ -353,7 +355,7 @@ package body Sem_Ch13 is
-- Sort by ascending position number -- Sort by ascending position number
Sort (Num_CC, CP_Move'Unrestricted_Access, CP_Lt'Unrestricted_Access); Sorting.Sort (Num_CC);
-- We now have all the components whose size does not exceed the max -- We now have all the components whose size does not exceed the max
-- machine scalar value, sorted by starting position. In this loop -- machine scalar value, sorted by starting position. In this loop
...@@ -1107,7 +1109,7 @@ package body Sem_Ch13 is ...@@ -1107,7 +1109,7 @@ package body Sem_Ch13 is
if VM_Target = No_VM then if VM_Target = No_VM then
Set_Has_External_Tag_Rep_Clause (U_Ent); Set_Has_External_Tag_Rep_Clause (U_Ent);
else elsif not Inspector_Mode then
Error_Msg_Name_1 := Attr; Error_Msg_Name_1 := Attr;
Error_Msg_N Error_Msg_N
("% attribute unsupported in this configuration", Nam); ("% attribute unsupported in this configuration", Nam);
...@@ -1170,7 +1172,9 @@ package body Sem_Ch13 is ...@@ -1170,7 +1172,9 @@ package body Sem_Ch13 is
when Attribute_Object_Size => Object_Size : declare when Attribute_Object_Size => Object_Size : declare
Size : constant Uint := Static_Integer (Expr); Size : constant Uint := Static_Integer (Expr);
Biased : Boolean; Biased : Boolean;
pragma Warnings (Off, Biased);
begin begin
if not Is_Type (U_Ent) then if not Is_Type (U_Ent) then
...@@ -2438,10 +2442,12 @@ package body Sem_Ch13 is ...@@ -2438,10 +2442,12 @@ package body Sem_Ch13 is
-- Count of entries in OC_Fbit and OC_Lbit -- Count of entries in OC_Fbit and OC_Lbit
function OC_Lt (Op1, Op2 : Natural) return Boolean; function OC_Lt (Op1, Op2 : Natural) return Boolean;
-- Compare routine for Sort (See GNAT.Heap_Sort_A) -- Compare routine for Sort
procedure OC_Move (From : Natural; To : Natural); procedure OC_Move (From : Natural; To : Natural);
-- Move routine for Sort (see GNAT.Heap_Sort_A) -- Move routine for Sort
package Sorting is new GNAT.Heap_Sort_G (OC_Move, OC_Lt);
function OC_Lt (Op1, Op2 : Natural) return Boolean is function OC_Lt (Op1, Op2 : Natural) return Boolean is
begin begin
...@@ -2476,10 +2482,7 @@ package body Sem_Ch13 is ...@@ -2476,10 +2482,7 @@ package body Sem_Ch13 is
Next (CC); Next (CC);
end loop; end loop;
Sort Sorting.Sort (OC_Count);
(OC_Count,
OC_Move'Unrestricted_Access,
OC_Lt'Unrestricted_Access);
Overlap_Check_Required := False; Overlap_Check_Required := False;
for J in 1 .. OC_Count - 1 loop for J in 1 .. OC_Count - 1 loop
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment