From 38806cd3da0ec930cef1c80934a3aa9afc2c90c5 Mon Sep 17 00:00:00 2001 From: Patrick Bernardi Date: Fri, 25 May 2018 09:05:28 +0000 Subject: [PATCH] [Ada] Remove 2GB secondary stack limit for 64-bit processors This patch removes the restriction introduced recently that limited the size of the secondary stack to 2GB. The size of the secondary stack is now limited to half of the size of the memory address space for the target. 2018-05-25 Patrick Bernardi gcc/ada/ * libgnat/s-parame.ads, libgnat/s-parame__vxworks.ads, libgnat/s-parame__ae653.ads, libgnat/s-parame__hpux.ads (Size_Type): Expand range of type to match the address space of the target. (Task_Storage_Size): Remove unused type. gcc/testsuite/ * gnat.dg/sec_stack1.adb: New testcase. From-SVN: r260742 --- gcc/ada/ChangeLog | 7 +++++++ gcc/ada/libgnat/s-parame.ads | 13 ++++++++----- gcc/ada/libgnat/s-parame__ae653.ads | 13 ++++++++----- gcc/ada/libgnat/s-parame__hpux.ads | 13 ++++++++----- gcc/ada/libgnat/s-parame__vxworks.ads | 13 ++++++++----- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gnat.dg/sec_stack1.adb | 26 ++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 gcc/testsuite/gnat.dg/sec_stack1.adb diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 66b84916ed9..4c6dd1fa1ec 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,10 @@ +2018-05-25 Patrick Bernardi + + * libgnat/s-parame.ads, libgnat/s-parame__vxworks.ads, + libgnat/s-parame__ae653.ads, libgnat/s-parame__hpux.ads (Size_Type): + Expand range of type to match the address space of the target. + (Task_Storage_Size): Remove unused type. + 2018-05-25 Ed Schonberg * sem_res.adb (Set_Mixed_Mode_Operand): If the operand is an expression diff --git a/gcc/ada/libgnat/s-parame.ads b/gcc/ada/libgnat/s-parame.ads index ead178a7480..4e9e81fb45d 100644 --- a/gcc/ada/libgnat/s-parame.ads +++ b/gcc/ada/libgnat/s-parame.ads @@ -55,11 +55,14 @@ package System.Parameters is -- Task And Stack Allocation Control -- --------------------------------------- - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime + type Size_Type is range + -(2 ** (Integer'(Standard'Address_Size) - 1)) .. + +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1; + -- Type used to provide task stack sizes to the runtime. Sized to permit + -- stack sizes of up to half the total addressable memory space. This may + -- seem excessively large (even for 32-bit systems), however there are many + -- instances of users requiring large stack sizes (for example string + -- processing). Unspecified_Size : constant Size_Type := Size_Type'First; -- Value used to indicate that no size type is set diff --git a/gcc/ada/libgnat/s-parame__ae653.ads b/gcc/ada/libgnat/s-parame__ae653.ads index c15f0ebfda4..e3acbad48c3 100644 --- a/gcc/ada/libgnat/s-parame__ae653.ads +++ b/gcc/ada/libgnat/s-parame__ae653.ads @@ -53,11 +53,14 @@ package System.Parameters is -- Task And Stack Allocation Control -- --------------------------------------- - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime + type Size_Type is range + -(2 ** (Integer'(Standard'Address_Size) - 1)) .. + +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1; + -- Type used to provide task stack sizes to the runtime. Sized to permit + -- stack sizes of up to half the total addressable memory space. This may + -- seem excessively large (even for 32-bit systems), however there are many + -- instances of users requiring large stack sizes (for example string + -- processing). Unspecified_Size : constant Size_Type := Size_Type'First; -- Value used to indicate that no size type is set diff --git a/gcc/ada/libgnat/s-parame__hpux.ads b/gcc/ada/libgnat/s-parame__hpux.ads index df16d0be627..dfd0e086e67 100644 --- a/gcc/ada/libgnat/s-parame__hpux.ads +++ b/gcc/ada/libgnat/s-parame__hpux.ads @@ -53,11 +53,14 @@ package System.Parameters is -- Task And Stack Allocation Control -- --------------------------------------- - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime + type Size_Type is range + -(2 ** (Integer'(Standard'Address_Size) - 1)) .. + +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1; + -- Type used to provide task stack sizes to the runtime. Sized to permit + -- stack sizes of up to half the total addressable memory space. This may + -- seem excessively large (even for 32-bit systems), however there are many + -- instances of users requiring large stack sizes (for example string + -- processing). Unspecified_Size : constant Size_Type := Size_Type'First; -- Value used to indicate that no size type is set diff --git a/gcc/ada/libgnat/s-parame__vxworks.ads b/gcc/ada/libgnat/s-parame__vxworks.ads index 9bdca23ec34..cfab9f77728 100644 --- a/gcc/ada/libgnat/s-parame__vxworks.ads +++ b/gcc/ada/libgnat/s-parame__vxworks.ads @@ -53,11 +53,14 @@ package System.Parameters is -- Task And Stack Allocation Control -- --------------------------------------- - type Task_Storage_Size is new Integer; - -- Type used in tasking units for task storage size - - type Size_Type is new Task_Storage_Size; - -- Type used to provide task storage size to runtime + type Size_Type is range + -(2 ** (Integer'(Standard'Address_Size) - 1)) .. + +(2 ** (Integer'(Standard'Address_Size) - 1)) - 1; + -- Type used to provide task stack sizes to the runtime. Sized to permit + -- stack sizes of up to half the total addressable memory space. This may + -- seem excessively large (even for 32-bit systems), however there are many + -- instances of users requiring large stack sizes (for example string + -- processing). Unspecified_Size : constant Size_Type := Size_Type'First; -- Value used to indicate that no size type is set diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2b2695e8c75..bcf7b51cee6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2018-05-25 Patrick Bernardi + + * gnat.dg/sec_stack1.adb: New testcase. + 2018-05-25 Ed Schonberg * gnat.dg/fixedpnt4.adb: New testcase. diff --git a/gcc/testsuite/gnat.dg/sec_stack1.adb b/gcc/testsuite/gnat.dg/sec_stack1.adb new file mode 100644 index 00000000000..4caeafedaea --- /dev/null +++ b/gcc/testsuite/gnat.dg/sec_stack1.adb @@ -0,0 +1,26 @@ +-- { dg-do run } +-- +-- This test checks that we can allocate more than 2GB on systems with word +-- sizes larger than 32-bits + +with Ada.Strings.Fixed; use Ada.Strings.Fixed; + +procedure Sec_Stack1 is + function Get_A_Big_String return String; + -- Return a very close to 2GB string on the secondary stack that would + -- overflow the secondary stack if we still had a 2GB limit. + + function Get_A_Big_String return String is + String_Size : constant Natural := Natural'Last; + begin + return String_Size * 'a'; + end Get_A_Big_String; + +begin + -- This test only works on systems with more than 32-bits + if Standard'Address_Size > 32 then + declare + R : String := Get_A_Big_String; + begin null; end; + end if; +end Sec_Stack1; -- 2.30.2