aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2024-02-22 08:47:42 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-16 10:49:30 +0200
commit8560a0644da71f5d411ef67382a47278085bad70 (patch)
treeee289d3affa01393c1516836b0964fdea1f8fb7d /gcc/ada/libgnat
parent513f6b889ab5c9fa88e82506cce7534f0400b1c6 (diff)
downloadgcc-8560a0644da71f5d411ef67382a47278085bad70.zip
gcc-8560a0644da71f5d411ef67382a47278085bad70.tar.gz
gcc-8560a0644da71f5d411ef67382a47278085bad70.tar.bz2
ada: Minor performance improvement for dynamically-allocated controlled objects
The values returned by Header_Alignment and Header_Size are known at compile time and powers of two on almost all platforms, so inlining them by means of an expression function improves the object code generated for alignment and size calculations involving them. gcc/ada/ * libgnat/s-finpri.ads: Add use type clause for Storage_Offset. (Header_Alignment): Turn into an expression function. (Header_Size): Likewise. * libgnat/s-finpri.adb: Remove use type clause for Storage_Offset. (Header_Alignment): Delete. (Header_Size): Likewise.
Diffstat (limited to 'gcc/ada/libgnat')
-rw-r--r--gcc/ada/libgnat/s-finpri.adb20
-rw-r--r--gcc/ada/libgnat/s-finpri.ads8
2 files changed, 6 insertions, 22 deletions
diff --git a/gcc/ada/libgnat/s-finpri.adb b/gcc/ada/libgnat/s-finpri.adb
index 5bd8eea..bd70e58 100644
--- a/gcc/ada/libgnat/s-finpri.adb
+++ b/gcc/ada/libgnat/s-finpri.adb
@@ -37,8 +37,6 @@ with System.Soft_Links; use System.Soft_Links;
package body System.Finalization_Primitives is
- use type System.Storage_Elements.Storage_Offset;
-
function To_Collection_Node_Ptr is
new Ada.Unchecked_Conversion (Address, Collection_Node_Ptr);
@@ -389,24 +387,6 @@ package body System.Finalization_Primitives is
end if;
end Finalize_Object;
- ----------------------
- -- Header_Alignment --
- ----------------------
-
- function Header_Alignment return System.Storage_Elements.Storage_Count is
- begin
- return Collection_Node'Alignment;
- end Header_Alignment;
-
- -----------------
- -- Header_Size --
- -----------------
-
- function Header_Size return System.Storage_Elements.Storage_Count is
- begin
- return Collection_Node'Object_Size / Storage_Unit;
- end Header_Size;
-
----------------
-- Initialize --
----------------
diff --git a/gcc/ada/libgnat/s-finpri.ads b/gcc/ada/libgnat/s-finpri.ads
index 468aa58..b0b662ca 100644
--- a/gcc/ada/libgnat/s-finpri.ads
+++ b/gcc/ada/libgnat/s-finpri.ads
@@ -39,6 +39,8 @@ with System.Storage_Elements;
package System.Finalization_Primitives with Preelaborate is
+ use type System.Storage_Elements.Storage_Offset;
+
type Finalize_Address_Ptr is access procedure (Obj : System.Address);
-- Values of this type denote finalization procedures associated with
-- objects that have controlled parts. For convenience, such objects
@@ -168,10 +170,12 @@ package System.Finalization_Primitives with Preelaborate is
-- Calls to the procedure with an object that has already been detached
-- have no effects.
- function Header_Alignment return System.Storage_Elements.Storage_Count;
+ function Header_Alignment return System.Storage_Elements.Storage_Count is
+ (Collection_Node'Alignment);
-- Return the alignment of type Collection_Node as Storage_Count
- function Header_Size return System.Storage_Elements.Storage_Count;
+ function Header_Size return System.Storage_Elements.Storage_Count is
+ (Collection_Node'Object_Size / Storage_Unit);
-- Return the object size of type Collection_Node as Storage_Count
private