aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/exp_ch3.adb
diff options
context:
space:
mode:
authorJavier Miranda <miranda@adacore.com>2005-12-09 18:13:28 +0100
committerArnaud Charlet <charlet@gcc.gnu.org>2005-12-09 18:13:28 +0100
commit4d744221db2ca7b17e1734998d8fb9a7b67608ca (patch)
tree74694593470bc6398db1d8d5eb792064a2175c0a /gcc/ada/exp_ch3.adb
parente51b97bef78798d57a052a1a09ce8823aa926efd (diff)
downloadgcc-4d744221db2ca7b17e1734998d8fb9a7b67608ca.zip
gcc-4d744221db2ca7b17e1734998d8fb9a7b67608ca.tar.gz
gcc-4d744221db2ca7b17e1734998d8fb9a7b67608ca.tar.bz2
a-tags.ads, a-tags.adb (Offset_To_Top): Moved from the package body to the specification because the frontend generates...
2005-12-05 Javier Miranda <miranda@adacore.com> Hristian Kirtchev <kirtchev@adacore.com> * a-tags.ads, a-tags.adb (Offset_To_Top): Moved from the package body to the specification because the frontend generates code that uses this subprogram. (Set_Interface_Table): Add missing assertion. Update documentation describing the run-time structure. (Displace): New subprogram that displaces the pointer to the object to reference one of its secondary dispatch tables. (IW_Membership): Modified to use the new table of interfaces. (Inherit_TSD): Modified to use the new table of interfaces. (Register_Interface_Tag): Use the additional formal to fill the contents of the new table of interfaces. (Set_Interface_Table): New subprogram that stores in the TSD the pointer to the table of interfaces. (Set_Offset_To_Top): Use the additional formal to save copy of the offset value in the table of interfaces. Update structure of GNAT Primary and Secondary dispatch table diagram. Add comment section on GNAT dispatch table prologue. (Offset_To_Signature): Update the constant value of the Signature field. (Dispatch_Table): Update comment on hidden fields in the prologue. (Get_Entry_Index, Get_Prim_Op_Kind, Get_Offset_Index, OSD, Set_Entry_Index, Set_Offset_Index, Set_Prim_Op_Kind, SSD, TSD): Change the type of formal parameter T to Tag, introduce additional assertions. (Get_Num_Prim_Ops, Set_Num_Prim_Ops): Remove an unnecessary type conversion. (Get_Tagged_Kind, Set_Tagged_Kind): New bodies. * exp_ch6.adb (Register_Interface_DT_Entry): Remove the Thunk_Id actual in all the calls to Expand_Interface_Thunk. Instead of referencing the record component containing the tag of the secondary dispatch table we have to use the Offset_To_Top run-time function to get this information; otherwise if the pointer to the base of the object has been displace we get a wrong value if we use the 'position attribute. * exp_disp.adb (Expand_Interface_Thunk): Remove the Thunk_Id actual in all the calls to Expand_Interface_Thunk. (Make_Secondary_DT): Secondary dispatch tables do not have a table of interfaces; hence the call to Set_Interface_Table was clearly wrong. (Collect_All_Interfaces): Modify the internal subprogram Collect to ensure that the interfaces implemented by the ancestors are placed at the header of the generated list. (Expand_Interface_Conversion): Handle the case in which the displacement associated with the interface conversion is not statically known. In this case we generate a call to the new run-time subprogram Displace. (Make_DT): Generate and fill the new table of interfaces. (Ada_Actions, Action_Is_Proc, Action_Nb_Arg): Add entries for Get_Tagged_Kind and Set_Tagged_Kind. (Tagged_Kind): New function that determines the tagged kind of a type with respect to limitedness and concurrency and returns a reference to RE_Tagged_Kind. (Make_Disp_Asynchronous_Select_Body, Make_Disp_Conditional_Select_Body, Make_Disp_Timed_Select_Body): Correctly retrieve the pointer to the primary dispatch table for a type. (Make_DT, Make_Secondary_DT): Set the tagged kind in the primary and secondary dispatch table respectively of a tagged type. * exp_disp.ads (Expand_Interface_Thunk): Remove Thunk_Id formal. (Expand_Interface_Conversion): New subprogram to indicate if the displacement of the type conversion is statically known. (DT_Access_Action): Add values Get_Tagged_Kind and Set_Tagged_Kind. * rtsfind.ads (RE_Offset_To_Top): New entity (RTU_Id): Add Ada_Task_Termination to the list so that it is made accessible to users. (Re_Displace): New entity (RE_Interface_Data): New entity (RE_Set_Interface_Data): New_Entity (RE_Id, RE_Unit_Table): Add entry for RE_Get_Tagged_Kind, Set_Tagged_Kind, RE_Tagged_Kind, RE_TK_Abstract_Limited_Tagged, RE_TK_Abstract_Tagged, RE_TK_Limited_Tagged, RE_TK_Protected, RE_TK_Tagged, RE_TK_Task. * exp_ch3.adb (Init_Secondary_Tags): Modify the subprogram Init_Secondary_Tags_Internal to allow its use with interface types and also to generate the code for the new additional actual required by Set_Offset_To_Top. (Build_Init_Statements): In case of components associated with abstract interface types there is no need to generate a call to its IP. (Freeze_Record_Type): Generate Select Specific Data tables only for concurrent types. (Make_Predefined_Primitive_Specs, Predefined_Primitive_Bodies): Generate the bodies and specifications of the predefined primitive operations dealing with dispatching selects and abort, 'Callable, 'Terminated only for concurrent types. * exp_sel.ads, exp_sel.adb: New files. * exp_ch9.adb (Build_Protected_Entry, Expand_N_Protected_Body, Expand_N_Protected_Type_Declaration, Make_Initialize_Protection): Handle properly protected objects and attach handler in the case of the restricted profile. Move embeded package Select_Expansion_Utilities into a separate external package. (Expand_N_Asynchronous_Select, Expand_N_Conditional_Select, Expand_N_Timed_Entry_Call): Correct calls external package Exp_Sel. (Build_K, Build_S_Assignment): New subprograms, part of the select expansion utilities. (Expand_N_Asynchronous_Select, Expand_N_Conditional_Entry_Call, Expand_N_Timed_Entry_Call): Optimize expansion of select statements where the trigger is a dispatching procedure of a limited tagged type. From-SVN: r108284
Diffstat (limited to 'gcc/ada/exp_ch3.adb')
-rw-r--r--gcc/ada/exp_ch3.adb90
1 files changed, 47 insertions, 43 deletions
diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 3feb7d3..6a975e6 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -1760,20 +1760,18 @@ package body Exp_Ch3 is
procedure Init_Secondary_Tags_Internal (Typ : Entity_Id) is
E : Entity_Id;
Aux_N : Node_Id;
+ Iface : Entity_Id;
begin
- if not Is_Interface (Typ) then
+ -- Climb to the ancestor (if any) handling private types
- -- Climb to the ancestor (if any) handling private types
-
- if Present (Full_View (Etype (Typ))) then
- if Full_View (Etype (Typ)) /= Typ then
- Init_Secondary_Tags_Internal (Full_View (Etype (Typ)));
- end if;
-
- elsif Etype (Typ) /= Typ then
- Init_Secondary_Tags_Internal (Etype (Typ));
+ if Present (Full_View (Etype (Typ))) then
+ if Full_View (Etype (Typ)) /= Typ then
+ Init_Secondary_Tags_Internal (Full_View (Etype (Typ)));
end if;
+
+ elsif Etype (Typ) /= Typ then
+ Init_Secondary_Tags_Internal (Etype (Typ));
end if;
if Present (Abstract_Interfaces (Typ))
@@ -1787,6 +1785,8 @@ package body Exp_Ch3 is
Aux_N := Node (ADT);
pragma Assert (Present (Aux_N));
+ Iface := Find_Interface (Typ, E);
+
-- Initialize the pointer to the secondary DT
-- associated with the interface
@@ -1801,15 +1801,23 @@ package body Exp_Ch3 is
New_Reference_To (Aux_N, Loc)));
-- Generate:
- -- Set_Offset_To_Top (DT_Ptr, n);
+ -- Set_Offset_To_Top (Init, Iface'Tag, n);
Append_To (Body_Stmts,
Make_Procedure_Call_Statement (Loc,
Name => New_Reference_To
(RTE (RE_Set_Offset_To_Top), Loc),
Parameter_Associations => New_List (
+ Make_Attribute_Reference (Loc,
+ Prefix => Make_Identifier (Loc, Name_uInit),
+ Attribute_Name => Name_Address),
+
Unchecked_Convert_To (RTE (RE_Tag),
- New_Reference_To (Aux_N, Loc)),
+ New_Reference_To
+ (Node (First_Elmt
+ (Access_Disp_Table (Iface))),
+ Loc)),
+
Unchecked_Convert_To (RTE (RE_Storage_Offset),
Make_Attribute_Reference (Loc,
Prefix =>
@@ -2118,7 +2126,9 @@ package body Exp_Ch3 is
-- Case of composite component with its own Init_Proc
- elsif Has_Non_Null_Base_Init_Proc (Typ) then
+ elsif not Is_Interface (Typ)
+ and then Has_Non_Null_Base_Init_Proc (Typ)
+ then
Stmts :=
Build_Initialization_Call
(Loc,
@@ -4743,18 +4753,15 @@ package body Exp_Ch3 is
Append_Freeze_Actions (Def_Id, Predef_List);
-- Populate the two auxiliary tables used for dispatching
- -- asynchronous, conditional and timed selects for tagged
+ -- asynchronous, conditional and timed selects for synchronized
-- types that implement a limited interface.
if Ada_Version >= Ada_05
- and then not Is_Interface (Def_Id)
- and then not Is_Abstract (Def_Id)
- and then not Is_Controlled (Def_Id)
- and then
- Implements_Interface
- (Typ => Def_Id,
- Kind => Any_Limited_Interface,
- Check_Parent => True)
+ and then Is_Concurrent_Record_Type (Def_Id)
+ and then Implements_Interface (
+ Typ => Def_Id,
+ Kind => Any_Limited_Interface,
+ Check_Parent => True)
then
Append_Freeze_Actions (Def_Id,
Make_Select_Specific_Data_Table (Def_Id));
@@ -5950,26 +5957,25 @@ package body Exp_Ch3 is
end if;
-- Generate the declarations for the following primitive operations:
+
-- disp_asynchronous_select
-- disp_conditional_select
-- disp_get_prim_op_kind
-- disp_get_task_id
-- disp_timed_select
- -- for limited interfaces and tagged types that implement a limited
- -- interface.
+
+ -- for limited interfaces and synchronized types that implement a
+ -- limited interface.
if Ada_Version >= Ada_05
and then
- ((Is_Interface (Tag_Typ)
- and then Is_Limited_Record (Tag_Typ))
- or else
- (not Is_Abstract (Tag_Typ)
- and then not Is_Controlled (Tag_Typ)
- and then
- Implements_Interface
- (Typ => Tag_Typ,
- Kind => Any_Limited_Interface,
- Check_Parent => True)))
+ ((Is_Interface (Tag_Typ) and then Is_Limited_Record (Tag_Typ))
+ or else
+ (Is_Concurrent_Record_Type (Tag_Typ)
+ and then Implements_Interface (
+ Typ => Tag_Typ,
+ Kind => Any_Limited_Interface,
+ Check_Parent => True)))
then
Append_To (Res,
Make_Subprogram_Declaration (Loc,
@@ -6360,20 +6366,18 @@ package body Exp_Ch3 is
-- disp_get_task_id
-- disp_timed_select
- -- for limited interfaces and tagged types that implement a limited
- -- interface. The interface versions will have null bodies.
+ -- for limited interfaces and synchronized types that implement a
+ -- limited interface. The interface versions will have null bodies.
if Ada_Version >= Ada_05
and then
((Is_Interface (Tag_Typ) and then Is_Limited_Record (Tag_Typ))
or else
- (not Is_Abstract (Tag_Typ)
- and then not Is_Controlled (Tag_Typ)
- and then
- Implements_Interface
- (Typ => Tag_Typ,
- Kind => Any_Limited_Interface,
- Check_Parent => True)))
+ (Is_Concurrent_Record_Type (Tag_Typ)
+ and then Implements_Interface (
+ Typ => Tag_Typ,
+ Kind => Any_Limited_Interface,
+ Check_Parent => True)))
then
Append_To (Res, Make_Disp_Asynchronous_Select_Body (Tag_Typ));
Append_To (Res, Make_Disp_Conditional_Select_Body (Tag_Typ));