diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-01-23 12:54:52 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-13 10:03:30 +0200 |
commit | c8e01e79224ff2ebd2e488ecb4243874b6ff3d6b (patch) | |
tree | 8ef89fa213404d8ff608e07d2baf53868dfad0eb /gcc/ada/libgnat/s-stposu.ads | |
parent | eff0e268f4b1c4d8783f1da4e8a54028a3e28a1a (diff) | |
download | gcc-c8e01e79224ff2ebd2e488ecb4243874b6ff3d6b.zip gcc-c8e01e79224ff2ebd2e488ecb4243874b6ff3d6b.tar.gz gcc-c8e01e79224ff2ebd2e488ecb4243874b6ff3d6b.tar.bz2 |
ada: Replace finalization masters with finalization collections
This change replaces finalization masters with finalization collections in
most cases, that is to say, when they implement a list of objects created
by allocators of a given access type; indeed the moniker is overloaded in
the front-end, e.g. Sem_Util.Is_Master determines if a node "constitutes
a finalization master" but is not affected by the change.
This is mostly a renaming at this stage, toward something more in keeping
with the terminology used in the RM 7.6.1 clause and no functional changes:
although it gets rid of the rest of the System.Finalization_Masters unit,
the functionalities are reimplemented in the System.Finalization_Primitives
unit in terms of collections with only minor adjustments.
gcc/ada/
* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Remove s-finmas$(objext).
* einfo.ads (Anonymous_Masters): Rename into Anonymous_Collections.
(Finalization_Master): Rename into Finalization_Collection.
* gen_il-fields.ads (Opt_Field_Enum): Replace Anonymous_Masters
with Anonymous_Collections; and Finalization_Master with
Finalization_Collection.
* gen_il-gen-gen_entities.adb (Access_Kind): Likewise.
(E_Function): Likewise.
(E_Procedure): Likewise.
(E_Package): Likewise.
(E_Subprogram_Body): Likewise.
* exp_ch3.adb (Build_Heap_Or_Pool_Allocator): Adjust to renamings.
(Freeze_Type): Likewise.
(Stream_Operation_OK): Remove obsolete test.
* exp_ch4.adb (Expand_Allocator_Expression): Adjust to renamings.
(Expand_N_Allocator): Likewise.
* exp_ch6.ads (BIP_Formal_Kind): Replace BIP_Finalization_Master
with BIP_Collection.
(Needs_BIP_Finalization_Master): Rename into...
(Needs_BIP_Collection): ...this.
* exp_ch6.adb (BIP_Finalization_Master_Suffix): Delete.
(BIP_Collection_Suffix): New constant string.
(Add_Finalization_Master_Actual_To_Build_In_Place_Call): Rename to
(Add_Collection_Actual_To_Build_In_Place_Call): ...this and adjust.
(BIP_Formal_Suffix): Replace BIP_Finalization_Master alternative
with BIP_Collection alternative.
(BIP_Suffix_Kind): Replace test on BIP_Finalization_Master_Suffix
with test on BIP_Collection_Suffix.
(Is_Build_In_Place_Entity): Likewise.
(Make_Build_In_Place_Call_In_Allocator): Call Needs_BIP_Collection
and Add_Collection_Actual_To_Build_In_Place_Call.
(Make_Build_In_Place_Call_In_Anonymous_Context): Likewise.
(Make_Build_In_Place_Call_In_Assignment): Likewise.
(Make_Build_In_Place_Call_In_Object_Declaration): Likewise.
(Needs_BIP_Finalization_Master): Rename into...
(Needs_BIP_Collection): ...this.
(Needs_BIP_Alloc_Form): Call Needs_BIP_Collection.
* exp_ch7.ads (Build_Anonymous_Master): Rename into...
(Build_Anonymous_Collection): ...this.
(Build_Finalization_Master): Rename into...
(Build_Finalization_Collection): ...this.
* exp_ch7.adb (Allows_Finalization_Master): Rename into...
(Allows_Finalization_Collection): ...this.
(Build_BIP_Cleanup_Stmts): Adjust to renamings.
(Build_Anonymous_Master): Rename into...
(Build_Anonymous_Collection): ...this. Adjust to renamings.
(Build_Finalization_Master): Rename into...
(Build_Finalization_Collection): ...this. Adjust to renamings.
(Build_Finalizer): Adjust comment to renamings.
* exp_ch13.adb (Expand_N_Free_Statement): Adjust to renamings.
* exp_util.adb (Build_Allocate_Deallocate_Proc): Likewise.
(Requires_Cleanup_Actions): Adjust comment to renamings.
* freeze.adb (Freeze_All): Likewise.
* rtsfind.ads (RTU_Id): Remove System_Finalization_Masters.
(RE_Id): Remove RE_Finalization_Master & RE_Finalization_Master_Ptr
add RE_Finalization_Collection & RE_Finalization_Collection_Ptr.
Adjust RE_Add_Offset_To_Address and RE_Finalization_Scope_Master.
(RE_Unit_Table): Remove entries for RE_Finalization_Master &
RE_Finalization_Master_Ptr, add ones for RE_Finalization_Collection
& RE_Finalization_Collection_Ptr. Also adjust those of
RE_Add_Offset_To_Address and RE_Finalization_Scope_Master.
* sem_ch3.adb (Access_Type_Declaration): Adjust to renamings.
* sem_ch6.adb (Create_Extra_Formals): Likewise.
* sem_util.adb (Designated_Subtype_Mark): Likewise.
* libgnat/s-finpri.ads: Add clauses for Ada.Finalization and
System.Storage_Elements.
(Finalization_Collection): New limited controlled type.
(Finalization_Collection_Ptr): Likewise.
(Initialize): New overriding procedure.
(Finalize): Likewise.
(Finalization_Started): Likewise.
(Collection_Node): New type.
(Collection_Node_Ptr): Likewise.
(Attach_Node_To_Collection): New procedure.
(Detach_Node_From_Collection): Likewise.
(Header_Size): New function.
(Add_Offset_To_Address): Likewise.
* libgnat/s-finpri.adb (Add_Offset_To_Address): New function.
(Attach_Node_To_Collection): New procedure.
(Detach_Node_From_Collection): Likewise.
(Finalization_Started): Likewise.
(Finalize): New overriding procedure.
(Header_Size): New function.
(Initialize): New overriding procedure.
* libgnat/s-spsufi.ads (Finalize_And_Deallocate): Adjust comment.
* libgnat/s-spsufi.adb: Remove clause for Finalization_Masters and
add clause for Finalization_Primitives.
(Finalize_And_Deallocate): Finalize the Collection component.
* libgnat/s-stposu.ads: Remove clause for Finalization_Masters and
add clause for Finalization_Primitives.
(Root_Subpool): Replace Master component with Collection.
(Allocate_Any_Controlled): Replace Context_Master parameter with
Context_Collection parameter.
* libgnat/s-stposu.adb: Remove clauses for Finalization_Masters and
add clauses for Finalization_Primitives.
(Address_To_FM_Node_Ptr): Delete.
(To_Collection_Node_Ptr): New instance of Ada.Unchecked_Conversion.
(Adjust_Controlled_Dereference): Adjust comment to renamings.
(Allocate_Any_Controlled): Replace Context_Master parameter with
Context_Collection parameter. Adjust to renamings.
(Deallocate_Any_Controlled): Adjust to renamings.
(Print_Subpool): Likewise.
* libgnat/s-finmas.ads: Delete.
* libgnat/s-finmas.adb: Likewise.
Diffstat (limited to 'gcc/ada/libgnat/s-stposu.ads')
-rw-r--r-- | gcc/ada/libgnat/s-stposu.ads | 109 |
1 files changed, 44 insertions, 65 deletions
diff --git a/gcc/ada/libgnat/s-stposu.ads b/gcc/ada/libgnat/s-stposu.ads index 823f5e5..f3b908d 100644 --- a/gcc/ada/libgnat/s-stposu.ads +++ b/gcc/ada/libgnat/s-stposu.ads @@ -34,7 +34,7 @@ ------------------------------------------------------------------------------ with Ada.Finalization; -with System.Finalization_Masters; +with System.Finalization_Primitives; with System.Storage_Elements; package System.Storage_Pools.Subpools is @@ -130,32 +130,8 @@ package System.Storage_Pools.Subpools is (System.Storage_Elements.Storage_Count'Last); private - -- Model - -- Pool_With_Subpools SP_Node SP_Node SP_Node - -- +-->+--------------------+ +-----+ +-----+ +-----+ - -- | | Subpools -------->| ------->| ------->| -------> - -- | +--------------------+ +-----+ +-----+ +-----+ - -- | |Finalization_Started|<------ |<------- |<------- |<--- - -- | +--------------------+ +-----+ +-----+ +-----+ - -- +--- Controller.Encl_Pool| | nul | | + | | + | - -- | +--------------------+ +-----+ +--|--+ +--:--+ - -- | : : Dummy | ^ : - -- | : : | | : - -- | Root_Subpool V | - -- | +-------------+ | - -- +-------------------------------- Owner | | - -- FM_Node FM_Node +-------------+ | - -- +-----+ +-----+<-- Master.Objects| | - -- <------ |<------ | +-------------+ | - -- +-----+ +-----+ | Node -------+ - -- | ------>| -----> +-------------+ - -- +-----+ +-----+ : : - -- |ctrl | Dummy : : - -- | obj | - -- +-----+ - -- - -- SP_Nodes are created on the heap. FM_Nodes and associated objects are - -- created on the pool_with_subpools. + -- SP_Nodes are created on the heap, while collection nodes and associated + -- objects are created on the pool_with_subpools. type Any_Storage_Pool_With_Subpools_Ptr is access all Root_Storage_Pool_With_Subpools'Class; @@ -205,7 +181,7 @@ private Finalization_Started : Boolean := False; pragma Atomic (Finalization_Started); - -- A flag which prevents the creation of new subpools while the master + -- A flag which prevents the creation of new subpools while the parent -- pool is being finalized. The flag needs to be atomic because it is -- accessed without Lock_Task / Unlock_Task. @@ -219,32 +195,35 @@ private -- contains links to all controlled objects allocated on a particular -- subpool. - -- Pool_With_Subpools SP_Node SP_Node SP_Node - -- +-->+----------------+ +-----+ +-----+ +-----+ - -- | | Subpools ------>| ------->| ------->| -------> - -- | +----------------+ +-----+ +-----+ +-----+ - -- | : :<------ |<------- |<------- | - -- | : : +-----+ +-----+ +-----+ - -- | |null | | + | | + | - -- | +-----+ +--|--+ +--:--+ - -- | | ^ : - -- | Root_Subpool V | - -- | +-------------+ | - -- +---------------------------- Owner | | - -- +-------------+ | - -- .......... Master | | - -- +-------------+ | - -- | Node -------+ - -- +-------------+ - -- : End-user : - -- : components : + -- Pool_With_Subpools SP_Node SP_Node SP_Node + -- +-->+--------------------+ +-----+ +-----+ +-----+ + -- | | Subpools -------->| ------->| ------->| -------> + -- | +--------------------+ +-----+ +-----+ +-----+ + -- | |Finalization_Started|<------ |<------- |<------- |<--- + -- | +--------------------+ +-----+ +-----+ +-----+ + -- +--- Controller.Encl_Pool| | nul | | + | | + | + -- | +--------------------+ +-----+ +--|--+ +--:--+ + -- | : : Dummy | ^ : + -- | : : | | : + -- | Root_Subpool V | + -- | +-------------+ | + -- +-------------------------------- Owner | | + -- Collection nodes +-------------+ | + -- +-----+ +-----+<-- | Collection | + -- <------ |<------ | +-------------+ | + -- +-----+ +-----+ | Node -------+ + -- | ------>| -----> +-------------+ + -- +-----+ +-----+ : : + -- |ctrl | Dummy : : + -- | obj | + -- +-----+ type Root_Subpool is abstract tagged limited record Owner : Any_Storage_Pool_With_Subpools_Ptr := null; - -- A reference to the master pool_with_subpools + -- A reference to the parent pool_with_subpools - Master : aliased System.Finalization_Masters.Finalization_Master; - -- A heterogeneous collection of controlled objects + Collection : aliased Finalization_Primitives.Finalization_Collection; + -- A collection of controlled objects Node : SP_Node_Ptr := null; -- A link to the doubly linked list node which contains the subpool. @@ -257,21 +236,21 @@ private Alignment : System.Storage_Elements.Storage_Count); -- Given the memory attributes of a heap-allocated object that is known to -- be controlled, adjust the address and size of the object to include the - -- two hidden pointers inserted by the finalization machinery. + -- collection node inserted by the finalization machinery and its padding. -- ??? Once Storage_Pools.Allocate_Any is removed, this should be renamed -- to Allocate_Any. procedure Allocate_Any_Controlled - (Pool : in out Root_Storage_Pool'Class; - Context_Subpool : Subpool_Handle; - Context_Master : Finalization_Masters.Finalization_Master_Ptr; - Fin_Address : Finalization_Masters.Finalize_Address_Ptr; - Addr : out System.Address; - Storage_Size : System.Storage_Elements.Storage_Count; - Alignment : System.Storage_Elements.Storage_Count; - Is_Controlled : Boolean; - On_Subpool : Boolean); + (Pool : in out Root_Storage_Pool'Class; + Context_Subpool : Subpool_Handle; + Context_Collection : Finalization_Primitives.Finalization_Collection_Ptr; + Fin_Address : Finalization_Primitives.Finalize_Address_Ptr; + Addr : out System.Address; + Storage_Size : System.Storage_Elements.Storage_Count; + Alignment : System.Storage_Elements.Storage_Count; + Is_Controlled : Boolean; + On_Subpool : Boolean); -- Compiler interface. This version of Allocate handles all possible cases, -- either on a pool or a pool_with_subpools, regardless of the controlled -- status of the allocated object. Parameter usage: @@ -283,9 +262,9 @@ private -- subpool handle is present at the point of allocation, the actual -- would be null. -- - -- * Context_Master - The finalization master associated with the access - -- type. If the access type's designated type is not controlled, the - -- actual would be null. + -- * Context_Collection - The finalization collection associated with the + -- access type. If the access type's designated type is not controlled, + -- the actual would be null. -- -- * Fin_Address - TSS routine Finalize_Address of the designated type. -- If the designated type is not controlled, the actual would be null. @@ -335,8 +314,8 @@ private procedure Finalize_Pool (Pool : in out Root_Storage_Pool_With_Subpools); -- Iterate over all subpools of Pool, detach them one by one and finalize - -- their masters. This action first detaches a controlled object from a - -- particular master, then invokes its Finalize_Address primitive. + -- their collections. This action first detaches a controlled object from a + -- particular collection, then invokes its Finalize_Address primitive. function Header_Size_With_Padding (Alignment : System.Storage_Elements.Storage_Count) |