From: "Marc Poulhiès" <poulhies@adacore.com>
To: gcc-patches@gcc.gnu.org
Cc: Eric Botcazou <ebotcazou@adacore.com>
Subject: [COMMITTED 33/35] ada: Start the initialization of the tasking runtime earlier
Date: Fri, 17 May 2024 10:32:05 +0200 [thread overview]
Message-ID: <20240517083207.130391-33-poulhies@adacore.com> (raw)
In-Reply-To: <20240517083207.130391-1-poulhies@adacore.com>
From: Eric Botcazou <ebotcazou@adacore.com>
This installs the tasking versions of the RTS_Lock manipulation routines
very early, before the elaboration of all the Ada units of the program,
including those of the runtime, because this elaboration may require the
initialization of RTS_Lock objects.
gcc/ada/
* bindgen.adb (Gen_Adainit): Generate declaration and call to the
imported procedure __gnat_tasking_runtime_initialize if need be.
* libgnat/s-soflin.ads (Locking Soft-Links): Add commentary.
* libgnarl/s-tasini.adb (Tasking_Runtime_Initialize): New procedure
exported as __gnat_tasking_runtime_initialize. Initialize RTS_Lock
manipulation routines here instead of...
(Init_RTS): ...here.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/bindgen.adb | 18 ++++++++++++++++--
gcc/ada/libgnarl/s-tasini.adb | 30 +++++++++++++++++++++---------
gcc/ada/libgnat/s-soflin.ads | 4 +++-
3 files changed, 40 insertions(+), 12 deletions(-)
diff --git a/gcc/ada/bindgen.adb b/gcc/ada/bindgen.adb
index fc834e3a9b6..f15f96495df 100644
--- a/gcc/ada/bindgen.adb
+++ b/gcc/ada/bindgen.adb
@@ -819,8 +819,7 @@ package body Bindgen is
WBI (" pragma Import (C, XDR_Stream, ""__gl_xdr_stream"");");
end if;
- -- Import entry point for elaboration time signal handler
- -- installation, and indication of if it's been called previously.
+ -- Import entry point for initialization of the runtime
WBI ("");
WBI (" procedure Runtime_Initialize " &
@@ -828,6 +827,15 @@ package body Bindgen is
WBI (" pragma Import (C, Runtime_Initialize, " &
"""__gnat_runtime_initialize"");");
+ -- Import entry point for initialization of the tasking runtime
+
+ if With_GNARL then
+ WBI ("");
+ WBI (" procedure Tasking_Runtime_Initialize;");
+ WBI (" pragma Import (C, Tasking_Runtime_Initialize, " &
+ """__gnat_tasking_runtime_initialize"");");
+ end if;
+
-- Import handlers attach procedure for sequential elaboration policy
if System_Interrupts_Used
@@ -1090,6 +1098,12 @@ package body Bindgen is
-- Generate call to Runtime_Initialize
WBI (" Runtime_Initialize (1);");
+
+ -- Generate call to Tasking_Runtime_Initialize
+
+ if With_GNARL then
+ WBI (" Tasking_Runtime_Initialize;");
+ end if;
end if;
-- Generate call to set Initialize_Scalar values if active
diff --git a/gcc/ada/libgnarl/s-tasini.adb b/gcc/ada/libgnarl/s-tasini.adb
index 22294145bed..794183f5356 100644
--- a/gcc/ada/libgnarl/s-tasini.adb
+++ b/gcc/ada/libgnarl/s-tasini.adb
@@ -102,10 +102,6 @@ package body System.Tasking.Initialization is
procedure Release_RTS_Lock (Addr : Address);
-- Release the RTS lock at Addr
- ------------------------
- -- Local Subprograms --
- ------------------------
-
----------------------------
-- Tasking Initialization --
----------------------------
@@ -116,6 +112,15 @@ package body System.Tasking.Initialization is
-- of initializing global locks, and installing tasking versions of certain
-- operations used by the compiler. Init_RTS is called during elaboration.
+ procedure Tasking_Runtime_Initialize;
+ pragma Export (Ada, Tasking_Runtime_Initialize,
+ "__gnat_tasking_runtime_initialize");
+ -- This procedure starts the initialization of the GNARL. It installs the
+ -- tasking versions of the RTS_Lock manipulation routines. It is called
+ -- very early before the elaboration of all the Ada units of the program,
+ -- including those of the runtime, because this elaboration may require
+ -- the initialization of RTS_Lock objects.
+
--------------------------
-- Change_Base_Priority --
--------------------------
@@ -414,11 +419,6 @@ package body System.Tasking.Initialization is
SSL.Task_Name := Task_Name'Access;
SSL.Get_Current_Excep := Get_Current_Excep'Access;
- SSL.Initialize_RTS_Lock := Initialize_RTS_Lock'Access;
- SSL.Finalize_RTS_Lock := Finalize_RTS_Lock'Access;
- SSL.Acquire_RTS_Lock := Acquire_RTS_Lock'Access;
- SSL.Release_RTS_Lock := Release_RTS_Lock'Access;
-
-- Initialize the tasking soft links (if not done yet) that are common
-- to the full and the restricted run times.
@@ -430,6 +430,18 @@ package body System.Tasking.Initialization is
Undefer_Abort (Environment_Task);
end Init_RTS;
+ --------------------------------
+ -- Tasking_Runtime_Initialize --
+ --------------------------------
+
+ procedure Tasking_Runtime_Initialize is
+ begin
+ SSL.Initialize_RTS_Lock := Initialize_RTS_Lock'Access;
+ SSL.Finalize_RTS_Lock := Finalize_RTS_Lock'Access;
+ SSL.Acquire_RTS_Lock := Acquire_RTS_Lock'Access;
+ SSL.Release_RTS_Lock := Release_RTS_Lock'Access;
+ end Tasking_Runtime_Initialize;
+
---------------------------
-- Locked_Abort_To_Level--
---------------------------
diff --git a/gcc/ada/libgnat/s-soflin.ads b/gcc/ada/libgnat/s-soflin.ads
index e88268081d8..c2d947535d9 100644
--- a/gcc/ada/libgnat/s-soflin.ads
+++ b/gcc/ada/libgnat/s-soflin.ads
@@ -258,12 +258,14 @@ package System.Soft_Links is
procedure Null_Set_Address (Addr : Address) is null;
-- Soft-Links are used for procedures that manipulate locks to avoid
- -- dragging the tasking run time when using access-to-controlled types.
+ -- dragging the tasking runtime when using access-to-controlled types.
Initialize_RTS_Lock : Set_Address_Call := Null_Set_Address'Access;
Finalize_RTS_Lock : Set_Address_Call := Null_Set_Address'Access;
Acquire_RTS_Lock : Set_Address_Call := Null_Set_Address'Access;
Release_RTS_Lock : Set_Address_Call := Null_Set_Address'Access;
+ -- The initialization of these variables must be static because the value
+ -- needs to be overridden very early when the tasking runtime is dragged.
--------------------------
-- Master_Id Soft-Links --
--
2.43.2
next prev parent reply other threads:[~2024-05-17 8:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-17 8:31 [COMMITTED 01/35] ada: Add support for 'Object_Size to pragma Compile_Time_{Warning,Error} Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 02/35] ada: Small cleanup in aggregate expansion code Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 03/35] ada: Remove superfluous Relocate_Node calls Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 04/35] ada: Fix checking range constraints within composite types Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 05/35] ada: Check subtype to avoid a precondition failure Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 06/35] ada: Fix probable copy/paste error Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 07/35] ada: Tune detection of unconstrained and tagged items in Depends contract Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 08/35] ada: Allow private items with unknown discriminants as Depends inputs Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 09/35] ada: Simplify code for private types with unknown discriminants Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 10/35] ada: Only record types with discriminants can be unconstrained Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 11/35] ada: Fix Constraint_Error on mutable assignment Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 12/35] ada: Fix crash caused by missing New_Copy_tree Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 13/35] ada: Make raise-gcc.c compatible with Clang Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 14/35] ada: gnatbind-related cleanups Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 15/35] ada: correction to " Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 16/35] ada: Fix containers' Reference_Preserving_Key functions' memory leaks Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 17/35] ada: Update docs for Resolve_Null_Array_Aggregate Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 18/35] ada: gnatbind: subprogram spec no longer exists Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 19/35] ada: Couple of adjustments coming from aliasing considerations Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 20/35] ada: Expose utility routine for processing of Depends contracts in SPARK Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 21/35] ada: Fix others error message location Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 22/35] ada: Clarify code for aggregate warnings Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 23/35] ada: Disable Equivalent_Array_Aggregate optimization if predicates involved Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 24/35] ada: Do not query the modification time of a special file Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 25/35] ada: Fix for validity checking and conditional evaluation of 'Old Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 26/35] ada: Factor out duplicated code in bodies of System.Task_Primitives.Operations Marc Poulhiès
2024-05-17 8:31 ` [COMMITTED 27/35] ada: Bug in computing local restrictions inherited from enclosing scopes Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 28/35] ada: Document secondary usage of Materialize_Entity flag Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 29/35] ada: Replace spinlocks with fully-fledged locks in finalization collections Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 30/35] ada: Further adjustments coming from aliasing considerations Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 31/35] ada: Restore dependency on System.OS_Interface in System.Task_Primitives Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 32/35] ada: Improve test for unprocessed preprocessor directives Marc Poulhiès
2024-05-17 8:32 ` Marc Poulhiès [this message]
2024-05-17 8:32 ` [COMMITTED 34/35] ada: Remove outdated workaround in aggregate expansion Marc Poulhiès
2024-05-17 8:32 ` [COMMITTED 35/35] ada: Improve deriving initial sizes for container aggregates Marc Poulhiès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240517083207.130391-33-poulhies@adacore.com \
--to=poulhies@adacore.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).